import "./cljs_env.js";
goog.provide('nextjournal.clojure_mode.extensions.eval_region');
var module$node_modules$$codemirror$state$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$state$dist$index_cjs", {});
var module$node_modules$$codemirror$view$dist$index_cjs=shadow.js.require("module$node_modules$$codemirror$view$dist$index_cjs", {});
var module$node_modules$w3c_keyname$index_cjs=shadow.js.require("module$node_modules$w3c_keyname$index_cjs", {});
/**
 * Returns node or its highest ancestor that starts or ends at the cursor position.
 */
nextjournal.clojure_mode.extensions.eval_region.uppermost_edge_here = (function nextjournal$clojure_mode$extensions$eval_region$uppermost_edge_here(pos,node){
var or__4223__auto__ = cljs.core.last(cljs.core.take_while.cljs$core$IFn$_invoke$arity$2(cljs.core.every_pred.cljs$core$IFn$_invoke$arity$2(cljs.core.complement(nextjournal.clojure_mode.node.top_QMARK_),(function (p1__58218_SHARP_){
return ((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$variadic(pos,nextjournal.clojure_mode.node.end(p1__58218_SHARP_),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([nextjournal.clojure_mode.node.end(node)], 0))) || (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$variadic(pos,nextjournal.clojure_mode.node.start(p1__58218_SHARP_),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([nextjournal.clojure_mode.node.start(node)], 0))));
})),cljs.core.iterate(nextjournal.clojure_mode.node.up,node)));
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return node;
}
});
nextjournal.clojure_mode.extensions.eval_region.main_selection = (function nextjournal$clojure_mode$extensions$eval_region$main_selection(state){
var obj58224 = (function (){var obj58222 = (function (){var parent__45060__auto__ = (state["selection"]);
var f__45061__auto__ = (parent__45060__auto__["asSingle"]);
return f__45061__auto__.call(parent__45060__auto__);
})();
var k58223 = "ranges";
if((function (){var obj58227 = obj58222;
return (((!((obj58227 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58223,obj58227)));
})()){
return (obj58222[k58223]);
} else {
return undefined;
}
})();
var k58225 = (0);
if((function (){var obj58228 = obj58224;
return (((!((obj58228 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58225,obj58228)));
})()){
return (obj58224[k58225]);
} else {
return undefined;
}
});
nextjournal.clojure_mode.extensions.eval_region.node_at_cursor = (function nextjournal$clojure_mode$extensions$eval_region$node_at_cursor(var_args){
var G__58242 = arguments.length;
switch (G__58242) {
case 1:
return nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));

}
});

(nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$core$IFn$_invoke$arity$1 = (function (state){
return nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$core$IFn$_invoke$arity$2(state,(function (){var obj58245 = nextjournal.clojure_mode.extensions.eval_region.main_selection(state);
var k58246 = "from";
if((function (){var obj58251 = obj58245;
return (((!((obj58251 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58246,obj58251)));
})()){
return (obj58245[k58246]);
} else {
return undefined;
}
})());
}));

(nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$core$IFn$_invoke$arity$2 = (function (state,from){
var G__58257 = nextjournal.clojure_mode.node.nearest_touching(state,from,(-1));
var G__58257__$1 = (((G__58257 == null))?null:(function (p1__58232_SHARP_){
if(((nextjournal.clojure_mode.node.terminal_type_QMARK_(nextjournal.clojure_mode.node.type(p1__58232_SHARP_))) || ((((nextjournal.clojure_mode.node.start(p1__58232_SHARP_) <= from)) || ((nextjournal.clojure_mode.node.end(p1__58232_SHARP_) <= from)))))){
var G__58261 = p1__58232_SHARP_;
if(((nextjournal.clojure_mode.node.top_QMARK_(p1__58232_SHARP_)) || ((((!(nextjournal.clojure_mode.node.terminal_type_QMARK_(nextjournal.clojure_mode.node.type(p1__58232_SHARP_))))) && ((((nextjournal.clojure_mode.node.start(p1__58232_SHARP_) < from)) && ((from < nextjournal.clojure_mode.node.end(p1__58232_SHARP_))))))))){
return cljs.core.first(nextjournal.clojure_mode.node.children.cljs$core$IFn$_invoke$arity$3(G__58261,from,(-1)));
} else {
return G__58261;
}
} else {
return null;
}
})(G__58257));
var G__58257__$2 = (((G__58257__$1 == null))?null:nextjournal.clojure_mode.extensions.eval_region.uppermost_edge_here(from,G__58257__$1));
if((G__58257__$2 == null)){
return null;
} else {
return nextjournal.clojure_mode.node.balanced_range.cljs$core$IFn$_invoke$arity$2(state,G__58257__$2);
}
}));

(nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$lang$maxFixedArity = 2);

nextjournal.clojure_mode.extensions.eval_region.top_level_node = (function nextjournal$clojure_mode$extensions$eval_region$top_level_node(state){
return cljs.core.last(cljs.core.take_while.cljs$core$IFn$_invoke$arity$2(cljs.core.every_pred.cljs$core$IFn$_invoke$arity$2(cljs.core.identity,cljs.core.complement(nextjournal.clojure_mode.node.top_QMARK_)),cljs.core.iterate(nextjournal.clojure_mode.node.up,nextjournal.clojure_mode.node.nearest_touching(state,(function (){var obj58277 = nextjournal.clojure_mode.extensions.eval_region.main_selection(state);
var k58278 = "from";
if((function (){var obj58279 = obj58277;
return (((!((obj58279 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58278,obj58279)));
})()){
return (obj58277[k58278]);
} else {
return undefined;
}
})(),(-1)))));
});
if((typeof nextjournal !== 'undefined') && (typeof nextjournal.clojure_mode !== 'undefined') && (typeof nextjournal.clojure_mode.extensions !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region.modifier_effect !== 'undefined')){
} else {
nextjournal.clojure_mode.extensions.eval_region.modifier_effect = module$node_modules$$codemirror$state$dist$index_cjs.StateEffect.define();
}
if((typeof nextjournal !== 'undefined') && (typeof nextjournal.clojure_mode !== 'undefined') && (typeof nextjournal.clojure_mode.extensions !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region.modifier_field !== 'undefined')){
} else {
nextjournal.clojure_mode.extensions.eval_region.modifier_field = module$node_modules$$codemirror$state$dist$index_cjs.StateField.define(({"create":cljs.core.constantly(cljs.core.PersistentArrayMap.EMPTY),"update":(function (value,tr){
var or__4223__auto__ = (function (){var G__58287 = cljs.core.first(cljs.core.filter.cljs$core$IFn$_invoke$arity$2((function (p1__58284_SHARP_){
return p1__58284_SHARP_.is(nextjournal.clojure_mode.extensions.eval_region.modifier_effect);
}),tr.effects));
if((G__58287 == null)){
return null;
} else {
var obj58291 = G__58287;
var k58292 = "value";
if((function (){var obj58293 = obj58291;
return (((!((obj58293 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58292,obj58293)));
})()){
return (obj58291[k58292]);
} else {
return undefined;
}
}
})();
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return value;
}
})}));
}
nextjournal.clojure_mode.extensions.eval_region.get_modifier_field = (function nextjournal$clojure_mode$extensions$eval_region$get_modifier_field(state){
return state.field(nextjournal.clojure_mode.extensions.eval_region.modifier_field);
});
nextjournal.clojure_mode.extensions.eval_region.set_modifier_field_BANG_ = (function nextjournal$clojure_mode$extensions$eval_region$set_modifier_field_BANG_(p__58301,value){
var map__58303 = p__58301;
var map__58303__$1 = (((((!((map__58303 == null))))?(((((map__58303.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58303.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58303):map__58303);
var view = map__58303__$1;
var dispatch = (function (){var obj58307 = map__58303__$1;
var k58308 = "dispatch";
if((function (){var obj58309 = obj58307;
return (((!((obj58309 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58308,obj58309)));
})()){
return (obj58307[k58308]);
} else {
return undefined;
}
})();
var state = (function (){var obj58311 = map__58303__$1;
var k58312 = "state";
if((function (){var obj58313 = obj58311;
return (((!((obj58313 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58312,obj58313)));
})()){
return (obj58311[k58312]);
} else {
return undefined;
}
})();
var G__58317 = ({"effects": nextjournal.clojure_mode.extensions.eval_region.modifier_effect.of(value)});
return (dispatch.cljs$core$IFn$_invoke$arity$1 ? dispatch.cljs$core$IFn$_invoke$arity$1(G__58317) : dispatch.call(null,G__58317));
});
nextjournal.clojure_mode.extensions.eval_region.mark = (function nextjournal$clojure_mode$extensions$eval_region$mark(spec,p__58318){
var map__58323 = p__58318;
var map__58323__$1 = (((((!((map__58323 == null))))?(((((map__58323.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58323.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58323):map__58323);
var from = (function (){var obj58328 = map__58323__$1;
var k58329 = "from";
if((function (){var obj58330 = obj58328;
return (((!((obj58330 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58329,obj58330)));
})()){
return (obj58328[k58329]);
} else {
return undefined;
}
})();
var to = (function (){var obj58332 = map__58323__$1;
var k58333 = "to";
if((function (){var obj58336 = obj58332;
return (((!((obj58336 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58333,obj58336)));
})()){
return (obj58332[k58333]);
} else {
return undefined;
}
})();
return module$node_modules$$codemirror$view$dist$index_cjs.Decoration.mark(spec).range(from,to);
});
nextjournal.clojure_mode.extensions.eval_region.single_mark = (function nextjournal$clojure_mode$extensions$eval_region$single_mark(spec,range){
return module$node_modules$$codemirror$view$dist$index_cjs.Decoration.set([nextjournal.clojure_mode.extensions.eval_region.mark(spec,range)]);
});
if((typeof nextjournal !== 'undefined') && (typeof nextjournal.clojure_mode !== 'undefined') && (typeof nextjournal.clojure_mode.extensions !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region.mark_spec !== 'undefined')){
} else {
nextjournal.clojure_mode.extensions.eval_region.mark_spec = ({"attributes":({"style":"background-color: rgba(0, 243, 255, 0.14);"})});
}
if((typeof nextjournal !== 'undefined') && (typeof nextjournal.clojure_mode !== 'undefined') && (typeof nextjournal.clojure_mode.extensions !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region.mark_spec_highlight !== 'undefined')){
} else {
nextjournal.clojure_mode.extensions.eval_region.mark_spec_highlight = ({"attributes":({"style":"background-color: rgba(0, 243, 255, 0.35);"})});
}
nextjournal.clojure_mode.extensions.eval_region.cursor_range = (function nextjournal$clojure_mode$extensions$eval_region$cursor_range(state){
if(cljs.core.truth_(state.selection.main.empty)){
return nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$core$IFn$_invoke$arity$1(state);
} else {
return state.selection.main;
}
});
if((typeof nextjournal !== 'undefined') && (typeof nextjournal.clojure_mode !== 'undefined') && (typeof nextjournal.clojure_mode.extensions !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region !== 'undefined') && (typeof nextjournal.clojure_mode.extensions.eval_region.region_field !== 'undefined')){
} else {
nextjournal.clojure_mode.extensions.eval_region.region_field = module$node_modules$$codemirror$state$dist$index_cjs.StateField.define(({"create":cljs.core.constantly(module$node_modules$$codemirror$view$dist$index_cjs.Decoration.none),"update":(function (_value,p__58362){
var map__58363 = p__58362;
var map__58363__$1 = (((((!((map__58363 == null))))?(((((map__58363.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58363.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58363):map__58363);
var state = (function (){var obj58370 = map__58363__$1;
var k58371 = "state";
if((function (){var obj58373 = obj58370;
return (((!((obj58373 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58371,obj58373)));
})()){
return (obj58370[k58371]);
} else {
return undefined;
}
})();
var map__58377 = nextjournal.clojure_mode.extensions.eval_region.get_modifier_field(state);
var map__58377__$1 = cljs.core.__destructure_map(map__58377);
var Alt = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__58377__$1,"Alt");
var Shift = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__58377__$1,"Shift");
var Enter = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__58377__$1,"Enter");
var spec = (cljs.core.truth_(Enter)?nextjournal.clojure_mode.extensions.eval_region.mark_spec_highlight:nextjournal.clojure_mode.extensions.eval_region.mark_spec);
var temp__5751__auto__ = (cljs.core.truth_((function (){var and__4221__auto__ = Alt;
if(cljs.core.truth_(and__4221__auto__)){
return Shift;
} else {
return and__4221__auto__;
}
})())?nextjournal.clojure_mode.extensions.eval_region.top_level_node(state):(cljs.core.truth_(Alt)?(function (){var or__4223__auto__ = nextjournal.clojure_mode.util.guard(nextjournal.clojure_mode.extensions.eval_region.main_selection(state),(function (p1__58360_SHARP_){
return cljs.core.not((function (){var obj58382 = p1__58360_SHARP_;
var k58383 = "empty";
if((function (){var obj58384 = obj58382;
return (((!((obj58384 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58383,obj58384)));
})()){
return (obj58382[k58383]);
} else {
return undefined;
}
})());
}));
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return nextjournal.clojure_mode.extensions.eval_region.cursor_range(state);
}
})():null));
if(cljs.core.truth_(temp__5751__auto__)){
var range = temp__5751__auto__;
return nextjournal.clojure_mode.extensions.eval_region.single_mark(spec,range);
} else {
return module$node_modules$$codemirror$view$dist$index_cjs.Decoration.none;
}
})}));
}
nextjournal.clojure_mode.extensions.eval_region.get_region_field = (function nextjournal$clojure_mode$extensions$eval_region$get_region_field(state){
return state.field(nextjournal.clojure_mode.extensions.eval_region.region_field);
});
nextjournal.clojure_mode.extensions.eval_region.current_range = (function nextjournal$clojure_mode$extensions$eval_region$current_range(state){
var or__4223__auto__ = (function (){var G__58391 = nextjournal.clojure_mode.extensions.eval_region.get_region_field(state);
var G__58391__$1 = (((G__58391 == null))?null:(function (){var obj__45053__auto__ = G__58391;
var f__45054__auto__ = (obj__45053__auto__["iter"]);
return f__45054__auto__.call(obj__45053__auto__);
})());
if((G__58391__$1 == null)){
return null;
} else {
return nextjournal.clojure_mode.util.guard(G__58391__$1,(function (p1__58390_SHARP_){
var obj58392 = p1__58390_SHARP_;
var k58393 = "value";
if((function (){var obj58394 = obj58392;
return (((!((obj58394 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58393,obj58394)));
})()){
return (obj58392[k58393]);
} else {
return undefined;
}
}));
}
})();
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return state.selection.main;
}
});
/**
 * Maintains modifier-state-field, containing a map of {<modifier> true}, including Enter.
 */
nextjournal.clojure_mode.extensions.eval_region.modifier_extension = (function nextjournal$clojure_mode$extensions$eval_region$modifier_extension(modifier){
var handle_enter = (function nextjournal$clojure_mode$extensions$eval_region$modifier_extension_$_handle_enter(p__58395){
var map__58396 = p__58395;
var map__58396__$1 = (((((!((map__58396 == null))))?(((((map__58396.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58396.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58396):map__58396);
var view = map__58396__$1;
var state = (function (){var obj58398 = map__58396__$1;
var k58399 = "state";
if((function (){var obj58400 = obj58398;
return (((!((obj58400 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58399,obj58400)));
})()){
return (obj58398[k58399]);
} else {
return undefined;
}
})();
nextjournal.clojure_mode.extensions.eval_region.set_modifier_field_BANG_(view,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(nextjournal.clojure_mode.extensions.eval_region.get_modifier_field(state),"Enter",true));

return null;
});
var handle_key_event = (function (p__58402,p__58403){
var map__58404 = p__58402;
var map__58404__$1 = (((((!((map__58404 == null))))?(((((map__58404.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58404.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58404):map__58404);
var event = map__58404__$1;
var altKey = (function (){var obj58408 = map__58404__$1;
var k58409 = "altKey";
if((function (){var obj58410 = obj58408;
return (((!((obj58410 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58409,obj58410)));
})()){
return (obj58408[k58409]);
} else {
return undefined;
}
})();
var shiftKey = (function (){var obj58411 = map__58404__$1;
var k58412 = "shiftKey";
if((function (){var obj58413 = obj58411;
return (((!((obj58413 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58412,obj58413)));
})()){
return (obj58411[k58412]);
} else {
return undefined;
}
})();
var metaKey = (function (){var obj58415 = map__58404__$1;
var k58416 = "metaKey";
if((function (){var obj58417 = obj58415;
return (((!((obj58417 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58416,obj58417)));
})()){
return (obj58415[k58416]);
} else {
return undefined;
}
})();
var controlKey = (function (){var obj58420 = map__58404__$1;
var k58421 = "controlKey";
if((function (){var obj58422 = obj58420;
return (((!((obj58422 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58421,obj58422)));
})()){
return (obj58420[k58421]);
} else {
return undefined;
}
})();
var type = (function (){var obj58425 = map__58404__$1;
var k58426 = "type";
if((function (){var obj58428 = obj58425;
return (((!((obj58428 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58426,obj58428)));
})()){
return (obj58425[k58426]);
} else {
return undefined;
}
})();
var map__58429 = p__58403;
var map__58429__$1 = (((((!((map__58429 == null))))?(((((map__58429.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58429.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58429):map__58429);
var view = map__58429__$1;
var state = (function (){var obj58436 = map__58429__$1;
var k58437 = "state";
if((function (){var obj58439 = obj58436;
return (((!((obj58439 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58437,obj58439)));
})()){
return (obj58436[k58437]);
} else {
return undefined;
}
})();
var prev = nextjournal.clojure_mode.extensions.eval_region.get_modifier_field(state);
var next = (function (){var G__58440 = cljs.core.PersistentArrayMap.EMPTY;
var G__58440__$1 = (cljs.core.truth_(altKey)?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__58440,"Alt",true):G__58440);
var G__58440__$2 = (cljs.core.truth_(shiftKey)?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__58440__$1,"Shift",true):G__58440__$1);
var G__58440__$3 = (cljs.core.truth_(metaKey)?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__58440__$2,"Meta",true):G__58440__$2);
var G__58440__$4 = (cljs.core.truth_(controlKey)?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__58440__$3,"Control",true):G__58440__$3);
if(((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("keydown",type)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("Enter",module$node_modules$w3c_keyname$index_cjs.keyName(event))))){
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__58440__$4,"Enter",true);
} else {
return G__58440__$4;
}
})();
if(cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(prev,next)){
return nextjournal.clojure_mode.extensions.eval_region.set_modifier_field_BANG_(view,next);
} else {
return null;
}
});
var handle_backspace = (function (p__58442){
var map__58443 = p__58442;
var map__58443__$1 = (((((!((map__58443 == null))))?(((((map__58443.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58443.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58443):map__58443);
var view = map__58443__$1;
var state = (function (){var obj58449 = map__58443__$1;
var k58450 = "state";
if((function (){var obj58451 = obj58449;
return (((!((obj58451 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58450,obj58451)));
})()){
return (obj58449[k58450]);
} else {
return undefined;
}
})();
var dispatch = (function (){var obj58452 = map__58443__$1;
var k58453 = "dispatch";
if((function (){var obj58454 = obj58452;
return (((!((obj58454 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58453,obj58454)));
})()){
return (obj58452[k58453]);
} else {
return undefined;
}
})();
var map__58455 = nextjournal.clojure_mode.extensions.eval_region.current_range(state);
var map__58455__$1 = (((((!((map__58455 == null))))?(((((map__58455.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__58455.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,map__58455):map__58455);
var from = (function (){var obj58457 = map__58455__$1;
var k58458 = "from";
if((function (){var obj58459 = obj58457;
return (((!((obj58459 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58458,obj58459)));
})()){
return (obj58457[k58458]);
} else {
return undefined;
}
})();
var to = (function (){var obj58460 = map__58455__$1;
var k58461 = "to";
if((function (){var obj58462 = obj58460;
return (((!((obj58462 == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k58461,obj58462)));
})()){
return (obj58460[k58461]);
} else {
return undefined;
}
})();
if(cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(from,to)){
var G__58463_58601 = ({"changes":({"from":from,"to":to,"insert":""}),"annotations":nextjournal.clojure_mode.util.user_event_annotation("delete")});
(dispatch.cljs$core$IFn$_invoke$arity$1 ? dispatch.cljs$core$IFn$_invoke$arity$1(G__58463_58601) : dispatch.call(null,G__58463_58601));
} else {
}

return true;
});
return [nextjournal.clojure_mode.extensions.eval_region.modifier_field,module$node_modules$$codemirror$view$dist$index_cjs.keymap.of([({"key":[cljs.core.str.cljs$core$IFn$_invoke$arity$1(modifier),"-Enter"].join(''),"shift":handle_enter,"run":handle_enter}),({"key":[cljs.core.str.cljs$core$IFn$_invoke$arity$1(modifier),"-Backspace"].join(''),"run":handle_backspace,"shift":handle_backspace})]),module$node_modules$$codemirror$view$dist$index_cjs.EditorView.domEventHandlers(({"keydown": handle_key_event, "keyup": handle_key_event}))];
});
nextjournal.clojure_mode.extensions.eval_region.extension = (function nextjournal$clojure_mode$extensions$eval_region$extension(p__58465){
var map__58513 = p__58465;
var map__58513__$1 = cljs.core.__destructure_map(map__58513);
var modifier = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__58513__$1,new cljs.core.Keyword(null,"modifier","modifier",1634442788),"Alt");
return [nextjournal.clojure_mode.extensions.eval_region.modifier_extension(modifier),nextjournal.clojure_mode.extensions.eval_region.region_field,module$node_modules$$codemirror$view$dist$index_cjs.EditorView.decorations.from(nextjournal.clojure_mode.extensions.eval_region.region_field)];
});
nextjournal.clojure_mode.extensions.eval_region.cursor_node_string = (function nextjournal$clojure_mode$extensions$eval_region$cursor_node_string(state){
return nextjournal.clojure_mode.util.guard((function (){var G__58534 = nextjournal.clojure_mode.extensions.eval_region.node_at_cursor.cljs$core$IFn$_invoke$arity$1(state);
if((G__58534 == null)){
return null;
} else {
return nextjournal.clojure_mode.util.range_str(state,G__58534);
}
})(),cljs.core.complement(clojure.string.blank_QMARK_));
});
nextjournal.clojure_mode.extensions.eval_region.top_level_string = (function nextjournal$clojure_mode$extensions$eval_region$top_level_string(state){
return nextjournal.clojure_mode.util.guard((function (){var G__58540 = nextjournal.clojure_mode.extensions.eval_region.top_level_node(state);
if((G__58540 == null)){
return null;
} else {
return nextjournal.clojure_mode.util.range_str(state,G__58540);
}
})(),cljs.core.complement(clojure.string.blank_QMARK_));
});

//# sourceMappingURL=nextjournal.clojure_mode.extensions.eval_region.js.map
