Liferay.Loader.define("liferay!object-js-components-web$codemirror@5.65.12/addon/selection/mark-selection",["module","exports","require","../../lib/codemirror"],(function(e,t,o){var r,n=void 0;window;r=function(e){"use strict";function onCursorActivity(e){e.state.markedSelection&&e.operation((function(){!function update(e){if(!e.somethingSelected())return clear(e);if(e.listSelections().length>1)return reset(e);var t=e.getCursor("start"),r=e.getCursor("end"),n=e.state.markedSelection;if(!n.length)return coverRange(e,t,r);var i=n[0].find(),c=n[n.length-1].find();if(!i||!c||r.line-t.line<=8||o(t,c.to)>=0||o(r,i.from)<=0)return reset(e);for(;o(t,i.from)>0;)n.shift().clear(),i=n[0].find();for(o(t,i.from)<0&&(i.to.line-t.line<8?(n.shift().clear(),coverRange(e,t,i.to,0)):coverRange(e,t,i.from,0));o(r,c.to)<0;)n.pop().clear(),c=n[n.length-1].find();o(r,c.to)>0&&(r.line-c.from.line<8?(n.pop().clear(),coverRange(e,c.from,r)):coverRange(e,c.to,r))}(e)}))}function onChange(e){e.state.markedSelection&&e.state.markedSelection.length&&e.operation((function(){clear(e)}))}e.defineOption("styleSelectedText",!1,(function(t,o,r){var n=r&&r!=e.Init;o&&!n?(t.state.markedSelection=[],t.state.markedSelectionStyle="string"==typeof o?o:"CodeMirror-selectedtext",reset(t),t.on("cursorActivity",onCursorActivity),t.on("change",onChange)):!o&&n&&(t.off("cursorActivity",onCursorActivity),t.off("change",onChange),clear(t),t.state.markedSelection=t.state.markedSelectionStyle=null)}));var t=e.Pos,o=e.cmpPos;function coverRange(e,r,n,i){if(0!=o(r,n))for(var c=e.state.markedSelection,a=e.state.markedSelectionStyle,l=r.line;;){var f=l==r.line?r:t(l,0),s=l+8,d=s>=n.line,m=d?n:t(s,0),u=e.markText(f,m,{className:a});if(null==i?c.push(u):c.splice(i++,0,u),d)break;l=s}}function clear(e){for(var t=e.state.markedSelection,o=0;o<t.length;++o)t[o].clear();t.length=0}function reset(e){clear(e);for(var t=e.listSelections(),o=0;o<t.length;o++)coverRange(e,t[o].from(),t[o].to())}},"object"==typeof t&&"object"==typeof e?r(o("../../lib/codemirror")):"function"==typeof n&&n.amd?n(["../../lib/codemirror"],r):r(CodeMirror)}));
//# sourceMappingURL=mark-selection.js.map