(function(){}).call(this),parcelRequire=function(t,e,n,i){var r,s="function"==typeof parcelRequire&&parcelRequire,o="function"==typeof require&&require;function a(n,i){if(!e[n]){if(!t[n]){var r="function"==typeof parcelRequire&&parcelRequire;if(!i&&r)return r(n,!0);if(s)return s(n,!0);if(o&&"string"==typeof n)return o(n);var f=new Error("Cannot find module '"+n+"'");throw f.code="MODULE_NOT_FOUND",f}l.resolve=function(e){return t[n][1][e]||e},l.cache={};var h=e[n]=new a.Module(n);t[n][0].call(h.exports,l,h,h.exports,this)}return e[n].exports;function l(t){return a(l.resolve(t))}}a.isParcelRequire=!0,a.Module=function(t){this.id=t,this.bundle=a,this.exports={}},a.modules=t,a.cache=e,a.parent=s,a.register=function(e,n){t[e]=[function(t,e){e.exports=n},{}]};for(var f=0;fe.length?t:e,f=t.length>e.length?e:t,h=a.indexOf(f);if(-1!=h)return o=[new i.Diff(1,a.substring(0,h)),new i.Diff(0,f),new i.Diff(1,a.substring(h+f.length))],t.length>e.length&&(o[0][0]=o[2][0]=r),o;if(1==f.length)return[new i.Diff(r,t),new i.Diff(1,e)];var l=this.diff_halfMatch_(t,e);if(l){var c=l[0],g=l[1],u=l[2],d=l[3],p=l[4],_=this.diff_main(c,u,n,s),m=this.diff_main(g,d,n,s);return _.concat([new i.Diff(0,p)],m)}return n&&t.length>100&&e.length>100?this.diff_lineMode_(t,e,s):this.diff_bisect_(t,e,s)},i.prototype.diff_lineMode_=function(t,e,n){var s=this.diff_linesToChars_(t,e);t=s.chars1,e=s.chars2;var o=s.lineArray,a=this.diff_main(t,e,!1,n);this.diff_charsToLines_(a,o),this.diff_cleanupSemantic(a),a.push(new i.Diff(0,""));for(var f=0,h=0,l=0,c="",g="";f=1&&l>=1){a.splice(f-h-l,h+l),f=f-h-l;for(var u=this.diff_main(c,g,!1,n),d=u.length-1;d>=0;d--)a.splice(f,0,u[d]);f+=u.length}l=0,h=0,c="",g=""}f++}return a.pop(),a},i.prototype.diff_bisect_=function(t,e,n){for(var s=t.length,o=e.length,a=Math.ceil((s+o)/2),f=a,h=2*a,l=new Array(h),c=new Array(h),g=0;gn);b++){for(var L=-b+p;L<=b-_;L+=2){for(var y=f+L,E=(C=L==-b||L!=b&&l[y-1]s)_+=2;else if(E>o)p+=2;else if(d&&(x=f+u-L)>=0&&x=(D=s-c[x]))return this.diff_bisectSplit_(t,e,C,E,n)}for(var w=-b+m;w<=b-v;w+=2){for(var D,x=f+w,S=(D=w==-b||w!=b&&c[x-1]s)v+=2;else if(S>o)m+=2;else if(!d){var C;if((y=f+u-w)>=0&&y=(D=s-D)))return this.diff_bisectSplit_(t,e,C,E,n)}}}return[new i.Diff(r,t),new i.Diff(1,e)]},i.prototype.diff_bisectSplit_=function(t,e,n,i,r){var s=t.substring(0,n),o=e.substring(0,i),a=t.substring(n),f=e.substring(i),h=this.diff_main(s,o,!1,r),l=this.diff_main(a,f,!1,r);return h.concat(l)},i.prototype.diff_linesToChars_=function(t,e){var n=[],i={};function r(t){for(var e="",r=0,o=-1,a=n.length;oi?t=t.substring(n-i):ne.length?t:e,i=t.length>e.length?e:t;if(n.length<4||2*i.length=t.length?[i,s,o,a,l]:null}var o,a,f,h,l,c=s(n,i,Math.ceil(n.length/4)),g=s(n,i,Math.ceil(n.length/2));return c||g?(o=g?c&&c[4].length>g[4].length?c:g:c,t.length>e.length?(a=o[0],f=o[1],h=o[2],l=o[3]):(h=o[0],l=o[1],a=o[2],f=o[3]),[a,f,h,l,o[4]]):null},i.prototype.diff_cleanupSemantic=function(t){for(var e=!1,n=[],s=0,o=null,a=0,f=0,h=0,l=0,c=0;a0?n[s-1]:-1,f=0,h=0,l=0,c=0,o=null,e=!0)),a++;for(e&&this.diff_cleanupMerge(t),this.diff_cleanupSemanticLossless(t),a=1;a=p?(d>=g.length/2||d>=u.length/2)&&(t.splice(a,0,new i.Diff(0,u.substring(0,d))),t[a-1][1]=g.substring(0,g.length-d),t[a+1][1]=u.substring(d),a++):(p>=g.length/2||p>=u.length/2)&&(t.splice(a,0,new i.Diff(0,g.substring(0,p))),t[a-1][0]=1,t[a-1][1]=u.substring(0,u.length-p),t[a+1][0]=r,t[a+1][1]=g.substring(p),a++),a++}a++}},i.prototype.diff_cleanupSemanticLossless=function(t){function e(t,e){if(!t||!e)return 6;var n=t.charAt(t.length-1),r=e.charAt(0),s=n.match(i.nonAlphaNumericRegex_),o=r.match(i.nonAlphaNumericRegex_),a=s&&n.match(i.whitespaceRegex_),f=o&&r.match(i.whitespaceRegex_),h=a&&n.match(i.linebreakRegex_),l=f&&r.match(i.linebreakRegex_),c=h&&t.match(i.blanklineEndRegex_),g=l&&e.match(i.blanklineStartRegex_);return c||g?5:h||l?4:s&&!a&&f?3:a||f?2:s||o?1:0}for(var n=1;n=g&&(g=u,h=r,l=s,c=o)}t[n-1][1]!=h&&(h?t[n-1][1]=h:(t.splice(n-1,1),n--),t[n][1]=l,c?t[n+1][1]=c:(t.splice(n+1,1),n--))}n++}},i.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,i.whitespaceRegex_=/\s/,i.linebreakRegex_=/[\r\n]/,i.blanklineEndRegex_=/\n\r?\n$/,i.blanklineStartRegex_=/^\r?\n\r?\n/,i.prototype.diff_cleanupEfficiency=function(t){for(var e=!1,n=[],s=0,o=null,a=0,f=!1,h=!1,l=!1,c=!1;a0?n[s-1]:-1,l=c=!1),e=!0)),a++;e&&this.diff_cleanupMerge(t)},i.prototype.diff_cleanupMerge=function(t){t.push(new i.Diff(0,""));for(var e,n=0,s=0,o=0,a="",f="";n1?(0!==s&&0!==o&&(0!==(e=this.diff_commonPrefix(f,a))&&(n-s-o>0&&0==t[n-s-o-1][0]?t[n-s-o-1][1]+=f.substring(0,e):(t.splice(0,0,new i.Diff(0,f.substring(0,e))),n++),f=f.substring(e),a=a.substring(e)),0!==(e=this.diff_commonSuffix(f,a))&&(t[n][1]=f.substring(f.length-e)+t[n][1],f=f.substring(0,f.length-e),a=a.substring(0,a.length-e))),n-=s+o,t.splice(n,s+o),a.length&&(t.splice(n,0,new i.Diff(r,a)),n++),f.length&&(t.splice(n,0,new i.Diff(1,f)),n++),n++):0!==n&&0==t[n-1][0]?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,o=0,s=0,a="",f=""}""===t[t.length-1][1]&&t.pop();var h=!1;for(n=1;ne));n++)o=i,a=s;return t.length!=n&&t[n][0]===r?a:a+(e-o)},i.prototype.diff_prettyHtml=function(t){for(var e=[],n=/&/g,i=//g,o=/\n/g,a=0;a");switch(f){case 1:e[a]=''+h+"";break;case r:e[a]=''+h+"";break;case 0:e[a]=""+h+""}}return e.join("")},i.prototype.diff_text1=function(t){for(var e=[],n=0;nthis.Match_MaxBits)throw new Error("Pattern too long for this browser.");var i=this.match_alphabet_(e),r=this;function s(t,i){var s=t/e.length,o=Math.abs(n-i);return r.Match_Distance?s+o/r.Match_Distance:o?1:s}var o=this.Match_Threshold,a=t.indexOf(e,n);-1!=a&&(o=Math.min(s(0,a),o),-1!=(a=t.lastIndexOf(e,n+e.length))&&(o=Math.min(s(0,a),o)));var f,h,l=1<=d;m--){var v=i[t.charAt(m-1)];if(_[m]=0===u?(_[m+1]<<1|1)&v:(_[m+1]<<1|1)&v|(c[m+1]|c[m])<<1|1|c[m+1],_[m]&l){var b=s(u,m-1);if(b<=o){if(o=b,!((a=m-1)>n))break;d=Math.max(1,2*n-a)}}}if(s(u+1,n)>o)break;c=_}return a},i.prototype.match_alphabet_=function(t){for(var e={},n=0;n2&&(this.diff_cleanupSemantic(o),this.diff_cleanupEfficiency(o));else if(t&&"object"==typeof t&&void 0===e&&void 0===n)o=t,s=this.diff_text1(o);else if("string"==typeof t&&e&&"object"==typeof e&&void 0===n)s=t,o=e;else{if("string"!=typeof t||"string"!=typeof e||!n||"object"!=typeof n)throw new Error("Unknown call format to patch_make.");s=t,o=n}if(0===o.length)return[];for(var a=[],f=new i.patch_obj,h=0,l=0,c=0,g=s,u=s,d=0;d=2*this.Patch_Margin&&h&&(this.patch_addContext_(f,g),a.push(f),f=new i.patch_obj,h=0,g=u,l=c)}1!==p&&(l+=_.length),p!==r&&(c+=_.length)}return h&&(this.patch_addContext_(f,g),a.push(f)),a},i.prototype.patch_deepCopy=function(t){for(var e=[],n=0;nthis.Match_MaxBits?-1!=(a=this.match_main(e,l.substring(0,this.Match_MaxBits),h))&&(-1==(c=this.match_main(e,l.substring(l.length-this.Match_MaxBits),h+l.length-this.Match_MaxBits))||a>=c)&&(a=-1):a=this.match_main(e,l,h),-1==a)s[o]=!1,i-=t[o].length2-t[o].length1;else if(s[o]=!0,i=a-h,l==(f=-1==c?e.substring(a,a+l.length):e.substring(a,c+this.Match_MaxBits)))e=e.substring(0,a)+this.diff_text2(t[o].diffs)+e.substring(a+l.length);else{var g=this.diff_main(l,f,!1);if(l.length>this.Match_MaxBits&&this.diff_levenshtein(g)/l.length>this.Patch_DeleteThreshold)s[o]=!1;else{this.diff_cleanupSemanticLossless(g);for(var u,d=0,p=0;po[0][1].length){var a=e-o[0][1].length;o[0][1]=n.substring(o[0][1].length)+o[0][1],s.start1-=a,s.start2-=a,s.length1+=a,s.length2+=a}return 0==(o=(s=t[t.length-1]).diffs).length||0!=o[o.length-1][0]?(o.push(new i.Diff(0,n)),s.length1+=e,s.length2+=e):e>o[o.length-1][1].length&&(a=e-o[o.length-1][1].length,o[o.length-1][1]+=n.substring(0,a),s.length1+=a,s.length2+=a),n},i.prototype.patch_splitMax=function(t){for(var e=this.Match_MaxBits,n=0;n2*e?(h.length1+=g.length,o+=g.length,l=!1,h.diffs.push(new i.Diff(c,g)),s.diffs.shift()):(g=g.substring(0,e-h.length1-this.Patch_Margin),h.length1+=g.length,o+=g.length,0===c?(h.length2+=g.length,a+=g.length):l=!1,h.diffs.push(new i.Diff(c,g)),g==s.diffs[0][1]?s.diffs.shift():s.diffs[0][1]=s.diffs[0][1].substring(g.length))}f=(f=this.diff_text2(h.diffs)).substring(f.length-this.Patch_Margin);var u=this.diff_text1(s.diffs).substring(0,this.Patch_Margin);""!==u&&(h.length1+=u.length,h.length2+=u.length,0!==h.diffs.length&&0===h.diffs[h.diffs.length-1][0]?h.diffs[h.diffs.length-1][1]+=u:h.diffs.push(new i.Diff(0,u))),l||t.splice(++n,0,h)}}},i.prototype.patch_toText=function(t){for(var e=[],n=0;n2&&void 0!==arguments[2]&&arguments[2],r=null,s=!0;return function(){for(var o=arguments.length,a=new Array(o),f=0;f0&&void 0!==arguments[0]?arguments[0]:"").replace(/\r\n/g,"\n")}},{}],j8WE:[function(t,e,n){e.exports=function(t,e,n,i){var r=t+(n-t)/2;return"M ".concat(t," ").concat(e," C ").concat(r,",").concat(e," ").concat(r,",").concat(i," ").concat(n,",").concat(i)}},{}],iJA9:[function(t,e,n){e.exports={DIFF_EQUAL:0,DIFF_DELETE:-1,DIFF_INSERT:1,EDITOR_RIGHT:"right",EDITOR_LEFT:"left",RTL:"rtl",LTR:"ltr",SVG_NS:"http://www.w3.org/2000/svg",DIFF_GRANULARITY_SPECIFIC:"specific",DIFF_GRANULARITY_BROAD:"broad"}},{}],gWhB:[function(t,e,n){var i=t("../constants");e.exports=function(t,e){var n=t.options.mode;return e===i.EDITOR_LEFT&&null!==t.options.left.mode&&(n=t.options.left.mode),e===i.EDITOR_RIGHT&&null!==t.options.right.mode&&(n=t.options.right.mode),n}},{"../constants":"iJA9"}],IRlp:[function(t,e,n){var i=t("../constants");e.exports=function(t,e){var n=t.options.theme;return e===i.EDITOR_LEFT&&null!==t.options.left.theme&&(n=t.options.left.theme),e===i.EDITOR_RIGHT&&null!==t.options.right.theme&&(n=t.options.right.theme),n}},{"../constants":"iJA9"}],L8P8:[function(t,e,n){e.exports=function(t,e){return t.ace.getSession().doc.getLine(e)}},{}],gpkQ:[function(t,e,n){e.exports=function(t){return document.getElementById(t.options.left.id).offsetHeight}},{}],QEUm:[function(t,e,n){e.exports=function(t){var e=document.createElement("div"),n={class:t.className,style:"top:".concat(t.topOffset,"px"),title:t.tooltip,"data-diff-index":t.diffIndex};for(var i in n)e.setAttribute(i,n[i]);return e.innerHTML=t.arrowContent,e}},{}],f1Db:[function(t,e,n){e.exports=function(t,e){var n=Math.random().toString(36).substr(2,5),i="js-".concat(e,"-").concat(n),r=t.querySelector(".".concat(e));if(r)return r.id=r.id||i,r.id;var s=document.createElement("div");return t.appendChild(s),s.className=e,s.id=i,s.id}},{}],FPMV:[function(t,e,n){e.exports={on:function(t,e,n,i){var r="document"===t?document:document.querySelector(t);r.addEventListener(e,(function(t){for(var e=r.querySelectorAll(n),s=t.target,o=0,a=e.length;o0&&void 0!==arguments[0]?arguments[0]:{};if(!(this instanceof b))return new b(t);var e=this;e.options=s({ace:window?window.ace:void 0,mode:null,theme:null,element:null,diffGranularity:m.DIFF_GRANULARITY_BROAD,lockScrolling:!1,showDiffs:!0,showConnectors:!0,maxDiffs:5e3,left:{id:null,content:null,mode:null,theme:null,editable:!0,copyLinkEnabled:!0},right:{id:null,content:null,mode:null,theme:null,editable:!0,copyLinkEnabled:!0},classes:{gutterID:"acediff__gutter",diff:"acediff__diffLine",connector:"acediff__connector",newCodeConnectorLink:"acediff__newCodeConnector",newCodeConnectorLinkContent:"→",deletedCodeConnectorLink:"acediff__deletedCodeConnector",deletedCodeConnectorLinkContent:"←",copyRightContainer:"acediff__copy--right",copyLeftContainer:"acediff__copy--left"},connectorYOffset:0},t);var n=e.options.ace;if(!n){var r="No ace editor found nor supplied - `options.ace` or `window.ace` is missing";return console.error(r),new Error(r)}if(!(i=v(n))){var o="Could not require Range module for Ace. Depends on your bundling strategy, but it usually comes with Ace itself. See https://ace.c9.io/api/range.html, open an issue on GitHub ace-diff/ace-diff";return console.error(o),new Error(o)}if(null===e.options.element){var a="You need to specify an element for Ace-diff - `options.element` is missing";return console.error(a),new Error(a)}if(e.options.element instanceof HTMLElement?e.el=e.options.element:e.el=document.body.querySelector(e.options.element),!e.el){var h="Can't find the specified element ".concat(e.options.element);return console.error(h),new Error(h)}e.options.left.id=p(e.el,"acediff__left"),e.options.classes.gutterID=p(e.el,"acediff__gutter"),e.options.right.id=p(e.el,"acediff__right"),e.el.innerHTML='
'.concat(e.el.innerHTML,"
"),e.editors={left:{ace:n.edit(e.options.left.id),markers:[],lineLengths:[]},right:{ace:n.edit(e.options.right.id),markers:[],lineLengths:[]},editorHeight:null},e.editors.left.ace.getSession().setMode(l(e,m.EDITOR_LEFT)),e.editors.right.ace.getSession().setMode(l(e,m.EDITOR_RIGHT)),e.editors.left.ace.setReadOnly(!e.options.left.editable),e.editors.right.ace.setReadOnly(!e.options.right.editable),e.editors.left.ace.setTheme(c(e,m.EDITOR_LEFT)),e.editors.right.ace.setTheme(c(e,m.EDITOR_RIGHT)),e.editors.left.ace.setValue(f(e.options.left.content),-1),e.editors.right.ace.setValue(f(e.options.right.content),-1),e.editors.editorHeight=u(e),setTimeout((function(){e.lineHeight=e.editors.left.ace.renderer.lineHeight,y(e),O(e),A(e),e.diff()}),1)}b.prototype={setOptions:function(t){s(this.options,t),this.diff()},getNumDiffs:function(){return this.diffs.length},getEditors:function(){return{left:this.editors.left.ace,right:this.editors.right.ace}},diff:function(){var t=this,e=new r,n=this.editors.left.ace.getSession().getValue(),i=this.editors.right.ace.getSession().getValue(),s=e.diff_main(i,n);e.diff_cleanupSemantic(s),this.editors.left.lineLengths=w(this.editors.left),this.editors.right.lineLengths=w(this.editors.right);var o=[],a={left:0,right:0};s.forEach((function(e,n,i){var r=e[0],f=e[1];i[n+1]&&f.endsWith("\n")&&i[n+1][1].startsWith("\n")&&(f+="\n",s[n][1]=f,s[n+1][1]=s[n+1][1].replace(/^\n/,"")),0!==f.length&&(r===m.DIFF_EQUAL?(a.left+=f.length,a.right+=f.length):r===m.DIFF_DELETE?(o.push(C(t,m.DIFF_DELETE,a.left,a.right,f)),a.right+=f.length):r===m.DIFF_INSERT&&(o.push(C(t,m.DIFF_INSERT,a.left,a.right,f)),a.left+=f.length))}),this),this.diffs=function(t,e){var n=[];function i(e){return t.options.diffGranularity===m.DIFF_GRANULARITY_SPECIFIC?e<1:e<=1}e.forEach((function(t,e){if(0!==e){for(var r=!1,s=0;sthis.options.maxDiffs||(S(this),F(this))},destroy:function(){var t=this.editors.left.ace.getValue();this.editors.left.ace.destroy();var e=this.editors.left.ace.container,n=e.cloneNode(!1);n.textContent=t,e.parentNode.replaceChild(n,e);var i=this.editors.right.ace.getValue();this.editors.right.ace.destroy(),(n=(e=this.editors.right.ace.container).cloneNode(!1)).textContent=i,e.parentNode.replaceChild(n,e),document.getElementById(this.options.classes.gutterID).innerHTML="",L()}};var L=function(){};function y(t){t.editors.left.ace.getSession().on("changeScrollTop",o((function(){x(t)}),16)),t.editors.right.ace.getSession().on("changeScrollTop",o((function(){x(t)}),16));var e=t.diff.bind(t);t.editors.left.ace.on("change",e),t.editors.right.ace.on("change",e),t.options.left.copyLinkEnabled&&_.on("#".concat(t.options.classes.gutterID),"click",".".concat(t.options.classes.newCodeConnectorLink),(function(e){E(t,e,m.LTR)})),t.options.right.copyLinkEnabled&&_.on("#".concat(t.options.classes.gutterID),"click",".".concat(t.options.classes.deletedCodeConnectorLink),(function(e){E(t,e,m.RTL)}));var n=a((function(){t.editors.availableHeight=document.getElementById(t.options.left.id).offsetHeight,t.diff()}),250);window.addEventListener("resize",n),L=function(){window.removeEventListener("resize",n)}}function E(t,e,n){var r,s,o,a,f,h,l=parseInt(e.target.getAttribute("data-diff-index"),10),c=t.diffs[l];n===m.LTR?(r=t.editors.left,s=t.editors.right,o=c.leftStartLine,a=c.leftEndLine,f=c.rightStartLine,h=c.rightEndLine):(r=t.editors.right,s=t.editors.left,o=c.rightStartLine,a=c.rightEndLine,f=c.leftStartLine,h=c.leftEndLine);for(var u="",d=o;dn?"lines":"targetOnly");o.markers.push(o.ace.session.addMarker(new i(n,0,r-1,1),a,"fullLine"))}function x(t){S(t),F(t),function(t){var e=t.editors.left.ace.getSession().getScrollTop(),n=t.editors.right.ace.getSession().getScrollTop();t.copyRightContainer.style.cssText="top: ".concat(-e,"px"),t.copyLeftContainer.style.cssText="top: ".concat(-n,"px")}(t)}function S(t){t.editors.left.markers.forEach((function(e){t.editors.left.ace.getSession().removeMarker(e)}),t),t.editors.right.markers.forEach((function(e){t.editors.right.ace.getSession().removeMarker(e)}),t)}function C(t,e,n,i,r){var s={},o=/^\n/.test(r);if(e===m.DIFF_INSERT){var a=M(t.editors.left,n,r),f=T(t.editors.right,i),h=I(t.editors.right,f),l=I(t.editors.left,a.startLine),c=f;0===I(t.editors.left,a.startLine)&&o&&(o=!1),0===a.startChar&&R(t.editors.right,i,o)&&(c=f+1);var g=a.startLine===a.endLine,u=0;(a.startChar>0||g&&r.length0&&a.startChar0||g&&r.length0&&a.startChar0&&I(t,i.startLine)===i.startChar&&(i.startLine++,i.startChar=0),0===i.endChar&&i.endLine--;var f=/\n$/.test(n);return i.startChar>0&&f&&i.endLine++,i}function I(t,e){return g(t,e).length}function T(t,e){for(var n=t.ace.getSession().doc.getAllLines(),i=0,r=0,s=0;se.leftStartLine&&t.options.left.copyLinkEnabled){var i=d({className:t.options.classes.newCodeConnectorLink,topOffset:e.leftStartLine*t.lineHeight,tooltip:"Copy to right",diffIndex:n,arrowContent:t.options.classes.newCodeConnectorLinkContent});t.copyRightContainer.appendChild(i)}if(e.rightEndLine>e.rightStartLine&&t.options.right.copyLinkEnabled){var r=d({className:t.options.classes.deletedCodeConnectorLink,topOffset:e.rightStartLine*t.lineHeight,tooltip:"Copy to left",diffIndex:n,arrowContent:t.options.classes.deletedCodeConnectorLinkContent});t.copyLeftContainer.appendChild(r)}}(t,e,n))}),t)}e.exports=b},{"diff-match-patch":"k8CM","./helpers/merge":"iSlp","./helpers/throttle":"Os6R","./helpers/debounce":"gTec","./helpers/normalizeContent":"xRfK","./visuals/getCurve":"j8WE","./visuals/getMode":"gWhB","./visuals/getTheme":"IRlp","./visuals/getLine":"L8P8","./visuals/getEditorHeight":"gpkQ","./visuals/createArrow":"QEUm","./dom/ensureElement":"f1Db","./dom/query":"FPMV","./constants":"iJA9"}]},{},["Focm"]);