@eigenpal/docx-js-editor 0.0.28 → 0.0.30
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-BzgQ-SOi.d.cts → ClipboardManager-t936d0KD.d.mts} +1 -1
- package/dist/{DocumentAgent-B9FUoSVS.d.cts → DocumentAgent-BqA9EJ3F.d.mts} +1 -1
- package/dist/FindReplaceDialog-AQFR4OCT.js +1 -1
- package/dist/FindReplaceDialog-N4J5OB7O.mjs +1 -0
- package/dist/FootnotePropertiesDialog-UFUIHLDW.mjs +1 -0
- package/dist/FootnotePropertiesDialog-YYIZU5U6.js +1 -1
- package/dist/HyperlinkDialog-HGZ2S37Z.js +1 -1
- package/dist/HyperlinkDialog-YQSQFHOP.mjs +1 -0
- package/dist/ImagePositionDialog-DQ4JWS4F.js +1 -1
- package/dist/ImagePositionDialog-HT6J2SHV.mjs +1 -0
- package/dist/ImagePropertiesDialog-3VK2S2AF.mjs +1 -0
- package/dist/ImagePropertiesDialog-GJMGLM6G.js +1 -1
- package/dist/PageSetupDialog-3QCVUNDL.mjs +1 -0
- package/dist/PageSetupDialog-ZZTFPZKJ.js +1 -1
- package/dist/TablePropertiesDialog-FI5E3RCB.mjs +1 -0
- package/dist/TablePropertiesDialog-STZOGHJB.js +1 -1
- package/dist/chunk-2KHL5RSD.js +3 -3
- package/dist/chunk-4VUZBV2S.js +1 -1
- package/dist/chunk-6WPRCJ5A.mjs +1 -0
- package/dist/chunk-7HZRJTOL.mjs +4 -0
- package/dist/chunk-AARNCPWR.js +1 -1
- package/dist/chunk-AZRYS2WF.mjs +2 -0
- package/dist/chunk-BUEMG4NW.js +1 -1
- package/dist/chunk-CQRI4YUS.mjs +26 -0
- package/dist/chunk-CTYOM6BE.js +2 -2
- package/dist/{chunk-PRBTINOW.js → chunk-DLVLK5FT.mjs} +2 -2
- package/dist/chunk-FVUGBRDD.js +1 -1
- package/dist/chunk-G72SXG7G.js +258 -0
- package/dist/chunk-H5NTJZO4.js +1 -1
- package/dist/chunk-I6LFWQFR.mjs +59 -0
- package/dist/chunk-IFPN3NT3.js +3 -3
- package/dist/chunk-IRO7KGGC.js +59 -0
- package/dist/chunk-KCUPCJFL.mjs +111 -0
- package/dist/chunk-LYBG4YI7.mjs +1 -0
- package/dist/chunk-M5F4SK3W.mjs +1 -0
- package/dist/chunk-MRWJ3GNH.js +9 -0
- package/dist/chunk-MVCTPHRR.mjs +258 -0
- package/dist/chunk-PB7VMDDP.js +24 -0
- package/dist/chunk-PJVI53AH.js +2 -2
- package/dist/chunk-QAZ4233N.mjs +1 -0
- package/dist/{chunk-OJ7NJK46.cjs → chunk-QQ63M65M.js} +1 -1
- package/dist/chunk-QTSXJRP6.mjs +1 -0
- package/dist/chunk-QVPR2W5S.js +1 -1
- package/dist/chunk-SE5EN2QL.js +1 -1
- package/dist/chunk-TAUMSKRE.mjs +1 -0
- package/dist/{chunk-JO2CKU4O.js → chunk-TDEHAPMZ.mjs} +1 -1
- package/dist/chunk-VHWEKJ35.js +10 -0
- package/dist/chunk-VR6PT4IZ.js +26 -0
- package/dist/chunk-W53SI3XW.mjs +1 -0
- package/dist/chunk-WOHFANC5.mjs +3 -0
- package/dist/chunk-XGL3EGKF.js +7 -7
- package/dist/chunk-XWBCP563.mjs +2 -0
- package/dist/{chunk-TOGKKPIW.js → chunk-YGTSQZRK.mjs} +1 -1
- package/dist/chunk-Z35FA4M4.mjs +10 -0
- package/dist/{clipboard-Cm7udEnb.d.cts → clipboard-BkM7Zvgs.d.mts} +1 -1
- package/dist/{colorResolver-Bu7uJqpw.d.cts → colorResolver-BwI_Uxp3.d.mts} +2 -2
- package/dist/{core-plugins-reexport.d.cts → core-plugins-reexport.d.mts} +4 -4
- package/dist/core-plugins-reexport.js +1 -1
- package/dist/core-plugins-reexport.mjs +1 -0
- package/dist/{core-reexport.d.cts → core-reexport.d.mts} +11 -11
- package/dist/core-reexport.js +1 -1
- package/dist/core-reexport.mjs +1 -0
- package/dist/executor-L2MVKMXO.js +1 -1
- package/dist/executor-XKBCCVNY.mjs +1 -0
- package/dist/{fontLoader-X8ocGzeD.d.cts → fontLoader-DicgJidU.d.mts} +1 -1
- package/dist/{headless-reexport.d.cts → headless-reexport.d.mts} +7 -7
- package/dist/headless-reexport.js +2 -2
- package/dist/headless-reexport.mjs +4 -0
- package/dist/{index.d.cts → index.d.mts} +14 -14
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +155 -0
- package/dist/lib-BCT2DRYI.mjs +1 -0
- package/dist/lib-U35UU4OU.js +1 -1
- package/dist/{mcp-reexport.d.cts → mcp-reexport.d.mts} +2 -2
- package/dist/mcp-reexport.js +9 -9
- package/dist/mcp-reexport.mjs +16 -0
- package/dist/processTemplate-5ZST2Q5L.js +1 -0
- package/dist/{processTemplate-CGIQEJ26.js → processTemplate-LRHXOWMZ.mjs} +1 -1
- package/dist/{react-BgZObIoP.d.ts → react-By80Gfi-.d.ts} +4 -0
- package/dist/{react-D9JDP3cV.d.cts → react-C-pJU0Y4.d.mts} +8 -4
- package/dist/{react.d.cts → react.d.mts} +5 -5
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -0
- package/dist/{registry-Bxb5ZI1z.d.cts → registry-DyIMyB-0.d.mts} +1 -1
- package/dist/selectionRects-6TRAXB7D.js +1 -0
- package/dist/selectionRects-IS7ZAS3A.mjs +1 -0
- package/dist/{types-D03hsi5t.d.cts → types-B3LkfO0u.d.mts} +1 -1
- package/dist/{ui.d.cts → ui.d.mts} +3 -3
- package/dist/ui.js +1 -1
- package/dist/ui.mjs +1 -0
- package/dist/{variableDetector-iGl52A6q.d.cts → variableDetector-CIqTek7A.d.mts} +1 -1
- package/package.json +17 -18
- package/dist/FindReplaceDialog-J3DI3U5I.cjs +0 -1
- package/dist/FootnotePropertiesDialog-DO5DCAW6.cjs +0 -1
- package/dist/HyperlinkDialog-PEPS3C2G.cjs +0 -1
- package/dist/ImagePositionDialog-UYXYHSP4.cjs +0 -1
- package/dist/ImagePropertiesDialog-V6SVKINO.cjs +0 -1
- package/dist/PageSetupDialog-RLMYJ3BA.cjs +0 -1
- package/dist/TablePropertiesDialog-A36OXG3A.cjs +0 -1
- package/dist/chunk-2FYTKTQL.cjs +0 -111
- package/dist/chunk-2VHQ7YOQ.cjs +0 -1
- package/dist/chunk-3YHC2RAO.js +0 -258
- package/dist/chunk-63YB7DGI.js +0 -59
- package/dist/chunk-7OCUAFPO.cjs +0 -258
- package/dist/chunk-HE3SUXOQ.cjs +0 -4
- package/dist/chunk-HRUPO723.js +0 -10
- package/dist/chunk-IA4LPH2A.cjs +0 -1
- package/dist/chunk-JMR5HNJP.cjs +0 -10
- package/dist/chunk-KR32M3S4.cjs +0 -1
- package/dist/chunk-MSV5LTHM.cjs +0 -9
- package/dist/chunk-NLYEW36R.js +0 -26
- package/dist/chunk-NVAQQYBJ.cjs +0 -1
- package/dist/chunk-P7ZF45KZ.cjs +0 -1
- package/dist/chunk-PCJ5ACUV.cjs +0 -1
- package/dist/chunk-PVV7DV3L.cjs +0 -59
- package/dist/chunk-QDNL7NWN.cjs +0 -3
- package/dist/chunk-VPDOOMUJ.cjs +0 -26
- package/dist/chunk-VTAS7VZ6.cjs +0 -2
- package/dist/chunk-XKBIFFAS.cjs +0 -24
- package/dist/chunk-XS2AQFMF.cjs +0 -2
- package/dist/chunk-YS7FDEZ4.cjs +0 -1
- package/dist/core-plugins-reexport.cjs +0 -1
- package/dist/core-reexport.cjs +0 -1
- package/dist/executor-JGWZ7S6Z.cjs +0 -1
- package/dist/headless-reexport.cjs +0 -4
- package/dist/index.cjs +0 -155
- package/dist/lib-SPXD4LFI.cjs +0 -1
- package/dist/mcp-reexport.cjs +0 -16
- package/dist/processTemplate-FOYV6BC5.cjs +0 -1
- package/dist/react.cjs +0 -1
- package/dist/selectionRects-BMXJJCPJ.cjs +0 -1
- package/dist/selectionRects-TWK7CAC3.js +0 -1
- package/dist/ui.cjs +0 -1
- /package/dist/{agentApi-BVHzyk2l.d.cts → agentApi-BVHzyk2l.d.mts} +0 -0
package/dist/chunk-PJVI53AH.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var j={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:"8px",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:"400px",maxWidth:"500px",width:"100%",margin:"20px"},J={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--doc-border)"},Q={margin:0,fontSize:"18px",fontWeight:600,color:"var(--doc-text)"},Z={background:"none",border:"none",fontSize:"20px",cursor:"pointer",color:"var(--doc-text-muted)",padding:"4px 8px",lineHeight:1},ee={padding:"20px"},T={marginBottom:"16px"},v={display:"block",marginBottom:"6px",fontSize:"14px",fontWeight:500,color:"var(--doc-text)"},g={width:"100%",padding:"10px 12px",border:"1px solid var(--doc-border-input)",borderRadius:"4px",fontSize:"14px",boxSizing:"border-box",outline:"none"},te={...g,borderColor:"var(--doc-error)"},re={...g,cursor:"pointer"},oe={color:"var(--doc-error)",fontSize:"12px",marginTop:"4px"},W={color:"var(--doc-text-muted)",fontSize:"12px",marginTop:"4px"},ie={display:"flex",borderBottom:"1px solid var(--doc-border)",marginBottom:"16px"},O={padding:"10px 16px",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"var(--doc-text-muted)",borderBottom:"2px solid transparent",marginBottom:"-1px"},w={...O,color:"var(--doc-link)",borderBottomColor:"var(--doc-link)",fontWeight:500},ne={display:"flex",justifyContent:"flex-end",gap:"12px",padding:"16px 20px",borderTop:"1px solid var(--doc-border)"},E={padding:"10px 20px",borderRadius:"4px",fontSize:"14px",fontWeight:500,cursor:"pointer",border:"none"},le={...E,backgroundColor:"var(--doc-link)",color:"white"},ae={...E,backgroundColor:"var(--doc-bg-hover)",color:"var(--doc-text)",border:"1px solid var(--doc-border-input)"},se={...E,backgroundColor:"var(--doc-error)",color:"white"},pe={...E,backgroundColor:"var(--doc-border-input)",color:"var(--doc-text-muted)",cursor:"not-allowed"};function z(t){if(!t||t.trim()==="")return false;let e=t.trim();if(e.startsWith("mailto:")||e.startsWith("tel:"))return e.length>7;if(e.startsWith("ftp://"))return e.length>6;try{let p=e.match(/^https?:\/\//)?e:`https://${e}`,u=new URL(p);return u.protocol==="http:"||u.protocol==="https:"}catch{return false}}function F(t){if(!t)return "";let e=t.trim();return e.startsWith("mailto:")||e.startsWith("tel:")||e.startsWith("ftp://")||e.match(/^https?:\/\//)?e:`https://${e}`}function ke(t){if(!t)return "unknown";let e=t.trim().toLowerCase();return e.startsWith("mailto:")?"email":e.startsWith("tel:")?"phone":e.startsWith("ftp://")?"ftp":e.startsWith("http://")||e.startsWith("https://")?"web":e.includes("@")&&!e.includes(" ")?"email":"web"}function de({isOpen:t,onClose:e,onSubmit:p,onRemove:u,initialData:a,selectedText:f="",isEditing:n=false,bookmarks:H=[],className:G,style:M}){let[i,y]=react.useState("url"),[s,C]=react.useState(""),[L,D]=react.useState(""),[x,_]=react.useState(""),[N,R]=react.useState(""),[k,m]=react.useState(""),[B,b]=react.useState(false),P=react.useRef(null),U=react.useRef(null);react.useEffect(()=>{t&&(a?(a.bookmark?(y("bookmark"),_(a.bookmark)):(y("url"),C(a.url||"")),D(a.displayText||""),R(a.tooltip||"")):(y("url"),C(""),D(f),_(""),R("")),m(""),b(false));},[t,a,f]),react.useEffect(()=>{t&&setTimeout(()=>{i==="url"?P.current?.focus():U.current?.focus();},100);},[t,i]);let $=react.useCallback(()=>{i==="url"&&s.trim()?z(s)?m(""):m("Please enter a valid URL"):m("");},[i,s]),h=react.useCallback(r=>{if(r?.preventDefault(),i==="url"){if(!s.trim()){m("URL is required"),b(true);return}if(!z(s)){m("Please enter a valid URL"),b(true);return}}else if(i==="bookmark"&&!x)return;let S={displayText:L.trim()||void 0,tooltip:N.trim()||void 0};i==="url"?S.url=F(s):S.bookmark=x,p(S);},[i,s,x,L,N,p]),K=react.useCallback(r=>{r.key==="Escape"?e():r.key==="Enter"&&!r.shiftKey&&r.target.tagName!=="TEXTAREA"&&(r.preventDefault(),h());},[e,h]),V=react.useCallback(r=>{r.target===r.currentTarget&&e();},[e]);if(!t)return null;let X=H.length>0,Y=i==="url"&&s.trim()&&!k||i==="bookmark"&&x;return jsxRuntime.jsx("div",{className:`docx-hyperlink-dialog-overlay ${G||""}`,style:{...j,...M},onClick:V,onKeyDown:K,role:"dialog","aria-modal":"true","aria-labelledby":"hyperlink-dialog-title",children:jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog",style:q,children:[jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog-header",style:J,children:[jsxRuntime.jsx("h2",{id:"hyperlink-dialog-title",style:Q,children:n?"Edit Hyperlink":"Insert Hyperlink"}),jsxRuntime.jsx("button",{type:"button",className:"docx-hyperlink-dialog-close",style:Z,onClick:e,"aria-label":"Close dialog",children:"\xD7"})]}),jsxRuntime.jsxs("form",{className:"docx-hyperlink-dialog-body",style:ee,onSubmit:h,children:[X&&jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog-tabs",style:ie,children:[jsxRuntime.jsx("button",{type:"button",className:`docx-hyperlink-dialog-tab ${i==="url"?"active":""}`,style:i==="url"?w:O,onClick:()=>y("url"),"aria-selected":i==="url",children:"Web Address"}),jsxRuntime.jsx("button",{type:"button",className:`docx-hyperlink-dialog-tab ${i==="bookmark"?"active":""}`,style:i==="bookmark"?w:O,onClick:()=>y("bookmark"),"aria-selected":i==="bookmark",children:"Bookmark"})]}),i==="url"&&jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog-field",style:T,children:[jsxRuntime.jsx("label",{htmlFor:"hyperlink-url",style:v,children:"URL"}),jsxRuntime.jsx("input",{ref:P,id:"hyperlink-url",type:"text",className:"docx-hyperlink-dialog-input",style:k&&B?te:g,value:s,onChange:r=>{C(r.target.value),B&&m("");},onBlur:()=>{b(true),$();},placeholder:"https://example.com","aria-invalid":!!k,"aria-describedby":k?"url-error":"url-hint"}),k&&B&&jsxRuntime.jsx("div",{id:"url-error",style:oe,children:k}),!k&&jsxRuntime.jsx("div",{id:"url-hint",style:W,children:"Enter a web address, email (mailto:), or phone (tel:)"})]}),i==="bookmark"&&jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog-field",style:T,children:[jsxRuntime.jsx("label",{htmlFor:"hyperlink-bookmark",style:v,children:"Bookmark"}),jsxRuntime.jsxs("select",{ref:U,id:"hyperlink-bookmark",className:"docx-hyperlink-dialog-select",style:re,value:x,onChange:r=>_(r.target.value),children:[jsxRuntime.jsx("option",{value:"",children:"Select a bookmark..."}),H.map(r=>jsxRuntime.jsx("option",{value:r.name,children:r.label||r.name},r.name))]})]}),jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog-field",style:T,children:[jsxRuntime.jsx("label",{htmlFor:"hyperlink-display-text",style:v,children:"Display Text"}),jsxRuntime.jsx("input",{id:"hyperlink-display-text",type:"text",className:"docx-hyperlink-dialog-input",style:g,value:L,onChange:r=>D(r.target.value),placeholder:"Text to display (optional)"}),jsxRuntime.jsx("div",{style:W,children:"Leave empty to use the selected text"})]}),jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog-field",style:T,children:[jsxRuntime.jsx("label",{htmlFor:"hyperlink-tooltip",style:v,children:"Tooltip (optional)"}),jsxRuntime.jsx("input",{id:"hyperlink-tooltip",type:"text",className:"docx-hyperlink-dialog-input",style:g,value:N,onChange:r=>R(r.target.value),placeholder:"Text shown on hover"})]})]}),jsxRuntime.jsxs("div",{className:"docx-hyperlink-dialog-footer",style:ne,children:[n&&u&&jsxRuntime.jsx("button",{type:"button",className:"docx-hyperlink-dialog-remove",style:se,onClick:u,children:"Remove Link"}),jsxRuntime.jsx("div",{style:{flex:1}}),jsxRuntime.jsx("button",{type:"button",className:"docx-hyperlink-dialog-cancel",style:ae,onClick:e,children:"Cancel"}),jsxRuntime.jsx("button",{type:"submit",className:"docx-hyperlink-dialog-submit",style:Y?le:pe,onClick:h,disabled:!Y,children:n?"Update":"Insert"})]})]})})}function me(t,e){return {url:F(t),displayText:e}}function ye(t,e){return {bookmark:t,displayText:e}}function xe(t){return !!t.url&&!t.bookmark}function ge(t){return !!t.bookmark}function fe(t){return t.displayText?t.displayText:t.url?t.url.replace(/^https?:\/\//,""):t.bookmark?t.bookmark:""}function be(t){return t.startsWith("mailto:")?t:`mailto:${t}`}function he(t){return t.startsWith("tel:")?t:`tel:${t.replace(/[\s\-\(\)\.]/g,"")}`}function Se(t){return t.filter(e=>!e.name.startsWith("_")).map(e=>({name:e.name,label:e.name})).sort((e,p)=>e.name.localeCompare(p.name))}function Te(){let[t,e]=react.useState({isOpen:false,isEditing:false}),p=react.useCallback(n=>{e({isOpen:true,selectedText:n,initialData:void 0,isEditing:false});},[]),u=react.useCallback(n=>{e({isOpen:true,initialData:n,selectedText:n.displayText,isEditing:true});},[]),a=react.useCallback(()=>{e(n=>({...n,isOpen:false}));},[]),f=react.useCallback(()=>{e(n=>({...n,isOpen:!n.isOpen}));},[]);return {state:t,openInsert:p,openEdit:u,close:a,toggle:f}}var ve=de;
|
|
2
|
+
exports.a=z;exports.b=F;exports.c=ke;exports.d=de;exports.e=me;exports.f=ye;exports.g=xe;exports.h=ge;exports.i=fe;exports.j=be;exports.k=he;exports.l=Se;exports.m=Te;exports.n=ve;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},T={black:"000000",blue:"0000FF",cyan:"00FFFF",darkBlue:"00008B",darkCyan:"008B8B",darkGray:"A9A9A9",darkGreen:"006400",darkMagenta:"8B008B",darkRed:"8B0000",darkYellow:"808000",green:"00FF00",lightGray:"D3D3D3",magenta:"FF00FF",red:"FF0000",white:"FFFFFF",yellow:"FFFF00",none:""},h={dk1:"dk1",lt1:"lt1",dk2:"dk2",lt2:"lt2",accent1:"accent1",accent2:"accent2",accent3:"accent3",accent4:"accent4",accent5:"accent5",accent6:"accent6",hlink:"hlink",folHlink:"folHlink",dark1:"dk1",light1:"lt1",dark2:"dk2",light2:"lt2",hyperlink:"hlink",followedHyperlink:"folHlink",background1:"lt1",text1:"dk1",background2:"lt2",text2:"dk2",tx1:"dk1",tx2:"dk2",bg1:"lt1",bg2:"lt2"};function b(e){if(!e)return 1;let t=parseInt(e,16);return isNaN(t)?1:t/255}function c(e){let t=e.padStart(6,"0").slice(0,6),n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),l=parseInt(t.slice(4,6),16);return {r:isNaN(n)?0:n,g:isNaN(r)?0:r,b:isNaN(l)?0:l}}function g(e,t,n){let r=l=>Math.max(0,Math.min(255,Math.round(l))).toString(16).padStart(2,"0");return `${r(e)}${r(t)}${r(n)}`.toUpperCase()}function p(e,t,n){e/=255,t/=255,n/=255;let r=Math.max(e,t,n),l=Math.min(e,t,n),o=(r+l)/2;if(r===l)return {h:0,s:0,l:o};let u=r-l,i=o>.5?u/(2-r-l):u/(r+l),a;switch(r){case e:a=((t-n)/u+(t<n?6:0))/6;break;case t:a=((n-e)/u+2)/6;break;case n:a=((e-t)/u+4)/6;break;default:a=0;}return {h:a*360,s:i,l:o}}function C(e,t,n){if(e=e/360,t===0){let u=Math.round(n*255);return {r:u,g:u,b:u}}let r=(u,i,a)=>(a<0&&(a+=1),a>1&&(a-=1),a<1/6?u+(i-u)*6*a:a<1/2?i:a<2/3?u+(i-u)*(2/3-a)*6:u),l=n<.5?n*(1+t):n+t-n*t,o=2*n-l;return {r:Math.round(r(o,l,e+1/3)*255),g:Math.round(r(o,l,e)*255),b:Math.round(r(o,l,e-1/3)*255)}}function f(e,t){if(t<=0||t>=1)return t>=1?"FFFFFF":e;let n=c(e),r=p(n.r,n.g,n.b);r.l=r.l+(1-r.l)*t;let l=C(r.h,r.s,r.l);return g(l.r,l.g,l.b)}function m(e,t){if(t<=0||t>=1)return t<=0?"000000":e;let n=c(e),r=p(n.r,n.g,n.b);r.l=r.l*t;let l=C(r.h,r.s,r.l);return g(l.r,l.g,l.b)}function k(e,t){let n=h[t]??t,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],l=o=>r.includes(o);return e?.colorScheme?l(n)?e.colorScheme[n]??d[n]??"000000":"000000":l(n)?d[n]??"000000":"000000"}function x(e){if(!e)return null;let t=e.toLowerCase();return h[e]??h[t]??null}function s(e,t,n="000000"){if(!e)return `#${n}`;if(e.auto)return `#${n}`;let r;if(e.themeColor){let l=x(e.themeColor);if(l?r=k(t,l):r=e.rgb??n,e.themeTint){let o=b(e.themeTint);r=f(r,o);}else if(e.themeShade){let o=b(e.themeShade);r=m(r,o);}}else e.rgb?r=e.rgb==="auto"?n:e.rgb:r=n;return `#${r.toUpperCase().replace(/^#/,"")}`}function S(e){if(!e||e==="none")return "";let t=T[e];return t?`#${t}`:""}function v(e,t){return e?e.auto?"transparent":s(e,t):""}function M(e,t){if(!e)return false;if(e.auto)return true;let r=s(e,t).replace(/^#/,"").toLowerCase(),l=c(r);return (l.r+l.g+l.b)/3<20}function A(e,t){if(!e)return false;let r=s(e,t).replace(/^#/,"").toLowerCase(),l=c(r);return (l.r+l.g+l.b)/3>235}function H(e,t){if(!e)return "#000000";let r=s(e,t).replace(/^#/,""),l=c(r);return (.299*l.r+.587*l.g+.114*l.b)/255>.5?"#000000":"#FFFFFF"}function R(e){if(!e)return;let t=e.trim();if(t.toLowerCase()==="auto")return {auto:true};let n=x(t);if(n)return {themeColor:n};let r=t.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(o=>o+o).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function E(e,t,n){let r={themeColor:e};return t!==void 0&&t>0&&t<1&&(r.themeTint=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),n!==void 0&&n>0&&n<1&&(r.themeShade=Math.round(n*255).toString(16).toUpperCase().padStart(2,"0")),r}function $(e){return {rgb:e.replace(/^#/,"").toUpperCase()}}function L(e,t,n){let l=s(e,t).replace(/^#/,""),o=1-n/100;return `#${m(l,o)}`}function B(e,t,n){let l=s(e,t).replace(/^#/,""),o=n/100;return `#${f(l,o)}`}function U(e,t,n,r){let l=s(e,r).replace(/^#/,""),o=s(t,r).replace(/^#/,""),u=c(l),i=c(o),a={r:Math.round(u.r*(1-n)+i.r*n),g:Math.round(u.g*(1-n)+i.g*n),b:Math.round(u.b*(1-n)+i.b*n)};return `#${g(a.r,a.g,a.b)}`}function F(e){return e.startsWith("#")?e:`#${e}`}function D(e){return S(e)||F(e)}var y=[{slot:"lt1",name:"Background 1"},{slot:"dk1",name:"Text 1"},{slot:"lt2",name:"Background 2"},{slot:"dk2",name:"Text 2"},{slot:"accent1",name:"Accent 1"},{slot:"accent2",name:"Accent 2"},{slot:"accent3",name:"Accent 3"},{slot:"accent4",name:"Accent 4"},{slot:"accent5",name:"Accent 5"},{slot:"accent6",name:"Accent 6"}],V=[{type:"base",value:0,hexValue:"",labelSuffix:""},{type:"tint",value:.8,hexValue:"CC",labelSuffix:", Lighter 80%"},{type:"tint",value:.6,hexValue:"99",labelSuffix:", Lighter 60%"},{type:"tint",value:.4,hexValue:"66",labelSuffix:", Lighter 40%"},{type:"shade",value:.75,hexValue:"BF",labelSuffix:", Darker 25%"},{type:"shade",value:.5,hexValue:"80",labelSuffix:", Darker 50%"}];function I(e,t,n){return t==="tint"?f(e,n):m(e,n)}function _(e){let t=e??d;return V.map(n=>y.map(r=>{let l=t[r.slot]??d[r.slot]??"000000",o;n.type==="base"?o=l.toUpperCase():n.type==="tint"?o=f(l,n.value):o=m(l,n.value);let u={hex:o,themeSlot:r.slot,label:`${r.name}${n.labelSuffix}`};return n.type==="tint"&&n.hexValue?u.tint=n.hexValue:n.type==="shade"&&n.hexValue&&(u.shade=n.hexValue),u}))}function O(e,t,n){if(!e&&!t)return true;if(!e||!t)return false;let r=s(e,n).toUpperCase(),l=s(t,n).toUpperCase();return r===l}export{s as a,S as b,v as c,M as d,A as e,H as f,R as g,E as h,$ as i,L as j,B as k,U as l,F as m,D as n,I as o,_ as p,O as q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';function ae(e,t,r,n){let a=e-t-r,o=(n.count-1)*n.gap;return (a-o)/n.count}function U(e){let{pageSize:t,margins:r}=e,n=e.columns??{count:1,gap:0},a=[],o=[],c=r.top,i=t.h-r.bottom;if(i-c<=0)throw new Error("Paginator: page size and margins yield no content area");let u=ae(t.w,r.left,r.right,n),g=c;function l(p){return r.left+p*(u+n.gap)}function m(){let p=a.length+1,S=e.footnoteReservedHeights?.get(p)??0,T=i-S,w={number:p,fragments:[],margins:{...r},size:{...t},footnoteReservedHeight:S>0?S:void 0,columns:n.count>1?{...n}:void 0},C={page:w,cursorY:c,columnIndex:0,topMargin:c,contentBottom:T,trailingSpacing:0};return a.push(w),o.push(C),g=c,e.onNewPage&&e.onNewPage(C),C}function f(){return o.length===0?m():o[o.length-1]}function x(p){return p.contentBottom-p.cursorY}function h(p,S){let T=S||f();return x(T)>=p}function b(p){return p.columnIndex<n.count-1?(p.columnIndex+=1,p.cursorY=g,p.trailingSpacing=0,p):m()}function d(p){let S=f(),T=Number.isFinite(p)&&p>0?p:0,w=S.contentBottom-S.topMargin;if(T>w)return S.cursorY!==S.topMargin&&(S=b(S)),S;for(;!h(T,S);)S=b(S);return S}function k(p,S,T=0,w=0){let C=Math.max(T,f().trailingSpacing),R=C+S,I=d(R),H=I.cursorY===I.topMargin?0:C,L=l(I.columnIndex),B=I.cursorY+H;return p.x=L,p.y=B,I.page.fragments.push(p),I.cursorY=B+S,I.trailingSpacing=w,{state:I,x:L,y:B}}function y(){return m()}function F(){let p=f();return b(p)}function M(p){n=p,u=ae(t.w,r.left,r.right,n);let S=f();S.page.columns=n.count>1?{...n}:void 0,g=S.cursorY,S.columnIndex=0;}return {pages:a,states:o,get columnWidth(){return u},get columns(){return {...n}},getCurrentState:f,getAvailableHeight:()=>x(f()),fits:p=>h(p),ensureFits:d,addFragment:k,forcePageBreak:y,forceColumnBreak:F,getColumnX:l,updateColumns:M}}function j(e){let t=new Map,r=new Set;for(let n=0;n<e.length;n++){if(r.has(n))continue;let a=e[n];if(a.kind!=="paragraph"||!a.attrs?.keepNext)continue;let c=[n],i=n;for(let g=n+1;g<e.length;g++){let l=e[g];if(l.kind==="sectionBreak"||l.kind==="pageBreak"||l.kind==="columnBreak"||l.kind!=="paragraph")break;if(l.attrs?.keepNext)c.push(g),i=g,r.add(g);else break}let s=i+1,u=-1;if(s<e.length){let g=e[s];g.kind!=="sectionBreak"&&g.kind!=="pageBreak"&&g.kind!=="columnBreak"&&(u=s);}t.set(n,{startIndex:n,endIndex:i,memberIndices:c,anchorIndex:u});}return t}function q(e,t,r){let n=0;for(let a of e.memberIndices){let o=t[a],c=r[a];if(o.kind!=="paragraph"||c.kind!=="paragraph")continue;let i=o,s=c,u=i.attrs?.spacing?.before??0;n+=u,n+=s.totalHeight;let g=i.attrs?.spacing?.after??0;n+=g;}if(e.anchorIndex!==-1){let a=r[e.anchorIndex];if(a?.kind==="paragraph"){let o=a;o.lines.length>0&&(n+=o.lines[0].lineHeight);}}return n}function K(e){let t=new Set;for(let r of e.values())for(let n=1;n<r.memberIndices.length;n++)t.add(r.memberIndices[n]);return t}function $(e){return e.kind!=="paragraph"?false:e.attrs?.pageBreakBefore===true}var We={top:4,bottom:4,left:7,right:7},Ue=200;var Be={w:816,h:1056},O={top:96,right:96,bottom:96,left:96};function ie(e){return e.attrs?.spacing?.before??0}function se(e){return e.attrs?.spacing?.after??0}function Fe(e){for(let t=0;t<e.length-1;t++){let r=e[t],n=e[t+1];if(r.kind!=="paragraph"||n.kind!=="paragraph")continue;let a=r.attrs,o=n.attrs;a?.contextualSpacing&&o?.contextualSpacing&&a.styleId&&a.styleId===o.styleId&&(a.spacing&&(a.spacing={...a.spacing,after:0}),o.spacing&&(o.spacing={...o.spacing,before:0}));}}function rt(e,t,r={}){if(e.length!==t.length)throw new Error(`layoutDocument: expected one measure per block (blocks=${e.length}, measures=${t.length})`);let n=r.pageSize??Be,a={top:r.margins?.top??O.top,right:r.margins?.right??O.right,bottom:r.margins?.bottom??O.bottom,left:r.margins?.left??O.left,header:r.margins?.header??r.margins?.top??O.top,footer:r.margins?.footer??r.margins?.bottom??O.bottom};r.headerContentHeights,r.footerContentHeights,r.titlePage,r.evenAndOddHeaders;let o={...a},c=n.w-o.left-o.right;if(c<=0)throw new Error("layoutDocument: page size and margins yield no content area");let i={count:1,gap:0},s=[],u=[];for(let h=0;h<e.length;h++)if(e[h].kind==="sectionBreak"){let b=e[h];s.push(b.columns??i),u.push(b.type);}s.push(r.columns??i),u.push(r.bodyBreakType);let g=s.length>0?s[0]:r.columns,l=U({pageSize:n,margins:o,columns:g,footnoteReservedHeights:r.footnoteReservedHeights});Fe(e);let m=j(e),f=K(m),x=0;for(let h=0;h<e.length;h++){let b=e[h],d=t[h];$(b)&&l.forcePageBreak();let k=m.get(h);if(k&&!f.has(h)){let y=q(k,e,t),F=l.getCurrentState(),M=l.getAvailableHeight(),p=F.contentBottom-F.topMargin;y<=p&&y>M&&F.page.fragments.length>0&&l.forcePageBreak();}switch(b.kind){case "paragraph":Me(b,d,l,c);break;case "table":b.floating?Te(b,d,l,c):we(b,d,l);break;case "image":Ce(b,d,l);break;case "textBox":Re(b,d,l);break;case "pageBreak":l.forcePageBreak();break;case "columnBreak":l.forceColumnBreak();break;case "sectionBreak":{let y=u[x+1]??u[x];Le(b,l,s[x+1]??i,y),x++;break}}}return l.pages.length===0&&l.getCurrentState(),{pageSize:n,pages:l.pages,columns:r.columns,pageGap:r.pageGap}}function Me(e,t,r,n){if(t.kind!=="paragraph")throw new Error("layoutParagraph: expected paragraph measure");let a=t.lines;if(a.length===0){let s=ie(e),u=se(e),g=r.getCurrentState(),l={kind:"paragraph",blockId:e.id,x:r.getColumnX(g.columnIndex),y:g.cursorY+s,width:n,height:0,fromLine:0,toLine:0,pmStart:e.pmStart,pmEnd:e.pmEnd};r.addFragment(l,0,s,u);return}let o=ie(e),c=se(e),i=0;for(;i<a.length;){let s=r.getCurrentState(),u=r.getAvailableHeight(),g=0,l=0;for(let k=i;k<a.length;k++){let y=a[k].lineHeight,F=g+y;if((i===0&&k===i?F+o:F)<=u||l===0)g=F,l++;else break}let m=i===0,f=i+l>=a.length,x=m?o:0,h=f?c:0,b={kind:"paragraph",blockId:e.id,x:r.getColumnX(s.columnIndex),y:0,width:n,height:g,fromLine:i,toLine:i+l,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!m,continuesOnNext:!f},d=r.addFragment(b,g,x,h);b.y=d.y,i+=l,i<a.length&&r.ensureFits(a[i].lineHeight);}}function Pe(e){let t=0;for(let r of e.rows)if(r.isHeader)t++;else break;return t}function z(e,t){let r=0;for(let n=0;n<t&&n<e.rows.length;n++)r+=e.rows[n].height;return r}function we(e,t,r){if(t.kind!=="table")throw new Error("layoutTable: expected table measure");let n=t.rows;if(n.length===0)return;let a=Pe(e),o=z(t,a),c=0;for(;c<n.length;){let i=r.getCurrentState(),s=r.getAvailableHeight(),u=c===0,g=u?i.trailingSpacing:0,l=s-g,m=!u&&a>0?o:0,f=0,x=0;for(let F=c;F<n.length;F++){let M=n[F].height;if(f+M+m<=l||x===0)f+=M,x++;else break}let h=f+m,b=c+x>=n.length,d=r.getColumnX(i.columnIndex);e.justification==="center"?d=d+(r.columnWidth-t.totalWidth)/2:e.justification==="right"?d=d+r.columnWidth-t.totalWidth:e.indent&&(d+=e.indent);let k={kind:"table",blockId:e.id,x:d,y:0,width:t.totalWidth,height:h,fromRow:c,toRow:c+x,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!u,continuesOnNext:!b,headerRowCount:!u&&a>0?a:void 0},y=r.addFragment(k,h,0,0);if(k.y=y.y,k.x=d,c+=x,c<n.length){let F=n[c].height+(a>0?o:0);r.ensureFits(F);}}}function Te(e,t,r,n){if(t.kind!=="table")throw new Error("layoutFloatingTable: expected table measure");let a=r.getCurrentState(),o=e.floating,c=a.page,i=c.margins,s=t.totalWidth,u=t.totalHeight,g=c.size.h-i.top-i.bottom,l=i.left,m=i.top;o?.horzAnchor==="page"&&(l=0),o?.vertAnchor==="page"&&(m=0);let f=r.getColumnX(a.columnIndex);if(o?.tblpX!==void 0)f=l+o.tblpX;else if(o?.tblpXSpec){let y=o.tblpXSpec;y==="left"||y==="inside"?f=l:y==="right"||y==="outside"?f=l+n-s:y==="center"&&(f=l+(n-s)/2);}else e.justification==="center"?f=l+(n-s)/2:e.justification==="right"&&(f=l+n-s);let x=a.cursorY,h=false;if(o?.tblpY!==void 0)x=m+o.tblpY,h=true;else if(o?.tblpYSpec){h=true;let y=o.tblpYSpec;y==="top"?x=m:y==="bottom"?x=m+g-u:y==="center"&&(x=m+(g-u)/2);}h||(x=r.ensureFits(u).cursorY);let b=i.left,d=i.left+n-s;Number.isFinite(d)&&(f=Math.max(b,Math.min(f,d)));let k={kind:"table",blockId:e.id,x:f,y:x,width:s,height:u,fromRow:0,toRow:e.rows.length,pmStart:e.pmStart,pmEnd:e.pmEnd,isFloating:true};a.page.fragments.push(k);}function Ce(e,t,r){if(t.kind!=="image")throw new Error("layoutImage: expected image measure");if(e.anchor?.isAnchored){Ie(e,t,r);return}let n=r.ensureFits(t.height),a={kind:"image",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Ie(e,t,r){let n=r.getCurrentState(),a=e.anchor,o=a.offsetH??r.getColumnX(n.columnIndex),c=a.offsetV??n.cursorY,i={kind:"image",blockId:e.id,x:o,y:c,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd,isAnchored:true,zIndex:a.behindDoc?-1:1};n.page.fragments.push(i);}function Re(e,t,r){if(t.kind!=="textBox")throw new Error("layoutTextBox: expected textBox measure");let n=r.ensureFits(t.height),a={kind:"textBox",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Le(e,t,r,n){switch(n??"nextPage"){case "nextPage":t.forcePageBreak();break;case "evenPage":{t.forcePageBreak().page.number%2!==0&&t.forcePageBreak();break}case "oddPage":{t.forcePageBreak().page.number%2===0&&t.forcePageBreak();break}}t.updateColumns(r);}var ve={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Calibri","Carlito","Arial","Helvetica","sans-serif"],singleLineRatio:1.2207},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Cambria","Caladea","Georgia","serif"],singleLineRatio:1.2676},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arial","Arimo","Helvetica","sans-serif"],singleLineRatio:1.1499},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Times New Roman","Tinos","Times","serif"],singleLineRatio:1.1499},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Courier New","Cousine","Courier","monospace"],singleLineRatio:1.1328},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"],singleLineRatio:1.1362},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"],singleLineRatio:1.2153},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"],singleLineRatio:1.2075},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"],singleLineRatio:1.1431},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"],singleLineRatio:1.3936},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"],singleLineRatio:1.2197},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"],singleLineRatio:1.068},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"],singleLineRatio:1.1611},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"],singleLineRatio:1.1655},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"],singleLineRatio:1.1387},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"],singleLineRatio:1.1626},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"],singleLineRatio:1.15},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"],singleLineRatio:1.15},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"],singleLineRatio:1.15},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"],singleLineRatio:1.15},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"],singleLineRatio:1.15}},He={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function Ee(e){let t=e.toLowerCase();return t.includes("mono")||t.includes("courier")||t.includes("consolas")||t.includes("console")||t.includes("code")||t.includes("terminal")?"monospace":t.includes("times")||t.includes("georgia")||t.includes("garamond")||t.includes("palatino")||t.includes("baskerville")||t.includes("bodoni")||t.includes("cambria")||t.includes("mincho")||t.includes("ming")||t.includes("song")||t.includes("serif")?"serif":t.includes("script")||t.includes("cursive")||t.includes("comic")||t.includes("brush")||t.includes("hand")?"cursive":"sans-serif"}function ce(e){let t=e.trim().toLowerCase(),r=ve[t];if(r)return {googleFont:r.googleFont,cssFallback:r.fallbackStack.map(le).join(", "),originalFont:e,hasGoogleEquivalent:true,singleLineRatio:r.singleLineRatio};let n=Ee(e),a=He[n];return {googleFont:null,cssFallback:`${le(e)}, ${a}`,originalFont:e,hasGoogleEquivalent:false,singleLineRatio:1.15}}function le(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${e.replace(/"/g,'\\"')}"`:e}function ct(e,t){if(!t)return null;let n=e.toLowerCase().startsWith("major")?t.majorFont:t.minorFont;if(!n)return null;let a=e.toLowerCase();return a.includes("eastasia")||a.includes("ea")?n.ea??n.latin??null:a.includes("cs")||a.includes("bidi")?n.cs??n.latin??null:n.latin??null}var ge=96,me=11,pe="Calibri",Ne=1,Oe=.8,ze=.2,_=null;function J(){if(!_){let e=typeof document<"u"?document.createElement("canvas"):null;if(!e)throw new Error("Canvas not available. Ensure this runs in a DOM environment.");if(_=e.getContext("2d"),!_)throw new Error("Failed to get 2D context from canvas")}return _}function pt(){_=null;}var ue=new Map;function fe(e){let t=ue.get(e);if(t===void 0){let r=ce(e);t={cssFallback:r.cssFallback,singleLineRatio:r.singleLineRatio},ue.set(e,t);}return t}function _e(e){return fe(e).cssFallback}function V(e){let t=[];e.italic&&t.push("italic"),e.bold&&t.push("bold");let r=e.fontSize??me,n=de(r);t.push(`${n}px`);let a=e.fontFamily??pe;return t.push(_e(a)),t.join(" ")}function Ye(e){let t=e.fontSize??me,r=e.fontFamily??pe,n=de(t),a=n*Oe,o=n*ze,c=n*Ne;try{let s=J();s.font=V(e);let u=s.measureText("Hg");typeof u.actualBoundingBoxAscent=="number"&&typeof u.actualBoundingBoxDescent=="number"&&(a=u.actualBoundingBoxAscent,o=u.actualBoundingBoxDescent);}catch{}c=Math.max(c,a+o);let i=fe(r).singleLineRatio;return {fontSize:t,ascent:a,descent:o,lineHeight:c,fontFamily:r,singleLineRatio:i}}function ft(e,t){if(!e)return 0;let r=J();r.font=V(t);let a=r.measureText(e).width;return t.letterSpacing&&e.length>1&&(a+=t.letterSpacing*(e.length-1)),a}function Q(e,t){let r=Ye(t);if(!e)return {width:0,charWidths:[],metrics:r};let n=J();n.font=V(t);let a=t.letterSpacing??0,o=[],c=0;for(let i=0;i<e.length;i++){let s=e[i],g=n.measureText(s).width;a&&i<e.length-1&&(g+=a),o.push(g),c+=g;}return {width:c,charWidths:o,metrics:r}}function dt(e,t){if(t.length===0||e<=0)return 0;let r=0;for(let n=0;n<t.length;n++){let a=t[n],o=r+a/2;if(e<=o)return n;r+=a;}return t.length}function de(e){return e*ge/72}function Z(e,t){let r=e.pageGap??0,n=0;for(let a=0;a<t&&a<e.pages.length;a++){let c=e.pages[a].size?.h??e.pageSize.h;n+=c+r;}return n}function he(e,t){return e.findIndex(r=>r.id===t)}function Xe(e,t){let r=0;for(let n=e.fromLine;n<e.toLine&&n<t.lines.length;n++)r+=t.lines[n].lineHeight;return r}function xt(e,t,r,n){let a=[...e.page.fragments].sort((o,c)=>{let i=o.y-c.y;return Math.abs(i)>.5?i:o.x-c.x});for(let o of a){let c=he(t,o.blockId);if(c===-1)continue;let i=t[c],s=r[c];if(!i||!s)continue;let u;if(o.kind==="paragraph"){if(i.kind!=="paragraph"||s.kind!=="paragraph")continue;u=Xe(o,s);}else if(o.kind==="table")u=o.height;else if(o.kind==="image")u=o.height;else continue;let g=n.x>=o.x&&n.x<=o.x+o.width,l=n.y>=o.y&&n.y<=o.y+u;if(g&&l)return {fragment:o,block:i,measure:s,pageIndex:e.pageIndex,localX:n.x-o.x,localY:n.y-o.y}}return null}function kt(e,t,r,n){for(let a of e.page.fragments){if(a.kind!=="table")continue;let o=a,c=n.x>=o.x&&n.x<=o.x+o.width,i=n.y>=o.y&&n.y<=o.y+o.height;if(!c||!i)continue;let s=he(t,o.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="table"||!g||g.kind!=="table")continue;let l=u,m=g,f=n.x-o.x,x=n.y-o.y,h=o.headerRowCount??0,b=h>0&&o.continuesFromPrev?z(m,h):0,d=0,k=-1;if(m.rows.length===0||l.rows.length===0)continue;if(b>0&&x<b){let B=0;for(let P=0;P<h&&P<m.rows.length;P++){let E=m.rows[P];if(x>=B&&x<B+E.height){k=P;break}B+=E.height;}k===-1&&(k=0);}else {let B=x-b;for(let P=o.fromRow;P<o.toRow&&P<m.rows.length;P++){let E=m.rows[P];if(B>=d&&B<d+E.height){k=P;break}d+=E.height;}}if(k===-1&&(k=Math.min(o.toRow-1,m.rows.length-1),k<o.fromRow))continue;let y=m.rows[k],F=l.rows[k];if(!y||!F)continue;let M=0,p=-1;if(y.cells.length===0||F.cells.length===0)continue;for(let B=0;B<y.cells.length;B++){let P=y.cells[B];if(f>=M&&f<M+P.width){p=B;break}M+=P.width;}if(p===-1&&(p=y.cells.length-1,p<0))continue;let S=y.cells[p],T=F.cells[p];if(!S||!T)continue;let w=0;if(b>0&&k<h)for(let B=0;B<k;B++)w+=m.rows[B]?.height??0;else {w=b;for(let B=o.fromRow;B<k;B++)w+=m.rows[B]?.height??0;}let R=0;for(let B=0;B<p;B++)R+=y.cells[B]?.width??0;let I,v;if(T.blocks&&T.blocks.length>0){let B=T.blocks[0],P=S.blocks[0];B.kind==="paragraph"&&P?.kind==="paragraph"&&(I=B,v=P);}let H=f-R,L=x-w;return {fragment:o,block:l,measure:m,pageIndex:e.pageIndex,rowIndex:k,colIndex:p,cellBlock:I,cellMeasure:v,cellLocalX:Math.max(0,H),cellLocalY:Math.max(0,L)}}return null}function be(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function ee(e,t){return e.findIndex(r=>r.id===t)}function D(e,t){let n=(e.pmStart??0)+1,a=0,o;for(let s=0;s<e.runs.length&&s<=t.toRun;s++){let u=e.runs[s];if(u){if(s<t.fromRun)u.kind==="text"?a+=(u.text??"").length:a+=1;else if(s===t.fromRun){a+=t.fromChar,o=n+a;break}}}o===void 0&&(o=n);let c=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let u=e.runs[s];if(u)if(u.kind==="text"){let g=u.text??"",l=s===t.fromRun?t.fromChar:0,m=s===t.toRun?t.toChar:g.length;c+=m-l;}else c+=1;}let i=o+c;return {pmStart:o,pmEnd:i}}function xe(e,t,r,n){let a=[];for(let o=0;o<t.lines.length;o++){let c=t.lines[o],i=D(e,c);i.pmStart===void 0||i.pmEnd===void 0||i.pmEnd>r&&i.pmStart<n&&a.push({line:c,index:o});}return a}function Y(e,t,r){let n=D(e,t);return n.pmStart===void 0?0:Math.max(0,r-n.pmStart)}function X(e,t,r,n){let a=0,o=0;for(let c=t.fromRun;c<=t.toRun&&c<e.runs.length;c++){let i=e.runs[c];if(i){if(i.kind==="tab"){let s=i.width??48;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="image"){let s=i.width;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="lineBreak"){if(r<=o)return a;o+=1;continue}if(i.kind==="text"){let s=i.text??"",u=c===t.fromRun,g=c===t.toRun,l=u?t.fromChar:0,m=g?t.toChar:s.length,f=s.slice(l,m);if(o+f.length>=r){let b=r-o,d=be(i),k=Q(f.slice(0,b),d);return a+k.width}let x=be(i),h=Q(f,x);a+=h.width,o+=f.length;}}}return a}function G(e,t){let r=0;for(let n=0;n<t&&n<e.lines.length;n++)r+=e.lines[n].lineHeight;return r}function Mt(e,t,r,n,a){if(n===a)return [];let o=Math.min(n,a),c=Math.max(n,a),i=[];for(let s=0;s<e.pages.length;s++){let u=e.pages[s],g=Z(e,s);for(let l of u.fragments){if(l.kind==="paragraph"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="paragraph"||!x||x.kind!=="paragraph")continue;let h=f,b=x,d=l,k=xe(h,b,o,c);for(let{line:y,index:F}of k){if(F<d.fromLine||F>=d.toLine)continue;let M=D(h,y);if(M.pmStart===void 0||M.pmEnd===void 0)continue;let p=Math.max(M.pmStart,o),S=Math.min(M.pmEnd,c);if(p>=S)continue;let T=Y(h,y,p),w=Y(h,y,S),C=h.attrs?.indent,R=C?.left??0,I=C?.right??0,v=Math.max(0,l.width-R-I),H=X(h,y,T),L=X(h,y,w),B=h.attrs?.alignment??"left",P=0;B==="center"?P=Math.max(0,(v-y.width)/2):B==="right"&&(P=Math.max(0,v-y.width));let E=G(b,F)-G(b,d.fromLine),A=l.x+R+P+Math.min(H,L),W=Math.max(1,Math.abs(L-H)),N=l.y+E;i.push({x:A,y:N+g,width:W,height:y.lineHeight,pageIndex:s});}}if(l.kind==="table"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="table"||!x||x.kind!=="table")continue;let h=f,b=x,d=l,k=d.headerRowCount??0,F=k>0&&d.continuesFromPrev?z(b,k):0;for(let M=d.fromRow;M<d.toRow&&M<h.rows.length;M++){let p=h.rows[M],S=b.rows[M];if(!p||!S)continue;let T=0;for(let w=0;w<p.cells.length;w++){let C=p.cells[w],R=S.cells[w];if(!(!C||!R)){for(let I=0;I<C.blocks.length;I++){let v=C.blocks[I],H=R.blocks[I];if(!v||v.kind!=="paragraph"||!H||H.kind!=="paragraph")continue;let L=v,B=H,P=xe(L,B,o,c),E=0;for(let{line:A,index:W}of P){let N=D(L,A);if(N.pmStart===void 0||N.pmEnd===void 0)continue;let te=Math.max(N.pmStart,o),ne=Math.min(N.pmEnd,c);if(te>=ne)continue;let ke=Y(L,A,te),ye=Y(L,A,ne),re=X(L,A,ke,R.width),oe=X(L,A,ye,R.width),Se=G(B,W);i.push({x:d.x+T+Math.min(re,oe),y:d.y+F+E+Se+g,width:Math.max(1,Math.abs(oe-re)),height:A.lineHeight,pageIndex:s});}E+=B.totalHeight;}T+=R.width;}}F+=S.height;}}if(l.kind==="image"){let m=l.pmStart??0;(l.pmEnd??m+1)>o&&m<c&&i.push({x:l.x,y:l.y+g,width:l.width,height:l.height,pageIndex:s});}}}return i}function Pt(e,t,r,n){for(let a=0;a<e.pages.length;a++){let o=e.pages[a],c=Z(e,a);for(let i of o.fragments){if(i.kind==="paragraph"){let s=ee(t,i.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="paragraph"||!g||g.kind!=="paragraph")continue;let l=u,m=g,f=i,x=l.pmStart??0,h=l.pmEnd??x;if(n<x||n>h)continue;for(let b=f.fromLine;b<f.toLine;b++){let d=m.lines[b];if(!d)continue;let k=D(l,d);if(!(k.pmStart===void 0||k.pmEnd===void 0)&&n>=k.pmStart&&n<=k.pmEnd){let y=Y(l,d,n),F=l.attrs?.indent,M=F?.left??0,p=F?.right??0,S=Math.max(0,i.width-M-p),T=X(l,d,y),w=l.attrs?.alignment??"left",C=0;w==="center"?C=Math.max(0,(S-d.width)/2):w==="right"&&(C=Math.max(0,S-d.width));let R=G(m,b)-G(m,f.fromLine);return {x:i.x+M+C+T,y:i.y+R+c,height:d.lineHeight,pageIndex:a}}}}if(i.kind==="image"){let s=i.pmStart??0,u=i.pmEnd??s+1;if(n>=s&&n<=u){let g=n===s?0:i.width;return {x:i.x+g,y:i.y+c,height:i.height,pageIndex:a}}}}}return null}function wt(e){return e.length<=1?false:new Set(e.map(r=>r.pageIndex)).size>1}function Tt(e){let t=new Map;for(let r of e){let n=t.get(r.pageIndex)??[];n.push(r),t.set(r.pageIndex,n);}return t}exports.a=ce;exports.b=ct;exports.c=We;exports.d=Ue;exports.e=rt;exports.f=pt;exports.g=Ye;exports.h=ft;exports.i=Q;exports.j=dt;exports.k=de;exports.l=xt;exports.m=kt;exports.n=Mt;exports.o=Pt;exports.p=wt;exports.q=Tt;
|
|
1
|
+
'use strict';function ae(e,t,r,n){let a=e-t-r,o=(n.count-1)*n.gap;return (a-o)/n.count}function U(e){let{pageSize:t,margins:r}=e,n=e.columns??{count:1,gap:0},a=[],o=[],c=r.top,i=t.h-r.bottom;if(i-c<=0)throw new Error("Paginator: page size and margins yield no content area");let u=ae(t.w,r.left,r.right,n),g=c;function l(p){return r.left+p*(u+n.gap)}function m(){let p=a.length+1,S=e.footnoteReservedHeights?.get(p)??0,T=i-S,w={number:p,fragments:[],margins:{...r},size:{...t},footnoteReservedHeight:S>0?S:void 0,columns:n.count>1?{...n}:void 0},C={page:w,cursorY:c,columnIndex:0,topMargin:c,contentBottom:T,trailingSpacing:0};return a.push(w),o.push(C),g=c,e.onNewPage&&e.onNewPage(C),C}function f(){return o.length===0?m():o[o.length-1]}function x(p){return p.contentBottom-p.cursorY}function h(p,S){let T=S||f();return x(T)>=p}function b(p){return p.columnIndex<n.count-1?(p.columnIndex+=1,p.cursorY=g,p.trailingSpacing=0,p):m()}function d(p){let S=f(),T=Number.isFinite(p)&&p>0?p:0,w=S.contentBottom-S.topMargin;if(T>w)return S.cursorY!==S.topMargin&&(S=b(S)),S;for(;!h(T,S);)S=b(S);return S}function k(p,S,T=0,w=0){let C=Math.max(T,f().trailingSpacing),R=C+S,I=d(R),H=I.cursorY===I.topMargin?0:C,L=l(I.columnIndex),B=I.cursorY+H;return p.x=L,p.y=B,I.page.fragments.push(p),I.cursorY=B+S,I.trailingSpacing=w,{state:I,x:L,y:B}}function y(){return m()}function F(){let p=f();return b(p)}function M(p){n=p,u=ae(t.w,r.left,r.right,n);let S=f();S.page.columns=n.count>1?{...n}:void 0,g=S.cursorY,S.columnIndex=0;}return {pages:a,states:o,get columnWidth(){return u},get columns(){return {...n}},getCurrentState:f,getAvailableHeight:()=>x(f()),fits:p=>h(p),ensureFits:d,addFragment:k,forcePageBreak:y,forceColumnBreak:F,getColumnX:l,updateColumns:M}}function j(e){let t=new Map,r=new Set;for(let n=0;n<e.length;n++){if(r.has(n))continue;let a=e[n];if(a.kind!=="paragraph"||!a.attrs?.keepNext)continue;let c=[n],i=n;for(let g=n+1;g<e.length;g++){let l=e[g];if(l.kind==="sectionBreak"||l.kind==="pageBreak"||l.kind==="columnBreak"||l.kind!=="paragraph")break;if(l.attrs?.keepNext)c.push(g),i=g,r.add(g);else break}let s=i+1,u=-1;if(s<e.length){let g=e[s];g.kind!=="sectionBreak"&&g.kind!=="pageBreak"&&g.kind!=="columnBreak"&&(u=s);}t.set(n,{startIndex:n,endIndex:i,memberIndices:c,anchorIndex:u});}return t}function q(e,t,r){let n=0;for(let a of e.memberIndices){let o=t[a],c=r[a];if(o.kind!=="paragraph"||c.kind!=="paragraph")continue;let i=o,s=c,u=i.attrs?.spacing?.before??0;n+=u,n+=s.totalHeight;let g=i.attrs?.spacing?.after??0;n+=g;}if(e.anchorIndex!==-1){let a=r[e.anchorIndex];if(a?.kind==="paragraph"){let o=a;o.lines.length>0&&(n+=o.lines[0].lineHeight);}}return n}function K(e){let t=new Set;for(let r of e.values())for(let n=1;n<r.memberIndices.length;n++)t.add(r.memberIndices[n]);return t}function $(e){return e.kind!=="paragraph"?false:e.attrs?.pageBreakBefore===true}var We={top:4,bottom:4,left:7,right:7},Ue=200;var Be={w:816,h:1056},O={top:96,right:96,bottom:96,left:96};function ie(e){return e.attrs?.spacing?.before??0}function se(e){return e.attrs?.spacing?.after??0}function Fe(e){for(let t=0;t<e.length-1;t++){let r=e[t],n=e[t+1];if(r.kind!=="paragraph"||n.kind!=="paragraph")continue;let a=r.attrs,o=n.attrs;a?.contextualSpacing&&o?.contextualSpacing&&a.styleId&&a.styleId===o.styleId&&(a.spacing&&(a.spacing={...a.spacing,after:0}),o.spacing&&(o.spacing={...o.spacing,before:0}));}}function rt(e,t,r={}){if(e.length!==t.length)throw new Error(`layoutDocument: expected one measure per block (blocks=${e.length}, measures=${t.length})`);let n=r.pageSize??Be,a={top:r.margins?.top??O.top,right:r.margins?.right??O.right,bottom:r.margins?.bottom??O.bottom,left:r.margins?.left??O.left,header:r.margins?.header??r.margins?.top??O.top,footer:r.margins?.footer??r.margins?.bottom??O.bottom};r.headerContentHeights,r.footerContentHeights,r.titlePage,r.evenAndOddHeaders;let o={...a},c=n.w-o.left-o.right;if(c<=0)throw new Error("layoutDocument: page size and margins yield no content area");let i={count:1,gap:0},s=[],u=[];for(let h=0;h<e.length;h++)if(e[h].kind==="sectionBreak"){let b=e[h];s.push(b.columns??i),u.push(b.type);}s.push(r.columns??i),u.push(r.bodyBreakType);let g=s.length>0?s[0]:r.columns,l=U({pageSize:n,margins:o,columns:g,footnoteReservedHeights:r.footnoteReservedHeights});Fe(e);let m=j(e),f=K(m),x=0;for(let h=0;h<e.length;h++){let b=e[h],d=t[h];$(b)&&l.forcePageBreak();let k=m.get(h);if(k&&!f.has(h)){let y=q(k,e,t),F=l.getCurrentState(),M=l.getAvailableHeight(),p=F.contentBottom-F.topMargin;y<=p&&y>M&&F.page.fragments.length>0&&l.forcePageBreak();}switch(b.kind){case "paragraph":Me(b,d,l,c);break;case "table":b.floating?Te(b,d,l,c):we(b,d,l);break;case "image":Ce(b,d,l);break;case "textBox":Re(b,d,l);break;case "pageBreak":l.forcePageBreak();break;case "columnBreak":l.forceColumnBreak();break;case "sectionBreak":{let y=u[x+1]??u[x];Le(b,l,s[x+1]??i,y),x++;break}}}return l.pages.length===0&&l.getCurrentState(),{pageSize:n,pages:l.pages,columns:r.columns,pageGap:r.pageGap}}function Me(e,t,r,n){if(t.kind!=="paragraph")throw new Error("layoutParagraph: expected paragraph measure");let a=t.lines;if(a.length===0){let s=ie(e),u=se(e),g=r.getCurrentState(),l={kind:"paragraph",blockId:e.id,x:r.getColumnX(g.columnIndex),y:g.cursorY+s,width:n,height:0,fromLine:0,toLine:0,pmStart:e.pmStart,pmEnd:e.pmEnd};r.addFragment(l,0,s,u);return}let o=ie(e),c=se(e),i=0;for(;i<a.length;){let s=r.getCurrentState(),u=r.getAvailableHeight(),g=0,l=0;for(let k=i;k<a.length;k++){let y=a[k].lineHeight,F=g+y;if((i===0&&k===i?F+o:F)<=u||l===0)g=F,l++;else break}let m=i===0,f=i+l>=a.length,x=m?o:0,h=f?c:0,b={kind:"paragraph",blockId:e.id,x:r.getColumnX(s.columnIndex),y:0,width:n,height:g,fromLine:i,toLine:i+l,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!m,continuesOnNext:!f},d=r.addFragment(b,g,x,h);b.y=d.y,i+=l,i<a.length&&r.ensureFits(a[i].lineHeight);}}function Pe(e){let t=0;for(let r of e.rows)if(r.isHeader)t++;else break;return t}function z(e,t){let r=0;for(let n=0;n<t&&n<e.rows.length;n++)r+=e.rows[n].height;return r}function we(e,t,r){if(t.kind!=="table")throw new Error("layoutTable: expected table measure");let n=t.rows;if(n.length===0)return;let a=Pe(e),o=z(t,a),c=0;for(;c<n.length;){let i=r.getCurrentState(),s=r.getAvailableHeight(),u=c===0,g=u?i.trailingSpacing:0,l=s-g,m=!u&&a>0?o:0,f=0,x=0;for(let F=c;F<n.length;F++){let M=n[F].height;if(f+M+m<=l||x===0)f+=M,x++;else break}let h=f+m,b=c+x>=n.length,d=r.getColumnX(i.columnIndex);e.justification==="center"?d=d+(r.columnWidth-t.totalWidth)/2:e.justification==="right"?d=d+r.columnWidth-t.totalWidth:e.indent&&(d+=e.indent);let k={kind:"table",blockId:e.id,x:d,y:0,width:t.totalWidth,height:h,fromRow:c,toRow:c+x,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!u,continuesOnNext:!b,headerRowCount:!u&&a>0?a:void 0},y=r.addFragment(k,h,0,0);if(k.y=y.y,k.x=d,c+=x,c<n.length){let F=n[c].height+(a>0?o:0);r.ensureFits(F);}}}function Te(e,t,r,n){if(t.kind!=="table")throw new Error("layoutFloatingTable: expected table measure");let a=r.getCurrentState(),o=e.floating,c=a.page,i=c.margins,s=t.totalWidth,u=t.totalHeight,g=c.size.h-i.top-i.bottom,l=i.left,m=i.top;o?.horzAnchor==="page"&&(l=0),o?.vertAnchor==="page"&&(m=0);let f=r.getColumnX(a.columnIndex);if(o?.tblpX!==void 0)f=l+o.tblpX;else if(o?.tblpXSpec){let y=o.tblpXSpec;y==="left"||y==="inside"?f=l:y==="right"||y==="outside"?f=l+n-s:y==="center"&&(f=l+(n-s)/2);}else e.justification==="center"?f=l+(n-s)/2:e.justification==="right"&&(f=l+n-s);let x=a.cursorY,h=false;if(o?.tblpY!==void 0)x=m+o.tblpY,h=true;else if(o?.tblpYSpec){h=true;let y=o.tblpYSpec;y==="top"?x=m:y==="bottom"?x=m+g-u:y==="center"&&(x=m+(g-u)/2);}h||(x=r.ensureFits(u).cursorY);let b=i.left,d=i.left+n-s;Number.isFinite(d)&&(f=Math.max(b,Math.min(f,d)));let k={kind:"table",blockId:e.id,x:f,y:x,width:s,height:u,fromRow:0,toRow:e.rows.length,pmStart:e.pmStart,pmEnd:e.pmEnd,isFloating:true};a.page.fragments.push(k);}function Ce(e,t,r){if(t.kind!=="image")throw new Error("layoutImage: expected image measure");if(e.anchor?.isAnchored){Ie(e,t,r);return}let n=r.ensureFits(t.height),a={kind:"image",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Ie(e,t,r){let n=r.getCurrentState(),a=e.anchor,o=a.offsetH??r.getColumnX(n.columnIndex),c=a.offsetV??n.cursorY,i={kind:"image",blockId:e.id,x:o,y:c,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd,isAnchored:true,zIndex:a.behindDoc?-1:1};n.page.fragments.push(i);}function Re(e,t,r){if(t.kind!=="textBox")throw new Error("layoutTextBox: expected textBox measure");let n=r.ensureFits(t.height),a={kind:"textBox",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Le(e,t,r,n){switch(n??"nextPage"){case "nextPage":t.forcePageBreak();break;case "evenPage":{t.forcePageBreak().page.number%2!==0&&t.forcePageBreak();break}case "oddPage":{t.forcePageBreak().page.number%2===0&&t.forcePageBreak();break}}t.updateColumns(r);}var ve={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Calibri","Carlito","Arial","Helvetica","sans-serif"],singleLineRatio:1.2207},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Cambria","Caladea","Georgia","serif"],singleLineRatio:1.2676},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arial","Arimo","Helvetica","sans-serif"],singleLineRatio:1.1499},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Times New Roman","Tinos","Times","serif"],singleLineRatio:1.1499},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Courier New","Cousine","Courier","monospace"],singleLineRatio:1.1328},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"],singleLineRatio:1.1362},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"],singleLineRatio:1.2153},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"],singleLineRatio:1.2075},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"],singleLineRatio:1.1431},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"],singleLineRatio:1.3936},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"],singleLineRatio:1.2197},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"],singleLineRatio:1.068},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"],singleLineRatio:1.1611},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"],singleLineRatio:1.1655},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"],singleLineRatio:1.1387},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"],singleLineRatio:1.1626},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"],singleLineRatio:1.15},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"],singleLineRatio:1.15},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"],singleLineRatio:1.15},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"],singleLineRatio:1.15},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"],singleLineRatio:1.15}},He={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function Ee(e){let t=e.toLowerCase();return t.includes("mono")||t.includes("courier")||t.includes("consolas")||t.includes("console")||t.includes("code")||t.includes("terminal")?"monospace":t.includes("times")||t.includes("georgia")||t.includes("garamond")||t.includes("palatino")||t.includes("baskerville")||t.includes("bodoni")||t.includes("cambria")||t.includes("mincho")||t.includes("ming")||t.includes("song")||t.includes("serif")?"serif":t.includes("script")||t.includes("cursive")||t.includes("comic")||t.includes("brush")||t.includes("hand")?"cursive":"sans-serif"}function ce(e){let t=e.trim().toLowerCase(),r=ve[t];if(r)return {googleFont:r.googleFont,cssFallback:r.fallbackStack.map(le).join(", "),originalFont:e,hasGoogleEquivalent:true,singleLineRatio:r.singleLineRatio};let n=Ee(e),a=He[n];return {googleFont:null,cssFallback:`${le(e)}, ${a}`,originalFont:e,hasGoogleEquivalent:false,singleLineRatio:1.15}}function le(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${e.replace(/"/g,'\\"')}"`:e}function ct(e,t){if(!t)return null;let n=e.toLowerCase().startsWith("major")?t.majorFont:t.minorFont;if(!n)return null;let a=e.toLowerCase();return a.includes("eastasia")||a.includes("ea")?n.ea??n.latin??null:a.includes("cs")||a.includes("bidi")?n.cs??n.latin??null:n.latin??null}var ge=96,me=11,pe="Calibri",Ne=1,Oe=.8,ze=.2,_=null;function J(){if(!_){let e=typeof document<"u"?document.createElement("canvas"):null;if(!e)throw new Error("Canvas not available. Ensure this runs in a DOM environment.");if(_=e.getContext("2d"),!_)throw new Error("Failed to get 2D context from canvas")}return _}function pt(){_=null;}var ue=new Map;function fe(e){let t=ue.get(e);if(t===void 0){let r=ce(e);t={cssFallback:r.cssFallback,singleLineRatio:r.singleLineRatio},ue.set(e,t);}return t}function _e(e){return fe(e).cssFallback}function V(e){let t=[];e.italic&&t.push("italic"),e.bold&&t.push("bold");let r=e.fontSize??me,n=de(r);t.push(`${n}px`);let a=e.fontFamily??pe;return t.push(_e(a)),t.join(" ")}function Ye(e){let t=e.fontSize??me,r=e.fontFamily??pe,n=de(t),a=n*Oe,o=n*ze,c=n*Ne;try{let s=J();s.font=V(e);let u=s.measureText("Hg");typeof u.actualBoundingBoxAscent=="number"&&typeof u.actualBoundingBoxDescent=="number"&&(a=u.actualBoundingBoxAscent,o=u.actualBoundingBoxDescent);}catch{}c=Math.max(c,a+o);let i=fe(r).singleLineRatio;return {fontSize:t,ascent:a,descent:o,lineHeight:c,fontFamily:r,singleLineRatio:i}}function ft(e,t){if(!e)return 0;let r=J();r.font=V(t);let a=r.measureText(e).width;return t.letterSpacing&&e.length>1&&(a+=t.letterSpacing*(e.length-1)),a}function Q(e,t){let r=Ye(t);if(!e)return {width:0,charWidths:[],metrics:r};let n=J();n.font=V(t);let a=t.letterSpacing??0,o=[],c=0;for(let i=0;i<e.length;i++){let s=e[i],g=n.measureText(s).width;a&&i<e.length-1&&(g+=a),o.push(g),c+=g;}return {width:c,charWidths:o,metrics:r}}function dt(e,t){if(t.length===0||e<=0)return 0;let r=0;for(let n=0;n<t.length;n++){let a=t[n],o=r+a/2;if(e<=o)return n;r+=a;}return t.length}function de(e){return e*ge/72}function Z(e,t){let r=e.pageGap??0,n=0;for(let a=0;a<t&&a<e.pages.length;a++){let c=e.pages[a].size?.h??e.pageSize.h;n+=c+r;}return n}function he(e,t){return e.findIndex(r=>r.id===t)}function Xe(e,t){let r=0;for(let n=e.fromLine;n<e.toLine&&n<t.lines.length;n++)r+=t.lines[n].lineHeight;return r}function xt(e,t,r,n){let a=[...e.page.fragments].sort((o,c)=>{let i=o.y-c.y;return Math.abs(i)>.5?i:o.x-c.x});for(let o of a){let c=he(t,o.blockId);if(c===-1)continue;let i=t[c],s=r[c];if(!i||!s)continue;let u;if(o.kind==="paragraph"){if(i.kind!=="paragraph"||s.kind!=="paragraph")continue;u=Xe(o,s);}else if(o.kind==="table")u=o.height;else if(o.kind==="image")u=o.height;else continue;let g=n.x>=o.x&&n.x<=o.x+o.width,l=n.y>=o.y&&n.y<=o.y+u;if(g&&l)return {fragment:o,block:i,measure:s,pageIndex:e.pageIndex,localX:n.x-o.x,localY:n.y-o.y}}return null}function kt(e,t,r,n){for(let a of e.page.fragments){if(a.kind!=="table")continue;let o=a,c=n.x>=o.x&&n.x<=o.x+o.width,i=n.y>=o.y&&n.y<=o.y+o.height;if(!c||!i)continue;let s=he(t,o.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="table"||!g||g.kind!=="table")continue;let l=u,m=g,f=n.x-o.x,x=n.y-o.y,h=o.headerRowCount??0,b=h>0&&o.continuesFromPrev?z(m,h):0,d=0,k=-1;if(m.rows.length===0||l.rows.length===0)continue;if(b>0&&x<b){let B=0;for(let P=0;P<h&&P<m.rows.length;P++){let E=m.rows[P];if(x>=B&&x<B+E.height){k=P;break}B+=E.height;}k===-1&&(k=0);}else {let B=x-b;for(let P=o.fromRow;P<o.toRow&&P<m.rows.length;P++){let E=m.rows[P];if(B>=d&&B<d+E.height){k=P;break}d+=E.height;}}if(k===-1&&(k=Math.min(o.toRow-1,m.rows.length-1),k<o.fromRow))continue;let y=m.rows[k],F=l.rows[k];if(!y||!F)continue;let M=0,p=-1;if(y.cells.length===0||F.cells.length===0)continue;for(let B=0;B<y.cells.length;B++){let P=y.cells[B];if(f>=M&&f<M+P.width){p=B;break}M+=P.width;}if(p===-1&&(p=y.cells.length-1,p<0))continue;let S=y.cells[p],T=F.cells[p];if(!S||!T)continue;let w=0;if(b>0&&k<h)for(let B=0;B<k;B++)w+=m.rows[B]?.height??0;else {w=b;for(let B=o.fromRow;B<k;B++)w+=m.rows[B]?.height??0;}let R=0;for(let B=0;B<p;B++)R+=y.cells[B]?.width??0;let I,v;if(T.blocks&&T.blocks.length>0){let B=T.blocks[0],P=S.blocks[0];B.kind==="paragraph"&&P?.kind==="paragraph"&&(I=B,v=P);}let H=f-R,L=x-w;return {fragment:o,block:l,measure:m,pageIndex:e.pageIndex,rowIndex:k,colIndex:p,cellBlock:I,cellMeasure:v,cellLocalX:Math.max(0,H),cellLocalY:Math.max(0,L)}}return null}function be(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function ee(e,t){return e.findIndex(r=>r.id===t)}function D(e,t){let n=(e.pmStart??0)+1,a=0,o;for(let s=0;s<e.runs.length&&s<=t.toRun;s++){let u=e.runs[s];if(u){if(s<t.fromRun)u.kind==="text"?a+=(u.text??"").length:a+=1;else if(s===t.fromRun){a+=t.fromChar,o=n+a;break}}}o===void 0&&(o=n);let c=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let u=e.runs[s];if(u)if(u.kind==="text"){let g=u.text??"",l=s===t.fromRun?t.fromChar:0,m=s===t.toRun?t.toChar:g.length;c+=m-l;}else c+=1;}let i=o+c;return {pmStart:o,pmEnd:i}}function xe(e,t,r,n){let a=[];for(let o=0;o<t.lines.length;o++){let c=t.lines[o],i=D(e,c);i.pmStart===void 0||i.pmEnd===void 0||i.pmEnd>r&&i.pmStart<n&&a.push({line:c,index:o});}return a}function Y(e,t,r){let n=D(e,t);return n.pmStart===void 0?0:Math.max(0,r-n.pmStart)}function X(e,t,r,n){let a=0,o=0;for(let c=t.fromRun;c<=t.toRun&&c<e.runs.length;c++){let i=e.runs[c];if(i){if(i.kind==="tab"){let s=i.width??48;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="image"){let s=i.width;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="lineBreak"){if(r<=o)return a;o+=1;continue}if(i.kind==="text"){let s=i.text??"",u=c===t.fromRun,g=c===t.toRun,l=u?t.fromChar:0,m=g?t.toChar:s.length,f=s.slice(l,m);if(o+f.length>=r){let b=r-o,d=be(i),k=Q(f.slice(0,b),d);return a+k.width}let x=be(i),h=Q(f,x);a+=h.width,o+=f.length;}}}return a}function G(e,t){let r=0;for(let n=0;n<t&&n<e.lines.length;n++)r+=e.lines[n].lineHeight;return r}function Mt(e,t,r,n,a){if(n===a)return [];let o=Math.min(n,a),c=Math.max(n,a),i=[];for(let s=0;s<e.pages.length;s++){let u=e.pages[s],g=Z(e,s);for(let l of u.fragments){if(l.kind==="paragraph"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="paragraph"||!x||x.kind!=="paragraph")continue;let h=f,b=x,d=l,k=xe(h,b,o,c);for(let{line:y,index:F}of k){if(F<d.fromLine||F>=d.toLine)continue;let M=D(h,y);if(M.pmStart===void 0||M.pmEnd===void 0)continue;let p=Math.max(M.pmStart,o),S=Math.min(M.pmEnd,c);if(p>=S)continue;let T=Y(h,y,p),w=Y(h,y,S),C=h.attrs?.indent,R=C?.left??0,I=C?.right??0,v=Math.max(0,l.width-R-I),H=X(h,y,T),L=X(h,y,w),B=h.attrs?.alignment??"left",P=0;B==="center"?P=Math.max(0,(v-y.width)/2):B==="right"&&(P=Math.max(0,v-y.width));let E=G(b,F)-G(b,d.fromLine),A=l.x+R+P+Math.min(H,L),W=Math.max(1,Math.abs(L-H)),N=l.y+E;i.push({x:A,y:N+g,width:W,height:y.lineHeight,pageIndex:s});}}if(l.kind==="table"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="table"||!x||x.kind!=="table")continue;let h=f,b=x,d=l,k=d.headerRowCount??0,F=k>0&&d.continuesFromPrev?z(b,k):0;for(let M=d.fromRow;M<d.toRow&&M<h.rows.length;M++){let p=h.rows[M],S=b.rows[M];if(!p||!S)continue;let T=0;for(let w=0;w<p.cells.length;w++){let C=p.cells[w],R=S.cells[w];if(!(!C||!R)){for(let I=0;I<C.blocks.length;I++){let v=C.blocks[I],H=R.blocks[I];if(!v||v.kind!=="paragraph"||!H||H.kind!=="paragraph")continue;let L=v,B=H,P=xe(L,B,o,c),E=0;for(let{line:A,index:W}of P){let N=D(L,A);if(N.pmStart===void 0||N.pmEnd===void 0)continue;let te=Math.max(N.pmStart,o),ne=Math.min(N.pmEnd,c);if(te>=ne)continue;let ke=Y(L,A,te),ye=Y(L,A,ne),re=X(L,A,ke,R.width),oe=X(L,A,ye,R.width),Se=G(B,W);i.push({x:d.x+T+Math.min(re,oe),y:d.y+F+E+Se+g,width:Math.max(1,Math.abs(oe-re)),height:A.lineHeight,pageIndex:s});}E+=B.totalHeight;}T+=R.width;}}F+=S.height;}}if(l.kind==="image"){let m=l.pmStart??0;(l.pmEnd??m+1)>o&&m<c&&i.push({x:l.x,y:l.y+g,width:l.width,height:l.height,pageIndex:s});}}}return i}function Pt(e,t,r,n){for(let a=0;a<e.pages.length;a++){let o=e.pages[a],c=Z(e,a);for(let i of o.fragments){if(i.kind==="paragraph"){let s=ee(t,i.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="paragraph"||!g||g.kind!=="paragraph")continue;let l=u,m=g,f=i,x=l.pmStart??0,h=l.pmEnd??x;if(n<x||n>h)continue;for(let b=f.fromLine;b<f.toLine;b++){let d=m.lines[b];if(!d)continue;let k=D(l,d);if(!(k.pmStart===void 0||k.pmEnd===void 0)&&n>=k.pmStart&&n<=k.pmEnd){let y=Y(l,d,n),F=l.attrs?.indent,M=F?.left??0,p=F?.right??0,S=Math.max(0,i.width-M-p),T=X(l,d,y),w=l.attrs?.alignment??"left",C=0;w==="center"?C=Math.max(0,(S-d.width)/2):w==="right"&&(C=Math.max(0,S-d.width));let R=G(m,b)-G(m,f.fromLine);return {x:i.x+M+C+T,y:i.y+R+c,height:d.lineHeight,pageIndex:a}}}}if(i.kind==="image"){let s=i.pmStart??0,u=i.pmEnd??s+1;if(n>=s&&n<=u){let g=n===s?0:i.width;return {x:i.x+g,y:i.y+c,height:i.height,pageIndex:a}}}}}return null}function wt(e){return e.length<=1?false:new Set(e.map(r=>r.pageIndex)).size>1}function Tt(e){let t=new Map;for(let r of e){let n=t.get(r.pageIndex)??[];n.push(r),t.set(r.pageIndex,n);}return t}exports.a=ce;exports.b=ct;exports.c=We;exports.d=Ue;exports.e=rt;exports.f=pt;exports.g=Ye;exports.h=ft;exports.i=Q;exports.j=dt;exports.k=de;exports.l=Z;exports.m=xt;exports.n=kt;exports.o=Mt;exports.p=Pt;exports.q=wt;exports.r=Tt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d as d$1}from'./chunk-TAUMSKRE.mjs';function E(){return {type:"break",breakType:"page"}}function K(){return {type:"break",breakType:"column"}}function j(t){return {type:"break",breakType:"textWrapping",clear:t}}function Z(){return {type:"run",content:[E()]}}function R(){return {type:"paragraph",content:[],formatting:{pageBreakBefore:true}}}function I(t){return t.content.filter(n=>n.type==="run")}function q(t,n){let{paragraphIndex:e}=n,o=[...t.package.document.content||[]],r=R();return o.splice(e+1,0,r),{...t,package:{...t.package,document:{...t.package.document,content:o}}}}function k(){return {type:"paragraph",content:[],formatting:{borders:{bottom:{style:"single",color:{rgb:"000000"},size:12,space:1}},spaceBefore:120,spaceAfter:120}}}function G(t,n){let{paragraphIndex:e}=n,o=[...t.package.document.content||[]],r=k();return o.splice(e+1,0,r),{...t,package:{...t.package,document:{...t.package.document,content:o}}}}function d(t){return t.type==="break"&&t.breakType==="page"}function Y(t){return t.type==="break"&&t.breakType==="column"}function Q(t){return t.type==="break"&&t.breakType==="textWrapping"}function ee(t){return t.type==="break"}function g(t){return t.formatting?.pageBreakBefore===true}function te(t){let n=0;for(let e of t.package.document.content||[])if(e.type==="paragraph"){let o=e;g(o)&&n++;let r=I(o);for(let a of r)for(let s of a.content)d(s)&&n++;}return n}function ne(t){let n=[],e=t.package.document.content||[];for(let o=0;o<e.length;o++){let r=e[o];if(r.type==="paragraph"){let a=r;g(a)&&n.push({paragraphIndex:o});let s=I(a);for(let l=0;l<s.length;l++){let c=s[l];for(let p of c.content)d(p)&&n.push({paragraphIndex:o,runIndex:l});}}}return n}function oe(t,n){let{paragraphIndex:e,runIndex:o}=n,r=[...t.package.document.content||[]],a=r[e];if(a.type!=="paragraph")return t;let s=a;if(g(s)&&o===void 0)return r[e]={...s,formatting:{...s.formatting,pageBreakBefore:false}},{...t,package:{...t.package,document:{...t.package.document,content:r}}};if(o!==void 0){let l=[],c=0;for(let p of s.content)if(p.type==="run"){if(c===o){let D=p.content.filter(X=>!d(X));D.length>0&&l.push({...p,content:D});}else l.push(p);c++;}else l.push(p);return r[e]={...s,content:l},{...t,package:{...t.package,document:{...t.package.document,content:r}}}}return t}var u=class{constructor(n){d$1(this,"listeners",new Set);d$1(this,"snapshot");d$1(this,"subscribe",n=>(this.listeners.add(n),()=>{this.listeners.delete(n);}));d$1(this,"getSnapshot",()=>this.snapshot);this.snapshot=n;}setSnapshot(n){this.snapshot=n,this.notify();}notify(){for(let n of this.listeners)n();}};var _="docx-editor-autosave",re=3e4,ae=1440*60*1e3,ie=2e3,A=1;function L(){try{let t="__docx_editor_test__";return localStorage.setItem(t,"test"),localStorage.removeItem(t),!0}catch{return false}}function P(t){return JSON.stringify({...t,originalBuffer:null})}function se(t){try{let n=JSON.parse(t);return !n||typeof n!="object"||!n.document||!n.savedAt?null:(n.version!==A&&console.warn("Auto-save data version mismatch, may need migration"),n)}catch{return null}}function le(t,n){let e=new Date(t).getTime();return Date.now()-e>n}var h=class extends u{constructor(e={}){super({status:"idle",lastSaveTime:null,hasRecoveryData:false,isEnabled:true});d$1(this,"storageKey");d$1(this,"interval");d$1(this,"maxAge");d$1(this,"saveOnChange");d$1(this,"debounceDelay");d$1(this,"onSaveCallback");d$1(this,"onErrorCallback");d$1(this,"onRecoveryAvailableCallback");d$1(this,"storageAvailable");d$1(this,"currentDocument",null);d$1(this,"lastSavedJson",null);d$1(this,"intervalTimer",null);d$1(this,"debounceTimer",null);d$1(this,"status","idle");d$1(this,"lastSaveTime",null);d$1(this,"_hasRecoveryData",false);d$1(this,"_isEnabled");this.storageKey=e.storageKey??_,this.interval=e.interval??re,this.maxAge=e.maxAge??ae,this.saveOnChange=e.saveOnChange??true,this.debounceDelay=e.debounceDelay??ie,this.onSaveCallback=e.onSave,this.onErrorCallback=e.onError,this.onRecoveryAvailableCallback=e.onRecoveryAvailable,this._isEnabled=true,this.storageAvailable=L(),this.checkRecoveryData();}onDocumentChanged(e){this.currentDocument=e,this._isEnabled&&this.saveOnChange&&e&&this.storageAvailable&&this.debounceSave();}async save(){if(!this.storageAvailable)return this.onErrorCallback?.(new Error("localStorage is not available")),false;let e=this.currentDocument;if(!e)return false;this.updateStatus("saving");try{let o=P(e);if(o===this.lastSavedJson)return this.updateStatus("saved"),!0;this.persistToStorage(o),this.lastSavedJson=o;let r=new Date;return this.lastSaveTime=r,this.updateStatus("saved"),this.onSaveCallback?.(r),!0}catch(o){return console.error("Auto-save failed:",o),this.updateStatus("error"),this.onErrorCallback?.(o),false}}clear(){if(this.storageAvailable)try{localStorage.removeItem(this.storageKey),this._hasRecoveryData=!1,this.lastSavedJson=null,this.emitSnapshot();}catch(e){console.error("Failed to clear auto-save:",e);}}getRecoveryData(){if(!this.storageAvailable)return null;try{let e=localStorage.getItem(this.storageKey);if(!e)return null;let o=se(e);return o?le(o.savedAt,this.maxAge)?(this.clear(),null):o:null}catch{return null}}acceptRecovery(){let e=this.getRecoveryData();return e?(this._hasRecoveryData=false,this.emitSnapshot(),e.document):null}dismissRecovery(){this.clear(),this._hasRecoveryData=false,this.emitSnapshot();}enable(){this._isEnabled=true,this.startInterval(),this.emitSnapshot();}disable(){this._isEnabled=false,this.stopTimers(),this.emitSnapshot();}startInterval(){this.stopTimers(),!(!this._isEnabled||!this.storageAvailable)&&(this.intervalTimer=setInterval(()=>{this.save();},this.interval));}destroy(){if(this.stopTimers(),this._isEnabled&&this.currentDocument&&this.storageAvailable)try{this.persistToStorage(P(this.currentDocument));}catch(e){console.error("Failed to save on destroy:",e);}}checkRecoveryData(){if(!this.storageAvailable)return;let e=this.getRecoveryData();e&&(this._hasRecoveryData=true,this.emitSnapshot(),this.onRecoveryAvailableCallback?.(e));}persistToStorage(e){let o={document:JSON.parse(e),savedAt:new Date().toISOString(),version:A};localStorage.setItem(this.storageKey,JSON.stringify(o));}debounceSave(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.save();},this.debounceDelay);}stopTimers(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null),this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null);}updateStatus(e){this.status=e,this.emitSnapshot();}emitSnapshot(){this.setSnapshot({status:this.status,lastSaveTime:this.lastSaveTime,hasRecoveryData:this._hasRecoveryData,isEnabled:this._isEnabled});}};function B(t){if(!t)return "Never";let e=new Date().getTime()-t.getTime(),o=Math.floor(e/1e3),r=Math.floor(o/60),a=Math.floor(r/60);return o<10?"Just now":o<60?`${o} seconds ago`:r<60?`${r} minute${r===1?"":"s"} ago`:a<24?`${a} hour${a===1?"":"s"} ago`:t.toLocaleDateString()}function F(t){return {idle:"Ready",saving:"Saving...",saved:"Saved",error:"Save failed"}[t]}function z(t=_){try{let n=localStorage.getItem(t);return n?new Blob([n]).size:0}catch{return 0}}function w(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function N(){return L()}var m={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function O(t,n){if(!(t instanceof Element))return null;let e=t;for(;e&&e!==n;){if(e.tagName==="TD"||e.tagName==="TH"){let o=e.getAttribute(m.ROW_INDEX),r=e.getAttribute(m.COLUMN_INDEX);if(o!==null&&r!==null){let a=e;for(;a&&a!==n;){if(a.tagName==="TABLE"){let s=a.getAttribute(m.TABLE_INDEX);if(s!==null)return {tableIndex:parseInt(s,10),rowIndex:parseInt(o,10),columnIndex:parseInt(r,10)};break}a=a.parentElement;}}break}e=e.parentElement;}return null}function M(t,n){if(!t.package?.document?.content)return null;let e=0;for(let o of t.package.document.content)if(o.type==="table"){if(e===n)return o;e++;}return null}function H(t,n,e){if(!t.package?.document?.content)return t;let o=0,r=t.package.document.content.map(a=>{if(a.type==="table"){if(o===n)return o++,e;o++;}return a});return {...t,package:{...t.package,document:{...t.package.document,content:r}}}}function V(t,n){if(!t.package?.document?.content)return t;let e=0,o=t.package.document.content.filter(r=>{if(r.type==="table"){let a=e===n;return e++,!a}return true});return {...t,package:{...t.package,document:{...t.package.document,content:o}}}}var f=class extends u{constructor(){super({selectedCell:null});}selectCell(n){this.setSnapshot({selectedCell:n});}clearSelection(){this.setSnapshot({selectedCell:null});}isCellSelected(n,e,o){let{selectedCell:r}=this.getSnapshot();return r?r.tableIndex===n&&r.rowIndex===e&&r.columnIndex===o:false}getSelectedCell(){return this.getSnapshot().selectedCell}};function W(t){if(!t||t==="transparent"||t==="inherit")return null;if(t.startsWith("#"))return t.slice(1).toUpperCase();let n=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(n){let e=parseInt(n[1]).toString(16).padStart(2,"0"),o=parseInt(n[2]).toString(16).padStart(2,"0"),r=parseInt(n[3]).toString(16).padStart(2,"0");return (e+o+r).toUpperCase()}return null}function y(t){let n=window.getComputedStyle(t),e={};(n.fontWeight==="bold"||parseInt(n.fontWeight)>=700)&&(e.bold=true),n.fontStyle==="italic"&&(e.italic=true);let o=n.textDecoration||n.textDecorationLine;o&&o.includes("underline")&&(e.underline={style:"single"}),o&&o.includes("line-through")&&(e.strike=true);let r=parseFloat(n.fontSize);!isNaN(r)&&r>0&&(e.fontSize=Math.round(r/1.333*2));let a=n.fontFamily.replace(/["']/g,"").split(",")[0].trim();a&&(e.fontFamily={ascii:a});let s=n.color;if(s&&s!=="rgb(0, 0, 0)"){let c=W(s);c&&(e.color={rgb:c});}let l=n.backgroundColor;if(l&&l!=="transparent"&&l!=="rgba(0, 0, 0, 0)"){let c=T(l);c&&(e.shading={fill:{rgb:c}});}return Object.keys(e).length>0?e:void 0}function ue(t,n){let e=document.createRange();e.selectNodeContents(t);let o=n.compareBoundaryPoints(Range.START_TO_START,e)>=0&&n.compareBoundaryPoints(Range.START_TO_END,e)<=0,r=n.compareBoundaryPoints(Range.END_TO_START,e)>=0&&n.compareBoundaryPoints(Range.END_TO_END,e)<=0;if(o&&r)return n.toString();if(o){let a=document.createRange();return a.setStart(n.startContainer,n.startOffset),a.selectNodeContents(t),a.setEnd(e.endContainer,e.endOffset),a.toString()}else if(r){let a=document.createRange();return a.selectNodeContents(t),a.setEnd(n.endContainer,n.endOffset),a.setStart(e.startContainer,e.startOffset),a.toString()}else if(n.intersectsNode(t))return t.textContent||"";return ""}function U(t){let n=t;for(;n;){if(n.nodeType===Node.ELEMENT_NODE){let e=n;if(e.hasAttribute("data-paragraph-index"))return e}n=n.parentNode;}return null}function C(){let t=window.getSelection();if(!t||t.isCollapsed)return [];let n=[],e=t.getRangeAt(0),o=e.commonAncestorContainer,r=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement;if(!r)return n;if(r.querySelectorAll(".docx-run").forEach(s=>{if(e.intersectsNode(s)){let l=ue(s,e);if(l){let c=y(s);n.push({type:"run",formatting:c,content:[{type:"text",text:l}]});}}}),n.length===0){let s=t.toString();s&&n.push({type:"run",content:[{type:"text",text:s}]});}return n}function $(){let t=window.getSelection();if(!t||t.isCollapsed)return null;let n=C();if(n.length===0)return null;let e=t.toString(),o=t.getRangeAt(0),r=U(o.startContainer),a=U(o.endContainer),s=r?parseInt(r.getAttribute("data-paragraph-index")||"0",10):0,l=a?parseInt(a.getAttribute("data-paragraph-index")||"0",10):0;return {text:e,runs:n,startParagraphIndex:s,startRunIndex:0,startOffset:o.startOffset,endParagraphIndex:l,endRunIndex:0,endOffset:o.endOffset,isMultiParagraph:s!==l}}var T=W;var S=class extends u{constructor(){super({notifications:[]});d$1(this,"notifications",[]);d$1(this,"idCounter",0);d$1(this,"timers",new Set);}showError(e,o){return this.addNotification(e,"error",o)}showWarning(e,o){return this.addNotification(e,"warning",o)}showInfo(e,o){return this.addNotification(e,"info",o)}dismiss(e){this.notifications=this.notifications.map(r=>r.id===e?{...r,dismissed:true}:r),this.emitSnapshot();let o=setTimeout(()=>{this.timers.delete(o),this.notifications=this.notifications.filter(r=>r.id!==e),this.emitSnapshot();},300);this.timers.add(o);}clearAll(){this.notifications=[];for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.emitSnapshot();}destroy(){for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.notifications=[];}addNotification(e,o,r){let a=`error-${++this.idCounter}-${Date.now()}`,s={id:a,message:e,severity:o,details:r,timestamp:Date.now()};if(this.notifications=[...this.notifications,s],this.emitSnapshot(),o!=="error"){let l=setTimeout(()=>{this.timers.delete(l),this.dismiss(a);},5e3);this.timers.add(l);}return a}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};function J(t,n){let e=`plugin-styles-${t}`,o=document.getElementById(e);o&&o.remove();let r=document.createElement("style");return r.id=e,r.textContent=n,document.head.appendChild(r),()=>{let a=document.getElementById(e);a&&a.remove();}}var v=class extends u{constructor(){super({states:new Map,version:0});d$1(this,"plugins",[]);d$1(this,"pluginStates",new Map);d$1(this,"version",0);}initialize(e,o){this.destroyPlugins(),this.plugins=e;for(let r of e)r.initialize&&!this.pluginStates.has(r.id)&&this.pluginStates.set(r.id,r.initialize(o));this.emitSnapshot();}updateStates(e){let o=false;for(let r of this.plugins)if(r.onStateChange){let a=r.onStateChange(e);a!==void 0&&(this.pluginStates.set(r.id,a),o=true);}return o&&(this.version++,this.emitSnapshot()),o}getPluginState(e){return this.pluginStates.get(e)}setPluginState(e,o){this.pluginStates.set(e,o),this.version++,this.emitSnapshot();}destroy(){this.destroyPlugins(),this.emitSnapshot();}destroyPlugins(){for(let e of this.plugins)e.destroy&&e.destroy();this.pluginStates.clear(),this.plugins=[];}emitSnapshot(){this.setSnapshot({states:new Map(this.pluginStates),version:this.version});}};var b=class extends u{constructor(){super({hasLayout:false,selectionRects:[],caretPosition:null,selectedImageInfo:null,isFocused:false,isDragging:false,isResizingColumn:false,isImageInteracting:false,version:0});d$1(this,"_hasLayout",false);d$1(this,"_selectionRects",[]);d$1(this,"_caretPosition",null);d$1(this,"_isDragging",false);d$1(this,"_dragAnchor",null);d$1(this,"_columnResize",{isResizing:false,startX:0,columnIndex:0,tablePmStart:0,originalWidths:{left:0,right:0}});d$1(this,"_selectedImageInfo",null);d$1(this,"_isImageInteracting",false);d$1(this,"_isFocused",false);d$1(this,"_version",0);}setLayoutReady(e){this._hasLayout=e,this.emitSnapshot();}updateSelection(e,o){this._selectionRects=e,this._caretPosition=o,this.emitSnapshot();}startDrag(e){this._isDragging=true,this._dragAnchor=e,this.emitSnapshot();}endDrag(){this._isDragging=false,this._dragAnchor=null,this.emitSnapshot();}getDragAnchor(){return this._dragAnchor}startColumnResize(e,o,r,a){this._columnResize={isResizing:true,startX:r,columnIndex:o,tablePmStart:e,originalWidths:a},this.emitSnapshot();}endColumnResize(){this._columnResize={...this._columnResize,isResizing:false},this.emitSnapshot();}getColumnResize(){return this._columnResize}setSelectedImage(e){this._selectedImageInfo=e,this.emitSnapshot();}clearSelectedImage(){this._selectedImageInfo=null,this._isImageInteracting=false,this.emitSnapshot();}setImageInteracting(e){this._isImageInteracting=e,this.emitSnapshot();}setFocused(e){this._isFocused=e,this.emitSnapshot();}emitSnapshot(){this._version++,this.setSnapshot({hasLayout:this._hasLayout,selectionRects:this._selectionRects,caretPosition:this._caretPosition,selectedImageInfo:this._selectedImageInfo,isFocused:this._isFocused,isDragging:this._isDragging,isResizingColumn:this._columnResize.isResizing,isImageInteracting:this._isImageInteracting,version:this._version});}};var x=class extends u{constructor(e={}){let o=e.initialZoom??1;super({loadingState:"idle",parseError:null,isReady:false,zoom:o,fontsLoaded:false,version:0});d$1(this,"_loadingState","idle");d$1(this,"_parseError",null);d$1(this,"_zoom");d$1(this,"_fontsLoaded",false);d$1(this,"_document",null);d$1(this,"_version",0);d$1(this,"onChangeCallback");d$1(this,"onErrorCallback");this._zoom=o,this.onChangeCallback=e.onChange,this.onErrorCallback=e.onError;}setParsingStarted(){this._loadingState="parsing",this._parseError=null,this.emitSnapshot();}setDocumentLoaded(e){this._document=e,this._loadingState="loading-fonts",this._parseError=null,this.emitSnapshot();}setFontsLoaded(){this._fontsLoaded=true,this._loadingState="ready",this.emitSnapshot();}setLoadError(e){this._loadingState="error",this._parseError=e.message,this.onErrorCallback?.(e),this.emitSnapshot();}getDocument(){return this._document}updateDocument(e){this._document=e,this.onChangeCallback?.(e),this.emitSnapshot();}setZoom(e){this._zoom=Math.max(.25,Math.min(4,e)),this.emitSnapshot();}getZoom(){return this._zoom}emitSnapshot(){this._version++,this.setSnapshot({loadingState:this._loadingState,parseError:this._parseError,isReady:this._loadingState==="ready",zoom:this._zoom,fontsLoaded:this._fontsLoaded,version:this._version});}};var pn="0.0.2";export{H as A,V as B,f as C,y as D,C as E,$ as F,T as G,S as H,J as I,v as J,b as K,x as L,pn as M,E as a,K as b,j as c,Z as d,R as e,q as f,k as g,G as h,d as i,Y as j,Q as k,ee as l,g as m,te as n,ne as o,oe as p,u as q,h as r,B as s,F as t,z as u,w as v,N as w,m as x,O as y,M as z};
|
package/dist/chunk-QVPR2W5S.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function n(e){return {start:e,end:e,collapsed:true}}function r(e,t){return {start:e,end:t,collapsed:e.paragraphIndex===t.paragraphIndex&&e.offset===t.offset}}function o(e,t){return !(e.paragraphIndex<t.start.paragraphIndex||e.paragraphIndex===t.start.paragraphIndex&&e.offset<t.start.offset||e.paragraphIndex>t.end.paragraphIndex||e.paragraphIndex===t.end.paragraphIndex&&e.offset>t.end.offset)}function i(e,t){return e.paragraphIndex<t.paragraphIndex?-1:e.paragraphIndex>t.paragraphIndex?1:e.offset<t.offset?-1:e.offset>t.offset?1:0}function s(e){return {askAI:"Ask AI",rewrite:"Rewrite",expand:"Expand",summarize:"Summarize",translate:"Translate",explain:"Explain",fixGrammar:"Fix Grammar",makeFormal:"Make Formal",makeCasual:"Make Casual",custom:"Custom Prompt"}[e]}function m(e){return {askAI:"Ask AI a question about this text",rewrite:"Rewrite this text in a different way",expand:"Expand this text with more details",summarize:"Summarize this text to be shorter",translate:"Translate this text to another language",explain:"Explain what this text means",fixGrammar:"Fix grammar and spelling errors",makeFormal:"Make the tone more formal",makeCasual:"Make the tone more casual",custom:"Enter a custom prompt"}[e]}var p=["askAI","rewrite","expand","summarize","translate","explain"];function g(e){return {...e,id:a()}}function a(){return `cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}
|
|
1
|
+
'use strict';function n(e){return {start:e,end:e,collapsed:true}}function r(e,t){return {start:e,end:t,collapsed:e.paragraphIndex===t.paragraphIndex&&e.offset===t.offset}}function o(e,t){return !(e.paragraphIndex<t.start.paragraphIndex||e.paragraphIndex===t.start.paragraphIndex&&e.offset<t.start.offset||e.paragraphIndex>t.end.paragraphIndex||e.paragraphIndex===t.end.paragraphIndex&&e.offset>t.end.offset)}function i(e,t){return e.paragraphIndex<t.paragraphIndex?-1:e.paragraphIndex>t.paragraphIndex?1:e.offset<t.offset?-1:e.offset>t.offset?1:0}function s(e){return {askAI:"Ask AI",rewrite:"Rewrite",expand:"Expand",summarize:"Summarize",translate:"Translate",explain:"Explain",fixGrammar:"Fix Grammar",makeFormal:"Make Formal",makeCasual:"Make Casual",custom:"Custom Prompt"}[e]}function m(e){return {askAI:"Ask AI a question about this text",rewrite:"Rewrite this text in a different way",expand:"Expand this text with more details",summarize:"Summarize this text to be shorter",translate:"Translate this text to another language",explain:"Explain what this text means",fixGrammar:"Fix grammar and spelling errors",makeFormal:"Make the tone more formal",makeCasual:"Make the tone more casual",custom:"Enter a custom prompt"}[e]}var p=["askAI","rewrite","expand","summarize","translate","explain"];function g(e){return {...e,id:a()}}function a(){return `cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}exports.a=n;exports.b=r;exports.c=o;exports.d=i;exports.e=s;exports.f=m;exports.g=p;exports.h=g;
|
package/dist/chunk-SE5EN2QL.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function u(n){return n/1440*96}function o(n){return n/96*1440}function P(n){return n==null||isNaN(n)?0:Math.round(n*96/914400)}function _(n){return n/96*914400}function I(n){return n/914400*1440}function E(n){return n/1440*914400}function i(n){return n/72*96}function m(n){return n/144*96}function N(n){return n/2}function H(n){return n/576*96}function t(n,e=2){let r=Math.pow(10,e);return Math.round(n*r)/r}function b(n){return `${t(n)}px`}
|
|
1
|
+
'use strict';function u(n){return n/1440*96}function o(n){return n/96*1440}function P(n){return n==null||isNaN(n)?0:Math.round(n*96/914400)}function _(n){return n/96*914400}function I(n){return n/914400*1440}function E(n){return n/1440*914400}function i(n){return n/72*96}function m(n){return n/144*96}function N(n){return n/2}function H(n){return n/576*96}function t(n,e=2){let r=Math.pow(10,e);return Math.round(n*r)/r}function b(n){return `${t(n)}px`}exports.a=u;exports.b=o;exports.c=P;exports.d=_;exports.e=I;exports.f=E;exports.g=i;exports.h=m;exports.i=N;exports.j=H;exports.k=b;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var h=a=>{throw TypeError(a)};var n=(a,b,c)=>b in a?f(a,b,{enumerable:true,configurable:true,writable:true,value:c}):a[b]=c;var r=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var s=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var o=(a,b,c,d)=>{if(b&&typeof b=="object"||typeof b=="function")for(let e of k(b))!m.call(a,e)&&e!==c&&f(a,e,{get:()=>b[e],enumerable:!(d=j(b,e))||d.enumerable});return a};var t=(a,b,c)=>(c=a!=null?i(l(a)):{},o(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:true}):c,a));var u=(a,b,c)=>n(a,typeof b!="symbol"?b+"":b,c),g=(a,b,c)=>b.has(a)||h("Cannot "+c);var p=(a,b,c)=>(g(a,b,"read from private field"),c?c.call(a):b.get(a)),v=(a,b,c)=>b.has(a)?h("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),q=(a,b,c,d)=>(g(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c),w=(a,b,c)=>(g(a,b,"access private method"),c);var x=(a,b,c,d)=>({set _(e){q(a,b,e,c);},get _(){return p(a,b,d)}});export{r as a,s as b,t as c,u as d,p as e,v as f,q as g,w as h,x as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function ae(e,t,r,n){let a=e-t-r,o=(n.count-1)*n.gap;return (a-o)/n.count}function U(e){let{pageSize:t,margins:r}=e,n=e.columns??{count:1,gap:0},a=[],o=[],c=r.top,i=t.h-r.bottom;if(i-c<=0)throw new Error("Paginator: page size and margins yield no content area");let u=ae(t.w,r.left,r.right,n),g=c;function l(p){return r.left+p*(u+n.gap)}function m(){let p=a.length+1,S=e.footnoteReservedHeights?.get(p)??0,T=i-S,w={number:p,fragments:[],margins:{...r},size:{...t},footnoteReservedHeight:S>0?S:void 0,columns:n.count>1?{...n}:void 0},C={page:w,cursorY:c,columnIndex:0,topMargin:c,contentBottom:T,trailingSpacing:0};return a.push(w),o.push(C),g=c,e.onNewPage&&e.onNewPage(C),C}function f(){return o.length===0?m():o[o.length-1]}function x(p){return p.contentBottom-p.cursorY}function h(p,S){let T=S||f();return x(T)>=p}function b(p){return p.columnIndex<n.count-1?(p.columnIndex+=1,p.cursorY=g,p.trailingSpacing=0,p):m()}function d(p){let S=f(),T=Number.isFinite(p)&&p>0?p:0,w=S.contentBottom-S.topMargin;if(T>w)return S.cursorY!==S.topMargin&&(S=b(S)),S;for(;!h(T,S);)S=b(S);return S}function k(p,S,T=0,w=0){let C=Math.max(T,f().trailingSpacing),R=C+S,I=d(R),H=I.cursorY===I.topMargin?0:C,L=l(I.columnIndex),B=I.cursorY+H;return p.x=L,p.y=B,I.page.fragments.push(p),I.cursorY=B+S,I.trailingSpacing=w,{state:I,x:L,y:B}}function y(){return m()}function F(){let p=f();return b(p)}function M(p){n=p,u=ae(t.w,r.left,r.right,n);let S=f();S.page.columns=n.count>1?{...n}:void 0,g=S.cursorY,S.columnIndex=0;}return {pages:a,states:o,get columnWidth(){return u},get columns(){return {...n}},getCurrentState:f,getAvailableHeight:()=>x(f()),fits:p=>h(p),ensureFits:d,addFragment:k,forcePageBreak:y,forceColumnBreak:F,getColumnX:l,updateColumns:M}}function j(e){let t=new Map,r=new Set;for(let n=0;n<e.length;n++){if(r.has(n))continue;let a=e[n];if(a.kind!=="paragraph"||!a.attrs?.keepNext)continue;let c=[n],i=n;for(let g=n+1;g<e.length;g++){let l=e[g];if(l.kind==="sectionBreak"||l.kind==="pageBreak"||l.kind==="columnBreak"||l.kind!=="paragraph")break;if(l.attrs?.keepNext)c.push(g),i=g,r.add(g);else break}let s=i+1,u=-1;if(s<e.length){let g=e[s];g.kind!=="sectionBreak"&&g.kind!=="pageBreak"&&g.kind!=="columnBreak"&&(u=s);}t.set(n,{startIndex:n,endIndex:i,memberIndices:c,anchorIndex:u});}return t}function q(e,t,r){let n=0;for(let a of e.memberIndices){let o=t[a],c=r[a];if(o.kind!=="paragraph"||c.kind!=="paragraph")continue;let i=o,s=c,u=i.attrs?.spacing?.before??0;n+=u,n+=s.totalHeight;let g=i.attrs?.spacing?.after??0;n+=g;}if(e.anchorIndex!==-1){let a=r[e.anchorIndex];if(a?.kind==="paragraph"){let o=a;o.lines.length>0&&(n+=o.lines[0].lineHeight);}}return n}function K(e){let t=new Set;for(let r of e.values())for(let n=1;n<r.memberIndices.length;n++)t.add(r.memberIndices[n]);return t}function $(e){return e.kind!=="paragraph"?false:e.attrs?.pageBreakBefore===true}var We={top:4,bottom:4,left:7,right:7},Ue=200;var Be={w:816,h:1056},O={top:96,right:96,bottom:96,left:96};function ie(e){return e.attrs?.spacing?.before??0}function se(e){return e.attrs?.spacing?.after??0}function Fe(e){for(let t=0;t<e.length-1;t++){let r=e[t],n=e[t+1];if(r.kind!=="paragraph"||n.kind!=="paragraph")continue;let a=r.attrs,o=n.attrs;a?.contextualSpacing&&o?.contextualSpacing&&a.styleId&&a.styleId===o.styleId&&(a.spacing&&(a.spacing={...a.spacing,after:0}),o.spacing&&(o.spacing={...o.spacing,before:0}));}}function rt(e,t,r={}){if(e.length!==t.length)throw new Error(`layoutDocument: expected one measure per block (blocks=${e.length}, measures=${t.length})`);let n=r.pageSize??Be,a={top:r.margins?.top??O.top,right:r.margins?.right??O.right,bottom:r.margins?.bottom??O.bottom,left:r.margins?.left??O.left,header:r.margins?.header??r.margins?.top??O.top,footer:r.margins?.footer??r.margins?.bottom??O.bottom};r.headerContentHeights,r.footerContentHeights,r.titlePage,r.evenAndOddHeaders;let o={...a},c=n.w-o.left-o.right;if(c<=0)throw new Error("layoutDocument: page size and margins yield no content area");let i={count:1,gap:0},s=[],u=[];for(let h=0;h<e.length;h++)if(e[h].kind==="sectionBreak"){let b=e[h];s.push(b.columns??i),u.push(b.type);}s.push(r.columns??i),u.push(r.bodyBreakType);let g=s.length>0?s[0]:r.columns,l=U({pageSize:n,margins:o,columns:g,footnoteReservedHeights:r.footnoteReservedHeights});Fe(e);let m=j(e),f=K(m),x=0;for(let h=0;h<e.length;h++){let b=e[h],d=t[h];$(b)&&l.forcePageBreak();let k=m.get(h);if(k&&!f.has(h)){let y=q(k,e,t),F=l.getCurrentState(),M=l.getAvailableHeight(),p=F.contentBottom-F.topMargin;y<=p&&y>M&&F.page.fragments.length>0&&l.forcePageBreak();}switch(b.kind){case "paragraph":Me(b,d,l,c);break;case "table":b.floating?Te(b,d,l,c):we(b,d,l);break;case "image":Ce(b,d,l);break;case "textBox":Re(b,d,l);break;case "pageBreak":l.forcePageBreak();break;case "columnBreak":l.forceColumnBreak();break;case "sectionBreak":{let y=u[x+1]??u[x];Le(b,l,s[x+1]??i,y),x++;break}}}return l.pages.length===0&&l.getCurrentState(),{pageSize:n,pages:l.pages,columns:r.columns,pageGap:r.pageGap}}function Me(e,t,r,n){if(t.kind!=="paragraph")throw new Error("layoutParagraph: expected paragraph measure");let a=t.lines;if(a.length===0){let s=ie(e),u=se(e),g=r.getCurrentState(),l={kind:"paragraph",blockId:e.id,x:r.getColumnX(g.columnIndex),y:g.cursorY+s,width:n,height:0,fromLine:0,toLine:0,pmStart:e.pmStart,pmEnd:e.pmEnd};r.addFragment(l,0,s,u);return}let o=ie(e),c=se(e),i=0;for(;i<a.length;){let s=r.getCurrentState(),u=r.getAvailableHeight(),g=0,l=0;for(let k=i;k<a.length;k++){let y=a[k].lineHeight,F=g+y;if((i===0&&k===i?F+o:F)<=u||l===0)g=F,l++;else break}let m=i===0,f=i+l>=a.length,x=m?o:0,h=f?c:0,b={kind:"paragraph",blockId:e.id,x:r.getColumnX(s.columnIndex),y:0,width:n,height:g,fromLine:i,toLine:i+l,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!m,continuesOnNext:!f},d=r.addFragment(b,g,x,h);b.y=d.y,i+=l,i<a.length&&r.ensureFits(a[i].lineHeight);}}function Pe(e){let t=0;for(let r of e.rows)if(r.isHeader)t++;else break;return t}function z(e,t){let r=0;for(let n=0;n<t&&n<e.rows.length;n++)r+=e.rows[n].height;return r}function we(e,t,r){if(t.kind!=="table")throw new Error("layoutTable: expected table measure");let n=t.rows;if(n.length===0)return;let a=Pe(e),o=z(t,a),c=0;for(;c<n.length;){let i=r.getCurrentState(),s=r.getAvailableHeight(),u=c===0,g=u?i.trailingSpacing:0,l=s-g,m=!u&&a>0?o:0,f=0,x=0;for(let F=c;F<n.length;F++){let M=n[F].height;if(f+M+m<=l||x===0)f+=M,x++;else break}let h=f+m,b=c+x>=n.length,d=r.getColumnX(i.columnIndex);e.justification==="center"?d=d+(r.columnWidth-t.totalWidth)/2:e.justification==="right"?d=d+r.columnWidth-t.totalWidth:e.indent&&(d+=e.indent);let k={kind:"table",blockId:e.id,x:d,y:0,width:t.totalWidth,height:h,fromRow:c,toRow:c+x,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!u,continuesOnNext:!b,headerRowCount:!u&&a>0?a:void 0},y=r.addFragment(k,h,0,0);if(k.y=y.y,k.x=d,c+=x,c<n.length){let F=n[c].height+(a>0?o:0);r.ensureFits(F);}}}function Te(e,t,r,n){if(t.kind!=="table")throw new Error("layoutFloatingTable: expected table measure");let a=r.getCurrentState(),o=e.floating,c=a.page,i=c.margins,s=t.totalWidth,u=t.totalHeight,g=c.size.h-i.top-i.bottom,l=i.left,m=i.top;o?.horzAnchor==="page"&&(l=0),o?.vertAnchor==="page"&&(m=0);let f=r.getColumnX(a.columnIndex);if(o?.tblpX!==void 0)f=l+o.tblpX;else if(o?.tblpXSpec){let y=o.tblpXSpec;y==="left"||y==="inside"?f=l:y==="right"||y==="outside"?f=l+n-s:y==="center"&&(f=l+(n-s)/2);}else e.justification==="center"?f=l+(n-s)/2:e.justification==="right"&&(f=l+n-s);let x=a.cursorY,h=false;if(o?.tblpY!==void 0)x=m+o.tblpY,h=true;else if(o?.tblpYSpec){h=true;let y=o.tblpYSpec;y==="top"?x=m:y==="bottom"?x=m+g-u:y==="center"&&(x=m+(g-u)/2);}h||(x=r.ensureFits(u).cursorY);let b=i.left,d=i.left+n-s;Number.isFinite(d)&&(f=Math.max(b,Math.min(f,d)));let k={kind:"table",blockId:e.id,x:f,y:x,width:s,height:u,fromRow:0,toRow:e.rows.length,pmStart:e.pmStart,pmEnd:e.pmEnd,isFloating:true};a.page.fragments.push(k);}function Ce(e,t,r){if(t.kind!=="image")throw new Error("layoutImage: expected image measure");if(e.anchor?.isAnchored){Ie(e,t,r);return}let n=r.ensureFits(t.height),a={kind:"image",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Ie(e,t,r){let n=r.getCurrentState(),a=e.anchor,o=a.offsetH??r.getColumnX(n.columnIndex),c=a.offsetV??n.cursorY,i={kind:"image",blockId:e.id,x:o,y:c,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd,isAnchored:true,zIndex:a.behindDoc?-1:1};n.page.fragments.push(i);}function Re(e,t,r){if(t.kind!=="textBox")throw new Error("layoutTextBox: expected textBox measure");let n=r.ensureFits(t.height),a={kind:"textBox",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Le(e,t,r,n){switch(n??"nextPage"){case "nextPage":t.forcePageBreak();break;case "evenPage":{t.forcePageBreak().page.number%2!==0&&t.forcePageBreak();break}case "oddPage":{t.forcePageBreak().page.number%2===0&&t.forcePageBreak();break}}t.updateColumns(r);}var ve={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Calibri","Carlito","Arial","Helvetica","sans-serif"],singleLineRatio:1.2207},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Cambria","Caladea","Georgia","serif"],singleLineRatio:1.2676},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arial","Arimo","Helvetica","sans-serif"],singleLineRatio:1.1499},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Times New Roman","Tinos","Times","serif"],singleLineRatio:1.1499},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Courier New","Cousine","Courier","monospace"],singleLineRatio:1.1328},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"],singleLineRatio:1.1362},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"],singleLineRatio:1.2153},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"],singleLineRatio:1.2075},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"],singleLineRatio:1.1431},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"],singleLineRatio:1.3936},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"],singleLineRatio:1.2197},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"],singleLineRatio:1.068},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"],singleLineRatio:1.1611},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"],singleLineRatio:1.1655},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"],singleLineRatio:1.1387},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"],singleLineRatio:1.1626},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"],singleLineRatio:1.15},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"],singleLineRatio:1.15},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"],singleLineRatio:1.15},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"],singleLineRatio:1.15},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"],singleLineRatio:1.15}},He={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function Ee(e){let t=e.toLowerCase();return t.includes("mono")||t.includes("courier")||t.includes("consolas")||t.includes("console")||t.includes("code")||t.includes("terminal")?"monospace":t.includes("times")||t.includes("georgia")||t.includes("garamond")||t.includes("palatino")||t.includes("baskerville")||t.includes("bodoni")||t.includes("cambria")||t.includes("mincho")||t.includes("ming")||t.includes("song")||t.includes("serif")?"serif":t.includes("script")||t.includes("cursive")||t.includes("comic")||t.includes("brush")||t.includes("hand")?"cursive":"sans-serif"}function ce(e){let t=e.trim().toLowerCase(),r=ve[t];if(r)return {googleFont:r.googleFont,cssFallback:r.fallbackStack.map(le).join(", "),originalFont:e,hasGoogleEquivalent:true,singleLineRatio:r.singleLineRatio};let n=Ee(e),a=He[n];return {googleFont:null,cssFallback:`${le(e)}, ${a}`,originalFont:e,hasGoogleEquivalent:false,singleLineRatio:1.15}}function le(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${e.replace(/"/g,'\\"')}"`:e}function ct(e,t){if(!t)return null;let n=e.toLowerCase().startsWith("major")?t.majorFont:t.minorFont;if(!n)return null;let a=e.toLowerCase();return a.includes("eastasia")||a.includes("ea")?n.ea??n.latin??null:a.includes("cs")||a.includes("bidi")?n.cs??n.latin??null:n.latin??null}var ge=96,me=11,pe="Calibri",Ne=1,Oe=.8,ze=.2,_=null;function J(){if(!_){let e=typeof document<"u"?document.createElement("canvas"):null;if(!e)throw new Error("Canvas not available. Ensure this runs in a DOM environment.");if(_=e.getContext("2d"),!_)throw new Error("Failed to get 2D context from canvas")}return _}function pt(){_=null;}var ue=new Map;function fe(e){let t=ue.get(e);if(t===void 0){let r=ce(e);t={cssFallback:r.cssFallback,singleLineRatio:r.singleLineRatio},ue.set(e,t);}return t}function _e(e){return fe(e).cssFallback}function V(e){let t=[];e.italic&&t.push("italic"),e.bold&&t.push("bold");let r=e.fontSize??me,n=de(r);t.push(`${n}px`);let a=e.fontFamily??pe;return t.push(_e(a)),t.join(" ")}function Ye(e){let t=e.fontSize??me,r=e.fontFamily??pe,n=de(t),a=n*Oe,o=n*ze,c=n*Ne;try{let s=J();s.font=V(e);let u=s.measureText("Hg");typeof u.actualBoundingBoxAscent=="number"&&typeof u.actualBoundingBoxDescent=="number"&&(a=u.actualBoundingBoxAscent,o=u.actualBoundingBoxDescent);}catch{}c=Math.max(c,a+o);let i=fe(r).singleLineRatio;return {fontSize:t,ascent:a,descent:o,lineHeight:c,fontFamily:r,singleLineRatio:i}}function ft(e,t){if(!e)return 0;let r=J();r.font=V(t);let a=r.measureText(e).width;return t.letterSpacing&&e.length>1&&(a+=t.letterSpacing*(e.length-1)),a}function Q(e,t){let r=Ye(t);if(!e)return {width:0,charWidths:[],metrics:r};let n=J();n.font=V(t);let a=t.letterSpacing??0,o=[],c=0;for(let i=0;i<e.length;i++){let s=e[i],g=n.measureText(s).width;a&&i<e.length-1&&(g+=a),o.push(g),c+=g;}return {width:c,charWidths:o,metrics:r}}function dt(e,t){if(t.length===0||e<=0)return 0;let r=0;for(let n=0;n<t.length;n++){let a=t[n],o=r+a/2;if(e<=o)return n;r+=a;}return t.length}function de(e){return e*ge/72}function Z(e,t){let r=e.pageGap??0,n=0;for(let a=0;a<t&&a<e.pages.length;a++){let c=e.pages[a].size?.h??e.pageSize.h;n+=c+r;}return n}function he(e,t){return e.findIndex(r=>r.id===t)}function Xe(e,t){let r=0;for(let n=e.fromLine;n<e.toLine&&n<t.lines.length;n++)r+=t.lines[n].lineHeight;return r}function xt(e,t,r,n){let a=[...e.page.fragments].sort((o,c)=>{let i=o.y-c.y;return Math.abs(i)>.5?i:o.x-c.x});for(let o of a){let c=he(t,o.blockId);if(c===-1)continue;let i=t[c],s=r[c];if(!i||!s)continue;let u;if(o.kind==="paragraph"){if(i.kind!=="paragraph"||s.kind!=="paragraph")continue;u=Xe(o,s);}else if(o.kind==="table")u=o.height;else if(o.kind==="image")u=o.height;else continue;let g=n.x>=o.x&&n.x<=o.x+o.width,l=n.y>=o.y&&n.y<=o.y+u;if(g&&l)return {fragment:o,block:i,measure:s,pageIndex:e.pageIndex,localX:n.x-o.x,localY:n.y-o.y}}return null}function kt(e,t,r,n){for(let a of e.page.fragments){if(a.kind!=="table")continue;let o=a,c=n.x>=o.x&&n.x<=o.x+o.width,i=n.y>=o.y&&n.y<=o.y+o.height;if(!c||!i)continue;let s=he(t,o.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="table"||!g||g.kind!=="table")continue;let l=u,m=g,f=n.x-o.x,x=n.y-o.y,h=o.headerRowCount??0,b=h>0&&o.continuesFromPrev?z(m,h):0,d=0,k=-1;if(m.rows.length===0||l.rows.length===0)continue;if(b>0&&x<b){let B=0;for(let P=0;P<h&&P<m.rows.length;P++){let E=m.rows[P];if(x>=B&&x<B+E.height){k=P;break}B+=E.height;}k===-1&&(k=0);}else {let B=x-b;for(let P=o.fromRow;P<o.toRow&&P<m.rows.length;P++){let E=m.rows[P];if(B>=d&&B<d+E.height){k=P;break}d+=E.height;}}if(k===-1&&(k=Math.min(o.toRow-1,m.rows.length-1),k<o.fromRow))continue;let y=m.rows[k],F=l.rows[k];if(!y||!F)continue;let M=0,p=-1;if(y.cells.length===0||F.cells.length===0)continue;for(let B=0;B<y.cells.length;B++){let P=y.cells[B];if(f>=M&&f<M+P.width){p=B;break}M+=P.width;}if(p===-1&&(p=y.cells.length-1,p<0))continue;let S=y.cells[p],T=F.cells[p];if(!S||!T)continue;let w=0;if(b>0&&k<h)for(let B=0;B<k;B++)w+=m.rows[B]?.height??0;else {w=b;for(let B=o.fromRow;B<k;B++)w+=m.rows[B]?.height??0;}let R=0;for(let B=0;B<p;B++)R+=y.cells[B]?.width??0;let I,v;if(T.blocks&&T.blocks.length>0){let B=T.blocks[0],P=S.blocks[0];B.kind==="paragraph"&&P?.kind==="paragraph"&&(I=B,v=P);}let H=f-R,L=x-w;return {fragment:o,block:l,measure:m,pageIndex:e.pageIndex,rowIndex:k,colIndex:p,cellBlock:I,cellMeasure:v,cellLocalX:Math.max(0,H),cellLocalY:Math.max(0,L)}}return null}function be(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function ee(e,t){return e.findIndex(r=>r.id===t)}function D(e,t){let n=(e.pmStart??0)+1,a=0,o;for(let s=0;s<e.runs.length&&s<=t.toRun;s++){let u=e.runs[s];if(u){if(s<t.fromRun)u.kind==="text"?a+=(u.text??"").length:a+=1;else if(s===t.fromRun){a+=t.fromChar,o=n+a;break}}}o===void 0&&(o=n);let c=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let u=e.runs[s];if(u)if(u.kind==="text"){let g=u.text??"",l=s===t.fromRun?t.fromChar:0,m=s===t.toRun?t.toChar:g.length;c+=m-l;}else c+=1;}let i=o+c;return {pmStart:o,pmEnd:i}}function xe(e,t,r,n){let a=[];for(let o=0;o<t.lines.length;o++){let c=t.lines[o],i=D(e,c);i.pmStart===void 0||i.pmEnd===void 0||i.pmEnd>r&&i.pmStart<n&&a.push({line:c,index:o});}return a}function Y(e,t,r){let n=D(e,t);return n.pmStart===void 0?0:Math.max(0,r-n.pmStart)}function X(e,t,r,n){let a=0,o=0;for(let c=t.fromRun;c<=t.toRun&&c<e.runs.length;c++){let i=e.runs[c];if(i){if(i.kind==="tab"){let s=i.width??48;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="image"){let s=i.width;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="lineBreak"){if(r<=o)return a;o+=1;continue}if(i.kind==="text"){let s=i.text??"",u=c===t.fromRun,g=c===t.toRun,l=u?t.fromChar:0,m=g?t.toChar:s.length,f=s.slice(l,m);if(o+f.length>=r){let b=r-o,d=be(i),k=Q(f.slice(0,b),d);return a+k.width}let x=be(i),h=Q(f,x);a+=h.width,o+=f.length;}}}return a}function G(e,t){let r=0;for(let n=0;n<t&&n<e.lines.length;n++)r+=e.lines[n].lineHeight;return r}function Mt(e,t,r,n,a){if(n===a)return [];let o=Math.min(n,a),c=Math.max(n,a),i=[];for(let s=0;s<e.pages.length;s++){let u=e.pages[s],g=Z(e,s);for(let l of u.fragments){if(l.kind==="paragraph"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="paragraph"||!x||x.kind!=="paragraph")continue;let h=f,b=x,d=l,k=xe(h,b,o,c);for(let{line:y,index:F}of k){if(F<d.fromLine||F>=d.toLine)continue;let M=D(h,y);if(M.pmStart===void 0||M.pmEnd===void 0)continue;let p=Math.max(M.pmStart,o),S=Math.min(M.pmEnd,c);if(p>=S)continue;let T=Y(h,y,p),w=Y(h,y,S),C=h.attrs?.indent,R=C?.left??0,I=C?.right??0,v=Math.max(0,l.width-R-I),H=X(h,y,T),L=X(h,y,w),B=h.attrs?.alignment??"left",P=0;B==="center"?P=Math.max(0,(v-y.width)/2):B==="right"&&(P=Math.max(0,v-y.width));let E=G(b,F)-G(b,d.fromLine),A=l.x+R+P+Math.min(H,L),W=Math.max(1,Math.abs(L-H)),N=l.y+E;i.push({x:A,y:N+g,width:W,height:y.lineHeight,pageIndex:s});}}if(l.kind==="table"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="table"||!x||x.kind!=="table")continue;let h=f,b=x,d=l,k=d.headerRowCount??0,F=k>0&&d.continuesFromPrev?z(b,k):0;for(let M=d.fromRow;M<d.toRow&&M<h.rows.length;M++){let p=h.rows[M],S=b.rows[M];if(!p||!S)continue;let T=0;for(let w=0;w<p.cells.length;w++){let C=p.cells[w],R=S.cells[w];if(!(!C||!R)){for(let I=0;I<C.blocks.length;I++){let v=C.blocks[I],H=R.blocks[I];if(!v||v.kind!=="paragraph"||!H||H.kind!=="paragraph")continue;let L=v,B=H,P=xe(L,B,o,c),E=0;for(let{line:A,index:W}of P){let N=D(L,A);if(N.pmStart===void 0||N.pmEnd===void 0)continue;let te=Math.max(N.pmStart,o),ne=Math.min(N.pmEnd,c);if(te>=ne)continue;let ke=Y(L,A,te),ye=Y(L,A,ne),re=X(L,A,ke,R.width),oe=X(L,A,ye,R.width),Se=G(B,W);i.push({x:d.x+T+Math.min(re,oe),y:d.y+F+E+Se+g,width:Math.max(1,Math.abs(oe-re)),height:A.lineHeight,pageIndex:s});}E+=B.totalHeight;}T+=R.width;}}F+=S.height;}}if(l.kind==="image"){let m=l.pmStart??0;(l.pmEnd??m+1)>o&&m<c&&i.push({x:l.x,y:l.y+g,width:l.width,height:l.height,pageIndex:s});}}}return i}function Pt(e,t,r,n){for(let a=0;a<e.pages.length;a++){let o=e.pages[a],c=Z(e,a);for(let i of o.fragments){if(i.kind==="paragraph"){let s=ee(t,i.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="paragraph"||!g||g.kind!=="paragraph")continue;let l=u,m=g,f=i,x=l.pmStart??0,h=l.pmEnd??x;if(n<x||n>h)continue;for(let b=f.fromLine;b<f.toLine;b++){let d=m.lines[b];if(!d)continue;let k=D(l,d);if(!(k.pmStart===void 0||k.pmEnd===void 0)&&n>=k.pmStart&&n<=k.pmEnd){let y=Y(l,d,n),F=l.attrs?.indent,M=F?.left??0,p=F?.right??0,S=Math.max(0,i.width-M-p),T=X(l,d,y),w=l.attrs?.alignment??"left",C=0;w==="center"?C=Math.max(0,(S-d.width)/2):w==="right"&&(C=Math.max(0,S-d.width));let R=G(m,b)-G(m,f.fromLine);return {x:i.x+M+C+T,y:i.y+R+c,height:d.lineHeight,pageIndex:a}}}}if(i.kind==="image"){let s=i.pmStart??0,u=i.pmEnd??s+1;if(n>=s&&n<=u){let g=n===s?0:i.width;return {x:i.x+g,y:i.y+c,height:i.height,pageIndex:a}}}}}return null}function wt(e){return e.length<=1?false:new Set(e.map(r=>r.pageIndex)).size>1}function Tt(e){let t=new Map;for(let r of e){let n=t.get(r.pageIndex)??[];n.push(r),t.set(r.pageIndex,n);}return t}export{ce as a,ct as b,We as c,Ue as d,rt as e,pt as f,Ye as g,ft as h,Q as i,dt as j,de as k,xt as l,kt as m,Mt as n,Pt as o,wt as p,Tt as q};
|
|
1
|
+
function ae(e,t,r,n){let a=e-t-r,o=(n.count-1)*n.gap;return (a-o)/n.count}function U(e){let{pageSize:t,margins:r}=e,n=e.columns??{count:1,gap:0},a=[],o=[],c=r.top,i=t.h-r.bottom;if(i-c<=0)throw new Error("Paginator: page size and margins yield no content area");let u=ae(t.w,r.left,r.right,n),g=c;function l(p){return r.left+p*(u+n.gap)}function m(){let p=a.length+1,S=e.footnoteReservedHeights?.get(p)??0,T=i-S,w={number:p,fragments:[],margins:{...r},size:{...t},footnoteReservedHeight:S>0?S:void 0,columns:n.count>1?{...n}:void 0},C={page:w,cursorY:c,columnIndex:0,topMargin:c,contentBottom:T,trailingSpacing:0};return a.push(w),o.push(C),g=c,e.onNewPage&&e.onNewPage(C),C}function f(){return o.length===0?m():o[o.length-1]}function x(p){return p.contentBottom-p.cursorY}function h(p,S){let T=S||f();return x(T)>=p}function b(p){return p.columnIndex<n.count-1?(p.columnIndex+=1,p.cursorY=g,p.trailingSpacing=0,p):m()}function d(p){let S=f(),T=Number.isFinite(p)&&p>0?p:0,w=S.contentBottom-S.topMargin;if(T>w)return S.cursorY!==S.topMargin&&(S=b(S)),S;for(;!h(T,S);)S=b(S);return S}function k(p,S,T=0,w=0){let C=Math.max(T,f().trailingSpacing),R=C+S,I=d(R),H=I.cursorY===I.topMargin?0:C,L=l(I.columnIndex),B=I.cursorY+H;return p.x=L,p.y=B,I.page.fragments.push(p),I.cursorY=B+S,I.trailingSpacing=w,{state:I,x:L,y:B}}function y(){return m()}function F(){let p=f();return b(p)}function M(p){n=p,u=ae(t.w,r.left,r.right,n);let S=f();S.page.columns=n.count>1?{...n}:void 0,g=S.cursorY,S.columnIndex=0;}return {pages:a,states:o,get columnWidth(){return u},get columns(){return {...n}},getCurrentState:f,getAvailableHeight:()=>x(f()),fits:p=>h(p),ensureFits:d,addFragment:k,forcePageBreak:y,forceColumnBreak:F,getColumnX:l,updateColumns:M}}function j(e){let t=new Map,r=new Set;for(let n=0;n<e.length;n++){if(r.has(n))continue;let a=e[n];if(a.kind!=="paragraph"||!a.attrs?.keepNext)continue;let c=[n],i=n;for(let g=n+1;g<e.length;g++){let l=e[g];if(l.kind==="sectionBreak"||l.kind==="pageBreak"||l.kind==="columnBreak"||l.kind!=="paragraph")break;if(l.attrs?.keepNext)c.push(g),i=g,r.add(g);else break}let s=i+1,u=-1;if(s<e.length){let g=e[s];g.kind!=="sectionBreak"&&g.kind!=="pageBreak"&&g.kind!=="columnBreak"&&(u=s);}t.set(n,{startIndex:n,endIndex:i,memberIndices:c,anchorIndex:u});}return t}function q(e,t,r){let n=0;for(let a of e.memberIndices){let o=t[a],c=r[a];if(o.kind!=="paragraph"||c.kind!=="paragraph")continue;let i=o,s=c,u=i.attrs?.spacing?.before??0;n+=u,n+=s.totalHeight;let g=i.attrs?.spacing?.after??0;n+=g;}if(e.anchorIndex!==-1){let a=r[e.anchorIndex];if(a?.kind==="paragraph"){let o=a;o.lines.length>0&&(n+=o.lines[0].lineHeight);}}return n}function K(e){let t=new Set;for(let r of e.values())for(let n=1;n<r.memberIndices.length;n++)t.add(r.memberIndices[n]);return t}function $(e){return e.kind!=="paragraph"?false:e.attrs?.pageBreakBefore===true}var We={top:4,bottom:4,left:7,right:7},Ue=200;var Be={w:816,h:1056},O={top:96,right:96,bottom:96,left:96};function ie(e){return e.attrs?.spacing?.before??0}function se(e){return e.attrs?.spacing?.after??0}function Fe(e){for(let t=0;t<e.length-1;t++){let r=e[t],n=e[t+1];if(r.kind!=="paragraph"||n.kind!=="paragraph")continue;let a=r.attrs,o=n.attrs;a?.contextualSpacing&&o?.contextualSpacing&&a.styleId&&a.styleId===o.styleId&&(a.spacing&&(a.spacing={...a.spacing,after:0}),o.spacing&&(o.spacing={...o.spacing,before:0}));}}function rt(e,t,r={}){if(e.length!==t.length)throw new Error(`layoutDocument: expected one measure per block (blocks=${e.length}, measures=${t.length})`);let n=r.pageSize??Be,a={top:r.margins?.top??O.top,right:r.margins?.right??O.right,bottom:r.margins?.bottom??O.bottom,left:r.margins?.left??O.left,header:r.margins?.header??r.margins?.top??O.top,footer:r.margins?.footer??r.margins?.bottom??O.bottom};r.headerContentHeights,r.footerContentHeights,r.titlePage,r.evenAndOddHeaders;let o={...a},c=n.w-o.left-o.right;if(c<=0)throw new Error("layoutDocument: page size and margins yield no content area");let i={count:1,gap:0},s=[],u=[];for(let h=0;h<e.length;h++)if(e[h].kind==="sectionBreak"){let b=e[h];s.push(b.columns??i),u.push(b.type);}s.push(r.columns??i),u.push(r.bodyBreakType);let g=s.length>0?s[0]:r.columns,l=U({pageSize:n,margins:o,columns:g,footnoteReservedHeights:r.footnoteReservedHeights});Fe(e);let m=j(e),f=K(m),x=0;for(let h=0;h<e.length;h++){let b=e[h],d=t[h];$(b)&&l.forcePageBreak();let k=m.get(h);if(k&&!f.has(h)){let y=q(k,e,t),F=l.getCurrentState(),M=l.getAvailableHeight(),p=F.contentBottom-F.topMargin;y<=p&&y>M&&F.page.fragments.length>0&&l.forcePageBreak();}switch(b.kind){case "paragraph":Me(b,d,l,c);break;case "table":b.floating?Te(b,d,l,c):we(b,d,l);break;case "image":Ce(b,d,l);break;case "textBox":Re(b,d,l);break;case "pageBreak":l.forcePageBreak();break;case "columnBreak":l.forceColumnBreak();break;case "sectionBreak":{let y=u[x+1]??u[x];Le(b,l,s[x+1]??i,y),x++;break}}}return l.pages.length===0&&l.getCurrentState(),{pageSize:n,pages:l.pages,columns:r.columns,pageGap:r.pageGap}}function Me(e,t,r,n){if(t.kind!=="paragraph")throw new Error("layoutParagraph: expected paragraph measure");let a=t.lines;if(a.length===0){let s=ie(e),u=se(e),g=r.getCurrentState(),l={kind:"paragraph",blockId:e.id,x:r.getColumnX(g.columnIndex),y:g.cursorY+s,width:n,height:0,fromLine:0,toLine:0,pmStart:e.pmStart,pmEnd:e.pmEnd};r.addFragment(l,0,s,u);return}let o=ie(e),c=se(e),i=0;for(;i<a.length;){let s=r.getCurrentState(),u=r.getAvailableHeight(),g=0,l=0;for(let k=i;k<a.length;k++){let y=a[k].lineHeight,F=g+y;if((i===0&&k===i?F+o:F)<=u||l===0)g=F,l++;else break}let m=i===0,f=i+l>=a.length,x=m?o:0,h=f?c:0,b={kind:"paragraph",blockId:e.id,x:r.getColumnX(s.columnIndex),y:0,width:n,height:g,fromLine:i,toLine:i+l,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!m,continuesOnNext:!f},d=r.addFragment(b,g,x,h);b.y=d.y,i+=l,i<a.length&&r.ensureFits(a[i].lineHeight);}}function Pe(e){let t=0;for(let r of e.rows)if(r.isHeader)t++;else break;return t}function z(e,t){let r=0;for(let n=0;n<t&&n<e.rows.length;n++)r+=e.rows[n].height;return r}function we(e,t,r){if(t.kind!=="table")throw new Error("layoutTable: expected table measure");let n=t.rows;if(n.length===0)return;let a=Pe(e),o=z(t,a),c=0;for(;c<n.length;){let i=r.getCurrentState(),s=r.getAvailableHeight(),u=c===0,g=u?i.trailingSpacing:0,l=s-g,m=!u&&a>0?o:0,f=0,x=0;for(let F=c;F<n.length;F++){let M=n[F].height;if(f+M+m<=l||x===0)f+=M,x++;else break}let h=f+m,b=c+x>=n.length,d=r.getColumnX(i.columnIndex);e.justification==="center"?d=d+(r.columnWidth-t.totalWidth)/2:e.justification==="right"?d=d+r.columnWidth-t.totalWidth:e.indent&&(d+=e.indent);let k={kind:"table",blockId:e.id,x:d,y:0,width:t.totalWidth,height:h,fromRow:c,toRow:c+x,pmStart:e.pmStart,pmEnd:e.pmEnd,continuesFromPrev:!u,continuesOnNext:!b,headerRowCount:!u&&a>0?a:void 0},y=r.addFragment(k,h,0,0);if(k.y=y.y,k.x=d,c+=x,c<n.length){let F=n[c].height+(a>0?o:0);r.ensureFits(F);}}}function Te(e,t,r,n){if(t.kind!=="table")throw new Error("layoutFloatingTable: expected table measure");let a=r.getCurrentState(),o=e.floating,c=a.page,i=c.margins,s=t.totalWidth,u=t.totalHeight,g=c.size.h-i.top-i.bottom,l=i.left,m=i.top;o?.horzAnchor==="page"&&(l=0),o?.vertAnchor==="page"&&(m=0);let f=r.getColumnX(a.columnIndex);if(o?.tblpX!==void 0)f=l+o.tblpX;else if(o?.tblpXSpec){let y=o.tblpXSpec;y==="left"||y==="inside"?f=l:y==="right"||y==="outside"?f=l+n-s:y==="center"&&(f=l+(n-s)/2);}else e.justification==="center"?f=l+(n-s)/2:e.justification==="right"&&(f=l+n-s);let x=a.cursorY,h=false;if(o?.tblpY!==void 0)x=m+o.tblpY,h=true;else if(o?.tblpYSpec){h=true;let y=o.tblpYSpec;y==="top"?x=m:y==="bottom"?x=m+g-u:y==="center"&&(x=m+(g-u)/2);}h||(x=r.ensureFits(u).cursorY);let b=i.left,d=i.left+n-s;Number.isFinite(d)&&(f=Math.max(b,Math.min(f,d)));let k={kind:"table",blockId:e.id,x:f,y:x,width:s,height:u,fromRow:0,toRow:e.rows.length,pmStart:e.pmStart,pmEnd:e.pmEnd,isFloating:true};a.page.fragments.push(k);}function Ce(e,t,r){if(t.kind!=="image")throw new Error("layoutImage: expected image measure");if(e.anchor?.isAnchored){Ie(e,t,r);return}let n=r.ensureFits(t.height),a={kind:"image",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Ie(e,t,r){let n=r.getCurrentState(),a=e.anchor,o=a.offsetH??r.getColumnX(n.columnIndex),c=a.offsetV??n.cursorY,i={kind:"image",blockId:e.id,x:o,y:c,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd,isAnchored:true,zIndex:a.behindDoc?-1:1};n.page.fragments.push(i);}function Re(e,t,r){if(t.kind!=="textBox")throw new Error("layoutTextBox: expected textBox measure");let n=r.ensureFits(t.height),a={kind:"textBox",blockId:e.id,x:r.getColumnX(n.columnIndex),y:0,width:t.width,height:t.height,pmStart:e.pmStart,pmEnd:e.pmEnd},o=r.addFragment(a,t.height,0,0);a.y=o.y;}function Le(e,t,r,n){switch(n??"nextPage"){case "nextPage":t.forcePageBreak();break;case "evenPage":{t.forcePageBreak().page.number%2!==0&&t.forcePageBreak();break}case "oddPage":{t.forcePageBreak().page.number%2===0&&t.forcePageBreak();break}}t.updateColumns(r);}var ve={calibri:{googleFont:"Carlito",category:"sans-serif",fallbackStack:["Calibri","Carlito","Arial","Helvetica","sans-serif"],singleLineRatio:1.2207},cambria:{googleFont:"Caladea",category:"serif",fallbackStack:["Cambria","Caladea","Georgia","serif"],singleLineRatio:1.2676},arial:{googleFont:"Arimo",category:"sans-serif",fallbackStack:["Arial","Arimo","Helvetica","sans-serif"],singleLineRatio:1.1499},"times new roman":{googleFont:"Tinos",category:"serif",fallbackStack:["Times New Roman","Tinos","Times","serif"],singleLineRatio:1.1499},"courier new":{googleFont:"Cousine",category:"monospace",fallbackStack:["Courier New","Cousine","Courier","monospace"],singleLineRatio:1.1328},georgia:{googleFont:"Tinos",category:"serif",fallbackStack:["Georgia","Tinos","Times New Roman","serif"],singleLineRatio:1.1362},verdana:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Verdana","Open Sans","Arial","sans-serif"],singleLineRatio:1.2153},tahoma:{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Tahoma","Open Sans","Arial","sans-serif"],singleLineRatio:1.2075},"trebuchet ms":{googleFont:"Fira Sans",category:"sans-serif",fallbackStack:["Trebuchet MS","Fira Sans","Arial","sans-serif"],singleLineRatio:1.1431},"comic sans ms":{googleFont:"Comic Neue",category:"cursive",fallbackStack:["Comic Sans MS","Comic Neue","cursive"],singleLineRatio:1.3936},impact:{googleFont:"Anton",category:"sans-serif",fallbackStack:["Impact","Anton","Arial Black","sans-serif"],singleLineRatio:1.2197},"palatino linotype":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Palatino Linotype","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},"book antiqua":{googleFont:"EB Garamond",category:"serif",fallbackStack:["Book Antiqua","EB Garamond","Palatino","Georgia","serif"],singleLineRatio:1.0259},garamond:{googleFont:"EB Garamond",category:"serif",fallbackStack:["Garamond","EB Garamond","Georgia","serif"],singleLineRatio:1.068},"century gothic":{googleFont:"Questrial",category:"sans-serif",fallbackStack:["Century Gothic","Questrial","Arial","sans-serif"],singleLineRatio:1.1611},"lucida sans":{googleFont:"Open Sans",category:"sans-serif",fallbackStack:["Lucida Sans","Open Sans","Arial","sans-serif"],singleLineRatio:1.1655},"lucida console":{googleFont:"Cousine",category:"monospace",fallbackStack:["Lucida Console","Cousine","Courier New","monospace"],singleLineRatio:1.1387},consolas:{googleFont:"Inconsolata",category:"monospace",fallbackStack:["Consolas","Inconsolata","Cousine","Courier New","monospace"],singleLineRatio:1.1626},"ms mincho":{googleFont:"Noto Serif JP",category:"serif",fallbackStack:["MS Mincho","Noto Serif JP","serif"],singleLineRatio:1.15},"ms gothic":{googleFont:"Noto Sans JP",category:"sans-serif",fallbackStack:["MS Gothic","Noto Sans JP","sans-serif"],singleLineRatio:1.15},simhei:{googleFont:"Noto Sans SC",category:"sans-serif",fallbackStack:["SimHei","Noto Sans SC","sans-serif"],singleLineRatio:1.15},simsun:{googleFont:"Noto Serif SC",category:"serif",fallbackStack:["SimSun","Noto Serif SC","serif"],singleLineRatio:1.15},"malgun gothic":{googleFont:"Noto Sans KR",category:"sans-serif",fallbackStack:["Malgun Gothic","Noto Sans KR","sans-serif"],singleLineRatio:1.15}},He={"sans-serif":"Arial, Helvetica, sans-serif",serif:"Times New Roman, Times, serif",monospace:"Courier New, Courier, monospace",cursive:"cursive",fantasy:"fantasy","system-ui":"system-ui, sans-serif"};function Ee(e){let t=e.toLowerCase();return t.includes("mono")||t.includes("courier")||t.includes("consolas")||t.includes("console")||t.includes("code")||t.includes("terminal")?"monospace":t.includes("times")||t.includes("georgia")||t.includes("garamond")||t.includes("palatino")||t.includes("baskerville")||t.includes("bodoni")||t.includes("cambria")||t.includes("mincho")||t.includes("ming")||t.includes("song")||t.includes("serif")?"serif":t.includes("script")||t.includes("cursive")||t.includes("comic")||t.includes("brush")||t.includes("hand")?"cursive":"sans-serif"}function ce(e){let t=e.trim().toLowerCase(),r=ve[t];if(r)return {googleFont:r.googleFont,cssFallback:r.fallbackStack.map(le).join(", "),originalFont:e,hasGoogleEquivalent:true,singleLineRatio:r.singleLineRatio};let n=Ee(e),a=He[n];return {googleFont:null,cssFallback:`${le(e)}, ${a}`,originalFont:e,hasGoogleEquivalent:false,singleLineRatio:1.15}}function le(e){return ["serif","sans-serif","monospace","cursive","fantasy","system-ui"].includes(e.toLowerCase())?e:/[\s,'"()]/.test(e)?`"${e.replace(/"/g,'\\"')}"`:e}function ct(e,t){if(!t)return null;let n=e.toLowerCase().startsWith("major")?t.majorFont:t.minorFont;if(!n)return null;let a=e.toLowerCase();return a.includes("eastasia")||a.includes("ea")?n.ea??n.latin??null:a.includes("cs")||a.includes("bidi")?n.cs??n.latin??null:n.latin??null}var ge=96,me=11,pe="Calibri",Ne=1,Oe=.8,ze=.2,_=null;function J(){if(!_){let e=typeof document<"u"?document.createElement("canvas"):null;if(!e)throw new Error("Canvas not available. Ensure this runs in a DOM environment.");if(_=e.getContext("2d"),!_)throw new Error("Failed to get 2D context from canvas")}return _}function pt(){_=null;}var ue=new Map;function fe(e){let t=ue.get(e);if(t===void 0){let r=ce(e);t={cssFallback:r.cssFallback,singleLineRatio:r.singleLineRatio},ue.set(e,t);}return t}function _e(e){return fe(e).cssFallback}function V(e){let t=[];e.italic&&t.push("italic"),e.bold&&t.push("bold");let r=e.fontSize??me,n=de(r);t.push(`${n}px`);let a=e.fontFamily??pe;return t.push(_e(a)),t.join(" ")}function Ye(e){let t=e.fontSize??me,r=e.fontFamily??pe,n=de(t),a=n*Oe,o=n*ze,c=n*Ne;try{let s=J();s.font=V(e);let u=s.measureText("Hg");typeof u.actualBoundingBoxAscent=="number"&&typeof u.actualBoundingBoxDescent=="number"&&(a=u.actualBoundingBoxAscent,o=u.actualBoundingBoxDescent);}catch{}c=Math.max(c,a+o);let i=fe(r).singleLineRatio;return {fontSize:t,ascent:a,descent:o,lineHeight:c,fontFamily:r,singleLineRatio:i}}function ft(e,t){if(!e)return 0;let r=J();r.font=V(t);let a=r.measureText(e).width;return t.letterSpacing&&e.length>1&&(a+=t.letterSpacing*(e.length-1)),a}function Q(e,t){let r=Ye(t);if(!e)return {width:0,charWidths:[],metrics:r};let n=J();n.font=V(t);let a=t.letterSpacing??0,o=[],c=0;for(let i=0;i<e.length;i++){let s=e[i],g=n.measureText(s).width;a&&i<e.length-1&&(g+=a),o.push(g),c+=g;}return {width:c,charWidths:o,metrics:r}}function dt(e,t){if(t.length===0||e<=0)return 0;let r=0;for(let n=0;n<t.length;n++){let a=t[n],o=r+a/2;if(e<=o)return n;r+=a;}return t.length}function de(e){return e*ge/72}function Z(e,t){let r=e.pageGap??0,n=0;for(let a=0;a<t&&a<e.pages.length;a++){let c=e.pages[a].size?.h??e.pageSize.h;n+=c+r;}return n}function he(e,t){return e.findIndex(r=>r.id===t)}function Xe(e,t){let r=0;for(let n=e.fromLine;n<e.toLine&&n<t.lines.length;n++)r+=t.lines[n].lineHeight;return r}function xt(e,t,r,n){let a=[...e.page.fragments].sort((o,c)=>{let i=o.y-c.y;return Math.abs(i)>.5?i:o.x-c.x});for(let o of a){let c=he(t,o.blockId);if(c===-1)continue;let i=t[c],s=r[c];if(!i||!s)continue;let u;if(o.kind==="paragraph"){if(i.kind!=="paragraph"||s.kind!=="paragraph")continue;u=Xe(o,s);}else if(o.kind==="table")u=o.height;else if(o.kind==="image")u=o.height;else continue;let g=n.x>=o.x&&n.x<=o.x+o.width,l=n.y>=o.y&&n.y<=o.y+u;if(g&&l)return {fragment:o,block:i,measure:s,pageIndex:e.pageIndex,localX:n.x-o.x,localY:n.y-o.y}}return null}function kt(e,t,r,n){for(let a of e.page.fragments){if(a.kind!=="table")continue;let o=a,c=n.x>=o.x&&n.x<=o.x+o.width,i=n.y>=o.y&&n.y<=o.y+o.height;if(!c||!i)continue;let s=he(t,o.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="table"||!g||g.kind!=="table")continue;let l=u,m=g,f=n.x-o.x,x=n.y-o.y,h=o.headerRowCount??0,b=h>0&&o.continuesFromPrev?z(m,h):0,d=0,k=-1;if(m.rows.length===0||l.rows.length===0)continue;if(b>0&&x<b){let B=0;for(let P=0;P<h&&P<m.rows.length;P++){let E=m.rows[P];if(x>=B&&x<B+E.height){k=P;break}B+=E.height;}k===-1&&(k=0);}else {let B=x-b;for(let P=o.fromRow;P<o.toRow&&P<m.rows.length;P++){let E=m.rows[P];if(B>=d&&B<d+E.height){k=P;break}d+=E.height;}}if(k===-1&&(k=Math.min(o.toRow-1,m.rows.length-1),k<o.fromRow))continue;let y=m.rows[k],F=l.rows[k];if(!y||!F)continue;let M=0,p=-1;if(y.cells.length===0||F.cells.length===0)continue;for(let B=0;B<y.cells.length;B++){let P=y.cells[B];if(f>=M&&f<M+P.width){p=B;break}M+=P.width;}if(p===-1&&(p=y.cells.length-1,p<0))continue;let S=y.cells[p],T=F.cells[p];if(!S||!T)continue;let w=0;if(b>0&&k<h)for(let B=0;B<k;B++)w+=m.rows[B]?.height??0;else {w=b;for(let B=o.fromRow;B<k;B++)w+=m.rows[B]?.height??0;}let R=0;for(let B=0;B<p;B++)R+=y.cells[B]?.width??0;let I,v;if(T.blocks&&T.blocks.length>0){let B=T.blocks[0],P=S.blocks[0];B.kind==="paragraph"&&P?.kind==="paragraph"&&(I=B,v=P);}let H=f-R,L=x-w;return {fragment:o,block:l,measure:m,pageIndex:e.pageIndex,rowIndex:k,colIndex:p,cellBlock:I,cellMeasure:v,cellLocalX:Math.max(0,H),cellLocalY:Math.max(0,L)}}return null}function be(e){return {fontFamily:e.fontFamily??"Arial",fontSize:e.fontSize??12,bold:e.bold,italic:e.italic,letterSpacing:e.letterSpacing}}function ee(e,t){return e.findIndex(r=>r.id===t)}function D(e,t){let n=(e.pmStart??0)+1,a=0,o;for(let s=0;s<e.runs.length&&s<=t.toRun;s++){let u=e.runs[s];if(u){if(s<t.fromRun)u.kind==="text"?a+=(u.text??"").length:a+=1;else if(s===t.fromRun){a+=t.fromChar,o=n+a;break}}}o===void 0&&(o=n);let c=0;for(let s=t.fromRun;s<=t.toRun&&s<e.runs.length;s++){let u=e.runs[s];if(u)if(u.kind==="text"){let g=u.text??"",l=s===t.fromRun?t.fromChar:0,m=s===t.toRun?t.toChar:g.length;c+=m-l;}else c+=1;}let i=o+c;return {pmStart:o,pmEnd:i}}function xe(e,t,r,n){let a=[];for(let o=0;o<t.lines.length;o++){let c=t.lines[o],i=D(e,c);i.pmStart===void 0||i.pmEnd===void 0||i.pmEnd>r&&i.pmStart<n&&a.push({line:c,index:o});}return a}function Y(e,t,r){let n=D(e,t);return n.pmStart===void 0?0:Math.max(0,r-n.pmStart)}function X(e,t,r,n){let a=0,o=0;for(let c=t.fromRun;c<=t.toRun&&c<e.runs.length;c++){let i=e.runs[c];if(i){if(i.kind==="tab"){let s=i.width??48;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="image"){let s=i.width;if(o+1>=r)return r<=o?a:a+s;a+=s,o+=1;continue}if(i.kind==="lineBreak"){if(r<=o)return a;o+=1;continue}if(i.kind==="text"){let s=i.text??"",u=c===t.fromRun,g=c===t.toRun,l=u?t.fromChar:0,m=g?t.toChar:s.length,f=s.slice(l,m);if(o+f.length>=r){let b=r-o,d=be(i),k=Q(f.slice(0,b),d);return a+k.width}let x=be(i),h=Q(f,x);a+=h.width,o+=f.length;}}}return a}function G(e,t){let r=0;for(let n=0;n<t&&n<e.lines.length;n++)r+=e.lines[n].lineHeight;return r}function Mt(e,t,r,n,a){if(n===a)return [];let o=Math.min(n,a),c=Math.max(n,a),i=[];for(let s=0;s<e.pages.length;s++){let u=e.pages[s],g=Z(e,s);for(let l of u.fragments){if(l.kind==="paragraph"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="paragraph"||!x||x.kind!=="paragraph")continue;let h=f,b=x,d=l,k=xe(h,b,o,c);for(let{line:y,index:F}of k){if(F<d.fromLine||F>=d.toLine)continue;let M=D(h,y);if(M.pmStart===void 0||M.pmEnd===void 0)continue;let p=Math.max(M.pmStart,o),S=Math.min(M.pmEnd,c);if(p>=S)continue;let T=Y(h,y,p),w=Y(h,y,S),C=h.attrs?.indent,R=C?.left??0,I=C?.right??0,v=Math.max(0,l.width-R-I),H=X(h,y,T),L=X(h,y,w),B=h.attrs?.alignment??"left",P=0;B==="center"?P=Math.max(0,(v-y.width)/2):B==="right"&&(P=Math.max(0,v-y.width));let E=G(b,F)-G(b,d.fromLine),A=l.x+R+P+Math.min(H,L),W=Math.max(1,Math.abs(L-H)),N=l.y+E;i.push({x:A,y:N+g,width:W,height:y.lineHeight,pageIndex:s});}}if(l.kind==="table"){let m=ee(t,l.blockId);if(m===-1)continue;let f=t[m],x=r[m];if(!f||f.kind!=="table"||!x||x.kind!=="table")continue;let h=f,b=x,d=l,k=d.headerRowCount??0,F=k>0&&d.continuesFromPrev?z(b,k):0;for(let M=d.fromRow;M<d.toRow&&M<h.rows.length;M++){let p=h.rows[M],S=b.rows[M];if(!p||!S)continue;let T=0;for(let w=0;w<p.cells.length;w++){let C=p.cells[w],R=S.cells[w];if(!(!C||!R)){for(let I=0;I<C.blocks.length;I++){let v=C.blocks[I],H=R.blocks[I];if(!v||v.kind!=="paragraph"||!H||H.kind!=="paragraph")continue;let L=v,B=H,P=xe(L,B,o,c),E=0;for(let{line:A,index:W}of P){let N=D(L,A);if(N.pmStart===void 0||N.pmEnd===void 0)continue;let te=Math.max(N.pmStart,o),ne=Math.min(N.pmEnd,c);if(te>=ne)continue;let ke=Y(L,A,te),ye=Y(L,A,ne),re=X(L,A,ke,R.width),oe=X(L,A,ye,R.width),Se=G(B,W);i.push({x:d.x+T+Math.min(re,oe),y:d.y+F+E+Se+g,width:Math.max(1,Math.abs(oe-re)),height:A.lineHeight,pageIndex:s});}E+=B.totalHeight;}T+=R.width;}}F+=S.height;}}if(l.kind==="image"){let m=l.pmStart??0;(l.pmEnd??m+1)>o&&m<c&&i.push({x:l.x,y:l.y+g,width:l.width,height:l.height,pageIndex:s});}}}return i}function Pt(e,t,r,n){for(let a=0;a<e.pages.length;a++){let o=e.pages[a],c=Z(e,a);for(let i of o.fragments){if(i.kind==="paragraph"){let s=ee(t,i.blockId);if(s===-1)continue;let u=t[s],g=r[s];if(!u||u.kind!=="paragraph"||!g||g.kind!=="paragraph")continue;let l=u,m=g,f=i,x=l.pmStart??0,h=l.pmEnd??x;if(n<x||n>h)continue;for(let b=f.fromLine;b<f.toLine;b++){let d=m.lines[b];if(!d)continue;let k=D(l,d);if(!(k.pmStart===void 0||k.pmEnd===void 0)&&n>=k.pmStart&&n<=k.pmEnd){let y=Y(l,d,n),F=l.attrs?.indent,M=F?.left??0,p=F?.right??0,S=Math.max(0,i.width-M-p),T=X(l,d,y),w=l.attrs?.alignment??"left",C=0;w==="center"?C=Math.max(0,(S-d.width)/2):w==="right"&&(C=Math.max(0,S-d.width));let R=G(m,b)-G(m,f.fromLine);return {x:i.x+M+C+T,y:i.y+R+c,height:d.lineHeight,pageIndex:a}}}}if(i.kind==="image"){let s=i.pmStart??0,u=i.pmEnd??s+1;if(n>=s&&n<=u){let g=n===s?0:i.width;return {x:i.x+g,y:i.y+c,height:i.height,pageIndex:a}}}}}return null}function wt(e){return e.length<=1?false:new Set(e.map(r=>r.pageIndex)).size>1}function Tt(e){let t=new Map;for(let r of e){let n=t.get(r.pageIndex)??[];n.push(r),t.set(r.pageIndex,n);}return t}export{ce as a,ct as b,We as c,Ue as d,rt as e,pt as f,Ye as g,ft as h,Q as i,dt as j,de as k,Z as l,xt as m,kt as n,Mt as o,Pt as p,wt as q,Tt as r};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';var chunkPB7VMDDP_js=require('./chunk-PB7VMDDP.js'),chunkVR6PT4IZ_js=require('./chunk-VR6PT4IZ.js');function H(e){return g(e).variables}function g(e){let t=[],n={body:[],headers:[],footers:[],footnotes:[],endnotes:[],textBoxes:[]};if(e.package?.document){let r=$(e.package.document);r.forEach(o=>{t.push({name:o,location:"body"});}),n.body=Array.from(new Set(r)).sort();}if(e.package?.document?.sections&&e.package.document.sections.forEach((r,o)=>{r.properties.headerReferences&&r.properties.headerReferences.forEach(i=>{});}),e.package?.footnotes){let r=D(e.package.footnotes);r.forEach(o=>{t.push({name:o,location:"footnote"});}),n.footnotes=Array.from(new Set(r)).sort();}if(e.package?.endnotes){let r=D(e.package.endnotes);r.forEach(o=>{t.push({name:o,location:"endnote"});}),n.endnotes=Array.from(new Set(r)).sort();}e.templateVariables&&e.templateVariables.forEach(r=>{t.some(o=>o.name===r)||t.push({name:r,location:"body"});});let a=new Set;return t.forEach(r=>a.add(r.name)),{variables:Array.from(a).sort(),totalOccurrences:t.length,byLocation:n,occurrences:t}}function $(e){let t=[];if(e.content&&t.push(...R(e.content)),e.sections)for(let n of e.sections)n.content&&t.push(...R(n.content));return t}function R(e){let t=[];for(let n of e)n.type==="paragraph"?t.push(...b(n)):n.type==="table"&&t.push(...P(n));return t}function b(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="run"?t.push(...d(n)):n.type==="hyperlink"?t.push(...J(n)):n.type==="simpleField"?t.push(...L(n)):n.type==="complexField"&&t.push(...F(n));return t}function d(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="text"&&n.text&&t.push(...E(n.text));return t}function J(e){let t=[];if(!e.children)return t;for(let n of e.children)n.type==="run"&&t.push(...d(n));return t}function L(e){let t=[];if(e.instruction&&t.push(...E(e.instruction)),e.content)for(let n of e.content)n.type==="run"&&t.push(...d(n));return t}function F(e){let t=[];if(e.fieldCode)for(let n of e.fieldCode)n.type==="run"&&t.push(...d(n));if(e.fieldResult)for(let n of e.fieldResult)n.type==="run"&&t.push(...d(n));return t}function P(e){let t=[];if(!e.rows)return t;for(let n of e.rows)if(n.cells)for(let a of n.cells)t.push(...B(a));return t}function B(e){let t=[];if(!e.content)return t;for(let n of e.content)n.type==="paragraph"?t.push(...b(n)):n.type==="table"&&t.push(...P(n));return t}function D(e){let t=[];for(let n of e)if(n.content)for(let a of n.content)t.push(...b(a));return t}var k=/\{([a-zA-Z_][a-zA-Z0-9_\-\.]*)\}/g,M=/\{(.+?)\}/g;function E(e){if(!e)return [];let t=[],n=new RegExp(k),a;for(;(a=n.exec(e))!==null;)t.push(a[1]);return t}function q(e){return k.test(e)}function U(e){return !(!e||typeof e!="string"||e.length===0||e.length>100||!/^[a-zA-Z_]/.test(e)||!/^[a-zA-Z_][a-zA-Z0-9_\-\.]*$/.test(e))}function X(e){if(!e)return "";let t=e.replace(/\s+/g,"_");return t=t.replace(/[^a-zA-Z0-9_\-\.]/g,""),t&&!/^[a-zA-Z_]/.test(t)&&(t="_"+t),t.substring(0,100)}function G(e){return `{${e}}`}function K(e){let t=e.match(/^\{(.+?)\}$/);return t?t[1]:null}function Q(e,t){return e&&e.replace(M,(n,a)=>{let r=a.trim();return r in t?t[r]:n})}function Y(e,t=""){return e&&e.replace(M,t)}function ee(e){return H(e).length>0}function Z(e){return typeof e=="object"&&e!==null&&("_def"in e||"parse"in e||"safeParse"in e)}function h(e,t){let n=t,{position:a,variableName:r}=n,o=JSON.parse(JSON.stringify(e)),s=o.package.document.content.filter(u=>u.type==="paragraph");if(a.paragraphIndex>=s.length)throw new Error(`Paragraph index ${a.paragraphIndex} out of bounds`);let c=s[a.paragraphIndex],l=`{${r}}`;return S(c,a.offset,l),o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(r)||o.templateVariables.push(r),o}function y(e,t){let n=t,{range:a,variableName:r}=n,o=JSON.parse(JSON.stringify(e)),s=o.package.document.content.filter(u=>u.type==="paragraph");if(a.start.paragraphIndex!==a.end.paragraphIndex)throw new Error("Template variable replacement cannot span multiple paragraphs");if(a.start.paragraphIndex>=s.length)throw new Error(`Paragraph index ${a.start.paragraphIndex} out of bounds`);let c=s[a.start.paragraphIndex];z(c,a.start.offset,a.end.offset);let l=`{${r}}`;return S(c,a.start.offset,l),o.templateVariables||(o.templateVariables=[]),o.templateVariables.includes(r)||o.templateVariables.push(r),o}function S(e,t,n){let a=0,r=false;for(let o=0;o<e.content.length;o++){let i=e.content[o];if(i.type==="run"){let s=x(i),c=a,l=a+s.length;if(!r&&t>=c&&t<=l){let u=t-c,v=s.slice(0,u),V=s.slice(u),m=[];for(let p=0;p<o;p++)m.push(e.content[p]);v&&m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:v}]}),m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:n}]}),V&&m.push({type:"run",formatting:i.formatting,content:[{type:"text",text:V}]});for(let p=o+1;p<e.content.length;p++)m.push(e.content[p]);e.content=m,r=true;break}a=l;}else if(i.type==="hyperlink")for(let s of i.children)s.type==="run"&&(a+=x(s).length);}r||e.content.push({type:"run",content:[{type:"text",text:n}]});}function z(e,t,n){let a=[],r=0;for(let o of e.content)if(o.type==="run"){let i=x(o),s=r,c=r+i.length;if(c<=t||s>=n)a.push(o);else {let l="";s<t&&(l+=i.slice(0,t-s)),c>n&&(l+=i.slice(n-s)),l.length>0&&a.push({type:"run",formatting:o.formatting,content:[{type:"text",text:l}]});}r=c;}else a.push(o);e.content=a;}function x(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}var f={type:"string",description:"Document ID from a previous docx_load call"},j={type:"object",properties:{paragraphIndex:{type:"number",description:"Index of the paragraph (0-indexed)"},offset:{type:"number",description:"Character offset within the paragraph"}},required:["paragraphIndex","offset"]},_={name:"docx_get_variables",description:`List all template variables ({name} format) found in the document.
|
|
2
|
+
Returns variable names without braces, along with their locations (body, headers, footers, etc.).
|
|
3
|
+
Use this to discover what data fields a template document expects.`,inputSchema:{type:"object",properties:{documentId:f},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,a=t.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};try{let r=g(a.document);return {content:[{type:"text",text:JSON.stringify({variables:r.variables,count:r.variables.length,totalOccurrences:r.totalOccurrences,byLocation:r.byLocation},null,2)}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to detect variables: ${r.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low",examples:[{description:"Get all variables from a loaded document",input:{documentId:"doc_123"},output:'{"variables": ["customer_name", "invoice_date"], "count": 2}'}]}},A={name:"docx_insert_variable",description:`Insert a template variable placeholder ({name}) at a specific position in the document.
|
|
4
|
+
The variable can later be substituted with actual values using docx_apply_template.
|
|
5
|
+
Variable names should follow the pattern: letters, numbers, underscores, starting with a letter.`,inputSchema:{type:"object",properties:{documentId:f,position:j,variableName:{type:"string",description:'Variable name without braces (e.g., "customer_name"). Will be inserted as {customer_name}',pattern:"^[a-zA-Z_][a-zA-Z0-9_]*$"}},required:["documentId","position","variableName"]},handler:async(e,t)=>{let{documentId:n,position:a,variableName:r}=e,o=t.session.documents.get(n);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/.test(r))return {isError:true,content:[{type:"text",text:`Invalid variable name: ${r}. Must start with letter/underscore and contain only alphanumeric, underscore, hyphen, or dot.`}]};try{let{executeCommand:i}=await import('./executor-L2MVKMXO.js'),s=i(o.document,{type:"insertText",position:a,text:`{${r}}`});return o.document=s,o.lastModified=Date.now(),s.templateVariables||(s.templateVariables=[]),s.templateVariables.includes(r)||s.templateVariables.push(r),{content:[{type:"text",text:JSON.stringify({success:!0,variable:r,insertedAs:`{${r}}`,position:a})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to insert variable: ${i.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"low",examples:[{description:"Insert customer name variable at start of first paragraph",input:{documentId:"doc_123",position:{paragraphIndex:0,offset:0},variableName:"customer_name"}}]}},O={name:"docx_apply_template",description:`Substitute template variables with actual values in the document.
|
|
6
|
+
Replaces all {variable} placeholders with the corresponding values provided.
|
|
7
|
+
Preserves all formatting (fonts, styles, colors, tables).
|
|
8
|
+
Use docx_get_variables first to discover what variables exist in the document.`,inputSchema:{type:"object",properties:{documentId:f,variables:{type:"object",description:'Map of variable names to values (e.g., {"customer_name": "John Doe", "date": "2024-01-15"})',additionalProperties:{type:"string"}},keepUnmatchedVariables:{type:"boolean",description:"If true, keep {variable} placeholders for variables not in the map. If false, replace with empty string. Default: true",default:true}},required:["documentId","variables"]},handler:async(e,t)=>{let{documentId:n,variables:a,keepUnmatchedVariables:r=true}=e,o=t.session.documents.get(n);if(!o)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!o.buffer)return {isError:true,content:[{type:"text",text:"Cannot apply template: document was not loaded from a DOCX buffer"}]};try{let i=chunkPB7VMDDP_js.b(o.buffer,a,{nullGetter:r?"keep":"empty"}),s=await chunkVR6PT4IZ_js.n(i.buffer);return o.document=s,o.buffer=i.buffer,o.lastModified=Date.now(),{content:[{type:"text",text:JSON.stringify({success:!0,replacedVariables:i.replacedVariables,unreplacedVariables:i.unreplacedVariables,warnings:i.warnings})}]}}catch(i){return {isError:true,content:[{type:"text",text:`Failed to apply template: ${i.message}`}]}}},annotations:{category:"template",readOnly:false,complexity:"medium",examples:[{description:"Fill in customer and date values",input:{documentId:"doc_123",variables:{customer_name:"Jane Smith",invoice_date:"2024-02-15",amount:"$1,234.56"}}}]}},N={name:"docx_validate_template",description:`Validate that a document is a valid docxtemplater template.
|
|
9
|
+
Checks for syntax errors like unclosed braces, invalid tag names, etc.
|
|
10
|
+
Returns validation result with any errors found and list of valid tags.`,inputSchema:{type:"object",properties:{documentId:f},required:["documentId"]},handler:async(e,t)=>{let{documentId:n}=e,a=t.session.documents.get(n);if(!a)return {isError:true,content:[{type:"text",text:`Document not found: ${n}`}]};if(!a.buffer)return {isError:true,content:[{type:"text",text:"Cannot validate template: document was not loaded from a DOCX buffer"}]};try{let r=chunkPB7VMDDP_js.f(a.buffer);return {content:[{type:"text",text:JSON.stringify({valid:r.valid,tags:r.tags,errors:r.errors.map(o=>({message:o.message,variable:o.variable,type:o.type}))},null,2)}]}}catch(r){return {isError:true,content:[{type:"text",text:`Failed to validate template: ${r.message}`}]}}},annotations:{category:"template",readOnly:true,complexity:"low"}},T=[_,A,O,N];var W={id:"docxtemplater",name:"Docxtemplater",version:"1.0.0",description:"Template variable support using standard docxtemplater syntax ({variable})",commandHandlers:{insertTemplateVariable:h,replaceWithTemplateVariable:y},mcpTools:T};exports.a=H;exports.b=g;exports.c=$;exports.d=b;exports.e=E;exports.f=q;exports.g=U;exports.h=X;exports.i=G;exports.j=K;exports.k=Q;exports.l=Y;exports.m=ee;exports.n=Z;exports.o=W;
|