vare,t=require("diff-match-patch"),n=require("./helpers/merge"),i=require("./helpers/throttle"),r=require("./helpers/debounce"),o=require("./helpers/normalizeContent"),s=require("./visuals/getCurve"),a=require("./visuals/getMode"),c=require("./visuals/getTheme"),l=require("./visuals/getLine"),d=require("./visuals/getEditorHeight"),f=require("./visuals/createArrow"),h=require("./dom/ensureElement"),g=require("./dom/query"),u=require("./constants");functionp(e){if(e.Range)returne.Range;vart=e.acequire||e.require;return!!t&&t("ace/range")}functionL(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:{};if(!(thisinstanceofL))returnnewL(t);vari=this;i.options=n({ace:window?window.ace:void0,mode:null,theme:null,element:null,diffGranularity:u.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);varr=i.options.ace;if(!r){vars="No ace editor found nor supplied - `options.ace` or `window.ace` is missing";returnconsole.error(s),newError(s)}if(!(e=p(r))){varl="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";returnconsole.error(l),newError(l)}if(null===i.options.element){varf="You need to specify an element for Ace-diff - `options.element` is missing";returnconsole.error(f),newError(f)}if(i.options.elementinstanceofHTMLElement?i.el=i.options.element:i.el=document.body.querySelector(i.options.element),!i.el){varg="Can't find the specified element ".concat(i.options.element);returnconsole.error(g),newError(g)}i.options.left.id=h(i.el,"acediff__left"),i.options.classes.gutterID=h(i.el,"acediff__gutter"),i.options.right.id=h(i.el,"acediff__right"),i.el.innerHTML='<div class="acediff__wrap">'.concat(i.el.innerHTML,"</div>"),i.editors={left:{ace:r.edit(i.options.left.id),markers:[],lineLengths:[]},right:{ace:r.edit(i.options.right.id),markers:[],lineLengths:[]},editorHeight:null},i.editors.left.ace.getSession().setMode(a(i,u.EDITOR_LEFT)),i.editors.right.ace.getSession().setMode(a(i,u.EDITOR_RIGHT)),i.editors.left.ace.setReadOnly(!i.options.left.editable),i.editors.right.ace.setReadOnly(!i.options.right.editable),i.editors.left.ace.setTheme(c(i,u.EDITOR_LEFT)),i.editors.right.ace.setTheme(c(i,u.EDITOR_RIGHT)),i.editors.left.ace.setValue(o(i.options.left.content),-1),i.editors.right.ace.setValue(o(i.options.right.content),-1),i.editors.editorHeight=d(i),setTimeout(function(){i.lineHeight=i.editors.left.ace.renderer.lineHeight,C(i),O(i),F(i),i.diff()},1)}L.prototype={setOptions:function(e){n(this.options,e),this.diff()},getNumDiffs:function(){returnthis.diffs.length},getEditors:function(){return{left:this.editors.left.ace,right:this.editors.right.ace}},diff:function(){vare=this,n=newt,i=this.editors.left.ace.getSession().getValue(),r=this.editors.right.ace.getSession().getValue(),o=n.diff_main(r,i);n.diff_cleanupSemantic(o),this.editors.left.lineLengths=S(this.editors.left),this.editors.right.lineLengths=S(this.editors.right);vars=[],a={left:0,right:0};o.forEach(function(t,n,i){varr=t[0],c=t[1];i[n+1]&&c.endsWith("\n")&&i[n+1][1].startsWith("\n")&&(c+="\n",o[n][1]=c,o[n+1][1]=o[n+1][1].replace(/^\n/,"")),0!==c.length&&(r===u.DIFF_EQUAL?(a.left+=c.length,a.right+=c.length):r===u.DIFF_DELETE?(s.push(R(e,u.DIFF_DELETE,a.left,a.right,c)),a.right+=c.length):r===u.DIFF_INSERT&&(s.push(R(e,u.DIFF_INSERT,a.left,a.right,c)),a.left+=c.length))},this),this.diffs=G(this,s),this.diffs.length>this.options