import "./cljs_env.js";
shadow$provide.module$node_modules$$codemirror$closebrackets$dist$index_cjs=function(global,require,module,exports){function closing(ch){for(let i=0;8>i;i+=2)if("()[]{}\x3c\x3e".charCodeAt(i)==ch)return"()[]{}\x3c\x3e".charAt(i+1);return text.fromCodePoint(128>ch?ch:ch+1)}function insertBracket(state,bracket){let conf=state.languageDataAt("closeBrackets",state.selection.main.head)[0]||defaults,tokens=conf.brackets||defaults.brackets;for(let tok of tokens){let closed=closing(text.codePointAt(tok,0));
if(bracket==tok)return closed==tok?handleSame(state,tok,-1<tokens.indexOf(tok+tok+tok)):handleOpen(state,tok,closed,conf.before||defaults.before);if(bracket==closed&&closedBracketAt(state,state.selection.main.from))return handleClose(state,tok,closed)}return null}function closedBracketAt(state,pos){let found=!1;state.field(bracketState).between(0,state.doc.length,from=>{from==pos&&(found=!0)});return found}function nextChar(doc,pos){doc=doc.sliceString(pos,pos+2);return doc.slice(0,text.codePointSize(text.codePointAt(doc,
0)))}function handleOpen(state$1,open,close,closeBefore){let dont=null,changes=state$1.changeByRange(range=>{if(!range.empty)return{changes:[{insert:open,from:range.from},{insert:close,from:range.to}],effects:closeBracketEffect.of(range.to+open.length),range:state$jscomp$0.EditorSelection.range(range.anchor+open.length,range.head+open.length)};let next=nextChar(state$1.doc,range.head);return!next||/\s/.test(next)||-1<closeBefore.indexOf(next)?{changes:{insert:open+close,from:range.head},effects:closeBracketEffect.of(range.head+
open.length),range:state$jscomp$0.EditorSelection.cursor(range.head+open.length)}:{range:dont=range}});return dont?null:state$1.update(changes,{scrollIntoView:!0,userEvent:"input.type"})}function handleClose(state$1,_open,close){let dont=null;_open=state$1.selection.ranges.map(range=>range.empty&&nextChar(state$1.doc,range.head)==close?state$jscomp$0.EditorSelection.cursor(range.head+close.length):dont=range);return dont?null:state$1.update({selection:state$jscomp$0.EditorSelection.create(_open,state$1.selection.mainIndex),
scrollIntoView:!0,effects:state$1.selection.ranges.map(({from})=>skipBracketEffect.of(from))})}function handleSame(state$1,token,allowTriple){let dont=null,changes=state$1.changeByRange(range=>{if(!range.empty)return{changes:[{insert:token,from:range.from},{insert:token,from:range.to}],effects:closeBracketEffect.of(range.to+token.length),range:state$jscomp$0.EditorSelection.range(range.anchor+token.length,range.head+token.length)};let pos=range.head;var next=nextChar(state$1.doc,pos);if(next==token){if(nodeStart(state$1,
pos))return{changes:{insert:token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:state$jscomp$0.EditorSelection.cursor(pos+token.length)};if(closedBracketAt(state$1,pos))return range=allowTriple&&state$1.sliceDoc(pos,pos+3*token.length)==token+token+token,{range:state$jscomp$0.EditorSelection.cursor(pos+token.length*(range?3:1)),effects:skipBracketEffect.of(pos)}}else{if(allowTriple&&state$1.sliceDoc(pos-2*token.length,pos)==token+token&&nodeStart(state$1,pos-2*token.length))return{changes:{insert:token+
token+token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:state$jscomp$0.EditorSelection.cursor(pos+token.length)};if(state$1.charCategorizer(pos)(next)!=state$jscomp$0.CharCategory.Word){next=state$1.sliceDoc(pos-1,pos);if(next=next!=token&&state$1.charCategorizer(pos)(next)!=state$jscomp$0.CharCategory.Word){a:{var node=language.syntaxTree(state$1).resolveInner(pos,-1);for(next=0;5>next;next++){if(state$1.sliceDoc(node.from,node.from+token.length)==token){next=!0;break a}node=
node.to==pos&&node.parent;if(!node)break}next=!1}next=!next}if(next)return{changes:{insert:token+token,from:pos},effects:closeBracketEffect.of(pos+token.length),range:state$jscomp$0.EditorSelection.cursor(pos+token.length)}}}return{range:dont=range}});return dont?null:state$1.update(changes,{scrollIntoView:!0,userEvent:"input.type"})}function nodeStart(state,pos){state=language.syntaxTree(state).resolveInner(pos+1);return state.parent&&state.from==pos}Object.defineProperty(exports,"__esModule",{value:!0});
global=require("module$node_modules$$codemirror$view$dist$index_cjs");var state$jscomp$0=require("module$node_modules$$codemirror$state$dist$index_cjs"),rangeset=require("module$node_modules$$codemirror$rangeset$dist$index_cjs"),text=require("module$node_modules$$codemirror$text$dist$index_cjs"),language=require("module$node_modules$$codemirror$language$dist$index_cjs");const defaults={brackets:["(","[","{","'",'"'],before:")]}:;\x3e"},closeBracketEffect=state$jscomp$0.StateEffect.define({map(value,
mapping){value=mapping.mapPos(value,-1,state$jscomp$0.MapMode.TrackAfter);return null==value?void 0:value}}),skipBracketEffect=state$jscomp$0.StateEffect.define({map(value,mapping){return mapping.mapPos(value)}}),closedBracket=new class extends rangeset.RangeValue{};closedBracket.startSide=1;closedBracket.endSide=-1;const bracketState=state$jscomp$0.StateField.define({create(){return rangeset.RangeSet.empty},update(value,tr){if(tr.selection){let lineStart=tr.state.doc.lineAt(tr.selection.main.head).from,
prevLineStart=tr.startState.doc.lineAt(tr.startState.selection.main.head).from;lineStart!=tr.changes.mapPos(prevLineStart,-1)&&(value=rangeset.RangeSet.empty)}value=value.map(tr.changes);for(let effect of tr.effects)effect.is(closeBracketEffect)?value=value.update({add:[closedBracket.range(effect.value,effect.value+1)]}):effect.is(skipBracketEffect)&&(value=value.update({filter:from=>from!=effect.value}));return value}}),android="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),inputHandler=
global.EditorView.inputHandler.of((view,from,to,insert)=>{if((android?view.composing:view.compositionStarted)||view.state.readOnly)return!1;let sel=view.state.selection.main;if(2<insert.length||2==insert.length&&1==text.codePointSize(text.codePointAt(insert,0))||from!=sel.from||to!=sel.to)return!1;from=insertBracket(view.state,insert);if(!from)return!1;view.dispatch(from);return!0});require=({state:state$1,dispatch})=>{if(state$1.readOnly)return!1;let tokens=(state$1.languageDataAt("closeBrackets",
state$1.selection.main.head)[0]||defaults).brackets||defaults.brackets,dont=null,changes=state$1.changeByRange(range=>{if(range.empty){var JSCompiler_inline_result=range.head;JSCompiler_inline_result=state$1.doc.sliceString(JSCompiler_inline_result-2,JSCompiler_inline_result);JSCompiler_inline_result=text.codePointSize(text.codePointAt(JSCompiler_inline_result,0))==JSCompiler_inline_result.length?JSCompiler_inline_result:JSCompiler_inline_result.slice(1);for(let token of tokens)if(token==JSCompiler_inline_result&&
nextChar(state$1.doc,range.head)==closing(text.codePointAt(token,0)))return{changes:{from:range.head-token.length,to:range.head+token.length},range:state$jscomp$0.EditorSelection.cursor(range.head-token.length),userEvent:"delete.backward"}}return{range:dont=range}});dont||dispatch(state$1.update(changes,{scrollIntoView:!0}));return!dont};global=[{key:"Backspace",run:require}];exports.closeBrackets=function(){return[inputHandler,bracketState]};exports.closeBracketsKeymap=global;exports.deleteBracketPair=
require;exports.insertBracket=insertBracket}
//# sourceMappingURL=module$node_modules$$codemirror$closebrackets$dist$index_cjs.js.map
