import{t as e}from"./chunk-6hGRweTZ.js";import{t}from"./codemirror-mxAyinHX.js";var n=e(((e,n)=>{(function(r){typeof e==`object`&&typeof n==`object`?r(t()):typeof define==`function`&&define.amd?define([`../../lib/codemirror`],r):r(CodeMirror)})(function(e){var t=/MSIE \d/.test(navigator.userAgent)&&(document.documentMode==null||document.documentMode<8),n=e.Pos,r={"(":`)>`,")":`(<`,"[":`]>`,"]":`[<`,"{":`}>`,"}":`{<`,"<":`>>`,">":`<<`};function i(e){return e&&e.bracketRegex||/[(){}[\]]/}function a(e,t,a){var s=e.getLineHandle(t.line),c=t.ch-1,l=a&&a.afterCursor;l??=/(^| )cm-fat-cursor($| )/.test(e.getWrapperElement().className);var u=i(a),d=!l&&c>=0&&u.test(s.text.charAt(c))&&r[s.text.charAt(c)]||u.test(s.text.charAt(c+1))&&r[s.text.charAt(++c)];if(!d)return null;var f=d.charAt(1)==`>`?1:-1;if(a&&a.strict&&f>0!=(c==t.ch))return null;var p=e.getTokenTypeAt(n(t.line,c+1)),m=o(e,n(t.line,c+(f>0?1:0)),f,p,a);return m==null?null:{from:n(t.line,c),to:m&&m.pos,match:m&&m.ch==d.charAt(0),forward:f>0}}function o(e,t,a,o,s){for(var c=s&&s.maxScanLineLength||1e4,l=s&&s.maxScanLines||1e3,u=[],d=i(s),f=a>0?Math.min(t.line+l,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-l),p=t.line;p!=f;p+=a){var m=e.getLine(p);if(m){var h=a>0?0:m.length-1,g=a>0?m.length:-1;if(!(m.length>c))for(p==t.line&&(h=t.ch-(a<0?1:0));h!=g;h+=a){var _=m.charAt(h);if(d.test(_)&&(o===void 0||(e.getTokenTypeAt(n(p,h+1))||``)==(o||``))){var v=r[_];if(v&&v.charAt(1)==`>`==a>0)u.push(_);else if(u.length)u.pop();else return{pos:n(p,h),ch:_}}}}}return p-a==(a>0?e.lastLine():e.firstLine())?!1:null}function s(e,r,i){for(var o=e.state.matchBrackets.maxHighlightLineLength||1e3,s=i&&i.highlightNonMatching,c=[],l=e.listSelections(),u=0;u<l.length;u++){var d=l[u].empty()&&a(e,l[u].head,i);if(d&&(d.match||s!==!1)&&e.getLine(d.from.line).length<=o){var f=d.match?`CodeMirror-matchingbracket`:`CodeMirror-nonmatchingbracket`;c.push(e.markText(d.from,n(d.from.line,d.from.ch+1),{className:f})),d.to&&e.getLine(d.to.line).length<=o&&c.push(e.markText(d.to,n(d.to.line,d.to.ch+1),{className:f}))}}if(c.length){t&&e.state.focused&&e.focus();var p=function(){e.operation(function(){for(var e=0;e<c.length;e++)c[e].clear()})};if(r)setTimeout(p,800);else return p}}function c(e){e.operation(function(){e.state.matchBrackets.currentlyHighlighted&&(e.state.matchBrackets.currentlyHighlighted(),e.state.matchBrackets.currentlyHighlighted=null),e.state.matchBrackets.currentlyHighlighted=s(e,!1,e.state.matchBrackets)})}function l(e){e.state.matchBrackets&&e.state.matchBrackets.currentlyHighlighted&&(e.state.matchBrackets.currentlyHighlighted(),e.state.matchBrackets.currentlyHighlighted=null)}e.defineOption(`matchBrackets`,!1,function(t,n,r){r&&r!=e.Init&&(t.off(`cursorActivity`,c),t.off(`focus`,c),t.off(`blur`,l),l(t)),n&&(t.state.matchBrackets=typeof n==`object`?n:{},t.on(`cursorActivity`,c),t.on(`focus`,c),t.on(`blur`,l))}),e.defineExtension(`matchBrackets`,function(){s(this,!0)}),e.defineExtension(`findMatchingBracket`,function(e,t,n){return(n||typeof t==`boolean`)&&(n?(n.strict=t,t=n):t=t?{strict:!0}:null),a(this,e,t)}),e.defineExtension(`scanForBracket`,function(e,t,n,r){return o(this,e,t,n,r)})})}));export default n();export{n as t};
//# sourceMappingURL=matchbrackets-Dqxk2oYJ.js.map