@eigenpal/docx-js-editor 0.0.11 → 0.0.13
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/DocumentAgent-Ci6_T-XM.d.ts +412 -0
- package/dist/DocumentAgent-DEGFgYEN.d.cts +412 -0
- package/dist/FindReplaceDialog-BAACAU67.cjs +1 -0
- package/dist/FindReplaceDialog-RWYDRWHF.js +1 -0
- package/dist/FootnotePropertiesDialog-BC6JIPDA.cjs +1 -0
- package/dist/FootnotePropertiesDialog-CWQF5EBK.js +1 -0
- package/dist/HyperlinkDialog-EG2BSLPD.cjs +1 -0
- package/dist/HyperlinkDialog-YAVK64F4.js +1 -0
- package/dist/ImagePositionDialog-IGYS5KMK.cjs +1 -0
- package/dist/ImagePositionDialog-S6SMH7XH.js +1 -0
- package/dist/ImagePropertiesDialog-UO5QUIBS.js +1 -0
- package/dist/ImagePropertiesDialog-VGV4E4SN.cjs +1 -0
- package/dist/TablePropertiesDialog-VBOU4DID.js +1 -0
- package/dist/TablePropertiesDialog-WRM47JI6.cjs +1 -0
- package/dist/{types-BALm1KBi.d.cts → agentApi-CbVUCZRu.d.cts} +1 -308
- package/dist/{types-BALm1KBi.d.ts → agentApi-CbVUCZRu.d.ts} +1 -308
- package/dist/chunk-2ASOEN3V.js +1 -0
- package/dist/chunk-6MBDPZVD.js +111 -0
- package/dist/chunk-6YLNNCRZ.cjs +10 -0
- package/dist/chunk-BVQ2QRHA.cjs +4 -0
- package/dist/chunk-COP5BIBZ.js +10 -0
- package/dist/chunk-CZ7W7MCM.cjs +2 -0
- package/dist/chunk-E6XDMUAM.js +4 -0
- package/dist/chunk-EMKABJPH.js +1 -0
- package/dist/{chunk-TRAQI6RX.cjs → chunk-EPCZ24TY.cjs} +5 -5
- package/dist/chunk-ESI4BSBF.js +1 -0
- package/dist/chunk-FLECKDK4.cjs +58 -0
- package/dist/chunk-ITWEFKGQ.cjs +1 -0
- package/dist/chunk-KESNGXGO.js +1 -0
- package/dist/chunk-KVAT5SVD.js +2 -0
- package/dist/chunk-L34XFLQZ.cjs +1 -0
- package/dist/chunk-M7F2CUUD.js +2 -0
- package/dist/chunk-MDPDH7KS.js +58 -0
- package/dist/chunk-MTX3EEBJ.js +258 -0
- package/dist/chunk-NT2REEAA.cjs +1 -0
- package/dist/{chunk-PM4Y7OFN.js → chunk-OTG4NABM.js} +5 -5
- package/dist/chunk-OW5H5DNE.cjs +1 -0
- package/dist/chunk-PJVI53AH.js +2 -0
- package/dist/chunk-PNMZPPPI.cjs +2 -0
- package/dist/chunk-SF53KLDZ.cjs +1 -0
- package/dist/chunk-TOI5W3HK.js +8 -0
- package/dist/chunk-UAVOWAIF.cjs +8 -0
- package/dist/chunk-VN7XH644.cjs +258 -0
- package/dist/chunk-W4DUKACP.cjs +111 -0
- package/dist/chunk-XS2AQFMF.cjs +2 -0
- package/dist/chunk-ZDYHAYN6.js +1 -0
- package/dist/clipboard-BOocwmAM.d.ts +539 -0
- package/dist/clipboard-Cx7cb3kX.d.cts +539 -0
- package/dist/{colorResolver-BNj-uZ58.d.ts → colorResolver-CIDiSPWd.d.cts} +3 -411
- package/dist/{colorResolver-DiMquGWR.d.cts → colorResolver-KXbUgzWC.d.ts} +3 -411
- package/dist/core-plugins.cjs +1 -1
- package/dist/core-plugins.d.cts +4 -3
- package/dist/core-plugins.d.ts +4 -3
- package/dist/core-plugins.js +1 -1
- package/dist/core.cjs +1 -0
- package/dist/core.d.cts +23 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.js +1 -0
- package/dist/headless.cjs +2 -2
- package/dist/headless.d.cts +8 -175
- package/dist/headless.d.ts +8 -175
- package/dist/headless.js +1 -1
- package/dist/index.cjs +9 -378
- package/dist/index.d.cts +17 -4161
- package/dist/index.d.ts +17 -4161
- package/dist/index.js +9 -378
- package/dist/insertOperations-CzB5b-Of.d.ts +176 -0
- package/dist/insertOperations-DKVmCV32.d.cts +176 -0
- package/dist/mcp-cli.js +21 -21
- package/dist/mcp.cjs +10 -10
- package/dist/mcp.d.cts +2 -1
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.js +9 -9
- package/dist/processTemplate-BHBTDAIC.js +1 -0
- package/dist/processTemplate-QOEAXCKA.cjs +1 -0
- package/dist/react-Be1YOl4z.d.ts +1356 -0
- package/dist/react-DPuSVbgY.d.cts +1356 -0
- package/dist/react.cjs +1 -0
- package/dist/react.css +1 -0
- package/dist/react.d.cts +9 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.js +1 -0
- package/dist/{registry-CzqAPdui.d.ts → registry-D4tvj9f3.d.ts} +1 -1
- package/dist/{registry-BUTMLqSj.d.cts → registry-ngv6Bumt.d.cts} +1 -1
- package/dist/types-D96elyJF.d.cts +310 -0
- package/dist/types-xMzSPT4i.d.ts +310 -0
- package/dist/ui.cjs +1 -0
- package/dist/ui.d.cts +2103 -0
- package/dist/ui.d.ts +2103 -0
- package/dist/ui.js +1 -0
- package/dist/variableDetector-CPxKo9jP.d.cts +173 -0
- package/dist/variableDetector-DeM1N-_L.d.ts +173 -0
- package/package.json +85 -10
- package/dist/chunk-GQ4JYQWC.js +0 -58
- package/dist/chunk-H3JNHCD7.cjs +0 -10
- package/dist/chunk-L2UUZRZI.js +0 -10
- package/dist/chunk-QOIY4Y6N.cjs +0 -9
- package/dist/chunk-QYKJKSKZ.cjs +0 -58
- package/dist/chunk-TPUJJJWA.js +0 -9
package/dist/chunk-TPUJJJWA.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {a,n}from'./chunk-L2UUZRZI.js';import {d,e as e$1}from'./chunk-GQ4JYQWC.js';import {o}from'./chunk-PM4Y7OFN.js';import {b,a as a$1}from'./chunk-MMJD2DLL.js';import {e}from'./chunk-3IYNTJO5.js';var W={dk1:"000000",lt1:"FFFFFF",dk2:"44546A",lt2:"E7E6E6",accent1:"4472C4",accent2:"ED7D31",accent3:"A5A5A5",accent4:"FFC000",accent5:"5B9BD5",accent6:"70AD47",hlink:"0563C1",folHlink:"954F72"},J={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:""},w={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 $(n){if(!n)return 1;let t=parseInt(n,16);return isNaN(t)?1:t/255}function C(n){let t=n.padStart(6,"0").slice(0,6),e=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return {r:isNaN(e)?0:e,g:isNaN(r)?0:r,b:isNaN(a)?0:a}}function E(n,t,e){let r=a=>Math.max(0,Math.min(255,Math.round(a))).toString(16).padStart(2,"0");return `${r(n)}${r(t)}${r(e)}`.toUpperCase()}function U(n,t,e){n/=255,t/=255,e/=255;let r=Math.max(n,t,e),a=Math.min(n,t,e),o=(r+a)/2;if(r===a)return {h:0,s:0,l:o};let i=r-a,s=o>.5?i/(2-r-a):i/(r+a),c;switch(r){case n:c=((t-e)/i+(t<e?6:0))/6;break;case t:c=((e-n)/i+2)/6;break;case e:c=((n-t)/i+4)/6;break;default:c=0;}return {h:c*360,s,l:o}}function G(n,t,e){if(n=n/360,t===0){let i=Math.round(e*255);return {r:i,g:i,b:i}}let r=(i,s,c)=>(c<0&&(c+=1),c>1&&(c-=1),c<1/6?i+(s-i)*6*c:c<1/2?s:c<2/3?i+(s-i)*(2/3-c)*6:i),a=e<.5?e*(1+t):e+t-e*t,o=2*e-a;return {r:Math.round(r(o,a,n+1/3)*255),g:Math.round(r(o,a,n)*255),b:Math.round(r(o,a,n-1/3)*255)}}function q(n,t){if(t<=0||t>=1)return t>=1?"FFFFFF":n;let e=C(n),r=U(e.r,e.g,e.b);r.l=r.l+(1-r.l)*t;let a=G(r.h,r.s,r.l);return E(a.r,a.g,a.b)}function X(n,t){if(t<=0||t>=1)return t<=0?"000000":n;let e=C(n),r=U(e.r,e.g,e.b);r.l=r.l*t;let a=G(r.h,r.s,r.l);return E(a.r,a.g,a.b)}function Q(n,t){let e=w[t]??t,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],a=o=>r.includes(o);return n?.colorScheme?a(e)?n.colorScheme[e]??W[e]??"000000":"000000":a(e)?W[e]??"000000":"000000"}function K(n){if(!n)return null;let t=n.toLowerCase();return w[n]??w[t]??null}function g(n,t,e="000000"){if(!n)return `#${e}`;if(n.auto)return `#${e}`;let r;if(n.themeColor){let a=K(n.themeColor);if(a?r=Q(t,a):r=n.rgb??e,n.themeTint){let o=$(n.themeTint);r=q(r,o);}else if(n.themeShade){let o=$(n.themeShade);r=X(r,o);}}else n.rgb?r=n.rgb:r=e;return `#${r.toUpperCase().replace(/^#/,"")}`}function Et(n){if(!n||n==="none")return "";let t=J[n];return t?`#${t}`:""}function Bt(n,t){return n?n.auto?"transparent":g(n,t):""}function vt(n,t){if(!n)return false;if(n.auto)return true;let r=g(n,t).replace(/^#/,"").toLowerCase(),a=C(r);return (a.r+a.g+a.b)/3<20}function Ot(n,t){if(!n)return false;let r=g(n,t).replace(/^#/,"").toLowerCase(),a=C(r);return (a.r+a.g+a.b)/3>235}function Nt(n,t){if(!n)return "#000000";let r=g(n,t).replace(/^#/,""),a=C(r);return (.299*a.r+.587*a.g+.114*a.b)/255>.5?"#000000":"#FFFFFF"}function Vt(n){if(!n)return;let t=n.trim();if(t.toLowerCase()==="auto")return {auto:true};let e=K(t);if(e)return {themeColor:e};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 Lt(n,t,e){let r={themeColor:n};return t!==void 0&&t>0&&t<1&&(r.themeTint=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),e!==void 0&&e>0&&e<1&&(r.themeShade=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),r}function Mt(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function jt(n,t,e){let a=g(n,t).replace(/^#/,""),o=1-e/100;return `#${X(a,o)}`}function zt(n,t,e){let a=g(n,t).replace(/^#/,""),o=e/100;return `#${q(a,o)}`}function Wt(n,t,e,r){let a=g(n,r).replace(/^#/,""),o=g(t,r).replace(/^#/,""),i=C(a),s=C(o),c={r:Math.round(i.r*(1-e)+s.r*e),g:Math.round(i.g*(1-e)+s.g*e),b:Math.round(i.b*(1-e)+s.b*e)};return `#${E(c.r,c.g,c.b)}`}function $t(n,t,e){if(!n&&!t)return true;if(!n||!t)return false;let r=g(n,e).toUpperCase(),a=g(t,e).toUpperCase();return r===a}function Gt(n){return n/1440*96}function qt(n){return n/96*1440}function Xt(n){return n/914400*96}function Kt(n){return n/96*914400}function Yt(n){return n/914400*1440}function Jt(n){return n/1440*914400}function Qt(n){return n/72*96}function Zt(n){return n/144*96}function te(n){return n/2}function ee(n){return n/576*96}function Z(n,t=2){let e=Math.pow(10,t);return Math.round(n*e)/e}function ne(n){return `${Z(n)}px`}var S=class n$1{constructor(t){e(this,"_document");e(this,"_pendingVariables");t instanceof ArrayBuffer||ArrayBuffer.isView(t)?this._document={package:{document:{content:[]}},originalBuffer:t instanceof ArrayBuffer?t:t.buffer}:this._document=t,this._pendingVariables={};}static async fromBuffer(t){let e=await o(t);return new n$1(e)}static fromDocument(t){return new n$1(t)}getDocument(){return this._document}getText(){let t=this._document.package.document;return this._getBodyText(t)}getFormattedText(){let t=[],e=this._document.package.document;for(let r of e.content)r.type==="paragraph"&&this._extractParagraphSegments(r,t);return t}getVariables(){return a(this._document)}getStyles(){let t=this._document.package.styles;if(!t?.styles)return [];let e=[];for(let[r,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:r,name:o.name||r,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}getPageCount(){let t=this.getWordCount();return Math.max(1,Math.ceil(t/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.length>0).length}getCharacterCount(t=true){let e=this.getText();return t?e.length:e.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(t=>t.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(t=>t.type==="table").length}getAgentContext(t=100){let e=this._document.package.document,r=e.content.filter(i=>i.type==="paragraph"),a=r.map((i,s)=>{let c=this._getParagraphText(i),u=i.formatting?.styleId;return {index:s,preview:c.slice(0,t),style:u,isHeading:u?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(u),isListItem:!!i.listRendering,isEmpty:c.trim().length===0}}),o=(e.sections||[]).map((i,s)=>({index:s,paragraphCount:i.content?.length||0,pageSize:i.properties?.pageWidth&&i.properties?.pageHeight?{width:i.properties.pageWidth,height:i.properties.pageHeight}:void 0,isLandscape:i.properties?.orientation==="landscape",hasHeader:!!i.properties?.headerReferences?.length,hasFooter:!!i.properties?.footerReferences?.length}));return {paragraphCount:r.length,wordCount:this.getWordCount(),characterCount:this.getCharacterCount(),variables:this.getVariables(),variableCount:this.getVariables().length,availableStyles:this.getStyles(),outline:a,sections:o,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(t,e,r={}){let a={type:"insertText",position:t,text:e,formatting:r.formatting};return this._executeCommand(a)}replaceRange(t,e,r={}){let a={type:"replaceText",range:t,text:e,formatting:r.formatting};return this._executeCommand(a)}deleteRange(t){let e={type:"deleteText",range:t};return this._executeCommand(e)}applyFormatting(t,e){let r={type:"formatText",range:t,formatting:e};return this._executeCommand(r)}applyStyle(t,e){let r={type:"applyStyle",paragraphIndex:t,styleId:e};return this._executeCommand(r)}applyParagraphFormatting(t,e){let r={type:"formatParagraph",paragraphIndex:t,formatting:e};return this._executeCommand(r)}insertTable(t,e,r,a={}){let o={type:"insertTable",position:t,rows:e,columns:r,data:a.data,hasHeader:a.hasHeader};return this._executeCommand(o)}insertImage(t,e,r={}){let a={type:"insertImage",position:t,src:e,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(a)}insertHyperlink(t,e,r={}){let a={type:"insertHyperlink",range:t,url:e,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(a)}removeHyperlink(t){let e={type:"removeHyperlink",range:t};return this._executeCommand(e)}insertParagraphBreak(t){let e={type:"insertParagraphBreak",position:t};return this._executeCommand(e)}mergeParagraphs(t,e){let r={type:"mergeParagraphs",paragraphIndex:t,count:e};return this._executeCommand(r)}setVariable(t,e){return this._pendingVariables[t]=e,this}setVariables(t){for(let[e,r]of Object.entries(t))this._pendingVariables[e]=r;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(t){let e={...this._pendingVariables,...t};if(Object.keys(e).length===0)return this;let r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let a=n(r,e),o$1=await o(a),i=new n$1(o$1);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?d(this._document):e$1(this._document)}async toBlob(t="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let e=await this.toBuffer();return new Blob([e],{type:t})}executeCommands(t){let e=b(this._document,t);return new n$1(e)}_executeCommand(t){let e=a$1(this._document,t),r=new n$1(e);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(t){let e=[];for(let r of t.content)r.type==="paragraph"?e.push(this._getParagraphText(r)):r.type==="table"&&e.push(this._getTableText(r));return e.join(`
|
|
2
|
-
`)}_getParagraphText(t){let e=[];for(let r of t.content)r.type==="run"?e.push(this._getRunText(r)):r.type==="hyperlink"&&e.push(this._getHyperlinkText(r));return e.join("")}_getRunText(t){return t.content.filter(e=>e.type==="text").map(e=>e.text).join("")}_getHyperlinkText(t){let e=[];for(let r of t.children)r.type==="run"&&e.push(this._getRunText(r));return e.join("")}_getTableText(t){let e=[];for(let r of t.rows)for(let a of r.cells)for(let o of a.content)o.type==="paragraph"&&e.push(this._getParagraphText(o));return e.join(" ")}_extractParagraphSegments(t,e){for(let r of t.content)if(r.type==="run"){let a=this._getRunText(r);a&&e.push({text:a,formatting:r.formatting});}else if(r.type==="hyperlink"){let a=r.href||"";for(let o of r.children)if(o.type==="run"){let i=this._getRunText(o);i&&e.push({text:i,formatting:o.formatting,isHyperlink:true,hyperlinkUrl:a});}}}_parseHeadingLevel(t){if(!t)return;let e=t.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}_hasImages(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let r of e.content)if(r.type==="run"){for(let a of r.content)if(a.type==="drawing")return true}}return false}_hasHyperlinks(){let t=this._document.package.document;for(let e of t.content)if(e.type==="paragraph"){for(let r of e.content)if(r.type==="hyperlink")return true}return false}};async function ue(n){return S.fromBuffer(n)}function le(n){return S.fromDocument(n)}function tt(n,t={}){let{outlineMaxChars:e=100,maxOutlineParagraphs:r=50}=t,a$1=n.package.document,o=a$1.content.filter(y=>y.type==="paragraph"),i=et(o,e,r),s=a(n),c=nt(n),u=rt(a$1),l=at(a$1),x=ot(a$1),d=a$1.content.some(y=>y.type==="table"),b=ct(a$1),p=ut(a$1);return {paragraphCount:o.length,wordCount:l,characterCount:x,variables:s,variableCount:s.length,availableStyles:c,outline:i,sections:u,hasTables:d,hasImages:b,hasHyperlinks:p}}function de(n,t,e={}){let{contextChars:r=200,includeSuggestions:a=true}=e,i=n.package.document.content.filter(f=>f.type==="paragraph"),s=i[t.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${t.start.paragraphIndex}`);let c=m(s),u="";if(t.start.paragraphIndex===t.end.paragraphIndex)u=c.slice(t.start.offset,t.end.offset);else {let f=[];for(let P=t.start.paragraphIndex;P<=t.end.paragraphIndex;P++){let N=i[P];if(!N)continue;let R=m(N);P===t.start.paragraphIndex?f.push(R.slice(t.start.offset)):P===t.end.paragraphIndex?f.push(R.slice(0,t.end.offset)):f.push(R);}u=f.join(`
|
|
3
|
-
`);}let l=mt(i,t.start.paragraphIndex,t.start.offset,r),x=gt(i,t.end.paragraphIndex,t.end.offset,r),d=dt(s,t.start.offset),b=s.formatting||{},p={index:t.start.paragraphIndex,fullText:c,style:s.formatting?.styleId,wordCount:B(c)},y=false,F=ft(s,t.start.offset),_=a?ht(u):[];return {selectedText:u,range:t,formatting:d,paragraphFormatting:b,textBefore:l,textAfter:x,paragraph:p,inTable:y,inHyperlink:F,suggestedActions:_}}function Y(n){let t=tt(n,{outlineMaxChars:50,maxOutlineParagraphs:10}),e=[`Document with ${t.paragraphCount} paragraphs, ${t.wordCount} words.`];t.hasTables&&e.push("Contains tables."),t.hasImages&&e.push("Contains images."),t.hasHyperlinks&&e.push("Contains hyperlinks."),t.variableCount>0&&e.push(`Has ${t.variableCount} template variables: ${t.variables.join(", ")}`);let r=t.outline.filter(a=>a.isHeading);if(r.length>0){e.push(`
|
|
4
|
-
Headings:`);for(let a of r.slice(0,5)){let o=a.headingLevel||1;e.push(`${" ".repeat(o-1)}- ${a.preview}`);}r.length>5&&e.push(` ... and ${r.length-5} more headings`);}return e.join(" ")}function et(n,t,e){let r=[];for(let a=0;a<Math.min(n.length,e);a++){let o=n[a],i=m(o),s=o.formatting?.styleId;r.push({index:a,preview:i.slice(0,t),style:s,isHeading:lt(s),headingLevel:pt(s),isListItem:!!o.listRendering,isEmpty:i.trim().length===0});}return r}function nt(n){let t=n.package.styles;if(!t?.styles)return [];let e=[];for(let[r,a]of Object.entries(t.styles))if(typeof a=="object"&&a!==null){let o=a;e.push({id:r,name:o.name||r,type:o.type==="numbering"?"paragraph":o.type||"paragraph",builtIn:o.default});}return e}function rt(n){return n.sections?n.sections.map((t,e)=>({index:e,paragraphCount:t.content?.length||0,pageSize:t.properties?.pageWidth&&t.properties?.pageHeight?{width:t.properties.pageWidth,height:t.properties.pageHeight}:void 0,isLandscape:t.properties?.orientation==="landscape",hasHeader:!!t.properties?.headerReferences?.length,hasFooter:!!t.properties?.footerReferences?.length})):[]}function at(n){let t=0;for(let e of n.content)if(e.type==="paragraph"){let r=m(e);t+=B(r);}else e.type==="table"&&(t+=it(e));return t}function B(n){return n.split(/\s+/).filter(e=>e.length>0).length}function ot(n){let t=0;for(let e of n.content)if(e.type==="paragraph"){let r=m(e);t+=r.length;}else e.type==="table"&&(t+=st(e));return t}function it(n){let t=0;for(let e of n.rows)for(let r of e.cells)for(let a of r.content)if(a.type==="paragraph"){let o=m(a);t+=B(o);}return t}function st(n){let t=0;for(let e of n.rows)for(let r of e.cells)for(let a of r.content)if(a.type==="paragraph"){let o=m(a);t+=o.length;}return t}function m(n){let t=[];for(let e of n.content)e.type==="run"?t.push(A(e)):e.type==="hyperlink"&&t.push(v(e));return t.join("")}function A(n){return n.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function v(n){let t=[];for(let e of n.children)e.type==="run"&&t.push(A(e));return t.join("")}function ct(n){for(let t of n.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="run"){for(let r of e.content)if(r.type==="drawing")return true}}return false}function ut(n){for(let t of n.content)if(t.type==="paragraph"){for(let e of t.content)if(e.type==="hyperlink")return true}return false}function lt(n){return n?n.toLowerCase().includes("heading"):false}function pt(n){if(!n)return;let t=n.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}function mt(n,t,e,r){let a=[],o=0,i=n[t];if(i){let u=m(i).slice(0,e);a.unshift(u),o+=u.length;}for(let c=t-1;c>=0&&o<r;c--){let u=n[c];if(!u)continue;let l=m(u);a.unshift(l),o+=l.length;}let s=a.join(`
|
|
5
|
-
`);return s.length>r?"..."+s.slice(-r):s}function gt(n,t,e,r){let a=[],o=0,i=n[t];if(i){let u=m(i).slice(e);a.push(u),o+=u.length;}for(let c=t+1;c<n.length&&o<r;c++){let u=n[c];if(!u)continue;let l=m(u);a.push(l),o+=l.length;}let s=a.join(`
|
|
6
|
-
`);return s.length>r?s.slice(0,r)+"...":s}function dt(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=A(r),o=e,i=e+a.length;if(t>=o&&t<i)return r.formatting||{};e=i;}else if(r.type==="hyperlink"){let a=v(r),o=e,i=e+a.length;if(t>=o&&t<i){for(let s of r.children)if(s.type==="run")return s.formatting||{}}e=i;}return {}}function ft(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=A(r);e+=a.length;}else if(r.type==="hyperlink"){let a=v(r),o=e,i=e+a.length;if(t>=o&&t<i)return true;e=i;}return false}function ht(n,t,e){let r=[];return n.length>0&&(r.push({id:"rewrite",label:"Rewrite",description:"Rewrite this text",priority:10},{id:"summarize",label:"Summarize",description:"Summarize this text",priority:9}),n.length>200&&r.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:8}),n.length<50&&n.split(/\s+/).length<10&&r.push({id:"expand",label:"Expand",description:"Add more details",priority:8}),r.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7}),r.push({id:"translate",label:"Translate",description:"Translate to another language",priority:6}),r.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:5},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:4})),r.sort((a,o)=>(o.priority||0)-(a.priority||0)),r}function xt(n,t,e={}){let{contextCharsBefore:r=200,contextCharsAfter:a=200,includeSuggestions:o=true}=e,i=n.package.document,s=i.content.filter(f=>f.type==="paragraph");if(t.start.paragraphIndex>=s.length)throw new Error(`Invalid start paragraph index: ${t.start.paragraphIndex}`);let c=s[t.start.paragraphIndex],u=bt(s,t),l=yt(s,t.start,r),x=Ct(s,t.end,a),d=Pt(c,t.start.offset),b=c.formatting||{},p={index:t.start.paragraphIndex,fullText:h(c),style:c.formatting?.styleId,wordCount:O(h(c))},y=Tt(i,t.start),F=St(c,t.start.offset),_=o?At(u):[];return {selectedText:u,range:t,formatting:d,paragraphFormatting:b,textBefore:l,textAfter:x,paragraph:p,inTable:y,inHyperlink:F,suggestedActions:_}}function xe(n,t,e={}){let r=xt(n,t,e),{includeDocumentSummary:a=true}=e,i=n.package.document.content.filter(p=>p.type==="paragraph"),s=O(r.selectedText),c=r.selectedText.length,u=t.start.paragraphIndex!==t.end.paragraphIndex,l=[];for(let p=t.start.paragraphIndex;p<=t.end.paragraphIndex;p++)l.push(p);let x=kt(i,t),d=a?Y(n):void 0,b=Ft(r.selectedText);return {...r,documentSummary:d,wordCount:s,characterCount:c,isMultiParagraph:u,paragraphIndices:l,detectedLanguage:b,contentType:x}}function be(n,t){let r=n.package.document.content.filter(s=>s.type==="paragraph"),a=[];for(let s=t.start.paragraphIndex;s<=t.end.paragraphIndex;s++){let c=r[s];if(!c)continue;let u=s===t.start.paragraphIndex?t.start.offset:0,l=s===t.end.paragraphIndex?t.end.offset:1/0;It(c,u,l,a);}let o=a.length<=1||a.every(s=>_t(s,a[0]));return {predominant:a.length>0?a[0]:{},isConsistent:o,allFormatting:a}}function bt(n,t){if(t.start.paragraphIndex===t.end.paragraphIndex){let r=n[t.start.paragraphIndex];return r?h(r).slice(t.start.offset,t.end.offset):""}let e=[];for(let r=t.start.paragraphIndex;r<=t.end.paragraphIndex;r++){let a=n[r];if(!a)continue;let o=h(a);r===t.start.paragraphIndex?e.push(o.slice(t.start.offset)):r===t.end.paragraphIndex?e.push(o.slice(0,t.end.offset)):e.push(o);}return e.join(`
|
|
7
|
-
`)}function yt(n,t,e){let r=[],a=0,o=n[t.paragraphIndex];if(o){let c=h(o).slice(0,t.offset);r.unshift(c),a+=c.length;}for(let s=t.paragraphIndex-1;s>=0&&a<e;s--){let c=n[s];if(!c)continue;let u=h(c);r.unshift(u),a+=u.length;}let i=r.join(`
|
|
8
|
-
`);return i.length>e?"..."+i.slice(-e):i}function Ct(n,t,e){let r=[],a=0,o=n[t.paragraphIndex];if(o){let c=h(o).slice(t.offset);r.push(c),a+=c.length;}for(let s=t.paragraphIndex+1;s<n.length&&a<e;s++){let c=n[s];if(!c)continue;let u=h(c);r.push(u),a+=u.length;}let i=r.join(`
|
|
9
|
-
`);return i.length>e?i.slice(0,e)+"...":i}function Pt(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=I(r),o=e+a.length;if(t>=e&&t<o)return r.formatting||{};e=o;}else if(r.type==="hyperlink"){let a=k(r),o=e+a.length;if(t>=e&&t<o){for(let i of r.children)if(i.type==="run")return i.formatting||{}}e=o;}return {}}function It(n,t,e,r){let a=0;for(let o of n.content)if(o.type==="run"){let i=I(o),s=a,c=a+i.length;c>t&&s<e&&o.formatting&&r.push({...o.formatting}),a=c;}else if(o.type==="hyperlink"){let i=k(o),s=a,c=a+i.length;if(c>t&&s<e)for(let u of o.children)u.type==="run"&&u.formatting&&r.push({...u.formatting});a=c;}}function Tt(n,t){return false}function St(n,t){let e=0;for(let r of n.content)if(r.type==="run"){let a=I(r);e+=a.length;}else if(r.type==="hyperlink"){let a=k(r),o=e,i=e+a.length;if(t>=o&&t<i)return true;e=i;}return false}function At(n,t,e){let r=[];if(!n||n.trim().length===0)return r;r.push({id:"askAI",label:"Ask AI",description:"Ask AI about this text",priority:11},{id:"rewrite",label:"Rewrite",description:"Rewrite this text differently",priority:10});let a=O(n);return a>50&&r.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:9}),a<20&&r.push({id:"expand",label:"Expand",description:"Add more details",priority:9}),r.push({id:"fixGrammar",label:"Fix Grammar",description:"Fix grammar and spelling",priority:7},{id:"translate",label:"Translate",description:"Translate to another language",priority:6},{id:"explain",label:"Explain",description:"Explain what this means",priority:5}),r.push({id:"makeFormal",label:"Make Formal",description:"Use formal tone",priority:4},{id:"makeCasual",label:"Make Casual",description:"Use casual tone",priority:3}),r.sort((o,i)=>(i.priority||0)-(o.priority||0)),r}function kt(n,t){let e=new Set;for(let r=t.start.paragraphIndex;r<=t.end.paragraphIndex;r++){let a=n[r];a&&(a.listRendering?e.add("list"):a.formatting?.styleId?.toLowerCase().includes("heading")?e.add("heading"):e.add("prose"));}return e.size>1?"mixed":e.has("list")?"list":e.has("heading")?"heading":"prose"}function Ft(n){return /[а-яА-ЯёЁ]/.test(n)?"ru":/[一-龯]/.test(n)?"zh":/[ひらがなカタカナ]/.test(n)||/[\u3040-\u309F\u30A0-\u30FF]/.test(n)?"ja":/[가-힣]/.test(n)?"ko":/[àâäéèêëïîôùûüç]/i.test(n)?"fr":/[äöüß]/i.test(n)?"de":/[áéíóúñ]/i.test(n)?"es":"en"}function h(n){let t=[];for(let e of n.content)e.type==="run"?t.push(I(e)):e.type==="hyperlink"&&t.push(k(e));return t.join("")}function I(n){return n.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function k(n){let t=[];for(let e of n.children)e.type==="run"&&t.push(I(e));return t.join("")}function O(n){return n.split(/\s+/).filter(t=>t.length>0).length}function _t(n,t){let e=Object.keys(n),r=Object.keys(t);return e.length!==r.length?false:e.every(a=>{let o=n[a],i=t[a];return o===i})}function Rt(){return [{styleId:"Normal",type:"paragraph",name:"Normal",default:true,qFormat:true,uiPriority:0,rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},{styleId:"Title",type:"paragraph",name:"Title",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:10,rPr:{fontSize:52,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Subtitle",type:"paragraph",name:"Subtitle",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:11,rPr:{fontSize:30,color:{rgb:"666666"},fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:240}},{styleId:"Heading1",type:"paragraph",name:"Heading 1",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:40,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:400,spaceAfter:120,lineSpacing:240}},{styleId:"Heading2",type:"paragraph",name:"Heading 2",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:32,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:360,spaceAfter:80,lineSpacing:240}},{styleId:"Heading3",type:"paragraph",name:"Heading 3",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:28,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:320,spaceAfter:80,lineSpacing:240}},{styleId:"Heading4",type:"paragraph",name:"Heading 4",basedOn:"Normal",next:"Normal",qFormat:true,uiPriority:9,rPr:{fontSize:24,bold:true,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{spaceBefore:280,spaceAfter:80,lineSpacing:240}}]}function Ht(){return {pageWidth:12240,pageHeight:15840,orientation:"portrait",marginTop:1440,marginBottom:1440,marginLeft:1440,marginRight:1440,headerDistance:720,footerDistance:720,gutter:0,columnCount:1,columnSpace:720,equalWidth:true,sectionStart:"nextPage",verticalAlign:"top"}}function Dt(n={}){let t=Ht();n.pageWidth!==void 0&&(t.pageWidth=n.pageWidth),n.pageHeight!==void 0&&(t.pageHeight=n.pageHeight),n.orientation!==void 0&&(t.orientation=n.orientation),n.marginTop!==void 0&&(t.marginTop=n.marginTop),n.marginBottom!==void 0&&(t.marginBottom=n.marginBottom),n.marginLeft!==void 0&&(t.marginLeft=n.marginLeft),n.marginRight!==void 0&&(t.marginRight=n.marginRight);let e={type:"text",text:n.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:n.initialText?[e]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:t},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:Rt()}},templateVariables:[],warnings:[]}}function Ce(n,t={}){return Dt({...t,initialText:n})}function Ie(n){return {start:n,end:n,collapsed:true}}function Te(n,t){return {start:n,end:t,collapsed:n.paragraphIndex===t.paragraphIndex&&n.offset===t.offset}}function Se(n,t){return !(n.paragraphIndex<t.start.paragraphIndex||n.paragraphIndex===t.start.paragraphIndex&&n.offset<t.start.offset||n.paragraphIndex>t.end.paragraphIndex||n.paragraphIndex===t.end.paragraphIndex&&n.offset>t.end.offset)}function Ae(n,t){return n.paragraphIndex<t.paragraphIndex?-1:n.paragraphIndex>t.paragraphIndex?1:n.offset<t.offset?-1:n.offset>t.offset?1:0}function ke(n){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"}[n]}function Fe(n){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"}[n]}var _e=["askAI","rewrite","expand","summarize","translate","explain"];function Re(n){return {...n,id:wt()}}function wt(){return `cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}export{le as A,tt as B,de as C,Y as D,xt as E,xe as F,be as G,Dt as H,Ce as I,Ie as J,Te as K,Se as L,Ae as M,ke as N,Fe as O,_e as P,Re as Q,g as a,Et as b,Bt as c,vt as d,Ot as e,Nt as f,Vt as g,Lt as h,Mt as i,jt as j,zt as k,Wt as l,$t as m,Gt as n,qt as o,Xt as p,Kt as q,Yt as r,Jt as s,Qt as t,Zt as u,te as v,ee as w,ne as x,S as y,ue as z};
|