import "./cljs_env.js";
goog.provide('sci.impl.protocols');
sci.impl.protocols.defprotocol = (function sci$impl$protocols$defprotocol(var_args){
var args__4835__auto__ = [];
var len__4829__auto___83991 = arguments.length;
var i__4830__auto___83993 = (0);
while(true){
if((i__4830__auto___83993 < len__4829__auto___83991)){
args__4835__auto__.push((arguments[i__4830__auto___83993]));

var G__83994 = (i__4830__auto___83993 + (1));
i__4830__auto___83993 = G__83994;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((4) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((4)),(0),null)):null);
return sci.impl.protocols.defprotocol.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),argseq__4836__auto__);
});

(sci.impl.protocols.defprotocol.cljs$core$IFn$_invoke$arity$variadic = (function (_,___$1,_ctx,protocol_name,signatures){
var vec__83393 = (function (){var sig = cljs.core.first(signatures);
if(typeof sig === 'string'){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [sig,cljs.core.rest(signatures)], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,signatures], null);
}
})();
var docstring = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83393,(0),null);
var signatures__$1 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83393,(1),null);
var vec__83396 = (function (){var opt = cljs.core.first(signatures__$1);
if((opt instanceof cljs.core.Keyword)){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentArrayMap.createAsIfByAssoc([opt,cljs.core.second(signatures__$1)]),cljs.core.nnext(signatures__$1)], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,signatures__$1], null);
}
})();
var opts = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83396,(0),null);
var signatures__$2 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83396,(1),null);
var current_ns = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sci.impl.vars.current_ns_name());
var fq_name = cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(current_ns,cljs.core.str.cljs$core$IFn$_invoke$arity$1(protocol_name));
var expansion = cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"def","def",597100991,null),null,(1),null)),(new cljs.core.List(null,cljs.core.with_meta(protocol_name,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"doc","doc",1913296891),docstring], null)),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.array_map,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Keyword(null,"methods","methods",453930866),null,(1),null)),(new cljs.core.List(null,cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_set,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$0()))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword(null,"name","name",1843675177),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),null,(1),null)),(new cljs.core.List(null,fq_name,null,(1),null))))),null,(1),null)),(new cljs.core.List(null,new cljs.core.Keyword(null,"ns","ns",441598760),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","*ns*","cljs.core/*ns*",1155497085,null),null,(1),null))], 0))))),null,(1),null))], 0)))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p__83419){
var vec__83420 = p__83419;
var seq__83421 = cljs.core.seq(vec__83420);
var first__83422 = cljs.core.first(seq__83421);
var seq__83421__$1 = cljs.core.next(seq__83421);
var method_name = first__83422;
var ___$2 = seq__83421__$1;
var fq_name__$1 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(current_ns,cljs.core.str.cljs$core$IFn$_invoke$arity$1(method_name));
var impls = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmulti","cljs.core/defmulti",723984225,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","protocol-type-impl","cljs.core/protocol-type-impl",155177701,null),null,(1),null))], 0)))),cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword("sci.impl.protocols","reified","sci.impl.protocols/reified",-2019939396),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"x__83356__auto__","x__83356__auto__",1912486381,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"&","&",-2144855648,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"args__83357__auto__","args__83357__auto__",-769295466,null),null,(1),null))], 0))))),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","let","cljs.core/let",-308701135,null),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"methods__83358__auto__","methods__83358__auto__",1152236351,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","-reified-methods","cljs.core/-reified-methods",-1833109469,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"x__83356__auto__","x__83356__auto__",1912486381,null),null,(1),null))))),null,(1),null)))))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","apply","cljs.core/apply",1757277831,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","get","cljs.core/get",-296075407,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"methods__83358__auto__","methods__83358__auto__",1152236351,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null))))),null,(1),null))], 0)))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"x__83356__auto__","x__83356__auto__",1912486381,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"args__83357__auto__","args__83357__auto__",-769295466,null),null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))], 0))))], null);
var impls__$1 = (cljs.core.truth_(new cljs.core.Keyword(null,"extend-via-metadata","extend-via-metadata",-427346794).cljs$core$IFn$_invoke$arity$1(opts))?cljs.core.conj.cljs$core$IFn$_invoke$arity$2(impls,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword(null,"default","default",-1987822328),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"x__83363__auto__","x__83363__auto__",-1103899414,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"&","&",-2144855648,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"args__83364__auto__","args__83364__auto__",1074994792,null),null,(1),null))], 0))))),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","let","cljs.core/let",-308701135,null),null,(1),null)),(new cljs.core.List(null,cljs.core.vec(cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"meta__83365__auto__","meta__83365__auto__",1953979696,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","meta","cljs.core/meta",-748218346,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"x__83363__auto__","x__83363__auto__",-1103899414,null),null,(1),null))))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"method__83366__auto__","method__83366__auto__",-1317620784,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","get","cljs.core/get",-296075407,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"meta__83365__auto__","meta__83365__auto__",1953979696,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),null,(1),null)),(new cljs.core.List(null,fq_name__$1,null,(1),null))))),null,(1),null))], 0)))),null,(1),null))], 0))))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"if","if",1181717262,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"method__83366__auto__","method__83366__auto__",-1317620784,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","apply","cljs.core/apply",1757277831,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"method__83366__auto__","method__83366__auto__",-1317620784,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Symbol(null,"x__83363__auto__","x__83363__auto__",-1103899414,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"args__83364__auto__","args__83364__auto__",1074994792,null),null,(1),null))], 0)))),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"throw","throw",595905694,null),null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"new","new",-444906321,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol("js","Error","js/Error",-1692659266,null),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","str","cljs.core/str",-1971828991,null),null,(1),null)),(new cljs.core.List(null,"No implementation of method: ",null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.keyword.cljs$core$IFn$_invoke$arity$1(method_name),null,(1),null)),(new cljs.core.List(null," of protocol: ",null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"var","var",870848730,null),null,(1),null)),(new cljs.core.List(null,protocol_name,null,(1),null))))),null,(1),null)),(new cljs.core.List(null," found for: ",null,(1),null)),(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","protocol-type-impl","cljs.core/protocol-type-impl",155177701,null),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol(null,"x__83363__auto__","x__83363__auto__",-1103899414,null),null,(1),null))))),null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))))),null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))], 0))))):impls);
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),impls__$1,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol(null,"def","def",597100991,null),null,(1),null)),(new cljs.core.List(null,protocol_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","update","cljs.core/update",-908565906,null),null,(1),null)),(new cljs.core.List(null,protocol_name,null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,new cljs.core.Keyword(null,"methods","methods",453930866),null,(1),null)),(new cljs.core.List(null,new cljs.core.Symbol("cljs.core","conj","cljs.core/conj",-460750931,null),null,(1),null)),(new cljs.core.List(null,method_name,null,(1),null))], 0)))),null,(1),null))], 0)))),null,(1),null))], 0))));
}),signatures__$2)], 0))));
return expansion;
}));

(sci.impl.protocols.defprotocol.cljs$lang$maxFixedArity = (4));

/** @this {Function} */
(sci.impl.protocols.defprotocol.cljs$lang$applyTo = (function (seq83372){
var G__83374 = cljs.core.first(seq83372);
var seq83372__$1 = cljs.core.next(seq83372);
var G__83375 = cljs.core.first(seq83372__$1);
var seq83372__$2 = cljs.core.next(seq83372__$1);
var G__83376 = cljs.core.first(seq83372__$2);
var seq83372__$3 = cljs.core.next(seq83372__$2);
var G__83377 = cljs.core.first(seq83372__$3);
var seq83372__$4 = cljs.core.next(seq83372__$3);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__83374,G__83375,G__83376,G__83377,seq83372__$4);
}));

sci.impl.protocols.extend_protocol = (function sci$impl$protocols$extend_protocol(var_args){
var args__4835__auto__ = [];
var len__4829__auto___83998 = arguments.length;
var i__4830__auto___84000 = (0);
while(true){
if((i__4830__auto___84000 < len__4829__auto___83998)){
args__4835__auto__.push((arguments[i__4830__auto___84000]));

var G__84001 = (i__4830__auto___84000 + (1));
i__4830__auto___84000 = G__84001;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((4) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((4)),(0),null)):null);
return sci.impl.protocols.extend_protocol.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),argseq__4836__auto__);
});

(sci.impl.protocols.extend_protocol.cljs$core$IFn$_invoke$arity$variadic = (function (_,___$1,ctx,protocol_name,impls){
var impls__$1 = sci.impl.utils.split_when((function (p1__83509_SHARP_){
return (!(cljs.core.seq_QMARK_(p1__83509_SHARP_)));
}),impls);
var protocol_var = (function (){var G__83541 = ctx;
var G__83542 = new cljs.core.Keyword(null,"bindingx","bindingx",679516896).cljs$core$IFn$_invoke$arity$1(ctx);
var G__83543 = protocol_name;
var fexpr__83540 = cljs.core.deref(sci.impl.utils.eval_resolve_state);
return (fexpr__83540.cljs$core$IFn$_invoke$arity$3 ? fexpr__83540.cljs$core$IFn$_invoke$arity$3(G__83541,G__83542,G__83543) : fexpr__83540.call(null,G__83541,G__83542,G__83543));
})();
var protocol_ns = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(protocol_var));
var pns = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sci.impl.vars.getName(protocol_ns));
var fq_meth_name = (function (p1__83510_SHARP_){
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(pns,p1__83510_SHARP_);
});
var expansion = cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p__83560){
var vec__83561 = p__83560;
var seq__83562 = cljs.core.seq(vec__83561);
var first__83563 = cljs.core.first(seq__83562);
var seq__83562__$1 = cljs.core.next(seq__83562);
var type = first__83563;
var meths = seq__83562__$1;
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (meth){
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,fq_meth_name(cljs.core.name(cljs.core.first(meth))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,type,null,(1),null)),(new cljs.core.List(null,cljs.core.second(meth),null,(1),null)),cljs.core.nnext(meth)], 0))));
}),meths))));
}),impls__$1))));
return expansion;
}));

(sci.impl.protocols.extend_protocol.cljs$lang$maxFixedArity = (4));

/** @this {Function} */
(sci.impl.protocols.extend_protocol.cljs$lang$applyTo = (function (seq83523){
var G__83524 = cljs.core.first(seq83523);
var seq83523__$1 = cljs.core.next(seq83523);
var G__83525 = cljs.core.first(seq83523__$1);
var seq83523__$2 = cljs.core.next(seq83523__$1);
var G__83526 = cljs.core.first(seq83523__$2);
var seq83523__$3 = cljs.core.next(seq83523__$2);
var G__83527 = cljs.core.first(seq83523__$3);
var seq83523__$4 = cljs.core.next(seq83523__$3);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__83524,G__83525,G__83526,G__83527,seq83523__$4);
}));

sci.impl.protocols.extend = (function sci$impl$protocols$extend(var_args){
var args__4835__auto__ = [];
var len__4829__auto___84003 = arguments.length;
var i__4830__auto___84004 = (0);
while(true){
if((i__4830__auto___84004 < len__4829__auto___84003)){
args__4835__auto__.push((arguments[i__4830__auto___84004]));

var G__84005 = (i__4830__auto___84004 + (1));
i__4830__auto___84004 = G__84005;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((2) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((2)),(0),null)):null);
return sci.impl.protocols.extend.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4836__auto__);
});

(sci.impl.protocols.extend.cljs$core$IFn$_invoke$arity$variadic = (function (ctx,atype,proto_PLUS_mmaps){
var seq__83596 = cljs.core.seq(cljs.core.partition.cljs$core$IFn$_invoke$arity$2((2),proto_PLUS_mmaps));
var chunk__83598 = null;
var count__83599 = (0);
var i__83600 = (0);
while(true){
if((i__83600 < count__83599)){
var vec__83732 = chunk__83598.cljs$core$IIndexed$_nth$arity$2(null,i__83600);
var proto = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83732,(0),null);
var mmap = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83732,(1),null);
var proto_ns_84006 = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(proto);
var pns_84007 = sci.impl.vars.getName(proto_ns_84006);
var seq__83735_84008 = cljs.core.seq(mmap);
var chunk__83736_84009 = null;
var count__83737_84010 = (0);
var i__83738_84011 = (0);
while(true){
if((i__83738_84011 < count__83737_84010)){
var vec__83789_84012 = chunk__83736_84009.cljs$core$IIndexed$_nth$arity$2(null,i__83738_84011);
var fn_name_84013 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83789_84012,(0),null);
var f_84014 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83789_84012,(1),null);
var fn_sym_84015 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_84013));
var env_84016 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_84017 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_84016,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_84007,fn_sym_84015], null));
var multi_method_84018 = cljs.core.deref(multi_method_var_84017);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_84018,atype,f_84014);


var G__84019 = seq__83735_84008;
var G__84020 = chunk__83736_84009;
var G__84021 = count__83737_84010;
var G__84022 = (i__83738_84011 + (1));
seq__83735_84008 = G__84019;
chunk__83736_84009 = G__84020;
count__83737_84010 = G__84021;
i__83738_84011 = G__84022;
continue;
} else {
var temp__5753__auto___84023 = cljs.core.seq(seq__83735_84008);
if(temp__5753__auto___84023){
var seq__83735_84024__$1 = temp__5753__auto___84023;
if(cljs.core.chunked_seq_QMARK_(seq__83735_84024__$1)){
var c__4649__auto___84025 = cljs.core.chunk_first(seq__83735_84024__$1);
var G__84026 = cljs.core.chunk_rest(seq__83735_84024__$1);
var G__84027 = c__4649__auto___84025;
var G__84028 = cljs.core.count(c__4649__auto___84025);
var G__84029 = (0);
seq__83735_84008 = G__84026;
chunk__83736_84009 = G__84027;
count__83737_84010 = G__84028;
i__83738_84011 = G__84029;
continue;
} else {
var vec__83798_84030 = cljs.core.first(seq__83735_84024__$1);
var fn_name_84031 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83798_84030,(0),null);
var f_84032 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83798_84030,(1),null);
var fn_sym_84033 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_84031));
var env_84034 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_84035 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_84034,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_84007,fn_sym_84033], null));
var multi_method_84036 = cljs.core.deref(multi_method_var_84035);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_84036,atype,f_84032);


var G__84037 = cljs.core.next(seq__83735_84024__$1);
var G__84038 = null;
var G__84039 = (0);
var G__84040 = (0);
seq__83735_84008 = G__84037;
chunk__83736_84009 = G__84038;
count__83737_84010 = G__84039;
i__83738_84011 = G__84040;
continue;
}
} else {
}
}
break;
}


var G__84041 = seq__83596;
var G__84042 = chunk__83598;
var G__84043 = count__83599;
var G__84044 = (i__83600 + (1));
seq__83596 = G__84041;
chunk__83598 = G__84042;
count__83599 = G__84043;
i__83600 = G__84044;
continue;
} else {
var temp__5753__auto__ = cljs.core.seq(seq__83596);
if(temp__5753__auto__){
var seq__83596__$1 = temp__5753__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__83596__$1)){
var c__4649__auto__ = cljs.core.chunk_first(seq__83596__$1);
var G__84045 = cljs.core.chunk_rest(seq__83596__$1);
var G__84046 = c__4649__auto__;
var G__84047 = cljs.core.count(c__4649__auto__);
var G__84048 = (0);
seq__83596 = G__84045;
chunk__83598 = G__84046;
count__83599 = G__84047;
i__83600 = G__84048;
continue;
} else {
var vec__83819 = cljs.core.first(seq__83596__$1);
var proto = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83819,(0),null);
var mmap = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83819,(1),null);
var proto_ns_84049 = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(proto);
var pns_84050 = sci.impl.vars.getName(proto_ns_84049);
var seq__83822_84051 = cljs.core.seq(mmap);
var chunk__83823_84052 = null;
var count__83824_84053 = (0);
var i__83825_84054 = (0);
while(true){
if((i__83825_84054 < count__83824_84053)){
var vec__83850_84055 = chunk__83823_84052.cljs$core$IIndexed$_nth$arity$2(null,i__83825_84054);
var fn_name_84056 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83850_84055,(0),null);
var f_84057 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83850_84055,(1),null);
var fn_sym_84058 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_84056));
var env_84059 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_84060 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_84059,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_84050,fn_sym_84058], null));
var multi_method_84061 = cljs.core.deref(multi_method_var_84060);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_84061,atype,f_84057);


var G__84063 = seq__83822_84051;
var G__84064 = chunk__83823_84052;
var G__84065 = count__83824_84053;
var G__84066 = (i__83825_84054 + (1));
seq__83822_84051 = G__84063;
chunk__83823_84052 = G__84064;
count__83824_84053 = G__84065;
i__83825_84054 = G__84066;
continue;
} else {
var temp__5753__auto___84067__$1 = cljs.core.seq(seq__83822_84051);
if(temp__5753__auto___84067__$1){
var seq__83822_84068__$1 = temp__5753__auto___84067__$1;
if(cljs.core.chunked_seq_QMARK_(seq__83822_84068__$1)){
var c__4649__auto___84069 = cljs.core.chunk_first(seq__83822_84068__$1);
var G__84070 = cljs.core.chunk_rest(seq__83822_84068__$1);
var G__84071 = c__4649__auto___84069;
var G__84072 = cljs.core.count(c__4649__auto___84069);
var G__84073 = (0);
seq__83822_84051 = G__84070;
chunk__83823_84052 = G__84071;
count__83824_84053 = G__84072;
i__83825_84054 = G__84073;
continue;
} else {
var vec__83875_84074 = cljs.core.first(seq__83822_84068__$1);
var fn_name_84075 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83875_84074,(0),null);
var f_84076 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__83875_84074,(1),null);
var fn_sym_84077 = cljs.core.symbol.cljs$core$IFn$_invoke$arity$1(cljs.core.name(fn_name_84075));
var env_84078 = cljs.core.deref(new cljs.core.Keyword(null,"env","env",-1815813235).cljs$core$IFn$_invoke$arity$1(ctx));
var multi_method_var_84079 = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(env_84078,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"namespaces","namespaces",-1444157469),pns_84050,fn_sym_84077], null));
var multi_method_84080 = cljs.core.deref(multi_method_var_84079);
sci.impl.multimethods.multi_fn_add_method_impl(multi_method_84080,atype,f_84076);


var G__84081 = cljs.core.next(seq__83822_84068__$1);
var G__84082 = null;
var G__84083 = (0);
var G__84084 = (0);
seq__83822_84051 = G__84081;
chunk__83823_84052 = G__84082;
count__83824_84053 = G__84083;
i__83825_84054 = G__84084;
continue;
}
} else {
}
}
break;
}


var G__84085 = cljs.core.next(seq__83596__$1);
var G__84086 = null;
var G__84087 = (0);
var G__84088 = (0);
seq__83596 = G__84085;
chunk__83598 = G__84086;
count__83599 = G__84087;
i__83600 = G__84088;
continue;
}
} else {
return null;
}
}
break;
}
}));

(sci.impl.protocols.extend.cljs$lang$maxFixedArity = (2));

/** @this {Function} */
(sci.impl.protocols.extend.cljs$lang$applyTo = (function (seq83577){
var G__83578 = cljs.core.first(seq83577);
var seq83577__$1 = cljs.core.next(seq83577);
var G__83579 = cljs.core.first(seq83577__$1);
var seq83577__$2 = cljs.core.next(seq83577__$1);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__83578,G__83579,seq83577__$2);
}));

sci.impl.protocols.extend_type = (function sci$impl$protocols$extend_type(var_args){
var args__4835__auto__ = [];
var len__4829__auto___84089 = arguments.length;
var i__4830__auto___84090 = (0);
while(true){
if((i__4830__auto___84090 < len__4829__auto___84089)){
args__4835__auto__.push((arguments[i__4830__auto___84090]));

var G__84091 = (i__4830__auto___84090 + (1));
i__4830__auto___84090 = G__84091;
continue;
} else {
}
break;
}

var argseq__4836__auto__ = ((((4) < args__4835__auto__.length))?(new cljs.core.IndexedSeq(args__4835__auto__.slice((4)),(0),null)):null);
return sci.impl.protocols.extend_type.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),argseq__4836__auto__);
});

(sci.impl.protocols.extend_type.cljs$core$IFn$_invoke$arity$variadic = (function (_,___$1,ctx,atype,proto_PLUS_meths){
var proto_PLUS_meths__$1 = sci.impl.utils.split_when((function (p1__83881_SHARP_){
return (!(cljs.core.seq_QMARK_(p1__83881_SHARP_)));
}),proto_PLUS_meths);
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p__83909){
var vec__83910 = p__83909;
var seq__83911 = cljs.core.seq(vec__83910);
var first__83912 = cljs.core.first(seq__83911);
var seq__83911__$1 = cljs.core.next(seq__83911);
var proto = first__83912;
var meths = seq__83911__$1;
var protocol_var = (function (){var G__83935 = ctx;
var G__83937 = new cljs.core.Keyword(null,"bindings","bindings",1271397192).cljs$core$IFn$_invoke$arity$1(ctx);
var G__83938 = proto;
var fexpr__83934 = cljs.core.deref(sci.impl.utils.eval_resolve_state);
return (fexpr__83934.cljs$core$IFn$_invoke$arity$3 ? fexpr__83934.cljs$core$IFn$_invoke$arity$3(G__83935,G__83937,G__83938) : fexpr__83934.call(null,G__83935,G__83937,G__83938));
})();
var protocol_ns = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(protocol_var));
var pns = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sci.impl.vars.getName(protocol_ns));
var fq_meth_name = (function (p1__83882_SHARP_){
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(pns,p1__83882_SHARP_);
});
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol(null,"do","do",1686842252,null),null,(1),null)),cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (meth){
return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic((new cljs.core.List(null,new cljs.core.Symbol("cljs.core","defmethod","cljs.core/defmethod",-180785162,null),null,(1),null)),(new cljs.core.List(null,fq_meth_name(cljs.core.name(cljs.core.first(meth))),null,(1),null)),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([(new cljs.core.List(null,atype,null,(1),null)),(new cljs.core.List(null,cljs.core.second(meth),null,(1),null)),cljs.core.nnext(meth)], 0))));
}),meths))));
}),proto_PLUS_meths__$1))));
}));

(sci.impl.protocols.extend_type.cljs$lang$maxFixedArity = (4));

/** @this {Function} */
(sci.impl.protocols.extend_type.cljs$lang$applyTo = (function (seq83903){
var G__83904 = cljs.core.first(seq83903);
var seq83903__$1 = cljs.core.next(seq83903);
var G__83905 = cljs.core.first(seq83903__$1);
var seq83903__$2 = cljs.core.next(seq83903__$1);
var G__83906 = cljs.core.first(seq83903__$2);
var seq83903__$3 = cljs.core.next(seq83903__$2);
var G__83907 = cljs.core.first(seq83903__$3);
var seq83903__$4 = cljs.core.next(seq83903__$3);
var self__4816__auto__ = this;
return self__4816__auto__.cljs$core$IFn$_invoke$arity$variadic(G__83904,G__83905,G__83906,G__83907,seq83903__$4);
}));

sci.impl.protocols.find_matching_non_default_method = (function sci$impl$protocols$find_matching_non_default_method(protocol,obj){
return cljs.core.boolean$(cljs.core.some((function (p1__83940_SHARP_){
var temp__5753__auto__ = cljs.core.get_method(p1__83940_SHARP_,sci.impl.types.type_impl(obj));
if(cljs.core.truth_(temp__5753__auto__)){
var m = temp__5753__auto__;
var ms = cljs.core.methods$(p1__83940_SHARP_);
var default$ = cljs.core.get.cljs$core$IFn$_invoke$arity$2(ms,new cljs.core.Keyword(null,"default","default",-1987822328));
return (!((m === default$)));
} else {
return null;
}
}),new cljs.core.Keyword(null,"methods","methods",453930866).cljs$core$IFn$_invoke$arity$1(protocol)));
});
sci.impl.protocols.satisfies_QMARK_ = (function sci$impl$protocols$satisfies_QMARK_(protocol,obj){
if((obj instanceof sci.impl.types.Reified)){
return cljs.core.contains_QMARK_(obj.sci$impl$types$IReified$getProtocols$arity$1(null),protocol);
} else {
var p = new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(protocol);
var or__4223__auto__ = (function (){var and__4221__auto__ = p;
if(cljs.core.truth_(and__4221__auto__)){
var pred__83972 = cljs.core._EQ_;
var expr__83973 = p;
if(cljs.core.truth_((pred__83972.cljs$core$IFn$_invoke$arity$2 ? pred__83972.cljs$core$IFn$_invoke$arity$2(cljs.core.IDeref,expr__83973) : pred__83972.call(null,cljs.core.IDeref,expr__83973)))){
if((!((obj == null)))){
if((((obj.cljs$lang$protocol_mask$partition0$ & (32768))) || ((cljs.core.PROTOCOL_SENTINEL === obj.cljs$core$IDeref$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition0$)){
return cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_(cljs.core.IDeref,obj);
}
} else {
if(cljs.core.truth_((pred__83972.cljs$core$IFn$_invoke$arity$2 ? pred__83972.cljs$core$IFn$_invoke$arity$2(cljs.core.ISwap,expr__83973) : pred__83972.call(null,cljs.core.ISwap,expr__83973)))){
if((!((obj == null)))){
if((((obj.cljs$lang$protocol_mask$partition1$ & (65536))) || ((cljs.core.PROTOCOL_SENTINEL === obj.cljs$core$ISwap$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition1$)){
return cljs.core.native_satisfies_QMARK_(cljs.core.ISwap,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_(cljs.core.ISwap,obj);
}
} else {
if(cljs.core.truth_((pred__83972.cljs$core$IFn$_invoke$arity$2 ? pred__83972.cljs$core$IFn$_invoke$arity$2(cljs.core.IReset,expr__83973) : pred__83972.call(null,cljs.core.IReset,expr__83973)))){
if((!((obj == null)))){
if((((obj.cljs$lang$protocol_mask$partition1$ & (32768))) || ((cljs.core.PROTOCOL_SENTINEL === obj.cljs$core$IReset$)))){
return true;
} else {
if((!obj.cljs$lang$protocol_mask$partition1$)){
return cljs.core.native_satisfies_QMARK_(cljs.core.IReset,obj);
} else {
return false;
}
}
} else {
return cljs.core.native_satisfies_QMARK_(cljs.core.IReset,obj);
}
} else {
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(expr__83973)].join('')));
}
}
}
} else {
return and__4221__auto__;
}
})();
if(cljs.core.truth_(or__4223__auto__)){
return or__4223__auto__;
} else {
return sci.impl.protocols.find_matching_non_default_method(protocol,obj);
}
}
});
sci.impl.protocols.instance_impl = (function sci$impl$protocols$instance_impl(clazz,x){
if(cljs.core.truth_((function (){var and__4221__auto__ = (clazz instanceof cljs.core.Symbol);
if(and__4221__auto__){
var G__83988 = clazz;
var G__83988__$1 = (((G__83988 == null))?null:cljs.core.meta(G__83988));
if((G__83988__$1 == null)){
return null;
} else {
return new cljs.core.Keyword("sci.impl","record","sci.impl/record",-1939193950).cljs$core$IFn$_invoke$arity$1(G__83988__$1);
}
} else {
return and__4221__auto__;
}
})())){
return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(clazz,new cljs.core.Keyword(null,"type","type",1174270348).cljs$core$IFn$_invoke$arity$1(cljs.core.meta(x)));
} else {
return (x instanceof clazz);

}
});
/**
 * Returns true if atype extends protocol
 */
sci.impl.protocols.extends_QMARK_ = (function sci$impl$protocols$extends_QMARK_(protocol,atype){
return cljs.core.boolean$(cljs.core.some((function (p1__83989_SHARP_){
return cljs.core.get_method(p1__83989_SHARP_,atype);
}),new cljs.core.Keyword(null,"methods","methods",453930866).cljs$core$IFn$_invoke$arity$1(protocol)));
});

//# sourceMappingURL=sci.impl.protocols.js.map
