// Compiled by ClojureScript 1.9.562 {:target :nodejs}
goog.provide('weathergen.ipc');
goog.require('cljs.core');
goog.require('weathergen.encoding');
weathergen.ipc.electron = require("electron");
weathergen.ipc.channel = "weathergen-ipc";
if(typeof weathergen.ipc.on_message !== 'undefined'){
} else {
weathergen.ipc.on_message = (function (){var method_table__24369__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var prefer_table__24370__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var method_cache__24371__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var cached_hierarchy__24372__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var hierarchy__24373__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341),cljs.core.get_global_hierarchy.call(null));
return (new cljs.core.MultiFn(cljs.core.symbol.call(null,"weathergen.ipc","on-message"),((function (method_table__24369__auto__,prefer_table__24370__auto__,method_cache__24371__auto__,cached_hierarchy__24372__auto__,hierarchy__24373__auto__){
return (function() { 
var G__29472__delegate = function (type,event,args){
return type;
};
var G__29472 = function (type,event,var_args){
var args = null;
if (arguments.length > 2) {
var G__29474__i = 0, G__29474__a = new Array(arguments.length -  2);
while (G__29474__i < G__29474__a.length) {G__29474__a[G__29474__i] = arguments[G__29474__i + 2]; ++G__29474__i;}
  args = new cljs.core.IndexedSeq(G__29474__a,0,null);
} 
return G__29472__delegate.call(this,type,event,args);};
G__29472.cljs$lang$maxFixedArity = 2;
G__29472.cljs$lang$applyTo = (function (arglist__29475){
var type = cljs.core.first(arglist__29475);
arglist__29475 = cljs.core.next(arglist__29475);
var event = cljs.core.first(arglist__29475);
var args = cljs.core.rest(arglist__29475);
return G__29472__delegate(type,event,args);
});
G__29472.cljs$core$IFn$_invoke$arity$variadic = G__29472__delegate;
return G__29472;
})()
;})(method_table__24369__auto__,prefer_table__24370__auto__,method_cache__24371__auto__,cached_hierarchy__24372__auto__,hierarchy__24373__auto__))
,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__24373__auto__,method_table__24369__auto__,prefer_table__24370__auto__,method_cache__24371__auto__,cached_hierarchy__24372__auto__));
})();
}
/**
 * Sends a message from a renderer process to the main process.
 */
weathergen.ipc.send_to_main = (function weathergen$ipc$send_to_main(var_args){
var args__24566__auto__ = [];
var len__24559__auto___29489 = arguments.length;
var i__24560__auto___29490 = (0);
while(true){
if((i__24560__auto___29490 < len__24559__auto___29489)){
args__24566__auto__.push((arguments[i__24560__auto___29490]));

var G__29493 = (i__24560__auto___29490 + (1));
i__24560__auto___29490 = G__29493;
continue;
} else {
}
break;
}

var argseq__24567__auto__ = ((((1) < args__24566__auto__.length))?(new cljs.core.IndexedSeq(args__24566__auto__.slice((1)),(0),null)):null);
return weathergen.ipc.send_to_main.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__24567__auto__);
});

weathergen.ipc.send_to_main.cljs$core$IFn$_invoke$arity$variadic = (function (type,args){
return cljs.core.apply.call(null,(function (){var G__29485 = weathergen.ipc.electron.ipcRenderer;
return G__29485;
})().send,weathergen.ipc.channel,type,cljs.core.map.call(null,weathergen.encoding.encode,args));
});

weathergen.ipc.send_to_main.cljs$lang$maxFixedArity = (1);

weathergen.ipc.send_to_main.cljs$lang$applyTo = (function (seq29479){
var G__29480 = cljs.core.first.call(null,seq29479);
var seq29479__$1 = cljs.core.next.call(null,seq29479);
return weathergen.ipc.send_to_main.cljs$core$IFn$_invoke$arity$variadic(G__29480,seq29479__$1);
});

/**
 * Sends a message from the main process to a renderer process.
 */
weathergen.ipc.send_to_renderer = (function weathergen$ipc$send_to_renderer(var_args){
var args__24566__auto__ = [];
var len__24559__auto___29516 = arguments.length;
var i__24560__auto___29517 = (0);
while(true){
if((i__24560__auto___29517 < len__24559__auto___29516)){
args__24566__auto__.push((arguments[i__24560__auto___29517]));

var G__29518 = (i__24560__auto___29517 + (1));
i__24560__auto___29517 = G__29518;
continue;
} else {
}
break;
}

var argseq__24567__auto__ = ((((2) < args__24566__auto__.length))?(new cljs.core.IndexedSeq(args__24566__auto__.slice((2)),(0),null)):null);
return weathergen.ipc.send_to_renderer.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__24567__auto__);
});

weathergen.ipc.send_to_renderer.cljs$core$IFn$_invoke$arity$variadic = (function (window,type,args){
var wc = window.webContents;
var send = wc.send;
return send.apply(wc,cljs.core.clj__GT_js.call(null,cljs.core.into.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.ipc.channel,type], null),cljs.core.map.call(null,weathergen.encoding.encode,args))));
});

weathergen.ipc.send_to_renderer.cljs$lang$maxFixedArity = (2);

weathergen.ipc.send_to_renderer.cljs$lang$applyTo = (function (seq29505){
var G__29506 = cljs.core.first.call(null,seq29505);
var seq29505__$1 = cljs.core.next.call(null,seq29505);
var G__29507 = cljs.core.first.call(null,seq29505__$1);
var seq29505__$2 = cljs.core.next.call(null,seq29505__$1);
return weathergen.ipc.send_to_renderer.cljs$core$IFn$_invoke$arity$variadic(G__29506,G__29507,seq29505__$2);
});

weathergen.ipc.ipc = ((cljs.core._EQ_.call(null,"renderer",process.type))?weathergen.ipc.electron.ipcRenderer:weathergen.ipc.electron.ipcMain);
weathergen.ipc.ipc.on(weathergen.ipc.channel,(function() { 
var G__29532__delegate = function (event,p__29528){
var vec__29529 = p__29528;
var seq__29530 = cljs.core.seq.call(null,vec__29529);
var first__29531 = cljs.core.first.call(null,seq__29530);
var seq__29530__$1 = cljs.core.next.call(null,seq__29530);
var type = first__29531;
var args = seq__29530__$1;
return cljs.core.apply.call(null,weathergen.ipc.on_message,type,event,cljs.core.map.call(null,weathergen.encoding.decode,args));
};
var G__29532 = function (event,var_args){
var p__29528 = null;
if (arguments.length > 1) {
var G__29538__i = 0, G__29538__a = new Array(arguments.length -  1);
while (G__29538__i < G__29538__a.length) {G__29538__a[G__29538__i] = arguments[G__29538__i + 1]; ++G__29538__i;}
  p__29528 = new cljs.core.IndexedSeq(G__29538__a,0,null);
} 
return G__29532__delegate.call(this,event,p__29528);};
G__29532.cljs$lang$maxFixedArity = 1;
G__29532.cljs$lang$applyTo = (function (arglist__29542){
var event = cljs.core.first(arglist__29542);
var p__29528 = cljs.core.rest(arglist__29542);
return G__29532__delegate(event,p__29528);
});
G__29532.cljs$core$IFn$_invoke$arity$variadic = G__29532__delegate;
return G__29532;
})()
);
