Liferay.Loader.define("portal-search-web$codemirror@5.62.0/addon/edit/closebrackets",["module","exports","require","../../lib/codemirror"],(function(e,r,t){window,function(e){var r={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},t=e.Pos;function n(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:r[t]}e.defineOption("autoCloseBrackets",!1,(function(r,t,o){o&&o!=e.Init&&(r.removeKeyMap(i),r.state.closeBrackets=null),t&&(a(n(t,"pairs")),r.state.closeBrackets=t,r.addKeyMap(i))}));var i={Backspace:function(r){var i=s(r);if(!i||r.getOption("disableInput"))return e.Pass;for(var a=n(i,"pairs"),o=r.listSelections(),l=0;l<o.length;l++){if(!o[l].empty())return e.Pass;var c=h(r,o[l].head);if(!c||a.indexOf(c)%2!=0)return e.Pass}for(l=o.length-1;l>=0;l--){var f=o[l].head;r.replaceRange("",t(f.line,f.ch-1),t(f.line,f.ch+1),"+delete")}},Enter:function(r){var t=s(r),i=t&&n(t,"explode");if(!i||r.getOption("disableInput"))return e.Pass;for(var a=r.listSelections(),o=0;o<a.length;o++){if(!a[o].empty())return e.Pass;var c=h(r,a[o].head);if(!c||i.indexOf(c)%2!=0)return e.Pass}r.operation((function(){var e=r.lineSeparator()||"\n";r.replaceSelection(e+e,null),l(r,-1),a=r.listSelections();for(var t=0;t<a.length;t++){var n=a[t].head.line;r.indentLine(n,null,!0),r.indentLine(n+1,null,!0)}}))}};function a(e){for(var r=0;r<e.length;r++){var t=e.charAt(r),n="'"+t+"'";i[n]||(i[n]=o(t))}}function o(r){return function(i){return function(r,i){var a=s(r);if(!a||r.getOption("disableInput"))return e.Pass;var o=n(a,"pairs"),h=o.indexOf(i);if(-1==h)return e.Pass;for(var u,d=n(a,"closeBefore"),p=n(a,"triples"),g=o.charAt(h+1)==i,v=r.listSelections(),b=h%2==0,k=0;k<v.length;k++){var P,S=v[k],y=S.head,O=r.getRange(y,t(y.line,y.ch+1));if(b&&!S.empty())P="surround";else if(!g&&b||O!=i)if(g&&y.ch>1&&p.indexOf(i)>=0&&r.getRange(t(y.line,y.ch-2),y)==i+i){if(y.ch>2&&/\bstring/.test(r.getTokenTypeAt(t(y.line,y.ch-2))))return e.Pass;P="addFour"}else if(g){var m=0==y.ch?" ":r.getRange(t(y.line,y.ch-1),y);if(e.isWordChar(O)||m==i||e.isWordChar(m))return e.Pass;P="both"}else{if(!b||!(0===O.length||/\s/.test(O)||d.indexOf(O)>-1))return e.Pass;P="both"}else P=g&&f(r,y)?"both":p.indexOf(i)>=0&&r.getRange(y,t(y.line,y.ch+3))==i+i+i?"skipThree":"skip";if(u){if(u!=P)return e.Pass}else u=P}var x=h%2?o.charAt(h-1):i,A=h%2?i:o.charAt(h+1);r.operation((function(){if("skip"==u)l(r,1);else if("skipThree"==u)l(r,3);else if("surround"==u){for(var e=r.getSelections(),t=0;t<e.length;t++)e[t]=x+e[t]+A;for(r.replaceSelections(e,"around"),e=r.listSelections().slice(),t=0;t<e.length;t++)e[t]=c(e[t]);r.setSelections(e)}else"both"==u?(r.replaceSelection(x+A,null),r.triggerElectric(x+A),l(r,-1)):"addFour"==u&&(r.replaceSelection(x+x+x+x,"before"),l(r,1))}))}(i,r)}}function s(e){var r=e.state.closeBrackets;return!r||r.override?r:e.getModeAt(e.getCursor()).closeBrackets||r}function l(e,r){for(var t=[],n=e.listSelections(),i=0,a=0;a<n.length;a++){var o=n[a];o.head==e.getCursor()&&(i=a);var s=o.head.ch||r>0?{line:o.head.line,ch:o.head.ch+r}:{line:o.head.line-1};t.push({anchor:s,head:s})}e.setSelections(t,i)}function c(r){var n=e.cmpPos(r.anchor,r.head)>0;return{anchor:new t(r.anchor.line,r.anchor.ch+(n?-1:1)),head:new t(r.head.line,r.head.ch+(n?1:-1))}}function h(e,r){var n=e.getRange(t(r.line,r.ch-1),t(r.line,r.ch+1));return 2==n.length?n:null}function f(e,r){var n=e.getTokenAt(t(r.line,r.ch+1));return/\bstring/.test(n.type)&&n.start==r.ch&&(0==r.ch||!/\bstring/.test(e.getTokenTypeAt(r)))}a(r.pairs+"`")}("object"==typeof r&&"object"==typeof e?t("../../lib/codemirror"):CodeMirror)}));
//# sourceMappingURL=closebrackets.js.map