-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff.ts
More file actions
24 lines (24 loc) · 17.9 KB
/
Copy pathdiff.ts
File metadata and controls
24 lines (24 loc) · 17.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// @ts-nocheck
// jsdiff v8.0.4 bundle, vendored from https://esm.sh/diff@8.0.4
// MIT licensed (kpdecker/jsdiff). Inlined because blitz workers can't import npm packages.
/* esm.sh - diff@8.0.4 */
var C=class{diff(e,n,r={}){let l;typeof r=="function"?(l=r,r={}):"callback"in r&&(l=r.callback);let i=this.castInput(e,r),s=this.castInput(n,r),o=this.removeEmpty(this.tokenize(i,r)),f=this.removeEmpty(this.tokenize(s,r));return this.diffWithOptionsObj(o,f,r,l)}diffWithOptionsObj(e,n,r,l){var i;let s=a=>{if(a=this.postProcess(a,r),l){setTimeout(function(){l(a)},0);return}else return a},o=n.length,f=e.length,c=1,d=o+f;r.maxEditLength!=null&&(d=Math.min(d,r.maxEditLength));let p=(i=r.timeout)!==null&&i!==void 0?i:1/0,w=Date.now()+p,x=[{oldPos:-1,lastComponent:void 0}],h=this.extractCommon(x[0],n,e,0,r);if(x[0].oldPos+1>=f&&h+1>=o)return s(this.buildValues(x[0].lastComponent,n,e));let m=-1/0,v=1/0,W=()=>{for(let a=Math.max(m,-c);a<=Math.min(v,c);a+=2){let u,g=x[a-1],y=x[a+1];g&&(x[a-1]=void 0);let O=!1;if(y){let S=y.oldPos-a;O=y&&0<=S&&S<o}let E=g&&g.oldPos+1<f;if(!O&&!E){x[a]=void 0;continue}if(!E||O&&g.oldPos<y.oldPos?u=this.addToPath(y,!0,!1,0,r):u=this.addToPath(g,!1,!0,1,r),h=this.extractCommon(u,n,e,a,r),u.oldPos+1>=f&&h+1>=o)return s(this.buildValues(u.lastComponent,n,e))||!0;x[a]=u,u.oldPos+1>=f&&(v=Math.min(v,a-1)),h+1>=o&&(m=Math.max(m,a+1))}c++};if(l)(function a(){setTimeout(function(){if(c>d||Date.now()>w)return l(void 0);W()||a()},0)})();else for(;c<=d&&Date.now()<=w;){let a=W();if(a)return a}}addToPath(e,n,r,l,i){let s=e.lastComponent;return s&&!i.oneChangePerToken&&s.added===n&&s.removed===r?{oldPos:e.oldPos+l,lastComponent:{count:s.count+1,added:n,removed:r,previousComponent:s.previousComponent}}:{oldPos:e.oldPos+l,lastComponent:{count:1,added:n,removed:r,previousComponent:s}}}extractCommon(e,n,r,l,i){let s=n.length,o=r.length,f=e.oldPos,c=f-l,d=0;for(;c+1<s&&f+1<o&&this.equals(r[f+1],n[c+1],i);)c++,f++,d++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return d&&!i.oneChangePerToken&&(e.lastComponent={count:d,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=f,c}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){let l=[],i;for(;e;)l.push(e),i=e.previousComponent,delete e.previousComponent,e=i;l.reverse();let s=l.length,o=0,f=0,c=0;for(;o<s;o++){let d=l[o];if(d.removed)d.value=this.join(r.slice(c,c+d.count)),c+=d.count;else{if(!d.added&&this.useLongestToken){let p=n.slice(f,f+d.count);p=p.map(function(w,x){let h=r[c+x];return h.length>w.length?h:w}),d.value=this.join(p)}else d.value=this.join(n.slice(f,f+d.count));f+=d.count,d.added||(c+=d.count)}}return l}};var R=class extends C{},te=new R;function We(t,e,n){return te.diff(t,e,n)}function M(t,e){let n;for(n=0;n<t.length&&n<e.length;n++)if(t[n]!=e[n])return t.slice(0,n);return t.slice(0,n)}function _(t,e){let n;if(!t||!e||t[t.length-1]!=e[e.length-1])return"";for(n=0;n<t.length&&n<e.length;n++)if(t[t.length-(n+1)]!=e[e.length-(n+1)])return t.slice(-n);return t.slice(-n)}function F(t,e,n){if(t.slice(0,e.length)!=e)throw Error(`string ${JSON.stringify(t)} doesn't start with prefix ${JSON.stringify(e)}; this is a bug`);return n+t.slice(e.length)}function T(t,e,n){if(!e)return t+n;if(t.slice(-e.length)!=e)throw Error(`string ${JSON.stringify(t)} doesn't end with suffix ${JSON.stringify(e)}; this is a bug`);return t.slice(0,-e.length)+n}function L(t,e){return F(t,e,"")}function k(t,e){return T(t,e,"")}function $(t,e){return e.slice(0,Ce(t,e))}function Ce(t,e){let n=0;t.length>e.length&&(n=t.length-e.length);let r=e.length;t.length<e.length&&(r=t.length);let l=Array(r),i=0;l[0]=0;for(let s=1;s<r;s++){for(e[s]==e[i]?l[s]=l[i]:l[s]=i;i>0&&e[s]!=e[i];)i=l[i];e[s]==e[i]&&i++}i=0;for(let s=n;s<t.length;s++){for(;i>0&&t[s]!=e[i];)i=l[i];t[s]==e[i]&&i++}return i}function re(t){return t.includes(`\r
`)&&!t.startsWith(`
`)&&!t.match(/[^\r]\n/)}function ie(t){return!t.includes(`\r
`)&&t.includes(`
`)}function U(t,e){let n=[];for(let r of Array.from(e.segment(t))){let l=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(l)?n[n.length-1]+=l:n.push(l)}return n}function D(t,e){if(e)return A(t,e)[1];let n;for(n=t.length-1;n>=0&&t[n].match(/\s/);n--);return t.substring(n+1)}function P(t,e){if(e)return A(t,e)[0];let n=t.match(/^\s*/);return n?n[0]:""}function A(t,e){if(!e)return[P(t),D(t)];if(e.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');let n=U(t,e),r=n[0],l=n[n.length-1],i=/\s/.test(r)?r:"",s=/\s/.test(l)?l:"";return[i,s]}var N="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",Ee=new RegExp(`[${N}]+|\\s+|[^${N}]`,"ug"),J=class extends C{equals(e,n,r){return r.ignoreCase&&(e=e.toLowerCase(),n=n.toLowerCase()),e.trim()===n.trim()}tokenize(e,n={}){let r;if(n.intlSegmenter){let s=n.intlSegmenter;if(s.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');r=U(e,s)}else r=e.match(Ee)||[];let l=[],i=null;return r.forEach(s=>{/\s/.test(s)?i==null?l.push(s):l.push(l.pop()+s):i!=null&&/\s/.test(i)?l[l.length-1]==i?l.push(l.pop()+s):l.push(i+s):l.push(s),i=s}),l}join(e){return e.map((n,r)=>r==0?n:n.replace(/^\s+/,"")).join("")}postProcess(e,n){if(!e||n.oneChangePerToken)return e;let r=null,l=null,i=null;return e.forEach(s=>{s.added?l=s:s.removed?i=s:((l||i)&&le(r,i,l,s,n.intlSegmenter),r=s,l=null,i=null)}),(l||i)&&le(r,i,l,null,n.intlSegmenter),e}},se=new J;function Oe(t,e,n){return n?.ignoreWhitespace!=null&&!n.ignoreWhitespace?fe(t,e,n):se.diff(t,e,n)}function le(t,e,n,r,l){if(e&&n){let[i,s]=A(e.value,l),[o,f]=A(n.value,l);if(t){let c=M(i,o);t.value=T(t.value,o,c),e.value=L(e.value,c),n.value=L(n.value,c)}if(r){let c=_(s,f);r.value=F(r.value,f,c),e.value=k(e.value,c),n.value=k(n.value,c)}}else if(n){if(t){let i=P(n.value,l);n.value=n.value.substring(i.length)}if(r){let i=P(r.value,l);r.value=r.value.substring(i.length)}}else if(t&&r){let i=P(r.value,l),[s,o]=A(e.value,l),f=M(i,s);e.value=L(e.value,f);let c=_(L(i,f),o);e.value=k(e.value,c),r.value=F(r.value,i,c),t.value=T(t.value,i,i.slice(0,i.length-c.length))}else if(r){let i=P(r.value,l),s=D(e.value,l),o=$(s,i);e.value=k(e.value,o)}else if(t){let i=D(t.value,l),s=P(e.value,l),o=$(i,s);e.value=L(e.value,o)}}var q=class extends C{tokenize(e){let n=new RegExp(`(\\r?\\n)|[${N}]+|[^\\S\\n\\r]+|[^${N}]`,"ug");return e.match(n)||[]}},oe=new q;function fe(t,e,n){return oe.diff(t,e,n)}function ue(t,e){if(typeof t=="function")e.callback=t;else if(t)for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}var V=class extends C{constructor(){super(...arguments),this.tokenize=Y}equals(e,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(`
`))&&(e=e.trim()),(!r.newlineIsToken||!n.includes(`
`))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(e.endsWith(`
`)&&(e=e.slice(0,-1)),n.endsWith(`
`)&&(n=n.slice(0,-1))),super.equals(e,n,r)}},X=new V;function H(t,e,n){return X.diff(t,e,n)}function Se(t,e,n){return n=ue(n,{ignoreWhitespace:!0}),X.diff(t,e,n)}function Y(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
`));let n=[],r=t.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let l=0;l<r.length;l++){let i=r[l];l%2&&!e.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function Pe(t){return t=="."||t=="!"||t=="?"}var B=class extends C{tokenize(e){var n;let r=[],l=0;for(let i=0;i<e.length;i++){if(i==e.length-1){r.push(e.slice(l));break}if(Pe(e[i])&&e[i+1].match(/\s/)){for(r.push(e.slice(l,i+1)),i=l=i+1;!((n=e[i+1])===null||n===void 0)&&n.match(/\s/);)i++;r.push(e.slice(l,i+1)),l=i+1}}return r}},ae=new B;function Le(t,e,n){return ae.diff(t,e,n)}var Z=class extends C{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},ce=new Z;function Ae(t,e,n){return ce.diff(t,e,n)}var G=class extends C{constructor(){super(...arguments),this.tokenize=Y}get useLongestToken(){return!0}castInput(e,n){let{undefinedReplacement:r,stringifyReplacer:l=(i,s)=>typeof s>"u"?r:s}=n;return typeof e=="string"?e:JSON.stringify(I(e,null,null,l),null," ")}equals(e,n,r){return super.equals(e.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),r)}},de=new G;function ke(t,e,n){return de.diff(t,e,n)}function I(t,e,n,r,l){e=e||[],n=n||[],r&&(t=r(l===void 0?"":l,t));let i;for(i=0;i<e.length;i+=1)if(e[i]===t)return n[i];let s;if(Object.prototype.toString.call(t)==="[object Array]"){for(e.push(t),s=new Array(t.length),n.push(s),i=0;i<t.length;i+=1)s[i]=I(t[i],e,n,r,String(i));return e.pop(),n.pop(),s}if(t&&t.toJSON&&(t=t.toJSON()),typeof t=="object"&&t!==null){e.push(t),s={},n.push(s);let o=[],f;for(f in t)Object.prototype.hasOwnProperty.call(t,f)&&o.push(f);for(o.sort(),i=0;i<o.length;i+=1)f=o[i],s[f]=I(t[f],e,n,r,f);e.pop(),n.pop()}else s=t;return s}var Q=class extends C{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}},he=new Q;function Fe(t,e,n){return he.diff(t,e,n)}function K(t){return Array.isArray(t)?t.map(e=>K(e)):Object.assign(Object.assign({},t),{hunks:t.hunks.map(e=>Object.assign(Object.assign({},e),{lines:e.lines.map((n,r)=>{var l;return n.startsWith("\\")||n.endsWith("\r")||!((l=e.lines[r+1])===null||l===void 0)&&l.startsWith("\\")?n:n+"\r"})}))})}function ee(t){return Array.isArray(t)?t.map(e=>ee(e)):Object.assign(Object.assign({},t),{hunks:t.hunks.map(e=>Object.assign(Object.assign({},e),{lines:e.lines.map(n=>n.endsWith("\r")?n.substring(0,n.length-1):n)}))})}function me(t){return Array.isArray(t)||(t=[t]),!t.some(e=>e.hunks.some(n=>n.lines.some(r=>!r.startsWith("\\")&&r.endsWith("\r"))))}function pe(t){return Array.isArray(t)||(t=[t]),t.some(e=>e.hunks.some(n=>n.lines.some(r=>r.endsWith("\r"))))&&t.every(e=>e.hunks.every(n=>n.lines.every((r,l)=>{var i;return r.startsWith("\\")||r.endsWith("\r")||((i=n.lines[l+1])===null||i===void 0?void 0:i.startsWith("\\"))})))}function b(t){let e=t.split(/\n/),n=[],r=0;function l(){let o={};for(n.push(o);r<e.length;){let f=e[r];if(/^(---|\+\+\+|@@)\s/.test(f))break;let c=/^(?:Index:|diff(?: -r \w+)+)\s+/.exec(f);c&&(o.index=f.substring(c[0].length).trim()),r++}for(i(o),i(o),o.hunks=[];r<e.length;){let f=e[r];if(/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(f))break;if(/^@@/.test(f))o.hunks.push(s());else{if(f)throw new Error("Unknown line "+(r+1)+" "+JSON.stringify(f));r++}}}function i(o){let f=/^(---|\+\+\+)\s+/.exec(e[r]);if(f){let c=f[1],d=e[r].substring(3).trim().split(" ",2),p=(d[1]||"").trim(),w=d[0].replace(/\\\\/g,"\\");w.startsWith('"')&&w.endsWith('"')&&(w=w.substr(1,w.length-2)),c==="---"?(o.oldFileName=w,o.oldHeader=p):(o.newFileName=w,o.newHeader=p),r++}}function s(){var o;let f=r,c=e[r++],d=c.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),p={oldStart:+d[1],oldLines:typeof d[2]>"u"?1:+d[2],newStart:+d[3],newLines:typeof d[4]>"u"?1:+d[4],lines:[]};p.oldLines===0&&(p.oldStart+=1),p.newLines===0&&(p.newStart+=1);let w=0,x=0;for(;r<e.length&&(x<p.oldLines||w<p.newLines||!((o=e[r])===null||o===void 0)&&o.startsWith("\\"));r++){let h=e[r].length==0&&r!=e.length-1?" ":e[r][0];if(h==="+"||h==="-"||h===" "||h==="\\")p.lines.push(e[r]),h==="+"?w++:h==="-"?x++:h===" "&&(w++,x++);else throw new Error(`Hunk at line ${f+1} contained invalid line ${e[r]}`)}if(!w&&p.newLines===1&&(p.newLines=0),!x&&p.oldLines===1&&(p.oldLines=0),w!==p.newLines)throw new Error("Added line count did not match for hunk at line "+(f+1));if(x!==p.oldLines)throw new Error("Removed line count did not match for hunk at line "+(f+1));return p}for(;r<e.length;)l();return n}function ge(t,e,n){let r=!0,l=!1,i=!1,s=1;return function o(){if(r&&!i){if(l?s++:r=!1,t+s<=n)return t+s;i=!0}if(!l)return i||(r=!0),e<=t-s?t-s++:(l=!0,o())}}function we(t,e,n={}){let r;if(typeof e=="string"?r=b(e):Array.isArray(e)?r=e:r=[e],r.length>1)throw new Error("applyPatch only works with a single input.");return Te(t,r[0],n)}function Te(t,e,n={}){(n.autoConvertLineEndings||n.autoConvertLineEndings==null)&&(re(t)&&me(e)?e=K(e):ie(t)&&pe(e)&&(e=ee(e)));let r=t.split(`
`),l=e.hunks,i=n.compareLine||((h,m,v,W)=>m===W),s=n.fuzzFactor||0,o=0;if(s<0||!Number.isInteger(s))throw new Error("fuzzFactor must be a non-negative integer");if(!l.length)return t;let f="",c=!1,d=!1;for(let h=0;h<l[l.length-1].lines.length;h++){let m=l[l.length-1].lines[h];m[0]=="\\"&&(f[0]=="+"?c=!0:f[0]=="-"&&(d=!0)),f=m}if(c){if(d){if(!s&&r[r.length-1]=="")return!1}else if(r[r.length-1]=="")r.pop();else if(!s)return!1}else if(d){if(r[r.length-1]!="")r.push("");else if(!s)return!1}function p(h,m,v,W=0,a=!0,u=[],g=0){let y=0,O=!1;for(;W<h.length;W++){let E=h[W],S=E.length>0?E[0]:" ",j=E.length>0?E.substr(1):E;if(S==="-")if(i(m+1,r[m],S,j))m++,y=0;else return!v||r[m]==null?null:(u[g]=r[m],p(h,m+1,v-1,W,!1,u,g+1));if(S==="+"){if(!a)return null;u[g]=j,g++,y=0,O=!0}if(S===" ")if(y++,u[g]=r[m],i(m+1,r[m],S,j))g++,a=!0,O=!1,m++;else return O||!v?null:r[m]&&(p(h,m+1,v-1,W+1,!1,u,g+1)||p(h,m+1,v-1,W,!1,u,g+1))||p(h,m,v-1,W+1,!1,u,g)}return g-=y,m-=y,u.length=g,{patchedLines:u,oldLineLastI:m-1}}let w=[],x=0;for(let h=0;h<l.length;h++){let m=l[h],v,W=r.length-m.oldLines+s,a;for(let u=0;u<=s;u++){a=m.oldStart+x-1;let g=ge(a,o,W);for(;a!==void 0&&(v=p(m.lines,a,u),!v);a=g());if(v)break}if(!v)return!1;for(let u=o;u<a;u++)w.push(r[u]);for(let u=0;u<v.patchedLines.length;u++){let g=v.patchedLines[u];w.push(g)}o=v.oldLineLastI+1,x=a+1-m.oldStart}for(let h=o;h<r.length;h++)w.push(r[h]);return w.join(`
`)}function De(t,e){let n=typeof t=="string"?b(t):t,r=0;function l(){let i=n[r++];if(!i)return e.complete();e.loadFile(i,function(s,o){if(s)return e.complete(s);let f=we(o,i,e);e.patched(i,f,function(c){if(c)return e.complete(c);l()})})}l()}function xe(t){return Array.isArray(t)?t.map(e=>xe(e)).reverse():Object.assign(Object.assign({},t),{oldFileName:t.newFileName,oldHeader:t.newHeader,newFileName:t.oldFileName,newHeader:t.oldHeader,hunks:t.hunks.map(e=>({oldLines:e.newLines,oldStart:e.newStart,newLines:e.oldLines,newStart:e.oldStart,lines:e.lines.map(n=>n.startsWith("-")?`+${n.slice(1)}`:n.startsWith("+")?`-${n.slice(1)}`:n)}))})}var ve={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0},Ne={includeIndex:!1,includeUnderline:!1,includeFileHeaders:!0},He={includeIndex:!1,includeUnderline:!1,includeFileHeaders:!1};function ne(t,e,n,r,l,i,s){let o;s?typeof s=="function"?o={callback:s}:o=s:o={},typeof o.context>"u"&&(o.context=4);let f=o.context;if(o.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(o.callback){let{callback:d}=o;H(n,r,Object.assign(Object.assign({},o),{callback:p=>{let w=c(p);d(w)}}))}else return c(H(n,r,o));function c(d){if(!d)return;d.push({value:"",lines:[]});function p(a){return a.map(function(u){return" "+u})}let w=[],x=0,h=0,m=[],v=1,W=1;for(let a=0;a<d.length;a++){let u=d[a],g=u.lines||be(u.value);if(u.lines=g,u.added||u.removed){if(!x){let y=d[a-1];x=v,h=W,y&&(m=f>0?p(y.lines.slice(-f)):[],x-=m.length,h-=m.length)}for(let y of g)m.push((u.added?"+":"-")+y);u.added?W+=g.length:v+=g.length}else{if(x)if(g.length<=f*2&&a<d.length-2)for(let y of p(g))m.push(y);else{let y=Math.min(g.length,f);for(let E of p(g.slice(0,y)))m.push(E);let O={oldStart:x,oldLines:v-x+y,newStart:h,newLines:W-h+y,lines:m};w.push(O),x=0,h=0,m=[]}v+=g.length,W+=g.length}}for(let a of w)for(let u=0;u<a.lines.length;u++)a.lines[u].endsWith(`
`)?a.lines[u]=a.lines[u].slice(0,-1):(a.lines.splice(u+1,0,"\\ No newline at end of file"),u++);return{oldFileName:t,newFileName:e,oldHeader:l,newHeader:i,hunks:w}}}function z(t,e){if(e||(e=ve),Array.isArray(t)){if(t.length>1&&!e.includeFileHeaders)throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return t.map(r=>z(r,e)).join(`
`)}let n=[];e.includeIndex&&t.oldFileName==t.newFileName&&n.push("Index: "+t.oldFileName),e.includeUnderline&&n.push("==================================================================="),e.includeFileHeaders&&(n.push("--- "+t.oldFileName+(typeof t.oldHeader>"u"?"":" "+t.oldHeader)),n.push("+++ "+t.newFileName+(typeof t.newHeader>"u"?"":" "+t.newHeader)));for(let r=0;r<t.hunks.length;r++){let l=t.hunks[r];l.oldLines===0&&(l.oldStart-=1),l.newLines===0&&(l.newStart-=1),n.push("@@ -"+l.oldStart+","+l.oldLines+" +"+l.newStart+","+l.newLines+" @@");for(let i of l.lines)n.push(i)}return n.join(`
`)+`
`}function ye(t,e,n,r,l,i,s){if(typeof s=="function"&&(s={callback:s}),s?.callback){let{callback:o}=s;ne(t,e,n,r,l,i,Object.assign(Object.assign({},s),{callback:f=>{o(f?z(f,s.headerOptions):void 0)}}))}else{let o=ne(t,e,n,r,l,i,s);return o?z(o,s?.headerOptions):void 0}}function Ie(t,e,n,r,l,i){return ye(t,t,e,n,r,l,i)}function be(t){let e=t.endsWith(`
`),n=t.split(`
`).map(r=>r+`
`);return e?n.pop():n.push(n.pop().slice(0,-1)),n}function ze(t){let e=[],n,r;for(let l=0;l<t.length;l++)n=t[l],n.added?r=1:n.removed?r=-1:r=0,e.push([r,n.value]);return e}function je(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];r.added?e.push("<ins>"):r.removed&&e.push("<del>"),e.push(Re(r.value)),r.added?e.push("</ins>"):r.removed&&e.push("</del>")}return e.join("")}function Re(t){let e=t;return e=e.replace(/&/g,"&"),e=e.replace(/</g,"<"),e=e.replace(/>/g,">"),e=e.replace(/"/g,"""),e}export{C as Diff,Ne as FILE_HEADERS_ONLY,ve as INCLUDE_HEADERS,He as OMIT_HEADERS,we as applyPatch,De as applyPatches,he as arrayDiff,I as canonicalize,te as characterDiff,ze as convertChangesToDMP,je as convertChangesToXML,Ie as createPatch,ye as createTwoFilesPatch,ce as cssDiff,Fe as diffArrays,We as diffChars,Ae as diffCss,ke as diffJson,H as diffLines,Le as diffSentences,Se as diffTrimmedLines,Oe as diffWords,fe as diffWordsWithSpace,z as formatPatch,de as jsonDiff,X as lineDiff,b as parsePatch,xe as reversePatch,ae as sentenceDiff,ne as structuredPatch,se as wordDiff,oe as wordsWithSpaceDiff};
//# sourceMappingURL=diff.bundle.mjs.map