n8n-nodes-adeu 1.15.2 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,7 +54,7 @@ ${u}`,l++;else break}t.push([o,a]),r=l;}return t}h(ol,"_merge_footnote_sections"
54
54
  `)}h(cl,"format_ambiguity_error");function at(e){let t=e.nextSibling;for(;t;){if(t.nodeType===1)return t;t=t.nextSibling;}return null}h(at,"getNextElement");function kr(e){let t=e.previousSibling;for(;t;){if(t.nodeType===1)return t;t=t.previousSibling;}return null}h(kr,"getPreviousElement");function Pt(e,t){t.parentNode&&t.parentNode.insertBefore(e,t.nextSibling);}h(Pt,"insertAfter");var Pr=class extends Error{static{h(this,"BatchValidationError");}errors;constructor(e){super(`Batch validation failed:
55
55
  `+e.join(`
56
56
  `)),this.name="BatchValidationError",this.errors=e;}};function fl(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],a=n.target_text||"",i=n.new_text||"";if((i.includes("{++")||i.includes("{--")||i.includes("{>>")||i.includes("{=="))&&t.push(`- Edit ${r+1} Failed: Do not manually write CriticMarkup tags ({++, {--, {>>, {==) in \`new_text\`. The engine handles redlining automatically. To add a comment, use the \`comment\` parameter.`),a.includes("[^")||i.includes("[^")){let s=(a.match(/\[\^(?:fn|en)-[^\]]+\]/g)||[]).sort(),o=(i.match(/\[\^(?:fn|en)-[^\]]+\]/g)||[]).sort();JSON.stringify(s)!==JSON.stringify(o)&&(o.length>s.length||o.some(l=>o.filter(u=>u===l).length>s.filter(u=>u===l).length)?t.push(`- Edit ${r+1} Failed: Cannot insert footnote/endnote markers via text replace. Markers like \`[^fn-N]\` are read-only projections. Use Word's References menu.`):t.push(`- Edit ${r+1} Failed: Cannot delete footnote/endnote references via text replace. The marker corresponds to a structural XML element.`));}if(a.includes("](")||i.includes("](")){let s=(a.match(/\[(?!~)[^\]]+\]\([^)]+\)/g)||[]).sort(),o=(i.match(/\[(?!~)[^\]]+\]\([^)]+\)/g)||[]).sort();s.length!==o.length?o.length>s.length?t.push(`- Edit ${r+1} Failed: Cannot insert hyperlinks via text replace. Use a dedicated structural operation.`):t.push(`- Edit ${r+1} Failed: Cannot delete hyperlinks via text replace. The marker corresponds to a structural XML element.`):s.length>1&&JSON.stringify(s)!==JSON.stringify(o)&&t.push(`- Edit ${r+1} Failed: Can only edit or retarget one hyperlink per text replacement. Please split into multiple edits.`);}if(a.includes("[~")||i.includes("[~")){let s=a.match(/\[~[^~]+~\]\(#[^\)]+\)/g)||[],o=i.match(/\[~[^~]+~\]\(#[^\)]+\)/g)||[];s.length!==o.length?o.length>s.length?t.push(`- Edit ${r+1} Failed: Cannot insert cross-references via text replace. Markers are read-only projections.`):t.push(`- Edit ${r+1} Failed: Cannot delete cross-references via text replace. The marker corresponds to a structural XML element.`):JSON.stringify(s)!==JSON.stringify(o)&&t.push(`- Edit ${r+1} Failed: Modifying or retargeting cross-reference markers is disallowed to prevent dependency corruption.`);}if(a.includes("{#")||i.includes("{#")){let s=a.match(/\{#[^\}]+\}/g)||[],o=i.match(/\{#[^\}]+\}/g)||[];for(let l of o)if(o.filter(u=>u===l).length>s.filter(u=>u===l).length){t.push(`- Edit ${r+1} Failed: Cannot modify or insert internal anchor markers (\`{#...}\`). These represent structural XML bookmarks.`);break}}if(n.type==="modify"&&i){let s=i.split(/[\r\n]+/);for(let o of s){let l=o.trimStart();if(l.startsWith("#######")){let u=l.length-l.replace(/^#+/,"").length;if(l.substring(u).startsWith(" ")||l.substring(u)===""){t.push(`- Edit ${r+1} Failed: Heading level ${u} is not supported (maximum is 6).`);break}}}}(a.includes("READONLY_BOUNDARY_START")||i.includes("READONLY_BOUNDARY_START")||a.includes("# Document Structure (Read-Only)")||i.includes("# Document Structure (Read-Only)"))&&t.push(`- Edit ${r+1} Failed: Modification targets the read-only boundary (Structural Appendix). This section cannot be edited.`);}return t}h(fl,"validate_edit_strings");var Sn=class{static{h(this,"RedlineEngine");}doc;author;timestamp;current_id;mapper;comments_manager;clean_mapper=null;original_mapper=null;skipped_details=[];constructor(e,t="Adeu AI (TS)"){this.doc=e,this.author=t,this.timestamp=new Date().toISOString().replace(/\.\d{3}Z$/,"Z");let r="http://schemas.microsoft.com/office/word/2023/wordml/word16du";for(let n of this.doc.pkg.parts)(n===this.doc.part||n.contentType.includes("wordprocessingml")&&n.contentType.endsWith("+xml"))&&(n._element.hasAttribute("xmlns:w16du")||n._element.setAttribute("xmlns:w16du",r));this.current_id=this._scan_existing_ids(),this.mapper=new kt(this.doc),this.comments_manager=new ir(this.doc);}_check_punctuation_warning(e){return e&&(e.includes("_")||e.includes("-"))?`Warning: target_text '${e}' contains tokenization-splitting punctuation ('_' or '-'). This can trigger mid-word splits in the diff engine. Consider using a longer plain-prose anchor.`:null}_build_edit_context_previews(e){if(e.type!=="modify")return [null,null];e._resolved_proxy_edit&&(e=e._resolved_proxy_edit);let t=e._resolved_start_idx;if(t==null)return [null,null];let r=e.target_text||"",n=e.new_text||"",a=r.length,s=(e._active_mapper_ref||this.mapper).full_text;if(!s)return [null,null];let o=Math.max(0,t-30),l=s.substring(o,t),u=s.substring(t+a,t+a+30),f=n?`{++${n}++}`:"",c=`${l}{--${r}--}${f}${u}`,d=c;return d=d.replace(/\{>>.*?<<\}/gs,""),d=d.replace(/\{--.*?--\}/gs,""),d=d.replace(/\{\+\+(.*?)\+\+\}/gs,"$1"),[c,d]}_scan_existing_ids(){let e=0;for(let t of ["w:ins","w:del"]){let r=S(this.doc.element,t);for(let n of r){let a=parseInt(n.getAttribute("w:id")||"0",10);!isNaN(a)&&a>e&&(e=a);}}return e}_get_heading_path_and_page(e,t,r){let n=1;for(let l=0;l<r.length&&e>=r[l];l++)n=l+1;let i=t.substring(0,e).split(`
57
- `),s=[],o=999;for(let l=i.length-1;l>=0;l--){let f=i[l].match(/^(#{1,6})\s+(.*)/);if(f){let c=f[1].length;if(c<o){let d=f[2].replace(/\*\*|__|[*_]/g,"").replace(/\{#[^}]+\}/g,"").trim();if(d.length>80&&(d=d.substring(0,80)+"..."),s.unshift(d),o=c,c===1)break}}}return [s.join(" > "),n]}accept_all_revisions(){let e=[this.doc.element];for(let n of this.doc.pkg.parts)n!==this.doc.part&&n.contentType.includes("wordprocessingml")&&n.contentType.endsWith("+xml")&&e.push(n._element);for(let n of e){let a=S(n,"w:ins");for(let o of a){this._clean_wrapping_comments(o);let l=o.parentNode;if(l){if(l.tagName==="w:trPr"){l.removeChild(o);continue}for(;o.firstChild;)l.insertBefore(o.firstChild,o);l.removeChild(o);}}let i=S(n,"w:p");for(let o of i){let l=R(o,"w:pPr");if(l){let u=R(l,"w:rPr"),f=u?R(u,"w:del"):null;if(u&&f){let c=false;for(let d of ["w:t","w:tab","w:br"]){for(let p of S(o,d)){if(d==="w:t"&&!p.textContent)continue;let g=false,m=p.parentNode;for(;m&&m!==o;){if(m.tagName==="w:del"){g=true;break}m=m.parentNode;}if(!g){c=true;break}}if(c)break}c?u.removeChild(f):(this._clean_wrapping_comments(o),this._delete_comments_in_element(o),o.parentNode&&o.parentNode.removeChild(o));}}}let s=S(n,"w:del");for(let o of s){this._clean_wrapping_comments(o),this._delete_comments_in_element(o);let l=o.parentNode;if(l)if(l.tagName==="w:trPr"){let u=l.parentNode;u&&u.parentNode&&u.parentNode.removeChild(u);}else l.removeChild(o);}}for(let n of e){for(let i of ["w:commentRangeStart","w:commentRangeEnd"])for(let s of S(n,i))s.parentNode?.removeChild(s);let a=S(n,"w:commentReference");for(let i of a){let s=i.parentNode;s&&((s.tagName==="w:r"||s.tagName.endsWith(":r"))&&Array.from(s.childNodes).filter(l=>l.nodeType===1&&l.tagName!=="w:rPr"&&l.tagName!=="rPr").length<=1?s.parentNode?.removeChild(s):s.removeChild(i));}}let t=this.doc.pkg,r=new Set;for(let n of t.parts)if(n.partname.toLowerCase().includes("comments")){r.add(n.partname);let a=n.partname.startsWith("/")?n.partname:"/"+n.partname,i=n.partname.startsWith("/")?n.partname.substring(1):n.partname;r.add(a),r.add(i);}if(r.size>0){for(let a of t.parts)if(a.partname.endsWith(".rels")){let i=S(a._element,"Relationship"),s=[];for(let o of i)if((o.getAttribute("Target")||"").toLowerCase().includes("comments")){s.push(o);let u=a.partname.replace("/_rels/","/").replace(".rels",""),f=t.getPartByPath(u);if(f){let c=o.getAttribute("Id");c&&f.rels.delete(c);}}for(let o of s)o.parentNode?.removeChild(o);}let n=t.getPartByPath("[Content_Types].xml");if(n){let a=S(n._element,"Override"),i=[];for(let s of a){let o=s.getAttribute("PartName")||"";(r.has(o)||o.toLowerCase().includes("comments"))&&i.push(s);}for(let s of i)s.parentNode?.removeChild(s);}t.parts=t.parts.filter(a=>!a.partname.toLowerCase().includes("comments"));for(let a of Object.keys(t.unzipped))a.toLowerCase().includes("comments")&&delete t.unzipped[a];}}_getNextId(){return this.current_id++,this.current_id.toString()}_create_track_change_tag(e,t="",r=null){let a=this.doc.part._element.ownerDocument.createElement(e),i=r!==null?r:this._getNextId();return a.setAttribute("w:id",i),a.setAttribute("w:author",t||this.author),a.setAttribute("w:date",this.timestamp),a.setAttribute("w16du:dateUtc",this.timestamp),a}_set_text_content(e,t){e.textContent=t,t.trim()!==t&&e.setAttribute("xml:space","preserve");}_attach_comment(e,t,r,n){if(!n)return;let a=this.comments_manager.addComment(this.author,n),i=e.ownerDocument,s=i.createElement("w:commentRangeStart");s.setAttribute("w:id",a);let o=i.createElement("w:commentRangeEnd");o.setAttribute("w:id",a);let l=i.createElement("w:r"),u=i.createElement("w:rPr"),f=i.createElement("w:rStyle");f.setAttribute("w:val","CommentReference"),u.appendChild(f),l.appendChild(u);let c=i.createElement("w:commentReference");c.setAttribute("w:id",a),l.appendChild(c),e.insertBefore(s,t);let d=r.nextSibling;d?(e.insertBefore(o,d),e.insertBefore(l,o.nextSibling)):(e.appendChild(o),e.appendChild(l));}_attach_comment_spanning(e,t,r,n,a){if(!a)return;let i=this.comments_manager.addComment(this.author,a),s=e.ownerDocument,o=r.ownerDocument,l=s.createElement("w:commentRangeStart");l.setAttribute("w:id",i);let u=o.createElement("w:commentRangeEnd");u.setAttribute("w:id",i);let f=o.createElement("w:r"),c=o.createElement("w:rPr"),d=o.createElement("w:rStyle");d.setAttribute("w:val","CommentReference"),c.appendChild(d),f.appendChild(c);let p=o.createElement("w:commentReference");p.setAttribute("w:id",i),f.appendChild(p),e.insertBefore(l,t);let g=n.nextSibling;g?(r.insertBefore(u,g),r.insertBefore(f,u.nextSibling)):(r.appendChild(u),r.appendChild(f));}_track_insert_multiline(e,t,r,n){if(!e)return {first_node:null,last_p:null,last_ins:null,used_block_mode:false};let a=this.doc.part._element.ownerDocument,i=e.split(/[\r\n]+/),s=null;if(r!==null)s=r._element;else if(t!==null){let E=t._element;for(;E&&E.tagName!=="w:p";)E=E.parentNode;s=E;}for(;i.length>1&&i[i.length-1]==="";)i.pop();if(i.length===0)return {first_node:null,last_p:null,last_ins:null,used_block_mode:false};let[o,l]=this._parse_markdown_style(i[0]),f=l!==null&&s!==null,c=null,d=null;f||(d=this._build_tracked_ins_for_line((o===i[0],i[0]),t,n,a),c=d);let p=f?i:i.slice(1);if(p.length===0)return {first_node:c,last_p:null,last_ins:d,used_block_mode:false};if(!s)return {first_node:c,last_p:null,last_ins:d,used_block_mode:false};let g=s.parentNode;if(!g)return {first_node:c,last_p:null,last_ins:d,used_block_mode:false};let m=h((E,_)=>{g.insertBefore(E,_.nextSibling);},"insertAfterEl"),D=null,w=null,v=s;for(let E=0;E<p.length;E++){let _=p[E],[b,y]=this._parse_markdown_style(_),A=a.createElement("w:p");if(y)this._set_paragraph_style(A,y);else {let O=R(s,"w:pPr");O&&A.appendChild(O.cloneNode(true));}let N=R(A,"w:pPr");N||(N=a.createElement("w:pPr"),A.insertBefore(N,A.firstChild));let C=R(N,"w:rPr");C||(C=a.createElement("w:rPr"),N.appendChild(C));let M=this._create_track_change_tag("w:ins","",n);C.appendChild(M);let x=this._build_tracked_ins_for_line(b,t,n,a);x&&A.appendChild(x),m(A,v),v=A,D=A,w=x,c||(c=A);}return {first_node:c,last_p:D,last_ins:w,used_block_mode:f}}_build_tracked_ins_for_line(e,t,r,n){if(!e&&e!=="")return null;let a=this._create_track_change_tag("w:ins","",r),i=this._parse_inline_markdown(e);if(i.length===0)return null;for(let[s,o]of i){let l=n.createElement("w:r");if(t&&t._element){let f=R(t._element,"w:rPr");if(f){let c=f.cloneNode(true);for(let d of ["w:vanish","w:strike","w:dstrike","w:i","w:iCs","w:b","w:bCs"]){let p=R(c,d);p&&c.removeChild(p);}l.appendChild(c);}}this._apply_run_props(l,o,false);let u=n.createElement("w:t");this._set_text_content(u,s),l.appendChild(u),a.appendChild(l);}return a}_parse_markdown_style(e){let t=e.trimStart();if(t.startsWith("#")){let n=0,a=t;for(;a.startsWith("#");)n++,a=a.substring(1);if(a.startsWith(" "))return [a.trim(),`Heading ${n}`]}if(t.startsWith("* ")||t.startsWith("- "))return [t.substring(2).trim(),"List Paragraph"];let r=t.match(/^\d+\.\s+/);return r?[t.substring(r[0].length).trim(),"List Number"]:[e,null]}_parse_inline_markdown(e,t={}){if(!e)return [];let r=/(\*\*.*?\*\*)|(_.*?_)/,n=e.match(r);if(!n)return [[e,t]];let a=n.index,i=n[0],s=a+i.length,o=i.startsWith("**"),l=o?i.substring(2,i.length-2):i.substring(1,i.length-1),u=e.substring(0,a),f=e.substring(s),c=[];u&&c.push([u,t]);let d={...t};return o?d.bold=true:d.italic=true,c.push(...this._parse_inline_markdown(l,d)),c.push(...this._parse_inline_markdown(f,t)),c}_apply_run_props(e,t,r=false){if(!t){if(!r)return;t={};}let n=R(e,"w:rPr");if(!n&&(t.bold||t.italic||r)&&(n=e.ownerDocument.createElement("w:rPr"),e.appendChild(n)),n){let a=e.ownerDocument;if(t.bold){let i=R(n,"w:b");i||(i=a.createElement("w:b"),n.appendChild(i)),i.setAttribute("w:val","1");}else if(r){let i=R(n,"w:b");i&&n.removeChild(i);}if(t.italic){let i=R(n,"w:i");i||(i=a.createElement("w:i"),n.appendChild(i)),i.setAttribute("w:val","1");}else if(r){let i=R(n,"w:i");i&&n.removeChild(i);}}}_set_paragraph_style(e,t){let r=e.ownerDocument,n=R(e,"w:pPr");n&&e.removeChild(n);let a=r.createElement("w:pPr"),i=r.createElement("w:pStyle"),s=t.replace(/\s+/g,"");i.setAttribute("w:val",s),a.appendChild(i),e.insertBefore(a,e.firstChild);}_anchor_reply_comment(e,t){let r=this.doc.part._element.ownerDocument,n=S(this.doc.element,"w:commentRangeStart").filter(m=>m.getAttribute("w:id")===e);if(n.length===0)return;let a=n[0],i=r.createElement("w:commentRangeStart");i.setAttribute("w:id",t),Pt(i,a);let s=S(this.doc.element,"w:commentRangeEnd").filter(m=>m.getAttribute("w:id")===e);if(s.length===0)return;let o=s[0],l=S(this.doc.element,"w:commentReference").filter(m=>m.getAttribute("w:id")===e),u=o;if(l.length>0){let m=l[0];m.parentNode&&m.parentNode.tagName==="w:r"&&(u=m.parentNode);}let f=r.createElement("w:commentRangeEnd");f.setAttribute("w:id",t),Pt(f,u);let c=r.createElement("w:r"),d=r.createElement("w:rPr"),p=r.createElement("w:rStyle");p.setAttribute("w:val","CommentReference"),d.appendChild(p),c.appendChild(d);let g=r.createElement("w:commentReference");g.setAttribute("w:id",t),c.appendChild(g),Pt(c,f);}_clean_wrapping_comments(e){let t=e;for(;;){let l=kr(t);if(l&&(l.tagName==="w:ins"||l.tagName==="w:del"))t=l;else break}let r=e;for(;;){let l=at(r);if(l&&(l.tagName==="w:ins"||l.tagName==="w:del"))r=l;else break}let n=[],a=kr(t);for(;a;)if(a.tagName==="w:commentRangeStart")n.push(a),a=kr(a);else if(a.tagName==="w:rPr"||a.tagName==="w:pPr")a=kr(a);else break;let i=[],s=at(r);for(;s;)if(s.tagName==="w:commentRangeEnd")i.push(s),s=at(s);else if(s.tagName==="w:r"&&S(s,"w:commentReference").length>0)i.push(s),s=at(s);else if(s.tagName==="w:commentReference")i.push(s),s=at(s);else break;let o=new Set;for(let l of i)if(l.tagName==="w:commentRangeEnd"){let u=l.getAttribute("w:id");u&&o.add(u);}else {let u=S(l,"w:commentReference")[0];if(!u&&l.tagName==="w:commentReference"&&(u=l),u){let f=u.getAttribute("w:id");f&&o.add(f);}}for(let l of n){let u=l.getAttribute("w:id");if(u&&o.has(u)){this.comments_manager.deleteComment(u),l.parentNode&&l.parentNode.removeChild(l);for(let f of i){let c=null;if(f.tagName==="w:commentRangeEnd")c=f.getAttribute("w:id");else {let d=S(f,"w:commentReference")[0];!d&&f.tagName==="w:commentReference"&&(d=f),d&&(c=d.getAttribute("w:id"));}c===u&&f.parentNode&&f.parentNode.removeChild(f);}}}}_delete_comments_in_element(e){let t=S(e,"w:commentReference");for(let r of t){let n=r.getAttribute("w:id");if(n){this.comments_manager.deleteComment(n);for(let a of ["w:commentRangeStart","w:commentRangeEnd"]){let i=S(this.doc.element,a);for(let s of i)s.getAttribute("w:id")===n&&s.parentNode&&s.parentNode.removeChild(s);}}}}validate_edits(e){let t=[];this.mapper.full_text||this.mapper._build_map(),t.push(...fl(e));for(let r=0;r<e.length;r++){let n=e[r];if(!n.target_text)continue;let a=n.regex||false,i=n.match_mode||"strict",s=this.mapper.find_all_match_indices(n.target_text,a),o=this.mapper.full_text;this.mapper;s.length===0&&(this.clean_mapper||(this.clean_mapper=new kt(this.doc,true)),s=this.clean_mapper.find_all_match_indices(n.target_text,a),s.length>0&&(o=this.clean_mapper.full_text,this.clean_mapper)),o===this.mapper.full_text&&s.length>0&&(s=s.filter(([d,p])=>{let g=this.mapper.spans.filter(m=>m.run!==null&&m.end>d&&m.start<d+p);return g.length===0?true:g.some(m=>!m.del_id)}));let u=false,f=new Set;if(s.length===0){this.original_mapper||(this.original_mapper=new kt(this.doc,false,true));let c=this.original_mapper.find_all_match_indices(n.target_text,a);if(c.length>0){u=true;for(let[d,p]of c){let g=this.original_mapper.spans.filter(m=>m.end>d&&m.start<d+p);for(let m of g)if(m.run!==null){let D=m.run._element;for(;D;){if(D.nodeType===1&&D.tagName==="w:del"){let w=D.getAttribute("w:author");w&&f.add(w);break}D=D.parentNode;}}}}}if(s.length===0)if(u){let c=f.size>0?`by ${Array.from(f).sort().join(", ")}`:"by an existing revision";t.push(`- Edit ${r+1} Failed: Target text matches text inside a tracked deletion ${c}. Reject/accept that change first or target the active replacement text instead.`);}else t.push(`- Edit ${r+1} Failed: Target text not found in document:
57
+ `),s=[],o=999;for(let l=i.length-1;l>=0;l--){let f=i[l].match(/^(#{1,6})\s+(.*)/);if(f){let c=f[1].length;if(c<o){let d=f[2].replace(/\*\*|__|[*_]/g,"").replace(/\{#[^}]+\}/g,"").trim();if(d.length>80&&(d=d.substring(0,80)+"..."),s.unshift(d),o=c,c===1)break}}}return [s.join(" > "),n]}accept_all_revisions(){let e=[this.doc.element];for(let n of this.doc.pkg.parts)n!==this.doc.part&&n.contentType.includes("wordprocessingml")&&n.contentType.endsWith("+xml")&&e.push(n._element);for(let n of e){let a=S(n,"w:ins");for(let o of a){this._clean_wrapping_comments(o);let l=o.parentNode;if(l){if(l.tagName==="w:trPr"){l.removeChild(o);continue}for(;o.firstChild;)l.insertBefore(o.firstChild,o);l.removeChild(o);}}let i=S(n,"w:p");for(let o of i){let l=R(o,"w:pPr");if(l){let u=R(l,"w:rPr"),f=u?R(u,"w:del"):null;if(u&&f){let c=false;for(let d of ["w:t","w:tab","w:br"]){for(let p of S(o,d)){if(d==="w:t"&&!p.textContent)continue;let g=false,m=p.parentNode;for(;m&&m!==o;){if(m.tagName==="w:del"){g=true;break}m=m.parentNode;}if(!g){c=true;break}}if(c)break}c?u.removeChild(f):(this._clean_wrapping_comments(o),this._delete_comments_in_element(o),o.parentNode&&o.parentNode.removeChild(o));}}}let s=S(n,"w:del");for(let o of s){this._clean_wrapping_comments(o),this._delete_comments_in_element(o);let l=o.parentNode;if(l)if(l.tagName==="w:trPr"){let u=l.parentNode;u&&u.parentNode&&u.parentNode.removeChild(u);}else l.removeChild(o);}}for(let n of e){for(let i of ["w:commentRangeStart","w:commentRangeEnd"])for(let s of S(n,i))s.parentNode?.removeChild(s);let a=S(n,"w:commentReference");for(let i of a){let s=i.parentNode;s&&((s.tagName==="w:r"||s.tagName.endsWith(":r"))&&Array.from(s.childNodes).filter(l=>l.nodeType===1&&l.tagName!=="w:rPr"&&l.tagName!=="rPr").length<=1?s.parentNode?.removeChild(s):s.removeChild(i));}}let t=this.doc.pkg,r=new Set;for(let n of t.parts)if(n.partname.toLowerCase().includes("comments")){r.add(n.partname);let a=n.partname.startsWith("/")?n.partname:"/"+n.partname,i=n.partname.startsWith("/")?n.partname.substring(1):n.partname;r.add(a),r.add(i);}if(r.size>0){for(let a of t.parts)if(a.partname.endsWith(".rels")){let i=S(a._element,"Relationship"),s=[];for(let o of i)if((o.getAttribute("Target")||"").toLowerCase().includes("comments")){s.push(o);let u=a.partname.replace("/_rels/","/").replace(".rels",""),f=t.getPartByPath(u);if(f){let c=o.getAttribute("Id");c&&f.rels.delete(c);}}for(let o of s)o.parentNode?.removeChild(o);}let n=t.getPartByPath("[Content_Types].xml");if(n){let a=S(n._element,"Override"),i=[];for(let s of a){let o=s.getAttribute("PartName")||"";(r.has(o)||o.toLowerCase().includes("comments"))&&i.push(s);}for(let s of i)s.parentNode?.removeChild(s);}t.parts=t.parts.filter(a=>!a.partname.toLowerCase().includes("comments"));for(let a of Object.keys(t.unzipped))a.toLowerCase().includes("comments")&&delete t.unzipped[a];}}_getNextId(){return this.current_id++,this.current_id.toString()}_create_track_change_tag(e,t="",r=null){let a=this.doc.part._element.ownerDocument.createElement(e),i=r!==null?r:this._getNextId();return a.setAttribute("w:id",i),a.setAttribute("w:author",t||this.author),a.setAttribute("w:date",this.timestamp),a.setAttribute("w16du:dateUtc",this.timestamp),a}_set_text_content(e,t){e.textContent=t,t.trim()!==t&&e.setAttribute("xml:space","preserve");}_attach_comment(e,t,r,n){if(!n)return;let a=this.comments_manager.addComment(this.author,n),i=e.ownerDocument,s=i.createElement("w:commentRangeStart");s.setAttribute("w:id",a);let o=i.createElement("w:commentRangeEnd");o.setAttribute("w:id",a);let l=i.createElement("w:r"),u=i.createElement("w:rPr"),f=i.createElement("w:rStyle");f.setAttribute("w:val","CommentReference"),u.appendChild(f),l.appendChild(u);let c=i.createElement("w:commentReference");c.setAttribute("w:id",a),l.appendChild(c),e.insertBefore(s,t);let d=r.nextSibling;d?(e.insertBefore(o,d),e.insertBefore(l,o.nextSibling)):(e.appendChild(o),e.appendChild(l));}_attach_comment_spanning(e,t,r,n,a){if(!a)return;let i=this.comments_manager.addComment(this.author,a),s=e.ownerDocument,o=r.ownerDocument,l=s.createElement("w:commentRangeStart");l.setAttribute("w:id",i);let u=o.createElement("w:commentRangeEnd");u.setAttribute("w:id",i);let f=o.createElement("w:r"),c=o.createElement("w:rPr"),d=o.createElement("w:rStyle");d.setAttribute("w:val","CommentReference"),c.appendChild(d),f.appendChild(c);let p=o.createElement("w:commentReference");p.setAttribute("w:id",i),f.appendChild(p),e.insertBefore(l,t);let g=n.nextSibling;g?(r.insertBefore(u,g),r.insertBefore(f,u.nextSibling)):(r.appendChild(u),r.appendChild(f));}_track_insert_multiline(e,t,r,n){if(!e)return {first_node:null,last_p:null,last_ins:null,used_block_mode:false};let a=this.doc.part._element.ownerDocument,i=e.split(/[\r\n]+/),s=null;if(r!==null)s=r._element;else if(t!==null){let E=t._element;for(;E&&E.tagName!=="w:p";)E=E.parentNode;s=E;}for(;i.length>1&&i[i.length-1]==="";)i.pop();if(i.length===0)return {first_node:null,last_p:null,last_ins:null,used_block_mode:false};let[o,l]=this._parse_markdown_style(i[0]),f=l!==null&&s!==null,c=null,d=null;f||(d=this._build_tracked_ins_for_line((o===i[0],i[0]),t,n,a),c=d);let p=f?i:i.slice(1);if(p.length===0)return {first_node:c,last_p:null,last_ins:d,used_block_mode:false};if(!s)return {first_node:c,last_p:null,last_ins:d,used_block_mode:false};let g=s.parentNode;if(!g)return {first_node:c,last_p:null,last_ins:d,used_block_mode:false};let m=h((E,_)=>{g.insertBefore(E,_.nextSibling);},"insertAfterEl"),D=null,w=null,v=s;for(let E=0;E<p.length;E++){let _=p[E],[b,y]=this._parse_markdown_style(_),A=a.createElement("w:p");if(y)this._set_paragraph_style(A,y);else {let O=R(s,"w:pPr");O&&A.appendChild(O.cloneNode(true));}let N=R(A,"w:pPr");N||(N=a.createElement("w:pPr"),A.insertBefore(N,A.firstChild));let C=R(N,"w:rPr");C||(C=a.createElement("w:rPr"),N.appendChild(C));let M=this._create_track_change_tag("w:ins","",n);C.appendChild(M);let x=this._build_tracked_ins_for_line(b,t,n,a);x&&A.appendChild(x),m(A,v),v=A,D=A,w=x,c||(c=A);}return {first_node:c,last_p:D,last_ins:w,used_block_mode:f}}_build_tracked_ins_for_line(e,t,r,n){if(!e&&e!=="")return null;let a=this._create_track_change_tag("w:ins","",r),i=this._parse_inline_markdown(e);if(i.length===0)return null;for(let[s,o]of i){let l=n.createElement("w:r");if(t&&t._element){let f=R(t._element,"w:rPr");if(f){let c=f.cloneNode(true);for(let d of ["w:vanish","w:strike","w:dstrike","w:i","w:iCs","w:b","w:bCs"]){let p=R(c,d);p&&c.removeChild(p);}l.appendChild(c);}}this._apply_run_props(l,o,false);let u=n.createElement("w:t");this._set_text_content(u,s),l.appendChild(u),a.appendChild(l);}return a}_parse_markdown_style(e){let t=e.trimStart();if(t.startsWith("#")){let n=0,a=t;for(;a.startsWith("#");)n++,a=a.substring(1);if(a.startsWith(" "))return [a.trim(),`Heading ${n}`]}if(t.startsWith("* ")||t.startsWith("- "))return [t.substring(2).trim(),"List Paragraph"];let r=t.match(/^\d+\.\s+/);return r?[t.substring(r[0].length).trim(),"List Number"]:[e,null]}_parse_inline_markdown(e,t={}){if(!e)return [];let r=/(\*\*.*?\*\*)|(_.*?_)/,n=e.match(r);if(!n)return [[e,t]];let a=n.index,i=n[0],s=a+i.length,o=i.startsWith("**"),l=o?i.substring(2,i.length-2):i.substring(1,i.length-1),u=e.substring(0,a),f=e.substring(s),c=[];u&&c.push([u,t]);let d={...t};return o?d.bold=true:d.italic=true,c.push(...this._parse_inline_markdown(l,d)),c.push(...this._parse_inline_markdown(f,t)),c}_apply_run_props(e,t,r=false){if(!t){if(!r)return;t={};}let n=R(e,"w:rPr");if(!n&&(t.bold||t.italic||r)&&(n=e.ownerDocument.createElement("w:rPr"),e.appendChild(n)),n){let a=e.ownerDocument;if(t.bold){let i=R(n,"w:b");i||(i=a.createElement("w:b"),n.appendChild(i)),i.setAttribute("w:val","1");}else if(r){let i=R(n,"w:b");i&&n.removeChild(i);}if(t.italic){let i=R(n,"w:i");i||(i=a.createElement("w:i"),n.appendChild(i)),i.setAttribute("w:val","1");}else if(r){let i=R(n,"w:i");i&&n.removeChild(i);}}}_set_paragraph_style(e,t){let r=e.ownerDocument,n=R(e,"w:pPr");n&&e.removeChild(n);let a=r.createElement("w:pPr"),i=r.createElement("w:pStyle"),s=t.replace(/\s+/g,"");i.setAttribute("w:val",s),a.appendChild(i),e.insertBefore(a,e.firstChild);}_anchor_reply_comment(e,t){let r=this.doc.part._element.ownerDocument,n=S(this.doc.element,"w:commentRangeStart").filter(m=>m.getAttribute("w:id")===e);if(n.length===0)return;let a=n[0],i=r.createElement("w:commentRangeStart");i.setAttribute("w:id",t),Pt(i,a);let s=S(this.doc.element,"w:commentRangeEnd").filter(m=>m.getAttribute("w:id")===e);if(s.length===0)return;let o=s[0],l=S(this.doc.element,"w:commentReference").filter(m=>m.getAttribute("w:id")===e),u=o;if(l.length>0){let m=l[0];m.parentNode&&m.parentNode.tagName==="w:r"&&(u=m.parentNode);}let f=r.createElement("w:commentRangeEnd");f.setAttribute("w:id",t),Pt(f,u);let c=r.createElement("w:r"),d=r.createElement("w:rPr"),p=r.createElement("w:rStyle");p.setAttribute("w:val","CommentReference"),d.appendChild(p),c.appendChild(d);let g=r.createElement("w:commentReference");g.setAttribute("w:id",t),c.appendChild(g),Pt(c,f);}_clean_wrapping_comments(e){let t=e;for(;;){let l=kr(t);if(l&&(l.tagName==="w:ins"||l.tagName==="w:del"))t=l;else break}let r=e;for(;;){let l=at(r);if(l&&(l.tagName==="w:ins"||l.tagName==="w:del"))r=l;else break}let n=[],a=kr(t);for(;a;)if(a.tagName==="w:commentRangeStart")n.push(a),a=kr(a);else if(a.tagName==="w:rPr"||a.tagName==="w:pPr")a=kr(a);else break;let i=[],s=at(r);for(;s;)if(s.tagName==="w:commentRangeEnd")i.push(s),s=at(s);else if(s.tagName==="w:r"&&S(s,"w:commentReference").length>0)i.push(s),s=at(s);else if(s.tagName==="w:commentReference")i.push(s),s=at(s);else break;let o=new Set;for(let l of i)if(l.tagName==="w:commentRangeEnd"){let u=l.getAttribute("w:id");u&&o.add(u);}else {let u=S(l,"w:commentReference")[0];if(!u&&l.tagName==="w:commentReference"&&(u=l),u){let f=u.getAttribute("w:id");f&&o.add(f);}}for(let l of n){let u=l.getAttribute("w:id");if(u&&o.has(u)){this.comments_manager.deleteComment(u),l.parentNode&&l.parentNode.removeChild(l);for(let f of i){let c=null;if(f.tagName==="w:commentRangeEnd")c=f.getAttribute("w:id");else {let d=S(f,"w:commentReference")[0];!d&&f.tagName==="w:commentReference"&&(d=f),d&&(c=d.getAttribute("w:id"));}c===u&&f.parentNode&&f.parentNode.removeChild(f);}}}}_delete_comments_in_element(e){let t=S(e,"w:commentReference");for(let r of t){let n=r.getAttribute("w:id");if(n){this.comments_manager.deleteComment(n);for(let a of ["w:commentRangeStart","w:commentRangeEnd"]){let i=S(this.doc.element,a);for(let s of i)s.getAttribute("w:id")===n&&s.parentNode&&s.parentNode.removeChild(s);}}}}validate_edits(e){let t=[];this.mapper.full_text||this.mapper._build_map(),t.push(...fl(e));for(let r=0;r<e.length;r++){let n=e[r];if(typeof n!="object"||n===null){t.push(`- Edit ${r+1} Failed: Invalid change format. Expected a JSON object, but received a primitive ${typeof n}. Do not pass raw strings.`);continue}if(!n.target_text)continue;let a=n.regex||false,i=n.match_mode||"strict",s=this.mapper.find_all_match_indices(n.target_text,a),o=this.mapper.full_text;this.mapper;s.length===0&&(this.clean_mapper||(this.clean_mapper=new kt(this.doc,true)),s=this.clean_mapper.find_all_match_indices(n.target_text,a),s.length>0&&(o=this.clean_mapper.full_text,this.clean_mapper)),o===this.mapper.full_text&&s.length>0&&(s=s.filter(([d,p])=>{let g=this.mapper.spans.filter(m=>m.run!==null&&m.end>d&&m.start<d+p);return g.length===0?true:g.some(m=>!m.del_id)}));let u=false,f=new Set;if(s.length===0){this.original_mapper||(this.original_mapper=new kt(this.doc,false,true));let c=this.original_mapper.find_all_match_indices(n.target_text,a);if(c.length>0){u=true;for(let[d,p]of c){let g=this.original_mapper.spans.filter(m=>m.end>d&&m.start<d+p);for(let m of g)if(m.run!==null){let D=m.run._element;for(;D;){if(D.nodeType===1&&D.tagName==="w:del"){let w=D.getAttribute("w:author");w&&f.add(w);break}D=D.parentNode;}}}}}if(s.length===0)if(u){let c=f.size>0?`by ${Array.from(f).sort().join(", ")}`:"by an existing revision";t.push(`- Edit ${r+1} Failed: Target text matches text inside a tracked deletion ${c}. Reject/accept that change first or target the active replacement text instead.`);}else t.push(`- Edit ${r+1} Failed: Target text not found in document:
58
58
  "${n.target_text}"`);else if(s.length>1&&i==="strict"){let c=s.map(([d,p])=>[d,d+p]);t.push(cl(r+1,n.target_text,o,c));}if(s.length===1){let[c,d]=s[0],p=o.substring(c,c+d),[g,m]=bn(p,n.new_text||""),D=p.length-m,w=p.substring(g,D),v=(n.new_text||"").substring(g,(n.new_text||"").length-m);if(w.includes(`
59
59
 
60
60
  `))if(v.includes(`
@@ -63,7 +63,7 @@ ${u}`,l++;else break}t.push([o,a]),r=l;}return t}h(ol,"_merge_footnote_sections"
63
63
 
64
64
  `);E.length>=2&&E[0].trim()!==""&&E[E.length-1].trim()!==""&&t.push(`- Edit ${r+1} Failed: target_text spans a paragraph boundary with body text on both sides. The paragraph break is a structural element, not literal text, so it cannot be replaced as a single span without corrupting the document. Split this into one edit per paragraph.`);}else {let E=w.split(`
65
65
 
66
- `);E.length>=2&&E[0].trim()!==""&&E[E.length-1].trim()!==""&&t.push(`- Edit ${r+1} Failed: target_text spans a paragraph boundary with body text on both sides. The paragraph break is a structural element, not literal text, so it cannot be replaced as a single span without corrupting the document. Split this into one edit per paragraph.`);}}for(let[c,d]of s){let p=this.mapper.spans.filter(m=>m.end>c&&m.start<c+d),g=new Set;for(let m of p){if(m.ins_id){let D=S(this.doc.element,"w:ins").filter(w=>w.getAttribute("w:id")===m.ins_id);if(D.length>0){let w=D[0].getAttribute("w:author");w&&w!==this.author&&g.add(w);}}if(m.comment_ids)for(let D of m.comment_ids){let w=this.mapper.comments_map[D];w&&w.author&&w.author!==this.author&&g.add(w.author);}}g.size>0&&t.push(`- Edit ${r+1} Failed: Modification targets an active insertion from another author (${Array.from(g).join(", ")}). Accept that change first or scope your edit outside of it.`);}}return t}validate_review_actions(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],a=n.type;if(a==="reply"){let i=n.target_id.replace("Com:",""),s=false,o=this.doc.pkg.parts.find(l=>l.contentType==="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml");o&&(s=S(o._element,"w:comment").some(u=>u.getAttribute("w:id")===i)),s||t.push(`- Action ${r+1} Failed: Target comment ID ${n.target_id} not found.`);}else if(a==="accept"||a==="reject"){let i=n.target_id.replace("Chg:",""),s=S(this.doc.element,"w:ins").filter(l=>l.getAttribute("w:id")===i),o=S(this.doc.element,"w:del").filter(l=>l.getAttribute("w:id")===i);s.length===0&&o.length===0&&t.push(`- Action ${r+1} Failed: Target ID ${n.target_id} not found.`);}}return t}process_batch(e,t=false){if(Array.isArray(e)&&(e=e.map(r=>{if(typeof r=="string")try{let n=JSON.parse(r);return n!==null&&typeof n=="object"?n:r}catch{return r}return r})),t){let r=new Map;for(let n of this.doc.pkg.parts)n._element&&r.set(n,n._element.cloneNode(true));try{return this._process_batch_internal(e,!0)}finally{for(let[n,a]of r.entries()){let i=n._element.ownerDocument;i&&i.documentElement&&i.replaceChild(a,i.documentElement),n._element=a;}this.mapper=new kt(this.doc),this.comments_manager=new ir(this.doc),this.clean_mapper=null;}}else return this._process_batch_internal(e,false)}_process_batch_internal(e,t=false){this.skipped_details=[];let r=e.filter(d=>["accept","reject","reply"].includes(d.type)),n=e.filter(d=>!["accept","reject","reply"].includes(d.type));if(t){if(r.length>0){let d=this.validate_review_actions(r);if(d.length>0)throw new Pr(d)}}else {let d=[];if(r.length>0&&d.push(...this.validate_review_actions(r)),n.length>0&&d.push(...this.validate_edits(n)),d.length>0)throw new Pr(d)}let a=0,i=0;if(r.length>0){let d=this.apply_review_actions(r);if(a=d[0],i=d[1],i>0)throw new Pr(this.skipped_details);a>0&&(this.mapper._build_map(),this.clean_mapper&&this.clean_mapper._build_map());}let[s]=pa(this.mapper.full_text),l=ma(s,"").body_page_offsets,u=[],f=0,c=0;if(n.length>0)if(t)for(let d of n){let p=this.validate_edits([d]),g=this._check_punctuation_warning(d.target_text||"");if(p.length>0){c++,u.push({status:"failed",target_text:d.target_text||"",new_text:d.new_text||"",warning:g,error:p[0],critic_markup:null,clean_text:null});continue}this.apply_edits([d],l);if(d._applied_status){f++;let D=this._build_edit_context_previews(d);u.push({status:"applied",target_text:d.target_text||"",new_text:d.new_text||"",warning:g,error:null,critic_markup:D[0],clean_text:D[1],pages:d._pages||[],heading_path:d._heading_path||"",occurrences_modified:d._occurrences_modified||0,match_mode:d.match_mode||"strict"});}else {c++;let D=this.skipped_details.length>0?this.skipped_details[this.skipped_details.length-1]:"Failed to apply edit";u.push({status:"failed",target_text:d.target_text||"",new_text:d.new_text||"",warning:g,error:D,critic_markup:null,clean_text:null});}}else {let d=this.validate_edits(n);if(d.length>0)throw new Pr(d);let p=n.map(m=>JSON.parse(JSON.stringify(m)));this.apply_edits(p,l);f=p.filter(m=>m._applied_status).length,c=p.length-f;for(let m of p){let D=m._applied_status||false,w=m._error_msg||null,v=this._check_punctuation_warning(m.target_text||""),E=null,_=null;if(D){let b=this._build_edit_context_previews(m);E=b[0],_=b[1];}u.push({status:D?"applied":"failed",target_text:m.target_text||"",new_text:m.new_text||"",warning:v,error:w,critic_markup:E,clean_text:_,pages:m._pages||[],heading_path:m._heading_path||"",occurrences_modified:m._occurrences_modified||0,match_mode:m.match_mode||"strict"});}}return {actions_applied:a,actions_skipped:i,edits_applied:f,edits_skipped:c,skipped_details:this.skipped_details,edits:u,engine:"node",version:"1.10.0"}}apply_edits(e,t=[]){let r=0,n=0;if(!t||t.length===0){let[s]=pa(this.mapper.full_text);t=ma(s,"").body_page_offsets;}let a=[];for(let s of e)s._applied_status=false,s._error_msg=null;for(let s of e)if(s._resolved_start_idx!==void 0&&s._resolved_start_idx!==null)a.push([s,s.new_text||null]);else if(s._match_start_index!==void 0&&s._match_start_index!==null)s._resolved_start_idx=s._match_start_index,a.push([s,s.new_text||null]);else if(s.type==="insert_row"||s.type==="delete_row"){let o=this.mapper.find_all_match_indices(s.target_text);if(o.length===0&&(this.clean_mapper||(this.clean_mapper=new kt(this.doc,true)),o=this.clean_mapper.find_all_match_indices(s.target_text)),o.length>0)s._resolved_start_idx=o[0][0],a.push([s,null]);else {n++,s._applied_status=false;let u=`- Failed to locate row target: '${(s.target_text||"").trim().substring(0,40)}...'`;this.skipped_details.push(u),s._error_msg=u;}}else {let o=this._pre_resolve_heuristic_edit(s);if(o)if(Array.isArray(o))for(let l of o)l._resolved_start_idx=l._match_start_index,l._parent_edit_ref=s,(s._resolved_start_idx===void 0||s._resolved_start_idx===null)&&(s._resolved_start_idx=l._resolved_start_idx),s._resolved_proxy_edit||(s._resolved_proxy_edit=l),a.push([l,l.new_text]);else o._resolved_start_idx=o._match_start_index,o._parent_edit_ref=s,s._resolved_start_idx=o._resolved_start_idx,s._resolved_proxy_edit=o,a.push([o,o.new_text]);else {n++,s._applied_status=false;let f=`- Failed to apply edit targeting: '${(s.target_text||"insertion").trim().substring(0,40)}...'`;this.skipped_details.push(f),s._error_msg=f;}}a.sort((s,o)=>(o[0]._resolved_start_idx||0)-(s[0]._resolved_start_idx||0));let i=[];for(let[s,o]of a){let l=s._resolved_start_idx||0,u=l+(s.target_text?s.target_text.length:0);if(i.some(([d,p])=>l<p&&u>d)){n++;let g=`- Skipped overlapping edit targeting: '${(s.target_text||"insertion").trim().substring(0,40)}...'`;this.skipped_details.push(g),s._applied_status=false,s._error_msg=g;let m=s._parent_edit_ref;m&&(m._applied_status=false,m._error_msg=g);continue}let c=false;if(s.type==="modify"?c=this._apply_single_edit_indexed(s,o,false):(s.type==="insert_row"||s.type==="delete_row")&&(c=this._apply_table_edit(s,false)),c){r++,i.push([l,u]),s._applied_status=true;let d=s._parent_edit_ref;if(d){d._applied_status=true,d._occurrences_modified=(d._occurrences_modified||0)+1;let[p,g]=this._get_heading_path_and_page(l,this.mapper.full_text,t),m=d._pages||[];m.includes(g)||m.unshift(g),d._pages=m,d._heading_path=p;}else {s._occurrences_modified=(s._occurrences_modified||0)+1;let[p,g]=this._get_heading_path_and_page(l,this.mapper.full_text,t),m=s._pages||[];m.includes(g)||m.unshift(g),s._pages=m,s._heading_path=p;}}else {n++;let g=`- Failed to apply edit targeting: '${(s.target_text||"insertion").trim().substring(0,40)}...'`;this.skipped_details.push(g),s._applied_status=false,s._error_msg=g;let m=s._parent_edit_ref;m&&(m._applied_status||(m._applied_status=false,m._error_msg=g));}}return [r,n]}apply_review_actions(e){let t=0,r=0;for(let n of e){let a=n.type;if(a==="reply"){let u=n.target_id.replace("Com:",""),f=this.comments_manager.addComment(this.author,n.text,u);this._anchor_reply_comment(u,f),t++;continue}let i=n.target_id.replace("Chg:",""),s=S(this.doc.element,"w:ins").filter(u=>u.getAttribute("w:id")===i),o=S(this.doc.element,"w:del").filter(u=>u.getAttribute("w:id")===i),l=[...s,...o];if(l.length===0){r++,this.skipped_details.push(`- Failed to apply action: Target ID ${n.target_id} not found.`);continue}for(let u of l){let f=u.tagName==="w:ins",d=(u.parentNode?u.parentNode.tagName:"")==="w:trPr";if(a==="accept")if(f)if(this._clean_wrapping_comments(u),d)u.parentNode?.removeChild(u);else {for(;u.firstChild;)u.parentNode?.insertBefore(u.firstChild,u);u.parentNode?.removeChild(u);}else if(this._clean_wrapping_comments(u),this._delete_comments_in_element(u),d){let p=u.parentNode?.parentNode;p?.parentNode?.removeChild(p);}else u.parentNode?.removeChild(u);else if(a==="reject")if(f)if(this._clean_wrapping_comments(u),this._delete_comments_in_element(u),d){let p=u.parentNode?.parentNode;p?.parentNode?.removeChild(p);}else u.parentNode?.removeChild(u);else if(this._clean_wrapping_comments(u),d)u.parentNode?.removeChild(u);else {let p=Array.from(u.getElementsByTagName("w:delText"));for(let g of p){let m=g.ownerDocument.createElement("w:t");m.textContent=g.textContent,g.hasAttribute("xml:space")&&m.setAttribute("xml:space","preserve"),g.parentNode?.replaceChild(m,g);}for(;u.firstChild;)u.parentNode?.insertBefore(u.firstChild,u);u.parentNode?.removeChild(u);}}t++;}return [t,r]}_apply_table_edit(e,t){let r=e._resolved_start_idx!==void 0&&e._resolved_start_idx!==null?e._resolved_start_idx:e._match_start_index||0,[n,a]=this.mapper.get_insertion_anchor(r,t),i=null;if(n?i=n._element:a&&(i=a._element),!i)return false;let s=i;for(;s&&s.tagName!=="w:tr";)s=s.parentNode;if(!s)return false;if(e.type==="delete_row"){let o=R(s,"w:trPr");return o||(o=s.ownerDocument.createElement("w:trPr"),s.insertBefore(o,s.firstChild)),o.appendChild(this._create_track_change_tag("w:del")),true}else if(e.type==="insert_row"){let o=s.ownerDocument.createElement("w:tr"),l=s.ownerDocument.createElement("w:trPr");o.appendChild(l),l.appendChild(this._create_track_change_tag("w:ins"));for(let u of e.cells){let f=s.ownerDocument.createElement("w:tc"),c=s.ownerDocument.createElement("w:p"),d=s.ownerDocument.createElement("w:r"),p=s.ownerDocument.createElement("w:t");p.textContent=u,u.trim()!==u&&p.setAttribute("xml:space","preserve"),d.appendChild(p),c.appendChild(d),f.appendChild(c),o.appendChild(f);}return e.position==="above"?s.parentNode?.insertBefore(o,s):Pt(o,s),true}return false}_pre_resolve_heuristic_edit(e){if(!e.target_text)return null;let t=e.regex||false,r=e.match_mode||"strict",n=this.mapper.find_all_match_indices(e.target_text,t),a=false;if(n.length===0)if(this.clean_mapper||(this.clean_mapper=new kt(this.doc,true)),n=this.clean_mapper.find_all_match_indices(e.target_text,t),n.length>0)a=true;else return null;let i=a?this.clean_mapper:this.mapper,s=[];for(let[l,u]of n){let f=i.spans.filter(c=>c.run!==null&&c.end>l&&c.start<l+u);(f.length===0||f.some(c=>!c.del_id))&&s.push([l,u]);}if(s.length===0)return null;(r==="strict"||r==="first")&&(s=s.slice(0,1));let o=[];for(let[l,u]of s){let f=i.full_text.substring(l,l+u),c=e.new_text||"";if(t&&c)try{c=f.replace(new RegExp(e.target_text),c);}catch{}let[d,p]=this._parse_markdown_style(e.target_text),[g,m]=this._parse_markdown_style(c);if(p!==m){let[_]=this._parse_markdown_style(f),b=_,y=g,A=b===y?"STYLE_ONLY":"STYLE_AND_TEXT",N=f.indexOf(_),C=l+(N!==-1?N:0),M=m!==null?m:"Normal";o.push({type:"modify",target_text:b,new_text:y,comment:e.comment,_match_start_index:C,_internal_op:A,_new_style:M,_active_mapper_ref:i});continue}if(f===c||e.target_text===c){o.push({type:"modify",target_text:f,new_text:f,comment:e.comment,_match_start_index:l,_internal_op:"COMMENT_ONLY",_active_mapper_ref:i});continue}let D="",w="",v="",E=l;if(c.startsWith(f))D="INSERTION",v=c.substring(f.length),E=l+u;else {let[_,b]=bn(f,c),y=f.length-b,A=c.length-b;w=f.substring(_,y),v=c.substring(_,A),E=l+_,!w&&v?D="INSERTION":w&&!v?D="DELETION":w&&v?D="MODIFICATION":D="COMMENT_ONLY";}o.push({type:"modify",target_text:w,new_text:v,comment:e.comment,_match_start_index:E,_internal_op:D,_active_mapper_ref:i});}return o.length===0?null:r==="all"||o.length>1?o:o[0]}_apply_single_edit_indexed(e,t,r){let n=e._internal_op,a=e._active_mapper_ref||this.mapper,i=e._resolved_start_idx!==void 0&&e._resolved_start_idx!==null?e._resolved_start_idx:e._match_start_index||0,s=e.target_text?e.target_text.length:0;if(n==="STYLE_ONLY"||n==="STYLE_AND_TEXT"){let[w,v]=a.get_insertion_anchor(i,r),E=null;if(v)E=v._element;else if(w){let _=w._element;for(;_&&_.tagName!=="w:p";)_=_.parentNode;E=_;}if(E&&e._new_style&&this._set_paragraph_style(E,e._new_style),n==="STYLE_ONLY"){if(e.comment){let _=a.find_target_runs_by_index(i,s,r);if(_.length>0){let b=_[0]._element,y=_[_.length-1]._element,A=b;for(;A&&A.tagName!=="w:p";)A=A.parentNode;let N=y;for(;N&&N.tagName!=="w:p";)N=N.parentNode;if(A&&N){let C=h((O,U)=>{let I=O;for(;I.parentNode&&I.parentNode!==U;)I=I.parentNode;return I},"ascend_to_paragraph_child"),M=C(b,A),x=C(y,N);A===N?this._attach_comment(A,M,x,e.comment):this._attach_comment_spanning(A,M,N,x,e.comment);}}}return true}e.target_text&&e.new_text?n="MODIFICATION":!e.target_text&&e.new_text?n="INSERTION":e.target_text&&!e.new_text?n="DELETION":n="COMMENT_ONLY";}let o=["DELETION","MODIFICATION"].includes(n)?this._getNextId():null,l=["INSERTION","MODIFICATION"].includes(n)?this._getNextId():null;if(n==="COMMENT_ONLY"){let w=a.find_target_runs_by_index(i,s,r);if(w.length===0)return false;if(!e.comment)return true;let v=w[0]._element,E=w[w.length-1]._element,_=v;for(;_&&_.tagName!=="w:p";)_=_.parentNode;let b=E;for(;b&&b.tagName!=="w:p";)b=b.parentNode;if(!_||!b)return false;let y=h((C,M)=>{let x=C;for(;x.parentNode&&x.parentNode!==M;)x=x.parentNode;return x},"ascend_to_paragraph_child"),A=y(v,_),N=y(E,b);return _===b?this._attach_comment(_,A,N,e.comment):this._attach_comment_spanning(_,A,b,N,e.comment),true}if(n==="INSERTION"){let[w,v]=a.get_insertion_anchor(i,r);if(!w&&!v)return false;let E=e.new_text||"",_=/\n\s*$/.test(E),b=null;{let N=a.spans.filter(C=>C.paragraph!==null&&C.start===i);N.length>0&&N[0].paragraph&&(b=N[0].paragraph._element);}if(_&&b&&b.parentNode){let N=b.parentNode,C=this.doc.part._element.ownerDocument,M=E.split(/[\r\n]+/).filter(I=>I!==""),x=null,O=null,U=null;for(let I of M){let[Y,z]=this._parse_markdown_style(I),B=C.createElement("w:p");if(z)this._set_paragraph_style(B,z);else {let K=R(b,"w:pPr");K&&B.appendChild(K.cloneNode(true));}let L=R(B,"w:pPr");L||(L=C.createElement("w:pPr"),B.insertBefore(L,B.firstChild));let k=R(L,"w:rPr");k||(k=C.createElement("w:rPr"),L.appendChild(k)),k.appendChild(this._create_track_change_tag("w:ins","",l));let H=this._build_tracked_ins_for_line(Y,w,l,C);H&&B.appendChild(H),N.insertBefore(B,b),x||(x=B),O=B,U=H;}if(x){if(e.comment&&O&&U){let I=h((z,B)=>{let L=z;for(;L.parentNode&&L.parentNode!==B;)L=L.parentNode;return L},"ascend"),Y=S(x,"w:ins")[0]||x;this._attach_comment_spanning(x,I(Y,x),O,I(U,O),e.comment);}return true}}let y=this._track_insert_multiline(e.new_text||"",w,v,l);if(!y.first_node)return false;if(y.first_node.tagName==="w:ins"&&(w?Pt(y.first_node,w._element):v&&v._element.appendChild(y.first_node)),e.comment){let N=h((C,M)=>{let x=C;for(;x.parentNode&&x.parentNode!==M;)x=x.parentNode;return x},"ascend_to_paragraph_child");if(y.last_p&&y.last_ins){let C=y.first_node;for(;C&&C.tagName!=="w:p";)C=C.parentNode;if(C){let M=y.first_node;y.first_node.tagName==="w:p"&&(M=S(y.first_node,"w:ins")[0]||y.first_node);let x=N(M,C),O=N(y.last_ins,y.last_p);this._attach_comment_spanning(C,x,y.last_p,O,e.comment);}}else {let C=y.first_node;for(;C&&C.tagName!=="w:p";)C=C.parentNode;if(C){let M=y.first_node;y.first_node.tagName==="w:p"&&(M=S(y.first_node,"w:ins")[0]||y.first_node);let x=N(M,C);this._attach_comment(C,x,x,e.comment);}}}return true}let u=a.find_target_runs_by_index(i,s,r),f=a.get_virtual_spans_in_range(i,s);if(u.length===0&&f.length===0)return false;let c=new Set;for(let w of u){let v=w._element.parentNode;for(;v&&v.tagName!=="w:p";)v=v.parentNode;v&&c.add(v);}let d=null,p=null;for(let w of u){let v=this._create_track_change_tag("w:del","",o),E=w._element.cloneNode(true);Array.from(E.getElementsByTagName("w:t")).forEach(b=>{let y=E.ownerDocument.createElement("w:delText");y.textContent=b.textContent,b.hasAttribute("xml:space")&&y.setAttribute("xml:space","preserve"),E.replaceChild(y,b);}),v.appendChild(E),w._element.parentNode?.replaceChild(v,w._element),d===null&&(d=v),p=v;}let g=null,m=null,D=null;if(n==="MODIFICATION"&&e.new_text&&p){let w=p;for(;w&&w.tagName!=="w:p";)w=w.parentNode;let v=w?new Ze(w,null):null,E=u.length>0?u[u.length-1]:null,_=this._track_insert_multiline(e.new_text,E,v,l);_.first_node&&(_.first_node.tagName==="w:ins"?(Pt(_.first_node,p),g=_.first_node):g=_.last_ins,m=_.last_p,D=_.last_ins);}if(n==="DELETION"||n==="MODIFICATION"){if(n==="MODIFICATION"&&u.length===0&&f.length>0&&e.new_text){let w=f[0];if(w.paragraph){let v=w.paragraph._element,E=S(v,"w:r"),_=E.length>0?new Ke(E[E.length-1],w.paragraph):null,b=this._track_insert_multiline(e.new_text,_,w.paragraph,l);b.first_node&&v.appendChild(b.first_node);}}for(let w of [...f].reverse())if(w.paragraph){let v=w.paragraph._element,E=at(v);for(;E&&E.tagName!=="w:p";)E=at(E);if(E&&E.tagName==="w:p"){let _=R(v,"w:pPr");_||(_=v.ownerDocument.createElement("w:pPr"),v.insertBefore(_,v.firstChild));let b=R(_,"w:rPr");b||(b=v.ownerDocument.createElement("w:rPr"),_.appendChild(b));let y=this._create_track_change_tag("w:del");b.appendChild(y);let A=Array.from(E.childNodes);for(let N of A)N.nodeType===1&&N.tagName==="w:pPr"||v.appendChild(N);E.parentNode&&E.parentNode.removeChild(E);}}}if(e.comment&&d!==null){let w,v;if(m&&D)w=D,v=m;else {let A=g!==null?g:p;for(w=A,v=A;v&&v.tagName!=="w:p";)v=v.parentNode;}let E=d;for(;E&&E.tagName!=="w:p";)E=E.parentNode;if(!E||!v)return true;let _=h((A,N)=>{let C=A;for(;C.parentNode&&C.parentNode!==N;)C=C.parentNode;return C},"ascend_to_paragraph_child"),b=_(d,E),y=_(w,v);E===v?this._attach_comment(E,b,y,e.comment):this._attach_comment_spanning(E,b,v,y,e.comment);}for(let w of c){let v=false;for(let E of ["w:t","w:tab","w:br"]){let _=S(w,E);for(let b of _){let y=false,A=b.parentNode;for(;A&&A!==w.parentNode;){if(A.tagName==="w:del"){y=true;break}A=A.parentNode;}if(!y){if(E==="w:t"&&!b.textContent)continue;v=true;break}}if(v)break}if(!v){let E=R(w,"w:pPr");E||(E=w.ownerDocument.createElement("w:pPr"),w.insertBefore(E,w.firstChild));let _=R(E,"w:rPr");if(_||(_=w.ownerDocument.createElement("w:rPr"),E.appendChild(_)),!R(_,"w:del")){let b=this._create_track_change_tag("w:del");_.appendChild(b);}}}return true}};function Be(e,t){let r=[],n=e.getElementsByTagName("*");for(let a=0;a<n.length;a++){let i=n[a].tagName;(i===t||i.endsWith(":"+t))&&r.push(n[a]);}return r}h(Be,"findDescendantsByLocalName");function hl(e){let t=0;function r(s,o){let l=s?s.toString():"",u=o?o.toString():"";return l===u}h(r,"areRunsIdentical");function n(s){let o=["w:t","w:tab","w:br","w:cr","w:delText","w:rPr"];for(let l=0;l<s.childNodes.length;l++){let u=s.childNodes[l];if(u.nodeType===1){let f=u.tagName;if(!o.includes(f))return true}}return false}h(n,"hasSpecialContent");function a(s){let o=Array.from(s.childNodes).filter(u=>u.nodeType===1),l=0;for(;l<o.length-1;){let u=o[l],f=o[l+1];if(u.tagName==="w:r"&&f.tagName==="w:r"&&!n(u)&&!n(f)){let c=R(u,"w:rPr"),d=R(f,"w:rPr");if(r(c,d)){let p=null;for(let m=0;m<u.childNodes.length;m++){let D=u.childNodes[m];D.nodeType===1&&(D.tagName==="w:t"||D.tagName==="w:delText")&&(p=D);}let g=Array.from(f.childNodes).filter(m=>m.nodeType===1);for(let m of g)if(m.tagName!=="w:rPr")if((m.tagName==="w:t"||m.tagName==="w:delText")&&p&&p.tagName===m.tagName){let D=p.textContent||"",w=m.textContent||"",v=D+w;p.textContent=v,v.trim()!==v&&p.setAttribute("xml:space","preserve");}else u.appendChild(m),(m.tagName==="w:t"||m.tagName==="w:delText")&&(p=m);s.removeChild(f),o.splice(l+1,1),t++;continue}}["w:ins","w:del","w:hyperlink","w:sdt","w:smartTag","w:fldSimple","w:sdtContent"].includes(u.tagName)&&a(u),l++;}if(o.length>0){let u=o[o.length-1];["w:ins","w:del","w:hyperlink","w:sdt","w:smartTag","w:fldSimple","w:sdtContent"].includes(u.tagName)&&a(u);}}h(a,"coalesceContainer");let i=S(e.element,"w:p");for(let s of i)a(s);return t?[`Adjacent identical runs coalesced: ${t}`]:[]}h(hl,"coalesce_runs");function dl(e){let t=0,r=["w:rsidR","w:rsidRPr","w:rsidRDefault","w:rsidP","w:rsidDel","w:rsidSect","w:rsidTr"],n=e.element.getElementsByTagName("*");for(let i=0;i<n.length;i++)for(let s of r)n[i].hasAttribute(s)&&(n[i].removeAttribute(s),t++);let a=S(e.element,"w:rsids");for(let i of a)i.parentNode&&(i.parentNode.removeChild(i),t++);return t?[`rsid attributes: ${t} removed`]:[]}h(dl,"strip_rsid");function pl(e){let t=0,r=["w14:paraId","w14:textId"],n=e.element.getElementsByTagName("*");for(let a=0;a<n.length;a++)for(let i of r)n[a].hasAttribute(i)&&(n[a].removeAttribute(i),t++);return t?[`Paragraph/text IDs: ${t} removed`]:[]}h(pl,"strip_para_ids");function ml(e){let t=S(e.element,"w:proofErr");return t.forEach(r=>r.parentNode?.removeChild(r)),t.length?[`Spell check markers: ${t.length} removed`]:[]}h(ml,"strip_proof_errors");function gl(e){let t=0;for(let r of ["w:rPr","w:pPr"]){let n=S(e.element,r);for(let a of n)(a.childNodes.length===0||a.childNodes.length===1&&a.childNodes[0].nodeType===3&&!a.childNodes[0].textContent?.trim())&&(a.parentNode?.removeChild(a),t++);}return t?[`Empty property elements: ${t} removed`]:[]}h(gl,"strip_empty_properties");function _l(e){let t=0,r=S(e.element,"w:rPr");for(let n of r)if(R(n,"w:vanish")||R(n,"w:webHidden")){let a=n.parentNode;a&&a.tagName==="w:r"&&a.parentNode&&(a.parentNode.removeChild(a),t++);}return t?[`Hidden text runs: ${t} removed`]:[]}h(_l,"strip_hidden_text");function wa(e){let t=S(e.element,"w:ins").length,r=S(e.element,"w:del").length,n=S(e.element,"w:rPrChange").length+S(e.element,"w:pPrChange").length+S(e.element,"w:sectPrChange").length;return [t,r,n]}h(wa,"count_tracked_changes");function wl(e){let t=new Set;for(let r of ["w:ins","w:del","w:rPrChange","w:pPrChange","w:sectPrChange"])for(let n of S(e.element,r)){let a=n.getAttribute("w:author");a&&t.add(a);}return t}h(wl,"get_track_change_authors");function va(e){let t=[],r=S(e,"w:t");for(let a of r)a.textContent&&t.push(a.textContent);let n=S(e,"w:delText");for(let a of n)a.textContent&&t.push(a.textContent);return t.join("")}h(va,"_getElementText");function Mr(e,t=60){let r=e.replace(/\n/g," ").trim();return r.length<=t?r:r.substring(0,t-3)+"..."}h(Mr,"_truncate");function vl(e){let t=[],r=S(e.element,"w:ins"),n=S(e.element,"w:del");for(let s of r){let o=va(s).trim();o&&t.push(` Accepted insertion: "${Mr(o,60)}"`);}for(let s of n){let o=va(s).trim();o&&t.push(` Accepted deletion of: "${Mr(o,60)}"`);}new Sn(e).accept_all_revisions();for(let s of ["w:rPrChange","w:pPrChange","w:sectPrChange"])for(let o of S(e.element,s))o.parentNode?.removeChild(o);let i=r.length+n.length;return i?[`Tracked changes auto-accepted: ${i}`].concat(t):[]}h(vl,"accept_all_tracked_changes");function yl(e){let t=Br(e.pkg),r=[],n=0,a=0;for(let[i,s]of Object.entries(t))s.resolved?a++:n++,r.push({id:i,...s});return {total:r.length,open:n,resolved:a,comments:r}}h(yl,"get_comments_summary");function El(e){let t=Br(e.pkg),r=Object.keys(t);if(r.length===0)return [];let n=[],a=new ir(e);for(let[l,u]of Object.entries(t)){let f=u.resolved?"[Resolved]":"[Open]";n.push(` ${f} "${Mr(u.text||"",60)}" (${u.author||"Unknown"})`),a.deleteComment(l);}for(let l of ["w:commentRangeStart","w:commentRangeEnd"])for(let u of S(e.element,l))u.parentNode?.removeChild(u);let i=S(e.element,"w:commentReference");for(let l of i){let u=l.parentNode;u&&((u.tagName==="w:r"||u.tagName.endsWith(":r"))&&Array.from(u.childNodes).filter(c=>c.nodeType===1&&c.tagName!=="w:rPr"&&c.tagName!=="rPr").length<=1?u.parentNode?.removeChild(u):u.removeChild(l));}let s=Object.values(t).filter(l=>l.resolved).length,o=Object.values(t).filter(l=>!l.resolved).length;return [`Comments removed: ${r.length} (${s} resolved, ${o} open)`].concat(n)}h(El,"remove_all_comments");function Dl(e){let t=e.pkg,r=new Set;for(let a of t.parts)if(a.partname.toLowerCase().includes("comments")){r.add(a.partname);let i=a.partname.startsWith("/")?a.partname:"/"+a.partname,s=a.partname.startsWith("/")?a.partname.substring(1):a.partname;r.add(i),r.add(s);}if(r.size===0)return;for(let a of t.parts)if(a.partname.endsWith(".rels")){let i=S(a._element,"Relationship"),s=[];for(let o of i)if((o.getAttribute("Target")||"").toLowerCase().includes("comments")){s.push(o);let u=a.partname.replace("/_rels/","/").replace(".rels",""),f=t.getPartByPath(u);if(f){let c=o.getAttribute("Id");c&&f.rels.delete(c);}}for(let o of s)o.parentNode?.removeChild(o);}let n=t.getPartByPath("[Content_Types].xml");if(n){let a=S(n._element,"Override"),i=[];for(let s of a){let o=s.getAttribute("PartName")||"";(r.has(o)||o.toLowerCase().includes("comments"))&&i.push(s);}for(let s of i)s.parentNode?.removeChild(s);}t.parts=t.parts.filter(a=>!a.partname.toLowerCase().includes("comments"));for(let a of Object.keys(t.unzipped))a.toLowerCase().includes("comments")&&delete t.unzipped[a];}h(Dl,"eject_comment_parts");function bl(e,t){let r=new ir(e);if(!r.commentsPart)return [];let n=new Set,a=S(r.commentsPart._element,"w:comment");for(let i of a){let s=i.getAttribute("w:author");if(s&&(n.add(s),i.setAttribute("w:author",t)),i.hasAttribute("w:initials")){let o=t.split(" ").filter(Boolean).map(l=>l[0]).join("").toUpperCase();i.setAttribute("w:initials",o);}}return n.size?[`Comment authors replaced: ${Array.from(n).sort().join(", ")} \u2192 "${t}"`]:[]}h(bl,"replace_comment_authors");function Al(e,t){let r=new Set;for(let n of ["w:ins","w:del","w:rPrChange","w:pPrChange"])for(let a of S(e.element,n)){let i=a.getAttribute("w:author");i&&(r.add(i),a.setAttribute("w:author",t));}return r.size?[`Track change authors replaced: ${Array.from(r).sort().join(", ")} \u2192 "${t}"`]:[]}h(Al,"replace_change_authors");function Nl(e){let t=0,r="2025-01-01T00:00:00Z";for(let n of ["w:ins","w:del","w:rPrChange","w:pPrChange"])for(let a of S(e.element,n))a.hasAttribute("w:date")&&(a.setAttribute("w:date",r),t++);return t?[`Track change timestamps: ${t} normalized`]:[]}h(Nl,"normalize_change_dates");function Cl(e){let t=[],r=e.pkg.getPartByPath("docProps/core.xml");r&&(Be(r._element,"creator").forEach(o=>{o.textContent&&(t.push(`Author: ${o.textContent}`),o.textContent="");}),Be(r._element,"lastModifiedBy").forEach(o=>{o.textContent&&(t.push(`Last modified by: ${o.textContent}`),o.textContent="");}),Be(r._element,"revision").forEach(o=>{o.textContent&&parseInt(o.textContent)>1&&(t.push(`Revision count: ${o.textContent} \u2192 1`),o.textContent="1");}));let n=e.pkg.getPartByPath("docProps/app.xml");if(n){let a=n._element,i=["TotalTime","Words","Characters","Paragraphs","Lines","CharactersWithSpaces"];for(let o of i)Be(a,o).forEach(l=>{l.textContent&&l.textContent!=="0"&&(o==="TotalTime"&&t.push(`Total editing time: ${l.textContent} minutes`),l.textContent="0");});let s=["Template","Manager","Company"];for(let o of s)Be(a,o).forEach(l=>{l.textContent&&(t.push(`${o}: ${l.textContent}`),l.textContent="");});}return t.length?["Metadata scrubbed:",...t.map(a=>` ${a}`)]:[]}h(Cl,"scrub_doc_properties");function Tl(e){let t=false,r="1970-01-01T00:00:00Z",n=e.pkg.getPartByPath("docProps/core.xml");if(n)for(let a of ["created","modified","lastPrinted"])Be(n._element,a).forEach(i=>{i.textContent&&i.textContent!==r&&(i.textContent=r,t=true);});return t?["Timestamps normalized to epoch"]:[]}h(Tl,"scrub_timestamps");function xl(e){let t=e.pkg.parts.filter(s=>s.partname.includes("/customXml"));if(t.length===0)return [];let r=new Set(t.map(s=>s.partname));e.pkg.parts=e.pkg.parts.filter(s=>!r.has(s.partname));let n=h(s=>{let o=[];for(let l of S(s._element,"Relationship")){let u=l.getAttribute("Target");u&&u.includes("customXml")&&o.push(l);}o.forEach(l=>l.parentNode?.removeChild(l));},"removeRelationsTo"),a=e.pkg.getPartByPath("_rels/.rels");a&&n(a);let i=e.pkg.getOrCreateRelsPart(e.part.partname);i&&n(i);for(let s of S(e.element,"w:sdtPr"))_u(s,"w:dataBinding").forEach(o=>s.removeChild(o));return [`Custom XML parts: ${t.length} removed`]}h(xl,"strip_custom_xml");function Sl(e){let t=0;for(let r of Be(e.element,"docPr")){let n=r.getAttribute("descr");if(n){let a=n.length<10,i=n.includes(".")&&n.length<60;(a||i)&&(r.removeAttribute("descr"),t++);}}return t?[`Image alt text: ${t} auto-generated descriptions removed`]:[]}h(Sl,"strip_image_alt_text");function Il(e){let t=["sharepoint.com","onedrive.com",".internal","intranet","localhost","10.","192.168.","172.16."],r=[],n=e.pkg.getOrCreateRelsPart(e.part.partname);for(let a of S(n._element,"Relationship"))if(a.getAttribute("TargetMode")==="External"){let i=a.getAttribute("Target")||"";for(let s of t)if(i.toLowerCase().includes(s.toLowerCase())){r.push(`Hyperlink targets internal URL: ${Mr(i,80)}`);break}}return r}h(Il,"audit_hyperlinks");function kl(e,t,r=2){if(e===t)return 0;if(Math.abs(e.length-t.length)>r)return r+1;if(e.length===0)return t.length<=r?t.length:r+1;if(t.length===0)return e.length<=r?e.length:r+1;if(e.length>t.length){let a=e;e=t,t=a;}let n=Array.from({length:e.length+1},(a,i)=>i);for(let a=1;a<=t.length;a++){let i=[a],s=a;for(let o=1;o<=e.length;o++){let l=e[o-1]===t[a-1]?0:1,u=Math.min(n[o]+1,i[o-1]+1,n[o-1]+l);i.push(u),u<s&&(s=u);}if(s>r)return r+1;n=i;}return n[e.length]<=r?n[e.length]:r+1}h(kl,"boundedLevenshtein");function Pl(e){let t="",r=S(e._element,"w:r");for(let n of r)t+=st(new Ke(n,e));return t}h(Pl,"_get_paragraph_text");function Ol(e,t){let r={},n=new Set,a={},i=[],s=/^(?:[\d.\-()a-zA-Z]+\s*)?["“]([A-Z][A-Za-z0-9\s\-&'’]{1,60})["”]/,o=/\([^)]*?["“]([A-Z][A-Za-z0-9\s\-&'’]{1,60})["”][^)]*?\)/g;for(let w of xn(e)){if(!(w instanceof Ze))continue;let v=Pl(w).trim();if(!v)continue;let E=[],_=v.match(s);_&&E.push(_[1].trim());let b=v.matchAll(o);for(let N of b)E.push(N[1].trim());for(let N of E)r[N]?n.add(N):r[N]={count:0};let y=v.length>60?v.substring(0,60)+"...":v,A=S(w._element,"*");for(let N of A){if(N.tagName==="w:bookmarkStart"){let M=N.getAttribute("w:name");M&&(!M.startsWith("_")||M.startsWith("_Ref"))&&(a[M]||(a[M]={anchored_to:y,referenced_from:[]}));}let C=null;if(N.tagName==="w:fldSimple"){let x=(N.getAttribute("w:instr")||"").trim().split(/\s+/);x.length>1&&x[0]==="REF"&&(C=x[1]);}else if(N.tagName==="w:instrText"){let x=(N.textContent||"").trim().split(/\s+/);x.length>1&&x[0]==="REF"&&(C=x[1]);}C&&i.push([C,y]);}}for(let[w,v]of i)a[w]&&a[w].referenced_from.push(v);let l=[],u=Object.keys(r);if(u.length>0){let w=u.sort((b,y)=>y.length-b.length),v=h(b=>b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRegExp"),E=w.map(v).join("|"),_=new RegExp(`(?<!["\u201C])\\b(${E})\\b(?![\u201D"])`,"g");for(let b of t.matchAll(_)){let y=b[1];r[y]&&r[y].count++;}for(let b of u)r[b].count===0&&(delete r[b],n.delete(b));}for(let w of n)l.push(`[Error] Duplicate Definition: '${w}' is defined multiple times.`);let f=new Set(["The","This","That","Such","A","An","Any","All","Some","No","Every","Each","As","In","Of","For","To","On","By","With"]),c=/\b[A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*\b/g,d=new Set(t.match(c)||[]),p=new Set(Object.keys(r)),g={};for(let w of p){let v=w[0].toLowerCase();g[v]||(g[v]=[]),g[v].push(w);}let m={};for(let w of d){let v=w.trim(),E=v.split(/\s+/);for(;E.length>0;){let y=E[0],A=y.charAt(0).toUpperCase()+y.slice(1).toLowerCase();if(f.has(A))E.shift();else break}if(v=E.join(" "),v.length<4||p.has(v))continue;let _=v[0].toLowerCase(),b=g[_]||[];if(v.length>5)for(let[y,A]of Object.entries(g))y!==_&&(b=b.concat(A));for(let y of b){if(Math.abs(v.length-y.length)>2||v===y+"s"||v===y+"es"||y===v+"s"||y===v+"es")continue;let A=kl(v,y,2);A===0||A>2||y.length<=5&&(A>1||v[0].toLowerCase()!==y[0].toLowerCase())||(m[y]||(m[y]=[]),m[y].includes(v)||m[y].push(v));}}for(let[w,v]of Object.entries(m)){v.sort();let E=v.map(_=>`'${_}'`).join(", ");l.push(`[Info] Possible Typos for '${w}': Found ${E}`);}function D(w){return w.startsWith("[Error]")?0:w.startsWith("[Warning]")?1:2}return h(D,"diag_sort_key"),l.sort((w,v)=>{let E=D(w),_=D(v);return E!==_?E-_:w.localeCompare(v)}),[r,l,a]}h(Ol,"extract_all_domain_metadata");function Ml(e){let t=[],r=e.pkg.getPartByPath("word/settings.xml");if(!r)return t;let n=h(s=>{if(!s.hasAttribute("w:val"))return true;let o=(s.getAttribute("w:val")||"").toLowerCase();return o!=="0"&&o!=="false"&&o!=="off"},"isTruthy"),a=Be(r._element,"removePersonalInformation");a.length>0&&n(a[0])&&t.push("[Warning] Privacy flag `removePersonalInformation` is enabled in word/settings.xml. Microsoft Word will strip the `w:author`, `w:initials`, and `w:date` attributes from every tracked change and comment the next time this document is opened and saved. Edits made by this agent will lose attribution, breaking audit trails and any multi-turn workflow that relies on identifying prior edits.");let i=Be(r._element,"removeDateAndTime");return i.length>0&&n(i[0])&&t.push("[Warning] Privacy flag `removeDateAndTime` is enabled in word/settings.xml. Microsoft Word will strip the `w:date` attribute from every tracked change and comment the next time this document is opened and saved. Timestamps on this agent's edits will be lost on the next Word save."),t}h(Ml,"extract_document_settings_warnings");function Rl(e,t){let[r,n,a]=Ol(e,t),i=Ml(e),s=[`
66
+ `);E.length>=2&&E[0].trim()!==""&&E[E.length-1].trim()!==""&&t.push(`- Edit ${r+1} Failed: target_text spans a paragraph boundary with body text on both sides. The paragraph break is a structural element, not literal text, so it cannot be replaced as a single span without corrupting the document. Split this into one edit per paragraph.`);}}for(let[c,d]of s){let p=this.mapper.spans.filter(m=>m.end>c&&m.start<c+d),g=new Set;for(let m of p){if(m.ins_id){let D=S(this.doc.element,"w:ins").filter(w=>w.getAttribute("w:id")===m.ins_id);if(D.length>0){let w=D[0].getAttribute("w:author");w&&w!==this.author&&g.add(w);}}if(m.comment_ids)for(let D of m.comment_ids){let w=this.mapper.comments_map[D];w&&w.author&&w.author!==this.author&&g.add(w.author);}}g.size>0&&t.push(`- Edit ${r+1} Failed: Modification targets an active insertion from another author (${Array.from(g).join(", ")}). Accept that change first or scope your edit outside of it.`);}}return t}validate_review_actions(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],a=n.type;if(a==="reply"){let i=n.target_id.replace("Com:",""),s=false,o=this.doc.pkg.parts.find(l=>l.contentType==="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml");o&&(s=S(o._element,"w:comment").some(u=>u.getAttribute("w:id")===i)),s||t.push(`- Action ${r+1} Failed: Target comment ID ${n.target_id} not found.`);}else if(a==="accept"||a==="reject"){let i=n.target_id.replace("Chg:",""),s=S(this.doc.element,"w:ins").filter(l=>l.getAttribute("w:id")===i),o=S(this.doc.element,"w:del").filter(l=>l.getAttribute("w:id")===i);s.length===0&&o.length===0&&t.push(`- Action ${r+1} Failed: Target ID ${n.target_id} not found.`);}}return t}process_batch(e,t=false){if(Array.isArray(e)&&(e=e.map(r=>{if(typeof r=="string")try{let n=JSON.parse(r);return n!==null&&typeof n=="object"?n:r}catch{return r}return r})),t){let r=new Map;for(let n of this.doc.pkg.parts)n._element&&r.set(n,n._element.cloneNode(true));try{return this._process_batch_internal(e,!0)}finally{for(let[n,a]of r.entries()){let i=n._element.ownerDocument;i&&i.documentElement&&i.replaceChild(a,i.documentElement),n._element=a;}this.mapper=new kt(this.doc),this.comments_manager=new ir(this.doc),this.clean_mapper=null;}}else return this._process_batch_internal(e,false)}_process_batch_internal(e,t=false){this.skipped_details=[];let r=e.filter(d=>d!==null&&typeof d=="object"&&["accept","reject","reply"].includes(d.type)),n=e.filter(d=>d===null||typeof d!="object"||!["accept","reject","reply"].includes(d.type));if(t){if(r.length>0){let d=this.validate_review_actions(r);if(d.length>0)throw new Pr(d)}}else {let d=[];if(r.length>0&&d.push(...this.validate_review_actions(r)),n.length>0&&d.push(...this.validate_edits(n)),d.length>0)throw new Pr(d)}let a=0,i=0;if(r.length>0){let d=this.apply_review_actions(r);if(a=d[0],i=d[1],i>0)throw new Pr(this.skipped_details);a>0&&(this.mapper._build_map(),this.clean_mapper&&this.clean_mapper._build_map());}let[s]=pa(this.mapper.full_text),l=ma(s,"").body_page_offsets,u=[],f=0,c=0;if(n.length>0)if(t)for(let d of n){let p=this.validate_edits([d]),g=this._check_punctuation_warning(d.target_text||"");if(p.length>0){c++,u.push({status:"failed",target_text:d.target_text||"",new_text:d.new_text||"",warning:g,error:p[0],critic_markup:null,clean_text:null});continue}this.apply_edits([d],l);if(d._applied_status){f++;let D=this._build_edit_context_previews(d);u.push({status:"applied",target_text:d.target_text||"",new_text:d.new_text||"",warning:g,error:null,critic_markup:D[0],clean_text:D[1],pages:d._pages||[],heading_path:d._heading_path||"",occurrences_modified:d._occurrences_modified||0,match_mode:d.match_mode||"strict"});}else {c++;let D=this.skipped_details.length>0?this.skipped_details[this.skipped_details.length-1]:"Failed to apply edit";u.push({status:"failed",target_text:d.target_text||"",new_text:d.new_text||"",warning:g,error:D,critic_markup:null,clean_text:null});}}else {let d=this.validate_edits(n);if(d.length>0)throw new Pr(d);let p=n.map(m=>JSON.parse(JSON.stringify(m)));this.apply_edits(p,l);f=p.filter(m=>m._applied_status).length,c=p.length-f;for(let m of p){let D=m._applied_status||false,w=m._error_msg||null,v=this._check_punctuation_warning(m.target_text||""),E=null,_=null;if(D){let b=this._build_edit_context_previews(m);E=b[0],_=b[1];}u.push({status:D?"applied":"failed",target_text:m.target_text||"",new_text:m.new_text||"",warning:v,error:w,critic_markup:E,clean_text:_,pages:m._pages||[],heading_path:m._heading_path||"",occurrences_modified:m._occurrences_modified||0,match_mode:m.match_mode||"strict"});}}return {actions_applied:a,actions_skipped:i,edits_applied:f,edits_skipped:c,skipped_details:this.skipped_details,edits:u,engine:"node",version:"1.10.0"}}apply_edits(e,t=[]){let r=0,n=0;if(!t||t.length===0){let[s]=pa(this.mapper.full_text);t=ma(s,"").body_page_offsets;}let a=[];for(let s of e){if(typeof s!="object"||s===null){n++;continue}s._applied_status=false,s._error_msg=null;}for(let s of e)if(!(typeof s!="object"||s===null))if(s._resolved_start_idx!==void 0&&s._resolved_start_idx!==null)a.push([s,s.new_text||null]);else if(s._match_start_index!==void 0&&s._match_start_index!==null)s._resolved_start_idx=s._match_start_index,a.push([s,s.new_text||null]);else if(s.type==="insert_row"||s.type==="delete_row"){let o=this.mapper.find_all_match_indices(s.target_text);if(o.length===0&&(this.clean_mapper||(this.clean_mapper=new kt(this.doc,true)),o=this.clean_mapper.find_all_match_indices(s.target_text)),o.length>0)s._resolved_start_idx=o[0][0],a.push([s,null]);else {n++,s._applied_status=false;let u=`- Failed to locate row target: '${(s.target_text||"").trim().substring(0,40)}...'`;this.skipped_details.push(u),s._error_msg=u;}}else {let o=this._pre_resolve_heuristic_edit(s);if(o)if(Array.isArray(o))for(let l of o)l._resolved_start_idx=l._match_start_index,l._parent_edit_ref=s,(s._resolved_start_idx===void 0||s._resolved_start_idx===null)&&(s._resolved_start_idx=l._resolved_start_idx),s._resolved_proxy_edit||(s._resolved_proxy_edit=l),a.push([l,l.new_text]);else o._resolved_start_idx=o._match_start_index,o._parent_edit_ref=s,s._resolved_start_idx=o._resolved_start_idx,s._resolved_proxy_edit=o,a.push([o,o.new_text]);else {n++,s._applied_status=false;let f=`- Failed to apply edit targeting: '${(s.target_text||"insertion").trim().substring(0,40)}...'`;this.skipped_details.push(f),s._error_msg=f;}}a.sort((s,o)=>(o[0]._resolved_start_idx||0)-(s[0]._resolved_start_idx||0));let i=[];for(let[s,o]of a){let l=s._resolved_start_idx||0,u=l+(s.target_text?s.target_text.length:0);if(i.some(([d,p])=>l<p&&u>d)){n++;let g=`- Skipped overlapping edit targeting: '${(s.target_text||"insertion").trim().substring(0,40)}...'`;this.skipped_details.push(g),s._applied_status=false,s._error_msg=g;let m=s._parent_edit_ref;m&&(m._applied_status=false,m._error_msg=g);continue}let c=false;if(s.type==="modify"?c=this._apply_single_edit_indexed(s,o,false):(s.type==="insert_row"||s.type==="delete_row")&&(c=this._apply_table_edit(s,false)),c){r++,i.push([l,u]),s._applied_status=true;let d=s._parent_edit_ref;if(d){d._applied_status=true,d._occurrences_modified=(d._occurrences_modified||0)+1;let[p,g]=this._get_heading_path_and_page(l,this.mapper.full_text,t),m=d._pages||[];m.includes(g)||m.unshift(g),d._pages=m,d._heading_path=p;}else {s._occurrences_modified=(s._occurrences_modified||0)+1;let[p,g]=this._get_heading_path_and_page(l,this.mapper.full_text,t),m=s._pages||[];m.includes(g)||m.unshift(g),s._pages=m,s._heading_path=p;}}else {n++;let g=`- Failed to apply edit targeting: '${(s.target_text||"insertion").trim().substring(0,40)}...'`;this.skipped_details.push(g),s._applied_status=false,s._error_msg=g;let m=s._parent_edit_ref;m&&(m._applied_status||(m._applied_status=false,m._error_msg=g));}}return [r,n]}apply_review_actions(e){let t=0,r=0;for(let n of e){let a=n.type;if(a==="reply"){let u=n.target_id.replace("Com:",""),f=this.comments_manager.addComment(this.author,n.text,u);this._anchor_reply_comment(u,f),t++;continue}let i=n.target_id.replace("Chg:",""),s=S(this.doc.element,"w:ins").filter(u=>u.getAttribute("w:id")===i),o=S(this.doc.element,"w:del").filter(u=>u.getAttribute("w:id")===i),l=[...s,...o];if(l.length===0){r++,this.skipped_details.push(`- Failed to apply action: Target ID ${n.target_id} not found.`);continue}for(let u of l){let f=u.tagName==="w:ins",d=(u.parentNode?u.parentNode.tagName:"")==="w:trPr";if(a==="accept")if(f)if(this._clean_wrapping_comments(u),d)u.parentNode?.removeChild(u);else {for(;u.firstChild;)u.parentNode?.insertBefore(u.firstChild,u);u.parentNode?.removeChild(u);}else if(this._clean_wrapping_comments(u),this._delete_comments_in_element(u),d){let p=u.parentNode?.parentNode;p?.parentNode?.removeChild(p);}else u.parentNode?.removeChild(u);else if(a==="reject")if(f)if(this._clean_wrapping_comments(u),this._delete_comments_in_element(u),d){let p=u.parentNode?.parentNode;p?.parentNode?.removeChild(p);}else u.parentNode?.removeChild(u);else if(this._clean_wrapping_comments(u),d)u.parentNode?.removeChild(u);else {let p=Array.from(u.getElementsByTagName("w:delText"));for(let g of p){let m=g.ownerDocument.createElement("w:t");m.textContent=g.textContent,g.hasAttribute("xml:space")&&m.setAttribute("xml:space","preserve"),g.parentNode?.replaceChild(m,g);}for(;u.firstChild;)u.parentNode?.insertBefore(u.firstChild,u);u.parentNode?.removeChild(u);}}t++;}return [t,r]}_apply_table_edit(e,t){let r=e._resolved_start_idx!==void 0&&e._resolved_start_idx!==null?e._resolved_start_idx:e._match_start_index||0,[n,a]=this.mapper.get_insertion_anchor(r,t),i=null;if(n?i=n._element:a&&(i=a._element),!i)return false;let s=i;for(;s&&s.tagName!=="w:tr";)s=s.parentNode;if(!s)return false;if(e.type==="delete_row"){let o=R(s,"w:trPr");return o||(o=s.ownerDocument.createElement("w:trPr"),s.insertBefore(o,s.firstChild)),o.appendChild(this._create_track_change_tag("w:del")),true}else if(e.type==="insert_row"){let o=s.ownerDocument.createElement("w:tr"),l=s.ownerDocument.createElement("w:trPr");o.appendChild(l),l.appendChild(this._create_track_change_tag("w:ins"));for(let u of e.cells){let f=s.ownerDocument.createElement("w:tc"),c=s.ownerDocument.createElement("w:p"),d=s.ownerDocument.createElement("w:r"),p=s.ownerDocument.createElement("w:t");p.textContent=u,u.trim()!==u&&p.setAttribute("xml:space","preserve"),d.appendChild(p),c.appendChild(d),f.appendChild(c),o.appendChild(f);}return e.position==="above"?s.parentNode?.insertBefore(o,s):Pt(o,s),true}return false}_pre_resolve_heuristic_edit(e){if(!e.target_text)return null;let t=e.regex||false,r=e.match_mode||"strict",n=this.mapper.find_all_match_indices(e.target_text,t),a=false;if(n.length===0)if(this.clean_mapper||(this.clean_mapper=new kt(this.doc,true)),n=this.clean_mapper.find_all_match_indices(e.target_text,t),n.length>0)a=true;else return null;let i=a?this.clean_mapper:this.mapper,s=[];for(let[l,u]of n){let f=i.spans.filter(c=>c.run!==null&&c.end>l&&c.start<l+u);(f.length===0||f.some(c=>!c.del_id))&&s.push([l,u]);}if(s.length===0)return null;(r==="strict"||r==="first")&&(s=s.slice(0,1));let o=[];for(let[l,u]of s){let f=i.full_text.substring(l,l+u),c=e.new_text||"";if(t&&c)try{c=f.replace(new RegExp(e.target_text),c);}catch{}let[d,p]=this._parse_markdown_style(e.target_text),[g,m]=this._parse_markdown_style(c);if(p!==m){let[_]=this._parse_markdown_style(f),b=_,y=g,A=b===y?"STYLE_ONLY":"STYLE_AND_TEXT",N=f.indexOf(_),C=l+(N!==-1?N:0),M=m!==null?m:"Normal";o.push({type:"modify",target_text:b,new_text:y,comment:e.comment,_match_start_index:C,_internal_op:A,_new_style:M,_active_mapper_ref:i});continue}if(f===c||e.target_text===c){o.push({type:"modify",target_text:f,new_text:f,comment:e.comment,_match_start_index:l,_internal_op:"COMMENT_ONLY",_active_mapper_ref:i});continue}let D="",w="",v="",E=l;if(c.startsWith(f))D="INSERTION",v=c.substring(f.length),E=l+u;else {let[_,b]=bn(f,c),y=f.length-b,A=c.length-b;w=f.substring(_,y),v=c.substring(_,A),E=l+_,!w&&v?D="INSERTION":w&&!v?D="DELETION":w&&v?D="MODIFICATION":D="COMMENT_ONLY";}o.push({type:"modify",target_text:w,new_text:v,comment:e.comment,_match_start_index:E,_internal_op:D,_active_mapper_ref:i});}return o.length===0?null:r==="all"||o.length>1?o:o[0]}_apply_single_edit_indexed(e,t,r){let n=e._internal_op,a=e._active_mapper_ref||this.mapper,i=e._resolved_start_idx!==void 0&&e._resolved_start_idx!==null?e._resolved_start_idx:e._match_start_index||0,s=e.target_text?e.target_text.length:0;if(n==="STYLE_ONLY"||n==="STYLE_AND_TEXT"){let[w,v]=a.get_insertion_anchor(i,r),E=null;if(v)E=v._element;else if(w){let _=w._element;for(;_&&_.tagName!=="w:p";)_=_.parentNode;E=_;}if(E&&e._new_style&&this._set_paragraph_style(E,e._new_style),n==="STYLE_ONLY"){if(e.comment){let _=a.find_target_runs_by_index(i,s,r);if(_.length>0){let b=_[0]._element,y=_[_.length-1]._element,A=b;for(;A&&A.tagName!=="w:p";)A=A.parentNode;let N=y;for(;N&&N.tagName!=="w:p";)N=N.parentNode;if(A&&N){let C=h((O,U)=>{let I=O;for(;I.parentNode&&I.parentNode!==U;)I=I.parentNode;return I},"ascend_to_paragraph_child"),M=C(b,A),x=C(y,N);A===N?this._attach_comment(A,M,x,e.comment):this._attach_comment_spanning(A,M,N,x,e.comment);}}}return true}e.target_text&&e.new_text?n="MODIFICATION":!e.target_text&&e.new_text?n="INSERTION":e.target_text&&!e.new_text?n="DELETION":n="COMMENT_ONLY";}let o=["DELETION","MODIFICATION"].includes(n)?this._getNextId():null,l=["INSERTION","MODIFICATION"].includes(n)?this._getNextId():null;if(n==="COMMENT_ONLY"){let w=a.find_target_runs_by_index(i,s,r);if(w.length===0)return false;if(!e.comment)return true;let v=w[0]._element,E=w[w.length-1]._element,_=v;for(;_&&_.tagName!=="w:p";)_=_.parentNode;let b=E;for(;b&&b.tagName!=="w:p";)b=b.parentNode;if(!_||!b)return false;let y=h((C,M)=>{let x=C;for(;x.parentNode&&x.parentNode!==M;)x=x.parentNode;return x},"ascend_to_paragraph_child"),A=y(v,_),N=y(E,b);return _===b?this._attach_comment(_,A,N,e.comment):this._attach_comment_spanning(_,A,b,N,e.comment),true}if(n==="INSERTION"){let[w,v]=a.get_insertion_anchor(i,r);if(!w&&!v)return false;let E=e.new_text||"",_=/\n\s*$/.test(E),b=null;{let N=a.spans.filter(C=>C.paragraph!==null&&C.start===i);N.length>0&&N[0].paragraph&&(b=N[0].paragraph._element);}if(_&&b&&b.parentNode){let N=b.parentNode,C=this.doc.part._element.ownerDocument,M=E.split(/[\r\n]+/).filter(I=>I!==""),x=null,O=null,U=null;for(let I of M){let[Y,z]=this._parse_markdown_style(I),B=C.createElement("w:p");if(z)this._set_paragraph_style(B,z);else {let K=R(b,"w:pPr");K&&B.appendChild(K.cloneNode(true));}let L=R(B,"w:pPr");L||(L=C.createElement("w:pPr"),B.insertBefore(L,B.firstChild));let k=R(L,"w:rPr");k||(k=C.createElement("w:rPr"),L.appendChild(k)),k.appendChild(this._create_track_change_tag("w:ins","",l));let H=this._build_tracked_ins_for_line(Y,w,l,C);H&&B.appendChild(H),N.insertBefore(B,b),x||(x=B),O=B,U=H;}if(x){if(e.comment&&O&&U){let I=h((z,B)=>{let L=z;for(;L.parentNode&&L.parentNode!==B;)L=L.parentNode;return L},"ascend"),Y=S(x,"w:ins")[0]||x;this._attach_comment_spanning(x,I(Y,x),O,I(U,O),e.comment);}return true}}let y=this._track_insert_multiline(e.new_text||"",w,v,l);if(!y.first_node)return false;if(y.first_node.tagName==="w:ins"&&(w?Pt(y.first_node,w._element):v&&v._element.appendChild(y.first_node)),e.comment){let N=h((C,M)=>{let x=C;for(;x.parentNode&&x.parentNode!==M;)x=x.parentNode;return x},"ascend_to_paragraph_child");if(y.last_p&&y.last_ins){let C=y.first_node;for(;C&&C.tagName!=="w:p";)C=C.parentNode;if(C){let M=y.first_node;y.first_node.tagName==="w:p"&&(M=S(y.first_node,"w:ins")[0]||y.first_node);let x=N(M,C),O=N(y.last_ins,y.last_p);this._attach_comment_spanning(C,x,y.last_p,O,e.comment);}}else {let C=y.first_node;for(;C&&C.tagName!=="w:p";)C=C.parentNode;if(C){let M=y.first_node;y.first_node.tagName==="w:p"&&(M=S(y.first_node,"w:ins")[0]||y.first_node);let x=N(M,C);this._attach_comment(C,x,x,e.comment);}}}return true}let u=a.find_target_runs_by_index(i,s,r),f=a.get_virtual_spans_in_range(i,s);if(u.length===0&&f.length===0)return false;let c=new Set;for(let w of u){let v=w._element.parentNode;for(;v&&v.tagName!=="w:p";)v=v.parentNode;v&&c.add(v);}let d=null,p=null;for(let w of u){let v=this._create_track_change_tag("w:del","",o),E=w._element.cloneNode(true);Array.from(E.getElementsByTagName("w:t")).forEach(b=>{let y=E.ownerDocument.createElement("w:delText");y.textContent=b.textContent,b.hasAttribute("xml:space")&&y.setAttribute("xml:space","preserve"),E.replaceChild(y,b);}),v.appendChild(E),w._element.parentNode?.replaceChild(v,w._element),d===null&&(d=v),p=v;}let g=null,m=null,D=null;if(n==="MODIFICATION"&&e.new_text&&p){let w=p;for(;w&&w.tagName!=="w:p";)w=w.parentNode;let v=w?new Ze(w,null):null,E=u.length>0?u[u.length-1]:null,_=this._track_insert_multiline(e.new_text,E,v,l);_.first_node&&(_.first_node.tagName==="w:ins"?(Pt(_.first_node,p),g=_.first_node):g=_.last_ins,m=_.last_p,D=_.last_ins);}if(n==="DELETION"||n==="MODIFICATION"){if(n==="MODIFICATION"&&u.length===0&&f.length>0&&e.new_text){let w=f[0];if(w.paragraph){let v=w.paragraph._element,E=S(v,"w:r"),_=E.length>0?new Ke(E[E.length-1],w.paragraph):null,b=this._track_insert_multiline(e.new_text,_,w.paragraph,l);b.first_node&&v.appendChild(b.first_node);}}for(let w of [...f].reverse())if(w.paragraph){let v=w.paragraph._element,E=at(v);for(;E&&E.tagName!=="w:p";)E=at(E);if(E&&E.tagName==="w:p"){let _=R(v,"w:pPr");_||(_=v.ownerDocument.createElement("w:pPr"),v.insertBefore(_,v.firstChild));let b=R(_,"w:rPr");b||(b=v.ownerDocument.createElement("w:rPr"),_.appendChild(b));let y=this._create_track_change_tag("w:del");b.appendChild(y);let A=Array.from(E.childNodes);for(let N of A)N.nodeType===1&&N.tagName==="w:pPr"||v.appendChild(N);E.parentNode&&E.parentNode.removeChild(E);}}}if(e.comment&&d!==null){let w,v;if(m&&D)w=D,v=m;else {let A=g!==null?g:p;for(w=A,v=A;v&&v.tagName!=="w:p";)v=v.parentNode;}let E=d;for(;E&&E.tagName!=="w:p";)E=E.parentNode;if(!E||!v)return true;let _=h((A,N)=>{let C=A;for(;C.parentNode&&C.parentNode!==N;)C=C.parentNode;return C},"ascend_to_paragraph_child"),b=_(d,E),y=_(w,v);E===v?this._attach_comment(E,b,y,e.comment):this._attach_comment_spanning(E,b,v,y,e.comment);}for(let w of c){let v=false;for(let E of ["w:t","w:tab","w:br"]){let _=S(w,E);for(let b of _){let y=false,A=b.parentNode;for(;A&&A!==w.parentNode;){if(A.tagName==="w:del"){y=true;break}A=A.parentNode;}if(!y){if(E==="w:t"&&!b.textContent)continue;v=true;break}}if(v)break}if(!v){let E=R(w,"w:pPr");E||(E=w.ownerDocument.createElement("w:pPr"),w.insertBefore(E,w.firstChild));let _=R(E,"w:rPr");if(_||(_=w.ownerDocument.createElement("w:rPr"),E.appendChild(_)),!R(_,"w:del")){let b=this._create_track_change_tag("w:del");_.appendChild(b);}}}return true}};function Be(e,t){let r=[],n=e.getElementsByTagName("*");for(let a=0;a<n.length;a++){let i=n[a].tagName;(i===t||i.endsWith(":"+t))&&r.push(n[a]);}return r}h(Be,"findDescendantsByLocalName");function hl(e){let t=0;function r(s,o){let l=s?s.toString():"",u=o?o.toString():"";return l===u}h(r,"areRunsIdentical");function n(s){let o=["w:t","w:tab","w:br","w:cr","w:delText","w:rPr"];for(let l=0;l<s.childNodes.length;l++){let u=s.childNodes[l];if(u.nodeType===1){let f=u.tagName;if(!o.includes(f))return true}}return false}h(n,"hasSpecialContent");function a(s){let o=Array.from(s.childNodes).filter(u=>u.nodeType===1),l=0;for(;l<o.length-1;){let u=o[l],f=o[l+1];if(u.tagName==="w:r"&&f.tagName==="w:r"&&!n(u)&&!n(f)){let c=R(u,"w:rPr"),d=R(f,"w:rPr");if(r(c,d)){let p=null;for(let m=0;m<u.childNodes.length;m++){let D=u.childNodes[m];D.nodeType===1&&(D.tagName==="w:t"||D.tagName==="w:delText")&&(p=D);}let g=Array.from(f.childNodes).filter(m=>m.nodeType===1);for(let m of g)if(m.tagName!=="w:rPr")if((m.tagName==="w:t"||m.tagName==="w:delText")&&p&&p.tagName===m.tagName){let D=p.textContent||"",w=m.textContent||"",v=D+w;p.textContent=v,v.trim()!==v&&p.setAttribute("xml:space","preserve");}else u.appendChild(m),(m.tagName==="w:t"||m.tagName==="w:delText")&&(p=m);s.removeChild(f),o.splice(l+1,1),t++;continue}}["w:ins","w:del","w:hyperlink","w:sdt","w:smartTag","w:fldSimple","w:sdtContent"].includes(u.tagName)&&a(u),l++;}if(o.length>0){let u=o[o.length-1];["w:ins","w:del","w:hyperlink","w:sdt","w:smartTag","w:fldSimple","w:sdtContent"].includes(u.tagName)&&a(u);}}h(a,"coalesceContainer");let i=S(e.element,"w:p");for(let s of i)a(s);return t?[`Adjacent identical runs coalesced: ${t}`]:[]}h(hl,"coalesce_runs");function dl(e){let t=0,r=["w:rsidR","w:rsidRPr","w:rsidRDefault","w:rsidP","w:rsidDel","w:rsidSect","w:rsidTr"],n=e.element.getElementsByTagName("*");for(let i=0;i<n.length;i++)for(let s of r)n[i].hasAttribute(s)&&(n[i].removeAttribute(s),t++);let a=S(e.element,"w:rsids");for(let i of a)i.parentNode&&(i.parentNode.removeChild(i),t++);return t?[`rsid attributes: ${t} removed`]:[]}h(dl,"strip_rsid");function pl(e){let t=0,r=["w14:paraId","w14:textId"],n=e.element.getElementsByTagName("*");for(let a=0;a<n.length;a++)for(let i of r)n[a].hasAttribute(i)&&(n[a].removeAttribute(i),t++);return t?[`Paragraph/text IDs: ${t} removed`]:[]}h(pl,"strip_para_ids");function ml(e){let t=S(e.element,"w:proofErr");return t.forEach(r=>r.parentNode?.removeChild(r)),t.length?[`Spell check markers: ${t.length} removed`]:[]}h(ml,"strip_proof_errors");function gl(e){let t=0;for(let r of ["w:rPr","w:pPr"]){let n=S(e.element,r);for(let a of n)(a.childNodes.length===0||a.childNodes.length===1&&a.childNodes[0].nodeType===3&&!a.childNodes[0].textContent?.trim())&&(a.parentNode?.removeChild(a),t++);}return t?[`Empty property elements: ${t} removed`]:[]}h(gl,"strip_empty_properties");function _l(e){let t=0,r=S(e.element,"w:rPr");for(let n of r)if(R(n,"w:vanish")||R(n,"w:webHidden")){let a=n.parentNode;a&&a.tagName==="w:r"&&a.parentNode&&(a.parentNode.removeChild(a),t++);}return t?[`Hidden text runs: ${t} removed`]:[]}h(_l,"strip_hidden_text");function wa(e){let t=S(e.element,"w:ins").length,r=S(e.element,"w:del").length,n=S(e.element,"w:rPrChange").length+S(e.element,"w:pPrChange").length+S(e.element,"w:sectPrChange").length;return [t,r,n]}h(wa,"count_tracked_changes");function wl(e){let t=new Set;for(let r of ["w:ins","w:del","w:rPrChange","w:pPrChange","w:sectPrChange"])for(let n of S(e.element,r)){let a=n.getAttribute("w:author");a&&t.add(a);}return t}h(wl,"get_track_change_authors");function va(e){let t=[],r=S(e,"w:t");for(let a of r)a.textContent&&t.push(a.textContent);let n=S(e,"w:delText");for(let a of n)a.textContent&&t.push(a.textContent);return t.join("")}h(va,"_getElementText");function Mr(e,t=60){let r=e.replace(/\n/g," ").trim();return r.length<=t?r:r.substring(0,t-3)+"..."}h(Mr,"_truncate");function vl(e){let t=[],r=S(e.element,"w:ins"),n=S(e.element,"w:del");for(let s of r){let o=va(s).trim();o&&t.push(` Accepted insertion: "${Mr(o,60)}"`);}for(let s of n){let o=va(s).trim();o&&t.push(` Accepted deletion of: "${Mr(o,60)}"`);}new Sn(e).accept_all_revisions();for(let s of ["w:rPrChange","w:pPrChange","w:sectPrChange"])for(let o of S(e.element,s))o.parentNode?.removeChild(o);let i=r.length+n.length;return i?[`Tracked changes auto-accepted: ${i}`].concat(t):[]}h(vl,"accept_all_tracked_changes");function yl(e){let t=Br(e.pkg),r=[],n=0,a=0;for(let[i,s]of Object.entries(t))s.resolved?a++:n++,r.push({id:i,...s});return {total:r.length,open:n,resolved:a,comments:r}}h(yl,"get_comments_summary");function El(e){let t=Br(e.pkg),r=Object.keys(t);if(r.length===0)return [];let n=[],a=new ir(e);for(let[l,u]of Object.entries(t)){let f=u.resolved?"[Resolved]":"[Open]";n.push(` ${f} "${Mr(u.text||"",60)}" (${u.author||"Unknown"})`),a.deleteComment(l);}for(let l of ["w:commentRangeStart","w:commentRangeEnd"])for(let u of S(e.element,l))u.parentNode?.removeChild(u);let i=S(e.element,"w:commentReference");for(let l of i){let u=l.parentNode;u&&((u.tagName==="w:r"||u.tagName.endsWith(":r"))&&Array.from(u.childNodes).filter(c=>c.nodeType===1&&c.tagName!=="w:rPr"&&c.tagName!=="rPr").length<=1?u.parentNode?.removeChild(u):u.removeChild(l));}let s=Object.values(t).filter(l=>l.resolved).length,o=Object.values(t).filter(l=>!l.resolved).length;return [`Comments removed: ${r.length} (${s} resolved, ${o} open)`].concat(n)}h(El,"remove_all_comments");function Dl(e){let t=e.pkg,r=new Set;for(let a of t.parts)if(a.partname.toLowerCase().includes("comments")){r.add(a.partname);let i=a.partname.startsWith("/")?a.partname:"/"+a.partname,s=a.partname.startsWith("/")?a.partname.substring(1):a.partname;r.add(i),r.add(s);}if(r.size===0)return;for(let a of t.parts)if(a.partname.endsWith(".rels")){let i=S(a._element,"Relationship"),s=[];for(let o of i)if((o.getAttribute("Target")||"").toLowerCase().includes("comments")){s.push(o);let u=a.partname.replace("/_rels/","/").replace(".rels",""),f=t.getPartByPath(u);if(f){let c=o.getAttribute("Id");c&&f.rels.delete(c);}}for(let o of s)o.parentNode?.removeChild(o);}let n=t.getPartByPath("[Content_Types].xml");if(n){let a=S(n._element,"Override"),i=[];for(let s of a){let o=s.getAttribute("PartName")||"";(r.has(o)||o.toLowerCase().includes("comments"))&&i.push(s);}for(let s of i)s.parentNode?.removeChild(s);}t.parts=t.parts.filter(a=>!a.partname.toLowerCase().includes("comments"));for(let a of Object.keys(t.unzipped))a.toLowerCase().includes("comments")&&delete t.unzipped[a];}h(Dl,"eject_comment_parts");function bl(e,t){let r=new ir(e);if(!r.commentsPart)return [];let n=new Set,a=S(r.commentsPart._element,"w:comment");for(let i of a){let s=i.getAttribute("w:author");if(s&&(n.add(s),i.setAttribute("w:author",t)),i.hasAttribute("w:initials")){let o=t.split(" ").filter(Boolean).map(l=>l[0]).join("").toUpperCase();i.setAttribute("w:initials",o);}}return n.size?[`Comment authors replaced: ${Array.from(n).sort().join(", ")} \u2192 "${t}"`]:[]}h(bl,"replace_comment_authors");function Al(e,t){let r=new Set;for(let n of ["w:ins","w:del","w:rPrChange","w:pPrChange"])for(let a of S(e.element,n)){let i=a.getAttribute("w:author");i&&(r.add(i),a.setAttribute("w:author",t));}return r.size?[`Track change authors replaced: ${Array.from(r).sort().join(", ")} \u2192 "${t}"`]:[]}h(Al,"replace_change_authors");function Nl(e){let t=0,r="2025-01-01T00:00:00Z";for(let n of ["w:ins","w:del","w:rPrChange","w:pPrChange"])for(let a of S(e.element,n))a.hasAttribute("w:date")&&(a.setAttribute("w:date",r),t++);return t?[`Track change timestamps: ${t} normalized`]:[]}h(Nl,"normalize_change_dates");function Cl(e){let t=[],r=e.pkg.getPartByPath("docProps/core.xml");r&&(Be(r._element,"creator").forEach(o=>{o.textContent&&(t.push(`Author: ${o.textContent}`),o.textContent="");}),Be(r._element,"lastModifiedBy").forEach(o=>{o.textContent&&(t.push(`Last modified by: ${o.textContent}`),o.textContent="");}),Be(r._element,"revision").forEach(o=>{o.textContent&&parseInt(o.textContent)>1&&(t.push(`Revision count: ${o.textContent} \u2192 1`),o.textContent="1");}));let n=e.pkg.getPartByPath("docProps/app.xml");if(n){let a=n._element,i=["TotalTime","Words","Characters","Paragraphs","Lines","CharactersWithSpaces"];for(let o of i)Be(a,o).forEach(l=>{l.textContent&&l.textContent!=="0"&&(o==="TotalTime"&&t.push(`Total editing time: ${l.textContent} minutes`),l.textContent="0");});let s=["Template","Manager","Company"];for(let o of s)Be(a,o).forEach(l=>{l.textContent&&(t.push(`${o}: ${l.textContent}`),l.textContent="");});}return t.length?["Metadata scrubbed:",...t.map(a=>` ${a}`)]:[]}h(Cl,"scrub_doc_properties");function Tl(e){let t=false,r="1970-01-01T00:00:00Z",n=e.pkg.getPartByPath("docProps/core.xml");if(n)for(let a of ["created","modified","lastPrinted"])Be(n._element,a).forEach(i=>{i.textContent&&i.textContent!==r&&(i.textContent=r,t=true);});return t?["Timestamps normalized to epoch"]:[]}h(Tl,"scrub_timestamps");function xl(e){let t=e.pkg.parts.filter(s=>s.partname.includes("/customXml"));if(t.length===0)return [];let r=new Set(t.map(s=>s.partname));e.pkg.parts=e.pkg.parts.filter(s=>!r.has(s.partname));let n=h(s=>{let o=[];for(let l of S(s._element,"Relationship")){let u=l.getAttribute("Target");u&&u.includes("customXml")&&o.push(l);}o.forEach(l=>l.parentNode?.removeChild(l));},"removeRelationsTo"),a=e.pkg.getPartByPath("_rels/.rels");a&&n(a);let i=e.pkg.getOrCreateRelsPart(e.part.partname);i&&n(i);for(let s of S(e.element,"w:sdtPr"))_u(s,"w:dataBinding").forEach(o=>s.removeChild(o));return [`Custom XML parts: ${t.length} removed`]}h(xl,"strip_custom_xml");function Sl(e){let t=0;for(let r of Be(e.element,"docPr")){let n=r.getAttribute("descr");if(n){let a=n.length<10,i=n.includes(".")&&n.length<60;(a||i)&&(r.removeAttribute("descr"),t++);}}return t?[`Image alt text: ${t} auto-generated descriptions removed`]:[]}h(Sl,"strip_image_alt_text");function Il(e){let t=["sharepoint.com","onedrive.com",".internal","intranet","localhost","10.","192.168.","172.16."],r=[],n=e.pkg.getOrCreateRelsPart(e.part.partname);for(let a of S(n._element,"Relationship"))if(a.getAttribute("TargetMode")==="External"){let i=a.getAttribute("Target")||"";for(let s of t)if(i.toLowerCase().includes(s.toLowerCase())){r.push(`Hyperlink targets internal URL: ${Mr(i,80)}`);break}}return r}h(Il,"audit_hyperlinks");function kl(e,t,r=2){if(e===t)return 0;if(Math.abs(e.length-t.length)>r)return r+1;if(e.length===0)return t.length<=r?t.length:r+1;if(t.length===0)return e.length<=r?e.length:r+1;if(e.length>t.length){let a=e;e=t,t=a;}let n=Array.from({length:e.length+1},(a,i)=>i);for(let a=1;a<=t.length;a++){let i=[a],s=a;for(let o=1;o<=e.length;o++){let l=e[o-1]===t[a-1]?0:1,u=Math.min(n[o]+1,i[o-1]+1,n[o-1]+l);i.push(u),u<s&&(s=u);}if(s>r)return r+1;n=i;}return n[e.length]<=r?n[e.length]:r+1}h(kl,"boundedLevenshtein");function Pl(e){let t="",r=S(e._element,"w:r");for(let n of r)t+=st(new Ke(n,e));return t}h(Pl,"_get_paragraph_text");function Ol(e,t){let r={},n=new Set,a={},i=[],s=/^(?:[\d.\-()a-zA-Z]+\s*)?["“]([A-Z][A-Za-z0-9\s\-&'’]{1,60})["”]/,o=/\([^)]*?["“]([A-Z][A-Za-z0-9\s\-&'’]{1,60})["”][^)]*?\)/g;for(let w of xn(e)){if(!(w instanceof Ze))continue;let v=Pl(w).trim();if(!v)continue;let E=[],_=v.match(s);_&&E.push(_[1].trim());let b=v.matchAll(o);for(let N of b)E.push(N[1].trim());for(let N of E)r[N]?n.add(N):r[N]={count:0};let y=v.length>60?v.substring(0,60)+"...":v,A=S(w._element,"*");for(let N of A){if(N.tagName==="w:bookmarkStart"){let M=N.getAttribute("w:name");M&&(!M.startsWith("_")||M.startsWith("_Ref"))&&(a[M]||(a[M]={anchored_to:y,referenced_from:[]}));}let C=null;if(N.tagName==="w:fldSimple"){let x=(N.getAttribute("w:instr")||"").trim().split(/\s+/);x.length>1&&x[0]==="REF"&&(C=x[1]);}else if(N.tagName==="w:instrText"){let x=(N.textContent||"").trim().split(/\s+/);x.length>1&&x[0]==="REF"&&(C=x[1]);}C&&i.push([C,y]);}}for(let[w,v]of i)a[w]&&a[w].referenced_from.push(v);let l=[],u=Object.keys(r);if(u.length>0){let w=u.sort((b,y)=>y.length-b.length),v=h(b=>b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeRegExp"),E=w.map(v).join("|"),_=new RegExp(`(?<!["\u201C])\\b(${E})\\b(?![\u201D"])`,"g");for(let b of t.matchAll(_)){let y=b[1];r[y]&&r[y].count++;}for(let b of u)r[b].count===0&&(delete r[b],n.delete(b));}for(let w of n)l.push(`[Error] Duplicate Definition: '${w}' is defined multiple times.`);let f=new Set(["The","This","That","Such","A","An","Any","All","Some","No","Every","Each","As","In","Of","For","To","On","By","With"]),c=/\b[A-Z][a-zA-Z]*(?:\s+[A-Z][a-zA-Z]*)*\b/g,d=new Set(t.match(c)||[]),p=new Set(Object.keys(r)),g={};for(let w of p){let v=w[0].toLowerCase();g[v]||(g[v]=[]),g[v].push(w);}let m={};for(let w of d){let v=w.trim(),E=v.split(/\s+/);for(;E.length>0;){let y=E[0],A=y.charAt(0).toUpperCase()+y.slice(1).toLowerCase();if(f.has(A))E.shift();else break}if(v=E.join(" "),v.length<4||p.has(v))continue;let _=v[0].toLowerCase(),b=g[_]||[];if(v.length>5)for(let[y,A]of Object.entries(g))y!==_&&(b=b.concat(A));for(let y of b){if(Math.abs(v.length-y.length)>2||v===y+"s"||v===y+"es"||y===v+"s"||y===v+"es")continue;let A=kl(v,y,2);A===0||A>2||y.length<=5&&(A>1||v[0].toLowerCase()!==y[0].toLowerCase())||(m[y]||(m[y]=[]),m[y].includes(v)||m[y].push(v));}}for(let[w,v]of Object.entries(m)){v.sort();let E=v.map(_=>`'${_}'`).join(", ");l.push(`[Info] Possible Typos for '${w}': Found ${E}`);}function D(w){return w.startsWith("[Error]")?0:w.startsWith("[Warning]")?1:2}return h(D,"diag_sort_key"),l.sort((w,v)=>{let E=D(w),_=D(v);return E!==_?E-_:w.localeCompare(v)}),[r,l,a]}h(Ol,"extract_all_domain_metadata");function Ml(e){let t=[],r=e.pkg.getPartByPath("word/settings.xml");if(!r)return t;let n=h(s=>{if(!s.hasAttribute("w:val"))return true;let o=(s.getAttribute("w:val")||"").toLowerCase();return o!=="0"&&o!=="false"&&o!=="off"},"isTruthy"),a=Be(r._element,"removePersonalInformation");a.length>0&&n(a[0])&&t.push("[Warning] Privacy flag `removePersonalInformation` is enabled in word/settings.xml. Microsoft Word will strip the `w:author`, `w:initials`, and `w:date` attributes from every tracked change and comment the next time this document is opened and saved. Edits made by this agent will lose attribution, breaking audit trails and any multi-turn workflow that relies on identifying prior edits.");let i=Be(r._element,"removeDateAndTime");return i.length>0&&n(i[0])&&t.push("[Warning] Privacy flag `removeDateAndTime` is enabled in word/settings.xml. Microsoft Word will strip the `w:date` attribute from every tracked change and comment the next time this document is opened and saved. Timestamps on this agent's edits will be lost on the next Word save."),t}h(Ml,"extract_document_settings_warnings");function Rl(e,t){let[r,n,a]=Ol(e,t),i=Ml(e),s=[`
67
67
 
68
68
  ---`,"","<!-- READONLY_BOUNDARY_START -->","# Document Structure (Read-Only)","The content below is metadata describing the document's reference structure. Do not include this section in any tracked changes or edits \u2014 it is for your context only and will be discarded on write."],o=false;if(i.length>0){o=true,s.push(`
69
69
  ## Document Settings`);for(let l of i)s.push(`- ${l}`);}if(Object.keys(r).length>0){o=true,s.push(`
@@ -1 +1 @@
1
- {"inputs":{"nodes/Adeu/GenericFunctions.ts":{"bytes":14305,"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts":{"bytes":8420,"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"shims/module.js":{"bytes":224,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/fflate/esm/index.mjs":{"bytes":91765,"imports":[{"path":"shims/module.js","kind":"import-statement","original":"module"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../node_modules/@xmldom/xmldom/lib/conventions.js":{"bytes":13399,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/errors.js":{"bytes":6675,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/grammar.js":{"bytes":22988,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/dom.js":{"bytes":124722,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"../../node_modules/@xmldom/xmldom/lib/grammar.js","kind":"require-call","original":"./grammar"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/entities.js":{"bytes":44533,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/sax.js":{"bytes":29094,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/grammar.js","kind":"require-call","original":"./grammar"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/dom-parser.js":{"bytes":19949,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/dom.js","kind":"require-call","original":"./dom"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"../../node_modules/@xmldom/xmldom/lib/entities.js","kind":"require-call","original":"./entities"},{"path":"../../node_modules/@xmldom/xmldom/lib/sax.js","kind":"require-call","original":"./sax"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/index.js":{"bytes":1595,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"../../node_modules/@xmldom/xmldom/lib/dom.js","kind":"require-call","original":"./dom"},{"path":"../../node_modules/@xmldom/xmldom/lib/dom-parser.js","kind":"require-call","original":"./dom-parser"}],"format":"cjs"},"../../node_modules/diff-match-patch/index.js":{"bytes":78052,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../core/dist/index.js":{"bytes":252066,"imports":[{"path":"../../node_modules/fflate/esm/index.mjs","kind":"import-statement","original":"fflate"},{"path":"../../node_modules/@xmldom/xmldom/lib/index.js","kind":"import-statement","original":"@xmldom/xmldom"},{"path":"../../node_modules/diff-match-patch/index.js","kind":"import-statement","original":"diff-match-patch"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/extractMarkdown.operation.ts":{"bytes":2793,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/applyEdits.operation.ts":{"bytes":13053,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/generateDiff.operation.ts":{"bytes":6988,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/finalizeDocument.operation.ts":{"bytes":7710,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/index.ts":{"bytes":6044,"imports":[{"path":"nodes/Adeu/descriptions/extractMarkdown.operation.ts","kind":"import-statement","original":"./extractMarkdown.operation"},{"path":"nodes/Adeu/descriptions/applyEdits.operation.ts","kind":"import-statement","original":"./applyEdits.operation"},{"path":"nodes/Adeu/descriptions/generateDiff.operation.ts","kind":"import-statement","original":"./generateDiff.operation"},{"path":"nodes/Adeu/descriptions/finalizeDocument.operation.ts","kind":"import-statement","original":"./finalizeDocument.operation"},{"path":"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts","kind":"import-statement","original":"./hydrateToolOutput.operation"}],"format":"esm"},"nodes/Adeu/Adeu.node.ts":{"bytes":5930,"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts","kind":"import-statement","original":"./descriptions/hydrateToolOutput.operation"},{"path":"nodes/Adeu/descriptions/index.ts","kind":"import-statement","original":"./descriptions"},{"path":"nodes/Adeu/descriptions/extractMarkdown.operation.ts","kind":"import-statement","original":"./descriptions/extractMarkdown.operation"},{"path":"nodes/Adeu/descriptions/applyEdits.operation.ts","kind":"import-statement","original":"./descriptions/applyEdits.operation"},{"path":"nodes/Adeu/descriptions/generateDiff.operation.ts","kind":"import-statement","original":"./descriptions/generateDiff.operation"},{"path":"nodes/Adeu/descriptions/finalizeDocument.operation.ts","kind":"import-statement","original":"./descriptions/finalizeDocument.operation"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"./GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/nodes/Adeu/Adeu.node.js":{"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"n8n-workflow","kind":"import-statement","external":true}],"exports":["Adeu"],"entryPoint":"nodes/Adeu/Adeu.node.ts","inputs":{"shims/module.js":{"bytesInOutput":121},"../../node_modules/@xmldom/xmldom/lib/conventions.js":{"bytesInOutput":2426},"../../node_modules/@xmldom/xmldom/lib/errors.js":{"bytesInOutput":2862},"../../node_modules/@xmldom/xmldom/lib/grammar.js":{"bytesInOutput":4480},"../../node_modules/@xmldom/xmldom/lib/dom.js":{"bytesInOutput":31528},"../../node_modules/@xmldom/xmldom/lib/entities.js":{"bytesInOutput":35900},"../../node_modules/@xmldom/xmldom/lib/sax.js":{"bytesInOutput":12549},"../../node_modules/@xmldom/xmldom/lib/dom-parser.js":{"bytesInOutput":5025},"../../node_modules/@xmldom/xmldom/lib/index.js":{"bytesInOutput":1094},"../../node_modules/diff-match-patch/index.js":{"bytesInOutput":19270},"nodes/Adeu/Adeu.node.ts":{"bytesInOutput":3743},"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts":{"bytesInOutput":5292},"nodes/Adeu/GenericFunctions.ts":{"bytesInOutput":6014},"../../node_modules/fflate/esm/index.mjs":{"bytesInOutput":13379},"../core/dist/index.js":{"bytesInOutput":106451},"nodes/Adeu/descriptions/extractMarkdown.operation.ts":{"bytesInOutput":1587},"nodes/Adeu/descriptions/applyEdits.operation.ts":{"bytesInOutput":8088},"nodes/Adeu/descriptions/generateDiff.operation.ts":{"bytesInOutput":4279},"nodes/Adeu/descriptions/finalizeDocument.operation.ts":{"bytesInOutput":4878},"nodes/Adeu/descriptions/index.ts":{"bytesInOutput":4579}},"bytes":274155}}}
1
+ {"inputs":{"nodes/Adeu/GenericFunctions.ts":{"bytes":14305,"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts":{"bytes":8420,"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"shims/module.js":{"bytes":224,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/fflate/esm/index.mjs":{"bytes":91765,"imports":[{"path":"shims/module.js","kind":"import-statement","original":"module"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"../../node_modules/@xmldom/xmldom/lib/conventions.js":{"bytes":13399,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/errors.js":{"bytes":6675,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/grammar.js":{"bytes":22988,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/dom.js":{"bytes":124722,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"../../node_modules/@xmldom/xmldom/lib/grammar.js","kind":"require-call","original":"./grammar"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/entities.js":{"bytes":44533,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/sax.js":{"bytes":29094,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/grammar.js","kind":"require-call","original":"./grammar"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/dom-parser.js":{"bytes":19949,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/dom.js","kind":"require-call","original":"./dom"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"../../node_modules/@xmldom/xmldom/lib/entities.js","kind":"require-call","original":"./entities"},{"path":"../../node_modules/@xmldom/xmldom/lib/sax.js","kind":"require-call","original":"./sax"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../../node_modules/@xmldom/xmldom/lib/index.js":{"bytes":1595,"imports":[{"path":"../../node_modules/@xmldom/xmldom/lib/conventions.js","kind":"require-call","original":"./conventions"},{"path":"../../node_modules/@xmldom/xmldom/lib/errors.js","kind":"require-call","original":"./errors"},{"path":"../../node_modules/@xmldom/xmldom/lib/dom.js","kind":"require-call","original":"./dom"},{"path":"../../node_modules/@xmldom/xmldom/lib/dom-parser.js","kind":"require-call","original":"./dom-parser"}],"format":"cjs"},"../../node_modules/diff-match-patch/index.js":{"bytes":78052,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"cjs"},"../core/dist/index.js":{"bytes":252569,"imports":[{"path":"../../node_modules/fflate/esm/index.mjs","kind":"import-statement","original":"fflate"},{"path":"../../node_modules/@xmldom/xmldom/lib/index.js","kind":"import-statement","original":"@xmldom/xmldom"},{"path":"../../node_modules/diff-match-patch/index.js","kind":"import-statement","original":"diff-match-patch"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/extractMarkdown.operation.ts":{"bytes":2793,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/applyEdits.operation.ts":{"bytes":13053,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/generateDiff.operation.ts":{"bytes":6988,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/finalizeDocument.operation.ts":{"bytes":7710,"imports":[{"path":"../core/dist/index.js","kind":"import-statement","original":"@adeu/core"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"../GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"nodes/Adeu/descriptions/index.ts":{"bytes":6044,"imports":[{"path":"nodes/Adeu/descriptions/extractMarkdown.operation.ts","kind":"import-statement","original":"./extractMarkdown.operation"},{"path":"nodes/Adeu/descriptions/applyEdits.operation.ts","kind":"import-statement","original":"./applyEdits.operation"},{"path":"nodes/Adeu/descriptions/generateDiff.operation.ts","kind":"import-statement","original":"./generateDiff.operation"},{"path":"nodes/Adeu/descriptions/finalizeDocument.operation.ts","kind":"import-statement","original":"./finalizeDocument.operation"},{"path":"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts","kind":"import-statement","original":"./hydrateToolOutput.operation"}],"format":"esm"},"nodes/Adeu/Adeu.node.ts":{"bytes":5930,"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts","kind":"import-statement","original":"./descriptions/hydrateToolOutput.operation"},{"path":"nodes/Adeu/descriptions/index.ts","kind":"import-statement","original":"./descriptions"},{"path":"nodes/Adeu/descriptions/extractMarkdown.operation.ts","kind":"import-statement","original":"./descriptions/extractMarkdown.operation"},{"path":"nodes/Adeu/descriptions/applyEdits.operation.ts","kind":"import-statement","original":"./descriptions/applyEdits.operation"},{"path":"nodes/Adeu/descriptions/generateDiff.operation.ts","kind":"import-statement","original":"./descriptions/generateDiff.operation"},{"path":"nodes/Adeu/descriptions/finalizeDocument.operation.ts","kind":"import-statement","original":"./descriptions/finalizeDocument.operation"},{"path":"nodes/Adeu/GenericFunctions.ts","kind":"import-statement","original":"./GenericFunctions"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/nodes/Adeu/Adeu.node.js":{"imports":[{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"n8n-workflow","kind":"import-statement","external":true},{"path":"n8n-workflow","kind":"import-statement","external":true}],"exports":["Adeu"],"entryPoint":"nodes/Adeu/Adeu.node.ts","inputs":{"shims/module.js":{"bytesInOutput":121},"../../node_modules/@xmldom/xmldom/lib/conventions.js":{"bytesInOutput":2426},"../../node_modules/@xmldom/xmldom/lib/errors.js":{"bytesInOutput":2862},"../../node_modules/@xmldom/xmldom/lib/grammar.js":{"bytesInOutput":4480},"../../node_modules/@xmldom/xmldom/lib/dom.js":{"bytesInOutput":31528},"../../node_modules/@xmldom/xmldom/lib/entities.js":{"bytesInOutput":35900},"../../node_modules/@xmldom/xmldom/lib/sax.js":{"bytesInOutput":12549},"../../node_modules/@xmldom/xmldom/lib/dom-parser.js":{"bytesInOutput":5025},"../../node_modules/@xmldom/xmldom/lib/index.js":{"bytesInOutput":1094},"../../node_modules/diff-match-patch/index.js":{"bytesInOutput":19270},"nodes/Adeu/Adeu.node.ts":{"bytesInOutput":3743},"nodes/Adeu/descriptions/hydrateToolOutput.operation.ts":{"bytesInOutput":5292},"nodes/Adeu/GenericFunctions.ts":{"bytesInOutput":6014},"../../node_modules/fflate/esm/index.mjs":{"bytesInOutput":13379},"../core/dist/index.js":{"bytesInOutput":106777},"nodes/Adeu/descriptions/extractMarkdown.operation.ts":{"bytesInOutput":1587},"nodes/Adeu/descriptions/applyEdits.operation.ts":{"bytesInOutput":8088},"nodes/Adeu/descriptions/generateDiff.operation.ts":{"bytesInOutput":4279},"nodes/Adeu/descriptions/finalizeDocument.operation.ts":{"bytesInOutput":4878},"nodes/Adeu/descriptions/index.ts":{"bytesInOutput":4579}},"bytes":274481}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-adeu",
3
- "version": "1.15.2",
3
+ "version": "1.16.0",
4
4
  "description": "n8n community node for Adeu — apply AI-driven tracked changes, generate diffs, and sanitize Microsoft Word (.docx) documents.",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -49,7 +49,7 @@
49
49
  "n8n-workflow": "*"
50
50
  },
51
51
  "devDependencies": {
52
- "@adeu/core": "^1.15.2",
52
+ "@adeu/core": "^1.16.0",
53
53
  "@n8n/eslint-plugin-community-nodes": "^0.16.0",
54
54
  "@types/node": "^25.9.1",
55
55
  "@typescript-eslint/parser": "^8.59.4",