@eigenpal/docx-js-editor 0.0.3 → 0.0.5

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.
Files changed (49) hide show
  1. package/README.md +69 -132
  2. package/dist/chunk-2CFVFSUH.js +57 -0
  3. package/dist/{chunk-YJJ7HRPG.js → chunk-AOL255XD.js} +1 -1
  4. package/dist/chunk-BBGDBZJY.cjs +1 -0
  5. package/dist/{chunk-CM5WP7HZ.cjs → chunk-D2GERZ7M.cjs} +2 -2
  6. package/dist/chunk-DQHQWQHL.cjs +11 -0
  7. package/dist/chunk-FXILBPZI.cjs +9 -0
  8. package/dist/chunk-H2UMX5CK.js +9 -0
  9. package/dist/chunk-HGOIKOKZ.js +1 -0
  10. package/dist/chunk-I2C6ENCR.js +11 -0
  11. package/dist/chunk-TL3YTVN2.cjs +57 -0
  12. package/dist/{colorResolver-Yakhydrt.d.ts → colorResolver-DrNkos_H.d.ts} +1 -32
  13. package/dist/{colorResolver-C-tITrbI.d.cts → colorResolver-WsUxFs5p.d.cts} +1 -32
  14. package/dist/core-plugins.cjs +1 -1
  15. package/dist/core-plugins.d.cts +3 -3
  16. package/dist/core-plugins.d.ts +3 -3
  17. package/dist/core-plugins.js +1 -1
  18. package/dist/headless.cjs +2 -2
  19. package/dist/headless.d.cts +4 -4
  20. package/dist/headless.d.ts +4 -4
  21. package/dist/headless.js +1 -1
  22. package/dist/index.cjs +43 -43
  23. package/dist/index.css +1 -1
  24. package/dist/index.d.cts +174 -363
  25. package/dist/index.d.ts +174 -363
  26. package/dist/index.js +43 -43
  27. package/dist/mcp-cli.js +21 -21
  28. package/dist/mcp.cjs +3 -3
  29. package/dist/mcp.d.cts +1 -1
  30. package/dist/mcp.d.ts +1 -1
  31. package/dist/mcp.js +1 -1
  32. package/dist/{registry-DeeU0bQB.d.cts → registry-BWDZlJx6.d.cts} +1 -1
  33. package/dist/{registry-D3zhko7n.d.ts → registry-DifIQR1O.d.ts} +1 -1
  34. package/dist/selectionRects-M7QY6HKR.cjs +1 -0
  35. package/dist/selectionRects-O6YQMMCP.js +1 -0
  36. package/dist/styles.css +1 -1
  37. package/dist/{types-BJXChtaM.d.cts → types-XVRXTi4o.d.cts} +509 -336
  38. package/dist/{types-BJXChtaM.d.ts → types-XVRXTi4o.d.ts} +509 -336
  39. package/package.json +10 -10
  40. package/dist/chunk-7KNRIGGW.cjs +0 -1
  41. package/dist/chunk-CDT2SOKB.cjs +0 -9
  42. package/dist/chunk-EU5LN2WS.js +0 -11
  43. package/dist/chunk-G4AXMTQY.cjs +0 -11
  44. package/dist/chunk-HRPNPUU4.js +0 -1
  45. package/dist/chunk-NI5OFVY2.js +0 -57
  46. package/dist/chunk-RGYAPHXT.cjs +0 -57
  47. package/dist/chunk-T3I3VSJ3.js +0 -9
  48. package/dist/selectionRects-3PJ6FGHQ.js +0 -1
  49. package/dist/selectionRects-6QL5E7CE.cjs +0 -1
@@ -1,9 +0,0 @@
1
- import {a,n}from'./chunk-YJJ7HRPG.js';import {d,e as e$1}from'./chunk-NI5OFVY2.js';import {l}from'./chunk-EU5LN2WS.js';import {b,a as a$1}from'./chunk-AQ35GWDV.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"},Y={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 U(n){if(!n)return 1;let e=parseInt(n,16);return isNaN(e)?1:e/255}function C(n){let e=n.padStart(6,"0").slice(0,6),t=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),o=parseInt(e.slice(4,6),16);return {r:isNaN(t)?0:t,g:isNaN(r)?0:r,b:isNaN(o)?0:o}}function D(n,e,t){let r=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return `${r(n)}${r(e)}${r(t)}`.toUpperCase()}function $(n,e,t){n/=255,e/=255,t/=255;let r=Math.max(n,e,t),o=Math.min(n,e,t),a=(r+o)/2;if(r===o)return {h:0,s:0,l:a};let i=r-o,s=a>.5?i/(2-r-o):i/(r+o),u;switch(r){case n:u=((e-t)/i+(e<t?6:0))/6;break;case e:u=((t-n)/i+2)/6;break;case t:u=((n-e)/i+4)/6;break;default:u=0;}return {h:u*360,s,l:a}}function G(n,e,t){if(n=n/360,e===0){let i=Math.round(t*255);return {r:i,g:i,b:i}}let r=(i,s,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<1/6?i+(s-i)*6*u:u<1/2?s:u<2/3?i+(s-i)*(2/3-u)*6:i),o=t<.5?t*(1+e):t+e-t*e,a=2*t-o;return {r:Math.round(r(a,o,n+1/3)*255),g:Math.round(r(a,o,n)*255),b:Math.round(r(a,o,n-1/3)*255)}}function q(n,e){if(e<=0||e>=1)return e>=1?"FFFFFF":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l+(1-r.l)*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function X(n,e){if(e<=0||e>=1)return e<=0?"000000":n;let t=C(n),r=$(t.r,t.g,t.b);r.l=r.l*e;let o=G(r.h,r.s,r.l);return D(o.r,o.g,o.b)}function J(n,e){let t=w[e]??e,r=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],o=a=>r.includes(a);return n?.colorScheme?o(t)?n.colorScheme[t]??W[t]??"000000":"000000":o(t)?W[t]??"000000":"000000"}function K(n){if(!n)return null;let e=n.toLowerCase();return w[n]??w[e]??null}function g(n,e,t="000000"){if(!n)return `#${t}`;if(n.auto)return `#${t}`;let r;if(n.themeColor){let o=K(n.themeColor);if(o?r=J(e,o):r=n.rgb??t,n.themeTint){let a=U(n.themeTint);r=q(r,a);}else if(n.themeShade){let a=U(n.themeShade);r=X(r,a);}}else n.rgb?r=n.rgb:r=t;return `#${r.toUpperCase().replace(/^#/,"")}`}function De(n){if(!n||n==="none")return "";let e=Y[n];return e?`#${e}`:""}function Be(n,e){return n?n.auto?"transparent":g(n,e):""}function ve(n,e){if(!n)return false;if(n.auto)return true;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3<20}function Oe(n,e){if(!n)return false;let r=g(n,e).replace(/^#/,"").toLowerCase(),o=C(r);return (o.r+o.g+o.b)/3>235}function Ne(n,e){if(!n)return "#000000";let r=g(n,e).replace(/^#/,""),o=C(r);return (.299*o.r+.587*o.g+.114*o.b)/255>.5?"#000000":"#FFFFFF"}function Le(n){if(!n)return;let e=n.trim();if(e.toLowerCase()==="auto")return {auto:true};let t=K(e);if(t)return {themeColor:t};let r=e.replace(/^#/,"").toUpperCase();return /^[0-9A-F]{6}$/i.test(r)?{rgb:r}:/^[0-9A-F]{3}$/i.test(r)?{rgb:r.split("").map(a=>a+a).join("")}:{rgb:r.padStart(6,"0").slice(0,6)}}function Me(n,e,t){let r={themeColor:n};return e!==void 0&&e>0&&e<1&&(r.themeTint=Math.round(e*255).toString(16).toUpperCase().padStart(2,"0")),t!==void 0&&t>0&&t<1&&(r.themeShade=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")),r}function Ve(n){return {rgb:n.replace(/^#/,"").toUpperCase()}}function ze(n,e,t){let o=g(n,e).replace(/^#/,""),a=1-t/100;return `#${X(o,a)}`}function je(n,e,t){let o=g(n,e).replace(/^#/,""),a=t/100;return `#${q(o,a)}`}function We(n,e,t,r){let o=g(n,r).replace(/^#/,""),a=g(e,r).replace(/^#/,""),i=C(o),s=C(a),u={r:Math.round(i.r*(1-t)+s.r*t),g:Math.round(i.g*(1-t)+s.g*t),b:Math.round(i.b*(1-t)+s.b*t)};return `#${D(u.r,u.g,u.b)}`}function Ue(n,e,t){if(!n&&!e)return true;if(!n||!e)return false;let r=g(n,t).toUpperCase(),o=g(e,t).toUpperCase();return r===o}function Ge(n){return n/1440*96}function qe(n){return n/96*1440}function Xe(n){return n/914400*96}function Ke(n){return n/96*914400}function Ze(n){return n/914400*1440}function Ye(n){return n/1440*914400}function Je(n){return n/72*96}function Qe(n){return n/144*96}function et(n){return n/2}function tt(n){return n/576*96}function Q(n,e=2){let t=Math.pow(10,e);return Math.round(n*t)/t}function nt(n){return `${Q(n)}px`}var S=class n$1{constructor(e$1){e(this,"_document");e(this,"_pendingVariables");e$1 instanceof ArrayBuffer||ArrayBuffer.isView(e$1)?this._document={package:{document:{content:[]}},originalBuffer:e$1 instanceof ArrayBuffer?e$1:e$1.buffer}:this._document=e$1,this._pendingVariables={};}static async fromBuffer(e){let t=await l(e);return new n$1(t)}static fromDocument(e){return new n$1(e)}getDocument(){return this._document}getText(){let e=this._document.package.document;return this._getBodyText(e)}getFormattedText(){let e=[],t=this._document.package.document;for(let r of t.content)r.type==="paragraph"&&this._extractParagraphSegments(r,e);return e}getVariables(){return a(this._document)}getStyles(){let e=this._document.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}getPageCount(){let e=this.getWordCount();return Math.max(1,Math.ceil(e/500))}getWordCount(){return this.getText().split(/\s+/).filter(r=>r.length>0).length}getCharacterCount(e=true){let t=this.getText();return e?t.length:t.replace(/\s/g,"").length}getParagraphCount(){return this._document.package.document.content.filter(e=>e.type==="paragraph").length}getTableCount(){return this._document.package.document.content.filter(e=>e.type==="table").length}getAgentContext(e=100){let t=this._document.package.document,r=t.content.filter(i=>i.type==="paragraph"),o=r.map((i,s)=>{let u=this._getParagraphText(i),c=i.formatting?.styleId;return {index:s,preview:u.slice(0,e),style:c,isHeading:c?.toLowerCase().includes("heading")||false,headingLevel:this._parseHeadingLevel(c),isListItem:!!i.listRendering,isEmpty:u.trim().length===0}}),a=(t.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:o,sections:a,hasTables:this.getTableCount()>0,hasImages:this._hasImages(),hasHyperlinks:this._hasHyperlinks()}}insertText(e,t,r={}){let o={type:"insertText",position:e,text:t,formatting:r.formatting};return this._executeCommand(o)}replaceRange(e,t,r={}){let o={type:"replaceText",range:e,text:t,formatting:r.formatting};return this._executeCommand(o)}deleteRange(e){let t={type:"deleteText",range:e};return this._executeCommand(t)}applyFormatting(e,t){let r={type:"formatText",range:e,formatting:t};return this._executeCommand(r)}applyStyle(e,t){let r={type:"applyStyle",paragraphIndex:e,styleId:t};return this._executeCommand(r)}applyParagraphFormatting(e,t){let r={type:"formatParagraph",paragraphIndex:e,formatting:t};return this._executeCommand(r)}insertTable(e,t,r,o={}){let a={type:"insertTable",position:e,rows:t,columns:r,data:o.data,hasHeader:o.hasHeader};return this._executeCommand(a)}insertImage(e,t,r={}){let o={type:"insertImage",position:e,src:t,width:r.width,height:r.height,alt:r.alt};return this._executeCommand(o)}insertHyperlink(e,t,r={}){let o={type:"insertHyperlink",range:e,url:t,displayText:r.displayText,tooltip:r.tooltip};return this._executeCommand(o)}removeHyperlink(e){let t={type:"removeHyperlink",range:e};return this._executeCommand(t)}insertParagraphBreak(e){let t={type:"insertParagraphBreak",position:e};return this._executeCommand(t)}mergeParagraphs(e,t){let r={type:"mergeParagraphs",paragraphIndex:e,count:t};return this._executeCommand(r)}setVariable(e,t){return this._pendingVariables[e]=t,this}setVariables(e){for(let[t,r]of Object.entries(e))this._pendingVariables[t]=r;return this}getPendingVariables(){return {...this._pendingVariables}}clearPendingVariables(){return this._pendingVariables={},this}async applyVariables(e){let t={...this._pendingVariables,...e};if(Object.keys(t).length===0)return this;let r=this._document.originalBuffer;if(!r)throw new Error("Cannot apply variables: no original buffer for processing");let o=n(r,t),a=await l(o),i=new n$1(a);return i._pendingVariables={},i}async toBuffer(){return this._document.originalBuffer?d(this._document):e$1(this._document)}async toBlob(e="application/vnd.openxmlformats-officedocument.wordprocessingml.document"){let t=await this.toBuffer();return new Blob([t],{type:e})}executeCommands(e){let t=b(this._document,e);return new n$1(t)}_executeCommand(e){let t=a$1(this._document,e),r=new n$1(t);return r._pendingVariables={...this._pendingVariables},r}_getBodyText(e){let t=[];for(let r of e.content)r.type==="paragraph"?t.push(this._getParagraphText(r)):r.type==="table"&&t.push(this._getTableText(r));return t.join(`
2
- `)}_getParagraphText(e){let t=[];for(let r of e.content)r.type==="run"?t.push(this._getRunText(r)):r.type==="hyperlink"&&t.push(this._getHyperlinkText(r));return t.join("")}_getRunText(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}_getHyperlinkText(e){let t=[];for(let r of e.children)r.type==="run"&&t.push(this._getRunText(r));return t.join("")}_getTableText(e){let t=[];for(let r of e.rows)for(let o of r.cells)for(let a of o.content)a.type==="paragraph"&&t.push(this._getParagraphText(a));return t.join(" ")}_extractParagraphSegments(e,t){for(let r of e.content)if(r.type==="run"){let o=this._getRunText(r);o&&t.push({text:o,formatting:r.formatting});}else if(r.type==="hyperlink"){let o=r.href||"";for(let a of r.children)if(a.type==="run"){let i=this._getRunText(a);i&&t.push({text:i,formatting:a.formatting,isHyperlink:true,hyperlinkUrl:o});}}}_parseHeadingLevel(e){if(!e)return;let t=e.match(/heading\s*(\d)/i);if(t)return parseInt(t[1],10)}_hasImages(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="run"){for(let o of r.content)if(o.type==="drawing")return true}}return false}_hasHyperlinks(){let e=this._document.package.document;for(let t of e.content)if(t.type==="paragraph"){for(let r of t.content)if(r.type==="hyperlink")return true}return false}};async function ct(n){return S.fromBuffer(n)}function pt(n){return S.fromDocument(n)}function ee(n,e={}){let{outlineMaxChars:t=100,maxOutlineParagraphs:r=50}=e,o=n.package.document,a$1=o.content.filter(y=>y.type==="paragraph"),i=te(a$1,t,r),s=a(n),u=ne(n),c=re(o),p=oe(o),x=ae(o),d=o.content.some(y=>y.type==="table"),b=ue(o),l=ce(o);return {paragraphCount:a$1.length,wordCount:p,characterCount:x,variables:s,variableCount:s.length,availableStyles:u,outline:i,sections:c,hasTables:d,hasImages:b,hasHyperlinks:l}}function dt(n,e,t={}){let{contextChars:r=200,includeSuggestions:o=true}=t,i=n.package.document.content.filter(f=>f.type==="paragraph"),s=i[e.start.paragraphIndex];if(!s)throw new Error(`Paragraph not found at index ${e.start.paragraphIndex}`);let u=m(s),c="";if(e.start.paragraphIndex===e.end.paragraphIndex)c=u.slice(e.start.offset,e.end.offset);else {let f=[];for(let P=e.start.paragraphIndex;P<=e.end.paragraphIndex;P++){let N=i[P];if(!N)continue;let R=m(N);P===e.start.paragraphIndex?f.push(R.slice(e.start.offset)):P===e.end.paragraphIndex?f.push(R.slice(0,e.end.offset)):f.push(R);}c=f.join(`
3
- `);}let p=me(i,e.start.paragraphIndex,e.start.offset,r),x=ge(i,e.end.paragraphIndex,e.end.offset,r),d=de(s,e.start.offset),b=s.formatting||{},l={index:e.start.paragraphIndex,fullText:u,style:s.formatting?.styleId,wordCount:B(u)},y=false,_=fe(s,e.start.offset),F=o?he(c):[];return {selectedText:c,range:e,formatting:d,paragraphFormatting:b,textBefore:p,textAfter:x,paragraph:l,inTable:y,inHyperlink:_,suggestedActions:F}}function Z(n){let e=ee(n,{outlineMaxChars:50,maxOutlineParagraphs:10}),t=[`Document with ${e.paragraphCount} paragraphs, ${e.wordCount} words.`];e.hasTables&&t.push("Contains tables."),e.hasImages&&t.push("Contains images."),e.hasHyperlinks&&t.push("Contains hyperlinks."),e.variableCount>0&&t.push(`Has ${e.variableCount} template variables: ${e.variables.join(", ")}`);let r=e.outline.filter(o=>o.isHeading);if(r.length>0){t.push(`
4
- Headings:`);for(let o of r.slice(0,5)){let a=o.headingLevel||1;t.push(`${" ".repeat(a-1)}- ${o.preview}`);}r.length>5&&t.push(` ... and ${r.length-5} more headings`);}return t.join(" ")}function te(n,e,t){let r=[];for(let o=0;o<Math.min(n.length,t);o++){let a=n[o],i=m(a),s=a.formatting?.styleId;r.push({index:o,preview:i.slice(0,e),style:s,isHeading:pe(s),headingLevel:le(s),isListItem:!!a.listRendering,isEmpty:i.trim().length===0});}return r}function ne(n){let e=n.package.styles;if(!e?.styles)return [];let t=[];for(let[r,o]of Object.entries(e.styles))if(typeof o=="object"&&o!==null){let a=o;t.push({id:r,name:a.name||r,type:a.type==="numbering"?"paragraph":a.type||"paragraph",builtIn:a.default});}return t}function re(n){return n.sections?n.sections.map((e,t)=>({index:t,paragraphCount:e.content?.length||0,pageSize:e.properties?.pageWidth&&e.properties?.pageHeight?{width:e.properties.pageWidth,height:e.properties.pageHeight}:void 0,isLandscape:e.properties?.orientation==="landscape",hasHeader:!!e.properties?.headerReferences?.length,hasFooter:!!e.properties?.footerReferences?.length})):[]}function oe(n){let e=0;for(let t of n.content)if(t.type==="paragraph"){let r=m(t);e+=B(r);}else t.type==="table"&&(e+=ie(t));return e}function B(n){return n.split(/\s+/).filter(t=>t.length>0).length}function ae(n){let e=0;for(let t of n.content)if(t.type==="paragraph"){let r=m(t);e+=r.length;}else t.type==="table"&&(e+=se(t));return e}function ie(n){let e=0;for(let t of n.rows)for(let r of t.cells)for(let o of r.content)if(o.type==="paragraph"){let a=m(o);e+=B(a);}return e}function se(n){let e=0;for(let t of n.rows)for(let r of t.cells)for(let o of r.content)if(o.type==="paragraph"){let a=m(o);e+=a.length;}return e}function m(n){let e=[];for(let t of n.content)t.type==="run"?e.push(A(t)):t.type==="hyperlink"&&e.push(v(t));return e.join("")}function A(n){return n.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function v(n){let e=[];for(let t of n.children)t.type==="run"&&e.push(A(t));return e.join("")}function ue(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="run"){for(let r of t.content)if(r.type==="drawing")return true}}return false}function ce(n){for(let e of n.content)if(e.type==="paragraph"){for(let t of e.content)if(t.type==="hyperlink")return true}return false}function pe(n){return n?n.toLowerCase().includes("heading"):false}function le(n){if(!n)return;let e=n.match(/heading\s*(\d)/i);if(e)return parseInt(e[1],10)}function me(n,e,t,r){let o=[],a=0,i=n[e];if(i){let c=m(i).slice(0,t);o.unshift(c),a+=c.length;}for(let u=e-1;u>=0&&a<r;u--){let c=n[u];if(!c)continue;let p=m(c);o.unshift(p),a+=p.length;}let s=o.join(`
5
- `);return s.length>r?"..."+s.slice(-r):s}function ge(n,e,t,r){let o=[],a=0,i=n[e];if(i){let c=m(i).slice(t);o.push(c),a+=c.length;}for(let u=e+1;u<n.length&&a<r;u++){let c=n[u];if(!c)continue;let p=m(c);o.push(p),a+=p.length;}let s=o.join(`
6
- `);return s.length>r?s.slice(0,r)+"...":s}function de(n,e){let t=0;for(let r of n.content)if(r.type==="run"){let o=A(r),a=t,i=t+o.length;if(e>=a&&e<i)return r.formatting||{};t=i;}else if(r.type==="hyperlink"){let o=v(r),a=t,i=t+o.length;if(e>=a&&e<i){for(let s of r.children)if(s.type==="run")return s.formatting||{}}t=i;}return {}}function fe(n,e){let t=0;for(let r of n.content)if(r.type==="run"){let o=A(r);t+=o.length;}else if(r.type==="hyperlink"){let o=v(r),a=t,i=t+o.length;if(e>=a&&e<i)return true;t=i;}return false}function he(n,e,t){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((o,a)=>(a.priority||0)-(o.priority||0)),r}function xe(n,e,t={}){let{contextCharsBefore:r=200,contextCharsAfter:o=200,includeSuggestions:a=true}=t,i=n.package.document,s=i.content.filter(f=>f.type==="paragraph");if(e.start.paragraphIndex>=s.length)throw new Error(`Invalid start paragraph index: ${e.start.paragraphIndex}`);let u=s[e.start.paragraphIndex],c=be(s,e),p=ye(s,e.start,r),x=Ce(s,e.end,o),d=Pe(u,e.start.offset),b=u.formatting||{},l={index:e.start.paragraphIndex,fullText:h(u),style:u.formatting?.styleId,wordCount:O(h(u))},y=Ie(i,e.start),_=Se(u,e.start.offset),F=a?Ae(c):[];return {selectedText:c,range:e,formatting:d,paragraphFormatting:b,textBefore:p,textAfter:x,paragraph:l,inTable:y,inHyperlink:_,suggestedActions:F}}function xt(n,e,t={}){let r=xe(n,e,t),{includeDocumentSummary:o=true}=t,i=n.package.document.content.filter(l=>l.type==="paragraph"),s=O(r.selectedText),u=r.selectedText.length,c=e.start.paragraphIndex!==e.end.paragraphIndex,p=[];for(let l=e.start.paragraphIndex;l<=e.end.paragraphIndex;l++)p.push(l);let x=ke(i,e),d=o?Z(n):void 0,b=_e(r.selectedText);return {...r,documentSummary:d,wordCount:s,characterCount:u,isMultiParagraph:c,paragraphIndices:p,detectedLanguage:b,contentType:x}}function bt(n,e){let r=n.package.document.content.filter(s=>s.type==="paragraph"),o=[];for(let s=e.start.paragraphIndex;s<=e.end.paragraphIndex;s++){let u=r[s];if(!u)continue;let c=s===e.start.paragraphIndex?e.start.offset:0,p=s===e.end.paragraphIndex?e.end.offset:1/0;Te(u,c,p,o);}let a=o.length<=1||o.every(s=>Fe(s,o[0]));return {predominant:o.length>0?o[0]:{},isConsistent:a,allFormatting:o}}function be(n,e){if(e.start.paragraphIndex===e.end.paragraphIndex){let r=n[e.start.paragraphIndex];return r?h(r).slice(e.start.offset,e.end.offset):""}let t=[];for(let r=e.start.paragraphIndex;r<=e.end.paragraphIndex;r++){let o=n[r];if(!o)continue;let a=h(o);r===e.start.paragraphIndex?t.push(a.slice(e.start.offset)):r===e.end.paragraphIndex?t.push(a.slice(0,e.end.offset)):t.push(a);}return t.join(`
7
- `)}function ye(n,e,t){let r=[],o=0,a=n[e.paragraphIndex];if(a){let u=h(a).slice(0,e.offset);r.unshift(u),o+=u.length;}for(let s=e.paragraphIndex-1;s>=0&&o<t;s--){let u=n[s];if(!u)continue;let c=h(u);r.unshift(c),o+=c.length;}let i=r.join(`
8
- `);return i.length>t?"..."+i.slice(-t):i}function Ce(n,e,t){let r=[],o=0,a=n[e.paragraphIndex];if(a){let u=h(a).slice(e.offset);r.push(u),o+=u.length;}for(let s=e.paragraphIndex+1;s<n.length&&o<t;s++){let u=n[s];if(!u)continue;let c=h(u);r.push(c),o+=c.length;}let i=r.join(`
9
- `);return i.length>t?i.slice(0,t)+"...":i}function Pe(n,e){let t=0;for(let r of n.content)if(r.type==="run"){let o=T(r),a=t+o.length;if(e>=t&&e<a)return r.formatting||{};t=a;}else if(r.type==="hyperlink"){let o=k(r),a=t+o.length;if(e>=t&&e<a){for(let i of r.children)if(i.type==="run")return i.formatting||{}}t=a;}return {}}function Te(n,e,t,r){let o=0;for(let a of n.content)if(a.type==="run"){let i=T(a),s=o,u=o+i.length;u>e&&s<t&&a.formatting&&r.push({...a.formatting}),o=u;}else if(a.type==="hyperlink"){let i=k(a),s=o,u=o+i.length;if(u>e&&s<t)for(let c of a.children)c.type==="run"&&c.formatting&&r.push({...c.formatting});o=u;}}function Ie(n,e){return false}function Se(n,e){let t=0;for(let r of n.content)if(r.type==="run"){let o=T(r);t+=o.length;}else if(r.type==="hyperlink"){let o=k(r),a=t,i=t+o.length;if(e>=a&&e<i)return true;t=i;}return false}function Ae(n,e,t){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 o=O(n);return o>50&&r.push({id:"summarize",label:"Summarize",description:"Create a shorter version",priority:9}),o<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((a,i)=>(i.priority||0)-(a.priority||0)),r}function ke(n,e){let t=new Set;for(let r=e.start.paragraphIndex;r<=e.end.paragraphIndex;r++){let o=n[r];o&&(o.listRendering?t.add("list"):o.formatting?.styleId?.toLowerCase().includes("heading")?t.add("heading"):t.add("prose"));}return t.size>1?"mixed":t.has("list")?"list":t.has("heading")?"heading":"prose"}function _e(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 e=[];for(let t of n.content)t.type==="run"?e.push(T(t)):t.type==="hyperlink"&&e.push(k(t));return e.join("")}function T(n){return n.content.filter(e=>e.type==="text").map(e=>e.text).join("")}function k(n){let e=[];for(let t of n.children)t.type==="run"&&e.push(T(t));return e.join("")}function O(n){return n.split(/\s+/).filter(e=>e.length>0).length}function Fe(n,e){let t=Object.keys(n),r=Object.keys(e);return t.length!==r.length?false:t.every(o=>{let a=n[o],i=e[o];return a===i})}function Re(){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 He(){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 Ee(n={}){let e=He();n.pageWidth!==void 0&&(e.pageWidth=n.pageWidth),n.pageHeight!==void 0&&(e.pageHeight=n.pageHeight),n.orientation!==void 0&&(e.orientation=n.orientation),n.marginTop!==void 0&&(e.marginTop=n.marginTop),n.marginBottom!==void 0&&(e.marginBottom=n.marginBottom),n.marginLeft!==void 0&&(e.marginLeft=n.marginLeft),n.marginRight!==void 0&&(e.marginRight=n.marginRight);let t={type:"text",text:n.initialText||""};return {package:{document:{content:[{type:"paragraph",content:[{type:"run",content:n.initialText?[t]:[],formatting:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}}}],formatting:{lineSpacing:276}}],finalSectionProperties:e},styles:{docDefaults:{rPr:{fontSize:22,fontFamily:{ascii:"Arial",hAnsi:"Arial"}},pPr:{lineSpacing:276}},styles:Re()}},templateVariables:[],warnings:[]}}function Ct(n,e={}){return Ee({...e,initialText:n})}function Tt(n){return {start:n,end:n,collapsed:true}}function It(n,e){return {start:n,end:e,collapsed:n.paragraphIndex===e.paragraphIndex&&n.offset===e.offset}}function St(n,e){return !(n.paragraphIndex<e.start.paragraphIndex||n.paragraphIndex===e.start.paragraphIndex&&n.offset<e.start.offset||n.paragraphIndex>e.end.paragraphIndex||n.paragraphIndex===e.end.paragraphIndex&&n.offset>e.end.offset)}function At(n,e){return n.paragraphIndex<e.paragraphIndex?-1:n.paragraphIndex>e.paragraphIndex?1:n.offset<e.offset?-1:n.offset>e.offset?1:0}function kt(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 _t(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 Ft=["askAI","rewrite","expand","summarize","translate","explain"];function Rt(n){return {...n,id:we()}}function we(){return `cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}export{pt as A,ee as B,dt as C,Z as D,xe as E,xt as F,bt as G,Ee as H,Ct as I,Tt as J,It as K,St as L,At as M,kt as N,_t as O,Ft as P,Rt as Q,g as a,De as b,Be as c,ve as d,Oe as e,Ne as f,Le as g,Me as h,Ve as i,ze as j,je as k,We as l,Ue as m,Ge as n,qe as o,Xe as p,Ke as q,Ze as r,Ye as s,Je as t,Qe as u,et as v,tt as w,nt as x,S as y,ct as z};
@@ -1 +0,0 @@
1
- export{h as getCaretPosition,j as groupRectsByPage,i as isMultiPageSelection,g as selectionToRects}from'./chunk-HRPNPUU4.js';import'./chunk-3IYNTJO5.js';
@@ -1 +0,0 @@
1
- 'use strict';var chunk7KNRIGGW_cjs=require('./chunk-7KNRIGGW.cjs');require('./chunk-RTESADL3.cjs');Object.defineProperty(exports,"getCaretPosition",{enumerable:true,get:function(){return chunk7KNRIGGW_cjs.h}});Object.defineProperty(exports,"groupRectsByPage",{enumerable:true,get:function(){return chunk7KNRIGGW_cjs.j}});Object.defineProperty(exports,"isMultiPageSelection",{enumerable:true,get:function(){return chunk7KNRIGGW_cjs.i}});Object.defineProperty(exports,"selectionToRects",{enumerable:true,get:function(){return chunk7KNRIGGW_cjs.g}});