text: (function(e){function n(n){for(var a,c,s=n[0],l=n[1],i=n[2],u=0,d=[];u<s.length;u++)c=s[u],Object.prototype.hasOwnProperty.call(r,c)&&r[c]&&d.push(r[c][0]),r[c]=0;for(a in l)Object.prototype.hasOwnProperty.call(l,a)&&(e[a]=l[a]);h&&h(n);while(d.length)d.shift()();return o.push.apply(o,i||[]),t()}function t(){for(var e,n=0;n<o.length;n++){for(var t=o[n],a=!0,c=1;c<t.length;c++){var s=t[c];0!==r[s]&&(a=!1)}a&&(o.splice(n--,1),e=l(l.s=t[0]))}return e}var a={},c={app:0},r={app:0},o=[];function s(e){return l.p+"js/"+({}[e]||e)+"."+{"chunk-6fce5758":"cec5107b","chunk-54307d02":"9248c3e6","chunk-7f41d572":"c02313cb","chunk-02353afb":"21d5a2af"}[e]+".js"}function l(n){if(a[n])return a[n].exports;var t=a[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.e=function(e){var n=[],t={"chunk-6fce5758":1,"chunk-54307d02":1,"chunk-7f41d572":1,"chunk-02353afb":1};c[e]?n.push(c[e]):0!==c[e]&&t[e]&&n.push(c[e]=new Promise((function(n,t){for(var a="css/"+({}[e]||e)+"."+{"chunk-6fce5758":"d61a5a18","chunk-54307d02":"9e084c19","chunk-7f41d572":"f0caf6ea","chunk-02353afb":"9d21c0d7"}[e]+".css",r=l.p+a,o=document.getElementsByTagName("link"),s=0;s<o.length;s++){var i=o[s],u=i.getAttribute("data-href")||i.getAttribute("href");if("stylesheet"===i.rel&&(u===a||u===r))return n()}var d=document.getElementsByTagName("style");for(s=0;s<d.length;s++){i=d[s],u=i.getAttribute("data-href");if(u===a||u===r)return n()}var h=document.createElement("link");h.rel="stylesheet",h.type="text/css",h.onload=n,h.onerror=function(n){var a=n&&n.target&&n.target.src||r,o=new Error("Loading CSS chunk "+e+" failed.\n("+a+")");o.code="CSS_CHUNK_LOAD_FAILED",o.request=a,delete c[e],h.parentNode.removeChild(h),t(o)},h.href=r;var f=document.getElementsByTagName("head")[0];f.appendChild(h)})).then((function(){c[e]=0})));var a=r[e];if(0!==a)if(a)n.push(a[2]);else{var o=new Promise((function(n,t){a=r[e]=[n,t]}));n.push(a[2]=o);var i,u=document.createElement("script");u.charset="utf-8",u.timeout=120,l.nc&&u.setAttribute("nonce",l.nc),u.src=s(e);var d=new Error;i=function(n){u.onerror=u.onload=null,clearTimeout(h);var t=r[e];if(0!==t){if(t){var a=n&&("load"===n.type?"missing":n.type),c=n&&n.target&&n.target.src;d.message="Loading chunk "+e+" failed.\n("+a+": "+c+")",d.name="ChunkLoadError",d.type=a,d.request=c,t[1](d)}r[e]=void 0}};var h=setTimeout((function(){i({type:"timeout",target:u})}),12e4);u.onerror=u.onload=i,document.head.appendChild(u)}return Promise.all(n)},l.m=e,l.c=a,l.d=function(e,n,t){l.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},l.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,n){if(1&n&&(e=l(e)),8&n)return e;if(4&n&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var a in e)l.d(t,a,function(n){return e[n]}.bind(null,a));return t},l.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return l.d(n,"a",n),n},l.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},l.p="",l.oe=function(e){throw console.error(e),e};var i=window["webpackJsonp"]=window["webpackJsonp"]||[],u=i.push.bind(i);i.push=n,i=i.slice();for(var d=0;d<i.length;d++)n(i[d]);var h=u;o.push([0,"chunk-vendors"]),t()})({0:function(e,n,t){e.exports=t("56d7")},"3e8c":function(e,n,t){"use strict";var a=t("993e"),c=t.n(a);c.a},"56d7":function(e,n,t){"use strict";t.r(n);t("e260"),t("e6cf"),t("cca6"),t("a79d");var a=t("2b0e"),c=function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("v-app",[t("v-app-bar",{attrs:{app:"",dense:"",dark:""}}),t("v-main",[t("v-dialog",{attrs:{persistent:"","max-width":"320"},model:{value:e.needHandle,callback:function(n){e.needHandle=n},expression:"needHandle"}},[t("v-card",[t("v-card-title",{staticClass:"headline"},[e._v(" Tell us your nick name 😎 ")]),t("v-card-text",[e._v("As a super simple way to see who wrote a message your nick name or handle will be prepended to your messages.")]),t("v-card-text",[t("v-text-field",{attrs:{label:"Enter your handle",hint:"This will be added to your messages",dark:"",outlined:"","full-width":"","append-icon":"mdi-face-agent"},on:{keydown:function(n){return!n.type.indexOf("key")&&e._k(n.keyCode,"enter",13,n.key,"Enter")?null:e.agentHandleEntered(n)},"click:append":e.agentHandleEntered},model:{value:e.internalAgentHandle,callback:function(n){e.internalAgentHandle=n},expression:"internalAgentHandle"}})],1),t("v-card-actions",[t("v-spacer"),t("v-btn",{attrs:{text:""},on:{click:e.agentHandleEntered}},[e._v(" Let's Go ")])],1)],1)],1),t("v-responsive",{attrs:{height:"100%"}},[t("transition",{attrs:{name:"fade"}},[t("router-view",{attrs:{id:"router"}})],1)],1)],1)],1)},r=[],o=t("5530"),s=t("2f62"),l={name:"App",components:{},data:function(){return{internalAgentHandle:"",dialog:!1}},methods:Object(o["a"])(Object(o["a"])({},Object(s["b"])(["setAgentHandle"])),{},{agentHandleEntered:function(){""!==this.internalAgentHandle&&(this.setAgentHandle(this.internalAgentHandle),this.dialog=!1)}}),computed:Object(o["a"])(Object(o["a"])({},Object(s["c"])(["agentHandle","needsHandle"])),{},{needHandle:function(){return this.needsHandle}}),created:function(){this.$store.dispatch("initialiseStore"),this.$vuetify.theme.dark=!0}},i=l,u=(t("3e8c"),t("2877")),d=t("6544"),h=t.n(d),f=t("7496"),p=t("40dc"),g=t("8336"),m=t("b0af"),b=t("99d9"),v=t("169a"),w=t("f6c4"),y=t("6b53"),C=t("2fa4"),k=t("8654"),j=Object(u["a"])(i,c,r,!1,null,"f049417c",null),O=j.exports;h()(j,{VApp:f["a"],VAppBar:p["a"],VBtn:g["a"],VCard:m["a"],VCardActions:b["a"],VCardText:b["b"],VCardTitle:b["c"],VDialog:v["a"],VMain:w["a"],VResponsive:y["a"],VSpacer:C["a"],VTextField:k["a"]});var D=t("9483");Object(D["a"])("".concat("","service-worker.js"),{ready:function(){console.log("App is being served from cache by a service worker.\nFor more details, visit https://goo.gl/AFskqB")},registered:function(){console.log("Service worker has been registered.")},cached:function(){console.log("Content has been cached for offline use.")},updatefound:function(){console.log("New content is downloading.")},updated:function(){console.log("New content is available; please refresh.")},offline:function(){console.log("No internet connection found. App is running in offline mode.")},error:function(e){console.error("Error during service worker registration:",e)}});t("d3b7");var _=t("8c4f");a["a"].use(_["a"]);var x=[{path:"/",name:"Public Messages",component:function(){return t.e("chunk-6fce5758").then(t.bind(null,"4a94"))}}],H=new _["a"]({mode:"history",base:"",routes:x}),A=H,S=(t("99af"),t("7db0"),t("d81d"),t("b0c0"),t("2909")),I=t("15fd"),M=(t("96cf"),t("1da1")),T=t("ec26");function F(e,n,t){e("listMessages",{channel:n,date:t})}function E(e,n){console.log(n,e)}var R=0,B={namespaced:!0,state:{channels:[],channel:{info:{name:""},channel:{category:"General",uuid:""},messages:[]}},actions:{setChannel:function(){var e=Object(M["a"])(regeneratorRuntime.mark((function e(n,t){var a,c,r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:a=n.commit,c=n.rootState,r=n.dispatch,E("setChannel start",Date.now()),c.hcDb.elementalChat.get(t.channel.uuid).then((function(e){E("setChannel dexie done",Date.now()),void 0===e&&(e=t),a("setChannel",e),F(r,t,c.today),clearInterval(R),R=setInterval((function(){F(r,t,c.today)}),5e4)})).catch((function(e){return E(e)}));case 3:case"end":return e.stop()}}),e)})));function n(n,t){return e.apply(this,arguments)}return n}(),addSignalChannel:function(){var e=Object(M["a"])(regeneratorRuntime.mark((function e(n,t){var a,c,r,s,l,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(a=n.commit,c=n.state,r=n.rootState,s=n.dispatch,l=t,i=!!c.channels.find((function(e){return e.channel.uuid===l.channel.uuid})),!i){e.next=5;break}return e.abrupt("return");case 5:E("new channel signal received",Date.now()),console.log("received channel : ",l),l.last_seen={First:null},a("createChannel",Object(o["a"])(Object(o["a"])({},l),{},{messages:[]})),r.hcDb.elementalChat.put(Object(o["a"])(Object(o["a"])({},l),{},{messages:[]}),l.channel.uuid).then(E("createChannel dexie done",Date.now())).catch((function(e){return E(e)})),s("setChannel",Object(o["a"])(Object(o["a"])({},l),{},{messages:[]}));case 11:case"end":return e.stop()}}),e)})));function n(n,t){return e.apply(this,arguments)}return n}(),createChannel:function(){var e=Object(M["a"])(regeneratorRuntime.mark((function e(n,t){var a,c,r,s;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:a=n.commit,c=n.rootState,r=n.dispatch,E("createChannel start",Date.now()),s={name:t.info.name,channel:t.channel},c.holochainClient.callZome({cap:null,cell_id:c.appInterface.cellId,zome_name:"chat",fn_name:"create_channel",provenance:c.agentKey,payload:s}).then((function(e){E("createChannel zome done",Date.now()),e.last_seen={First:null},a("createChannel",Object(o["a"])(Object(o["a"])({},e),{},{messages:[]})),console.log("created channel : ",e),c.hcDb.elementalChat.put(Object(o["a"])(Object(o["a"])({},e),{},{messages:[]}),e.channel.uuid).then(E("createChannel dexie done",Date.now())).catch((function(e){return E(e)})),r("setChannel",Object(o["a"])(Object(o["a"])({},e),{},{messages:[]}))}));case 4:case"end":return e.stop()}}),e)})));function n(n,t){return e.apply(this,arguments)}return n}(),listChannels:function(e,n){var t=e.commit,a=e.rootState,c=e.state,r=e.dispatch;E("listChannels start",Date.now()),a.hcDb.elementalChat.get(n.category).then((function(e){E("get listChannels dexie done",Date.now()),void 0===e&&(e=[]),t("setChannels",e)})),E("listChannels zome start",Date.now()),a.holochainClient.callZome({cap:null,cell_id:a.appInterface.cellId,zome_name:"chat",fn_name:"list_channels",provenance:a.agentKey,payload:n}).then((function(e){E("listChannels zome done",Date.now()),t("setChannels",e.channels),E("put listChannels dexie start",Date.now()),a.hcDb.elementalChat.put(e.channels,n.category).then(E("put listChannels dexie done",Date.now())).catch((function(e){return E(e)})),""===c.channel.info.name&&e.channels.length>0&&r("setChannel",Object(o["a"])(Object(o["a"])({},e.channels[0]),{},{messages:[]}))}))},addSignalMessageToChannel:function(){var e=Object(M["a"])(regeneratorRuntime.mark((function e(n,t){var a,c,r,s,l;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(a=n.rootState,c=n.state,r=t.channel,s=Object(I["a"])(t,["channel"]),E("new message signal received",Date.now()),l=c.channels.find((function(e){return e.channel.uuid===r.uuid})),l){e.next=6;break}throw new Error("No channel exists for this message...");case 6:a.hcDb.elementalChat.get(l.channel.uuid).then((function(e){var n=!!e.messages.find((function(e){return e.message.uuid===s.message.uuid}));if(console.log("messageExists",n),!n){console.log("received signal message : ",s);var t=e.messages.push(s),c=Object(o["a"])(Object(o["a"])({},r),{},{last_seen:{Message:s.entryHash},messages:t});console.log("adding signal message to the channel",c),E("addSignalMessageToChannel dexie start",Date.now()),a.hcDb.elementalChat.put(c,l.channel.uuid).then(E("addSignalMessageToChannel dexie done",Date.now())).catch((function(e){return E(e)}))}})).catch((function(e){return E(e)}));case 7:case"end":return e.stop()}}),e)})));function n(n,t){return e.apply(this,arguments)}return n}(),addMessageToChannel:function(){var e=Object(M["a"])(regeneratorRuntime.mark((function e(n,t){var a,c,r,s;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:a=n.commit,c=n.rootState,r=n.state,E("addMessageToChannel start",Date.now()),s={last_seen:t.channel.last_seen,channel:t.channel.channel,message:Object(o["a"])(Object(o["a"])({},t.message),{},{content:"".concat(c.agentHandle,"\n        ").concat(t.message.content)})},c.holochainClient.callZome({cap:null,cell_id:c.appInterface.cellId,zome_name:"chat",fn_name:"create_message",provenance:c.agentKey,payload:s}).then((function(e){E("addMessageToChannel zome done",Date.now());var n=Object(S["a"])(r.channel.messages);n.push(e);var s=Object(o["a"])(Object(o["a"])({},t.channel),{},{last_seen:{Message:e.entryHash},messages:n});a("setChannel",s),console.log("created message for channel",s),E("addMessageToChannel dexie start",Date.now()),c.hcDb.elementalChat.put(s,t.channel.channel.uuid).then(E("addMessageToChannel dexie done",Date.now())).catch((function(e){return E(e)}))})).catch((function(e){return E(e)}));case 4:case"end":return e.stop()}}),e)})));function n(n,t){return e.apply(this,arguments)}return n}(),listMessages:function(e,n){var t=e.commit,a=e.rootState;E("listMessages start",Date.now());var c={channel:n.channel.channel,date:n.date};a.holochainClient.callZome({cap:null,cell_id:a.appInterface.cellId,zome_name:"chat",fn_name:"list_messages",provenance:a.agentKey,payload:c}).then((function(e){E("listMessages zome done",Date.now()),n.channel.last_seen={First:null},e.messages.length>0&&(n.channel.last_seen={Message:e.messages[e.messages.length-1].entryHash});var c=Object(o["a"])(Object(o["a"])({},n.channel),{},{messages:e.messages});t("setChannelMessages",c),E("put listMessages dexie start",Date.now()),a.hcDb.elementalChat.put(c,n.channel.channel.uuid).then(E("put listMessages dexie done",Date.now())).catch((function(e){return E(e)}))})).catch((function(e){return E(e)}))},breakIt:function(){var e=Object(M["a"])(regeneratorRuntime.mark((function e(n){var t,a,c;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:for(t=n.rootState,E("Start test",new Date),a=0;a<10;a++)c={name:"".concat(t.agentHandle,"-channel").concat(a),channel:{category:"General",uuid:Object(T["a"])()}},t.holochainClient.callZome({cap:null,cell_id:t.appInterface.cellId,zome_name:"chat",fn_name:"create_channel",provenance:t.agentKey,payload:c}).then((function(e){E("Channel Created:",new Date),E(e)}));case 3:case"end":return e.stop()}}),e)})));function n(n){return e.apply(this,arguments)}return n}()},mutations:{setChannel:function(e,n){e.channel=Object(o["a"])({},n)},setChannels:function(e,n){e.channels=n},setChannelMessages:function(e,n){e.channels=e.channels.map((function(e){return e.channel.uuid!==n.channel.uuid?e:Object(o["a"])(Object(o["a"])({},e),n)})),e.channel.channel.uuid===n.channel.uuid&&(e.channel=Object(o["a"])({},n))},createChannel:function(e,n){e.channels.push(n)}}},K=t("2d36"),P=function(e){e.subscribe((function(e,n){})),e.subscribeAction({before:function(e,n){},after:function(e,n){}})};a["a"].use(s["a"]);var V=443,z="elemental-chat:hCAkJ6Yx5xJiCMS95amHmsczjlm39lQaKFRFyrfxosn/kYIGRCkk",N=window.location.hostname,L=new Date,Z=String(L.getUTCDate()),G=String(L.getUTCMonth()+1),J=String(L.getUTCFullYear());(function(){function e(){var e=this;return new Promise((function(n){var t=new FileReader;t.onload=function(){n(t.result)},t.readAsArrayBuffer(e)}))}"File"in self&&(File.prototype.arrayBuffer=File.prototype.arrayBuffer||e),Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||e})();var U=new s["a"].Store({state:{connectedToHolochain:!1,needsHandle:!1,today:{year:J,month:G,day:Z},agentHandle:""},mutations:{setAgentKey:function(e,n){e.agentKey=n},needsHandle:function(e,n){e.needsHandle=n},setAgentHandle:function(e,n){e.agentHandle=n,e.needsHandle=!1},setAppInterface:function(e,n){e.appInterface=n},setHolochainClient:function(e,n){e.holochainClient=n,e.connectedToHolochain=!0}},actions:{initialiseStore:function(e){var n=e.state,t=e.dispatch;n.hcDb.version(1).stores({agent:"",elementalChat:""}),t("initialiseAgent")},initialiseAgent:function(e){var n=e.commit,t=e.dispatch,a=e.state;K["AppWebsocket"].connect("wss://".concat(N,"/api/v1/ws/")).then((function(e){a.hcDb.agent.get("agentKey").then((function(t){console.log(t),void 0===t||null===t?e.appInfo({app_id:z}).then((function(e){console.log("appInfo fetched : ",e);var t=e.cell_data[0][0],c=t[1];n("setAgentKey",c),n("setAppInterface",{port:V,cellId:t}),a.hcDb.agent.put(c,"agentKey").catch((function(e){return console.log(e)})),a.hcDb.agent.put({port:V,cellId:t},"appInterface")})):(n("setAgentKey",t),a.hcDb.agent.get("appInterface").then((function(e){n("setAppInterface",{port:e.port,cellId:e.cellId})})))})),e.onclose=function(e){console.log("Socket is closed. Reconnect will be attempted in 1 second.",e.reason),setTimeout((function(){t("initialiseAgent")}),1e3)},console.log("holochainClient connected : ",e),n("setHolochainClient",e)})),a.hcDb.agent.get("agentHandle").then((function(e){null===e||void 0===e?n("needsHandle",!0):n("setAgentHandle",e)}))},setAgentHandle:function(e,n){var t=e.commit,a=e.state;t("setAgentHandle",n),a.hcDb.agent.put(n,"agentHandle")}},modules:{elementalChat:B},plugins:[P]}),$=t("f309");a["a"].use($["a"]);var q=new $["a"]({theme:{dark:!0,themes:{dark:{primary:"#5c007a",accent:"#424242",secondary:"#9c27b0",success:"#4CAF50",info:"#2196F3",warning:"#FB8C00",error:"#FF5252"},light:{primary:"#1976D2",accent:"#e91e63",secondary:"#30b1dc",success:"#4CAF50",info:"#2196F3",warning:"#FB8C00",error:"#FF5252"}}}}),Y=t("4dec"),Q=new Y["a"]("holochain"),W=U;W.state.hcDb=Q,a["a"].config.productionTip=!1,new a["a"]({router:A,store:W,vuetify:q,render:function(e){return e(O)}}).$mount("#app")},"993e":function(e,n,t){}});
  //# sourceMappingURL=app.5080644a.js.map