!function(e){function t(t){for(var a,s,i=t[0],l=t[1],c=t[2],f=0,d=[];f0?s.ids.pop():s.maxId++,s.inFlight[a]=t,n.port.postMessage(new p(a,r,o).deflate()),i});var r=chrome.runtime.connect({name:t});r.onMessage.addListener(function(e){console.log(e);var t=(e.type,n.requestCallback),a=t.inFlight[e.id];console.assert(void 0!==a),t.ids.push(e.id),a(e)}),this.port=r,this.requestCallback={inFlight:{},ids:[],maxId:0}}},43:function(e,t,n){"use strict";n.d(t,"e",function(){return p}),n.d(t,"b",function(){return h}),n.d(t,"f",function(){return m}),n.d(t,"g",function(){return g}),n.d(t,"c",function(){return y}),n.d(t,"d",function(){return v}),n.d(t,"a",function(){return j});var a=n(109),r=n.n(a);function o(e,t){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];return new Promise(function(t){return chrome.identity.getAuthToken({interactive:e},function(e){return t([e,!chrome.runtime.lastError])})}).then(function(e){var t=i(e,2),n=t[0];if(t[1])return n;throw c.notLoggedIn})}function p(){return null===f?d(!1).then(function(){return f=!0}).catch(function(){return f=!1}).then(function(){return f}):Promise.resolve(f)}function h(){return p().then(function(e){if(e)return d(!1);throw c.notLoggedIn})}function m(){return p().then(function(e){if(e)throw c.notLoggedOut;return d(!0).then(function(){return f=!0})})}function g(){return h().then(function(e){return fetch("https://accounts.google.com/o/oauth2/revoke?".concat(u({token:e})),{method:"GET",async:!0}).then(function(t){return function(e){return new Promise(function(t){return chrome.identity.removeCachedAuthToken({token:e},function(){return t()})})}(e)})}).then(function(){return f=!1})}function y(e){return fetch("".concat(l,"/users/me/calendarList?").concat(u({access_token:e})),{method:"GET",async:!0}).then(function(e){return e.json()}).then(function(e){return e.items})}function v(e){return fetch("".concat(l,"/colors?").concat(u({access_token:e})),{method:"GET",async:!0}).then(function(e){return e.json()})}function b(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:100,i=[];return function n(f,d){return fetch("".concat(l,"/calendars/").concat(e,"/events?").concat(u({access_token:t,pageToken:f,syncToken:d,timeMin:a,timeMax:r,maxResults:o})),{method:"GET",async:!0}).then(function(e){if(200===e.status)return e.json();throw 410===e.status?c.invalidSyncToken:c.otherError}).then(function(e){return i.push.apply(i,s(e.items)),e.nextPageToken?n(e.nextPageToken,""):{nextSyncToken:e.nextSyncToken,results:i}})}("",n)}var j=function(){function e(t,n){var a=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{maxCachedItems:100,nDaysPerSlot:10,largeQuery:10};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.calId=t,this.name=n,this.syncToken="",this.cache=new r.a({max:o.maxCachedItems,dispose:function(e,t){return a.onRemoveSlot(e,t)}}),this.eventMeta={},this.options=o,this.divider=864e5*this.options.nDaysPerSlot}var t,n,a;return t=e,(n=[{key:"dateToCacheKey",value:function(e){return Math.floor(e/this.divider)}},{key:"dateRangeToCacheKeys",value:function(e){return{start:this.dateToCacheKey(e.start),end:this.dateToCacheKey(new Date(e.end.getTime()-1))}}},{key:"getSlot",value:function(e){if(this.cache.has(e))return this.cache.get(e);var t={};return this.cache.set(e,t),t}},{key:"onRemoveSlot",value:function(e,t){for(var n in t){console.assert(this.eventMeta[n]);var a=this.eventMeta[n].keys;a.delete(e),0===a.size&&delete this.eventMeta[n]}}},{key:"slotStartDate",value:function(e){return new Date(e*this.divider)}},{key:"slotEndDate",value:function(e){return new Date((e+1)*this.divider)}},{key:"addEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.eventMeta.hasOwnProperty(e.id)&&this.removeEvent(e);for(var n=this.dateRangeToCacheKeys(e),a=n.start,r=n.end,o=this.cache.length,s=new Set,i=a;i<=r;i++)s.add(i),this.cache.has(i)||o++;if(this.eventMeta[e.id]={keys:s,summary:e.summary},t||!(o>this.options.maxCachedItems))if(a===r)this.getSlot(a)[e.id]={start:e.start,end:e.end,id:e.id};else{this.getSlot(a)[e.id]={start:e.start,end:this.slotEndDate(a),id:e.id},this.getSlot(r)[e.id]={start:this.slotStartDate(r),end:e.end,id:e.id};for(var l=a+1;l=n||a[o].end<=t||r.push({id:o,start:a[o].startn?n:a[o].end,summary:this.eventMeta[o].summary});return r}},{key:"getCachedEvents",value:function(e){for(var t=this.dateRangeToCacheKeys(e),n=t.start,a=t.end,r=this.getSlotEvents(n,e.start,e.end),o=n+1;on&&r.push.apply(r,s(this.getSlotEvents(a,e.start,e.end))),r}},{key:"sync",value:function(){var e=this;return this.token.then(function(t){return b(e.calId,t,e.syncToken).then(function(n){var a=n.results.map(function(n){return n.start?Promise.resolve(n):function(e,t,n){return fetch("".concat(l,"/calendars/").concat(e,"/events/").concat(t,"?").concat(u({access_token:n})),{method:"GET",async:!0}).then(function(e){return e.json()})}(e.calId,n.id,t)});return Promise.all(a).then(function(t){t.forEach(function(t){t.start=new Date(t.start.dateTime),t.end=new Date(t.end.dateTime),"confirmed"===t.status?e.addEvent(t):"cancelled"===t.status&&e.removeEvent(t)}),e.syncToken=n.nextSyncToken})})}).catch(function(t){if(t!==c.invalidSyncToken)throw t;e.syncToken="",e.sync()})}},{key:"getEvents",value:function(e,t){for(var n=this,a=this.dateRangeToCacheKeys({start:e,end:t}),r={},o=a.start;o<=a.end;o++)this.cache.has(o)||(r.hasOwnProperty("start")||(r.start=o),r.end=o);return console.log("start: ".concat(e," end: ").concat(t)),r.hasOwnProperty("start")?(console.assert(r.start<=r.end),r.end-r.start+1>this.options.largeQuery?(console.log("encounter large query, use direct fetch"),this.token.then(function(a){return b(n.calId,a,null,e.toISOString(),t.toISOString()).then(function(n){var a=[];return n.results.forEach(function(e){console.assert(e.start),e.start=new Date(e.start.dateTime),e.end=new Date(e.end.dateTime),a.push(e)}),a.filter(function(n){return!(n.start>=t||n.end<=e)}).map(function(n){return{id:n.id,start:n.startt?t:n.end,summary:n.summary}})})})):(console.log("fetching short event list"),this.token.then(function(e){return b(n.calId,e,null,n.slotStartDate(r.start).toISOString(),n.slotEndDate(r.end).toISOString()).then(function(e){e.results.forEach(function(e){"confirmed"===e.status&&(console.assert(e.start),e.start=new Date(e.start.dateTime),e.end=new Date(e.end.dateTime),n.addEvent(e,!0))}),""===n.syncToken&&(n.syncToken=e.nextSyncToken)})}).then(function(){return n.sync()}).then(function(){return n.getCachedEvents({start:e,end:t})}))):(console.log("cache hit"),this.sync().then(function(){return n.getCachedEvents({start:e,end:t})}))}},{key:"token",get:function(){return h()}}])&&o(t.prototype,n),a&&o(t,a),e}()},467:function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return a});Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function a(){"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})}}).call(this,n(414))},589:function(e,t,n){var a={"./af":232,"./af.js":232,"./ar":233,"./ar-dz":234,"./ar-dz.js":234,"./ar-kw":235,"./ar-kw.js":235,"./ar-ly":236,"./ar-ly.js":236,"./ar-ma":237,"./ar-ma.js":237,"./ar-sa":238,"./ar-sa.js":238,"./ar-tn":239,"./ar-tn.js":239,"./ar.js":233,"./az":240,"./az.js":240,"./be":241,"./be.js":241,"./bg":242,"./bg.js":242,"./bm":243,"./bm.js":243,"./bn":244,"./bn.js":244,"./bo":245,"./bo.js":245,"./br":246,"./br.js":246,"./bs":247,"./bs.js":247,"./ca":248,"./ca.js":248,"./cs":249,"./cs.js":249,"./cv":250,"./cv.js":250,"./cy":251,"./cy.js":251,"./da":252,"./da.js":252,"./de":253,"./de-at":254,"./de-at.js":254,"./de-ch":255,"./de-ch.js":255,"./de.js":253,"./dv":256,"./dv.js":256,"./el":257,"./el.js":257,"./en-SG":258,"./en-SG.js":258,"./en-au":259,"./en-au.js":259,"./en-ca":260,"./en-ca.js":260,"./en-gb":261,"./en-gb.js":261,"./en-ie":262,"./en-ie.js":262,"./en-il":263,"./en-il.js":263,"./en-nz":264,"./en-nz.js":264,"./eo":265,"./eo.js":265,"./es":266,"./es-do":267,"./es-do.js":267,"./es-us":268,"./es-us.js":268,"./es.js":266,"./et":269,"./et.js":269,"./eu":270,"./eu.js":270,"./fa":271,"./fa.js":271,"./fi":272,"./fi.js":272,"./fo":273,"./fo.js":273,"./fr":274,"./fr-ca":275,"./fr-ca.js":275,"./fr-ch":276,"./fr-ch.js":276,"./fr.js":274,"./fy":277,"./fy.js":277,"./ga":278,"./ga.js":278,"./gd":279,"./gd.js":279,"./gl":280,"./gl.js":280,"./gom-latn":281,"./gom-latn.js":281,"./gu":282,"./gu.js":282,"./he":283,"./he.js":283,"./hi":284,"./hi.js":284,"./hr":285,"./hr.js":285,"./hu":286,"./hu.js":286,"./hy-am":287,"./hy-am.js":287,"./id":288,"./id.js":288,"./is":289,"./is.js":289,"./it":290,"./it-ch":291,"./it-ch.js":291,"./it.js":290,"./ja":292,"./ja.js":292,"./jv":293,"./jv.js":293,"./ka":294,"./ka.js":294,"./kk":295,"./kk.js":295,"./km":296,"./km.js":296,"./kn":297,"./kn.js":297,"./ko":298,"./ko.js":298,"./ku":299,"./ku.js":299,"./ky":300,"./ky.js":300,"./lb":301,"./lb.js":301,"./lo":302,"./lo.js":302,"./lt":303,"./lt.js":303,"./lv":304,"./lv.js":304,"./me":305,"./me.js":305,"./mi":306,"./mi.js":306,"./mk":307,"./mk.js":307,"./ml":308,"./ml.js":308,"./mn":309,"./mn.js":309,"./mr":310,"./mr.js":310,"./ms":311,"./ms-my":312,"./ms-my.js":312,"./ms.js":311,"./mt":313,"./mt.js":313,"./my":314,"./my.js":314,"./nb":315,"./nb.js":315,"./ne":316,"./ne.js":316,"./nl":317,"./nl-be":318,"./nl-be.js":318,"./nl.js":317,"./nn":319,"./nn.js":319,"./pa-in":320,"./pa-in.js":320,"./pl":321,"./pl.js":321,"./pt":322,"./pt-br":323,"./pt-br.js":323,"./pt.js":322,"./ro":324,"./ro.js":324,"./ru":325,"./ru.js":325,"./sd":326,"./sd.js":326,"./se":327,"./se.js":327,"./si":328,"./si.js":328,"./sk":329,"./sk.js":329,"./sl":330,"./sl.js":330,"./sq":331,"./sq.js":331,"./sr":332,"./sr-cyrl":333,"./sr-cyrl.js":333,"./sr.js":332,"./ss":334,"./ss.js":334,"./sv":335,"./sv.js":335,"./sw":336,"./sw.js":336,"./ta":337,"./ta.js":337,"./te":338,"./te.js":338,"./tet":339,"./tet.js":339,"./tg":340,"./tg.js":340,"./th":341,"./th.js":341,"./tl-ph":342,"./tl-ph.js":342,"./tlh":343,"./tlh.js":343,"./tr":344,"./tr.js":344,"./tzl":345,"./tzl.js":345,"./tzm":346,"./tzm-latn":347,"./tzm-latn.js":347,"./tzm.js":346,"./ug-cn":348,"./ug-cn.js":348,"./uk":349,"./uk.js":349,"./ur":350,"./ur.js":350,"./uz":351,"./uz-latn":352,"./uz-latn.js":352,"./uz.js":351,"./vi":353,"./vi.js":353,"./x-pseudo":354,"./x-pseudo.js":354,"./yo":355,"./yo.js":355,"./zh-cn":356,"./zh-cn.js":356,"./zh-hk":357,"./zh-hk.js":357,"./zh-tw":358,"./zh-tw.js":358};function r(e){var t=o(e);return n(t)}function o(e){var t=a[e];if(!(t+1)){var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}return t}r.keys=function(){return Object.keys(a)},r.resolve=o,e.exports=r,r.id=589},849:function(e,t,n){"use strict";n.r(t);var a=n(1),r=n.n(a),o=n(30),s=n.n(o),i=n(0),l=n.n(i),c=(n(475),n(28)),u=n(142),f=n.n(u),d=n(464),p=n.n(d),h=n(193),m=n.n(h),g=n(40),y=n.n(g),v=n(465),b=n.n(v),j=n(198),E=n.n(j),w=n(853),k=n(854),O=n(857),S=n(858),P=n(856),C=function(e){return r.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 98.905998 93.557997",version:"1.1",style:e.style},r.a.createElement("g",{id:"g13",transform:"translate(-153.533,-203.047)"},r.a.createElement("g",{id:"g29"},r.a.createElement("g",{id:"g27"},r.a.createElement("polygon",{id:"polygon7",points:"252.439,241.924 234.556,288.703 185.103,296.605 153.533,257.728 171.416,210.949 220.869,203.047 ",style:{fill:"#ff8000"}}),r.a.createElement("g",{id:"g11",transform:"translate(167.24355,224.20734)"},r.a.createElement("text",{id:"text9",style:{fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",fontStretch:"normal",fontSize:75,fontFamily:"TypoPRO Fantasque Sans Mono",fill:"#ffeade"},transform:"translate(0.586,49.072)"},"Cr"))))))},x=n(153),T=n.n(x),D=Object(c.createMuiTheme)({palette:{primary:{light:T.a[300],main:T.a[500],dark:T.a[700],contrastText:"#fff"}},typography:{useNextVariants:!0}}),R=(n(560),n(586),n(435)),M=n(115),_=n.n(M),I=n(46),z=n.n(I),A=n(71),B=n.n(A),N=n(73),L=n.n(N),G=n(37),q=n.n(G),W=n(150),F=n.n(W),H=n(53),K=n.n(H),U=n(43),V=n(27);function Y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function $(e,t){for(var n=0;nt+2&&(c=5,l="start"),on+2&&(u=10),r.a.createElement("text",{x:a,y:o,dx:c,dy:u,fill:s,textAnchor:l},"".concat(i))}function se(e){return r.a.createElement(q.a,{container:!0,spacing:0},r.a.createElement(q.a,{item:!0,xs:12,lg:6},r.a.createElement("div",{className:e.classes.patternTableWrapper},r.a.createElement(te.a,{width:400,height:250,className:e.classes.pieChart},r.a.createElement(ne.a,{data:e.patternGraphData,dataKey:"value",cx:200,cy:125,outerRadius:60,fill:ee.a[300],label:oe}),r.a.createElement(ae.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}})))),r.a.createElement(q.a,{item:!0,xs:12,lg:6},r.a.createElement("div",{className:e.classes.patternTableWrapper},r.a.createElement(te.a,{width:400,height:250,className:e.classes.pieChart},r.a.createElement(ne.a,{data:e.calendarGraphData,dataKey:"value",cx:200,cy:125,innerRadius:40,outerRadius:70,fill:_.a[300],label:oe},e.calendarGraphData.map(function(e,t){return r.a.createElement(re.a,{key:t,fill:e.color})})),r.a.createElement(ae.a,{formatter:function(e){return"".concat(e.toFixed(2)," hr")}})))))}se.propTypes={patternGraphData:l.a.array.isRequired,calendarGraphData:l.a.array.isRequired};var ie=Object(c.withStyles)(function(e){return{pieChart:{margin:"0 auto"}}})(se),le=n(147),ce=n.n(le),ue=n(148),fe=n.n(ue),de=n(149),pe=n.n(de),he=n(62),me=n.n(he),ge=n(72),ye=n.n(ge),ve=n(192),be=n.n(ve),je=n(450),Ee=n.n(je),we=n(449),ke=n.n(we),Oe=n(141),Se=n.n(Oe),Pe=n(189),Ce=n.n(Pe);function xe(e){return(xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Te(e,t){for(var n=0;n0&&r.a.createElement(me.a,{style:{height:48*c}},r.a.createElement(ye.a,{colSpan:qe.length}))))),r.a.createElement(Ee.a,{rowsPerPageOptions:[5,10,25],component:"div",count:o.length,rowsPerPage:i,page:l,backIconButtonProps:{"aria-label":"Previous Page"},nextIconButtonProps:{"aria-label":"Next Page"},onChangePage:this.handleChangePage,onChangeRowsPerPage:this.handleChangeRowsPerPage}))}}])&&Ae(n.prototype,a),o&&Ae(n,o),t}();We.propTypes={classes:l.a.object.isRequired,patterns:l.a.array.isRequired,calendars:l.a.object.isRequired,onRemovePattern:l.a.func.isRequired,onUpdatePattern:l.a.func.isRequired};var Fe=Object(c.withStyles)(function(e){return{deleteButtonShow:{position:"absolute",right:0,height:48},deleteButtonHide:{display:"none"},deleteIcon:{height:"100%",cursor:"pointer"},patternTableWrapper:{overflowX:"auto",overflowY:"hidden"},patternTable:{minWidth:600}}})(We),He=n(6),Ke=n.n(He),Ue=n(453),Ve=n.n(Ue),Ye=n(454),$e=n.n(Ye),Je=n(195),Qe=n.n(Je),Xe=n(451),Ze=n.n(Xe),et=n(452),tt=n.n(et),nt=n(455),at=n.n(nt);function rt(){return(rt=Object.assign||function(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var st={error:Ze.a,warning:tt.a};var it=Object(c.withStyles)(function(e){return{error:{backgroundColor:e.palette.error.dark},warning:{backgroundColor:Ve.a[700]},icon:{fontSize:20},iconVariant:{opacity:.9,marginRight:e.spacing.unit},message:{display:"flex",alignItems:"center"}}})(function(e){var t=e.classes,n=e.className,a=e.message,o=e.variant,s=e.open,i=e.onClose,l=ot(e,["classes","className","message","variant","open","onClose"]),c=st[o];return r.a.createElement($e.a,{anchorOrigin:{vertical:"top",horizontal:"center"},open:s,autoHideDuration:1e4,onClose:i},r.a.createElement(Qe.a,rt({className:Ke()(t[o],n),"aria-describedby":"snackbar-content",message:r.a.createElement("span",{id:"snackbar-content",className:t.message},r.a.createElement(c,{className:Ke()(t.icon,t.iconVariant)}),a),action:[r.a.createElement(K.a,{key:"close","aria-label":"Close",color:"inherit",className:t.close,onClick:i},r.a.createElement(at.a,{className:t.icon}))]},l)))}),lt=n(456),ct=n.n(lt),ut=n(460),ft=n.n(ut),dt=n(458),pt=n.n(dt),ht=n(459),mt=n.n(ht),gt=n(457),yt=n.n(gt),vt=n(194),bt=n.n(vt);function jt(){return(jt=Object.assign||function(e){for(var t=1;t0&&a.push(n.getCalEvents(o,e,t).then(function(e){return{id:o,events:e,patterns:s}}))};for(var s in r)o(s);Promise.all(a).then(function(e){console.log(e);var t={},a={},o={},s={};e.forEach(function(e){t[e.id]=e.events,a[e.id]=e.patterns});for(var i=0;i