-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
63 lines (63 loc) · 32.5 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function _toConsumableArray(d){return _arrayWithoutHoles(d)||_iterableToArray(d)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance");}function _iterableToArray(d){if(Symbol.iterator in Object(d)||"[object Arguments]"===Object.prototype.toString.call(d))return Array.from(d)}function _arrayWithoutHoles(d){if(Array.isArray(d)){for(var a=0,c=Array(d.length);a<d.length;a++)c[a]=d[a];return c}}
function _typeof(d){_typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"===typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};return _typeof(d)}function asyncGeneratorStep(d,a,c,b,e,l,f){try{var g=d[l](f),k=g.value}catch(m){c(m);return}g.done?a(k):Promise.resolve(k).then(b,e)}
function _asyncToGenerator(d){return function(){var a=this,c=arguments;return new Promise(function(b,e){function l(a){asyncGeneratorStep(g,b,e,l,f,"next",a)}function f(a){asyncGeneratorStep(g,b,e,l,f,"throw",a)}var g=d.apply(a,c);l(void 0)})}}function _defineProperties(d,a){for(var c=0;c<a.length;c++){var b=a[c];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(d,b.key,b)}}
function _createClass(d,a,c){a&&_defineProperties(d.prototype,a);c&&_defineProperties(d,c);return d}function _classCallCheck(d,a){if(!(d instanceof a))throw new TypeError("Cannot call a class as a function");}
var APIQueue=function APIQueue(){_classCallCheck(this,APIQueue)},html={spinner:'<svg class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">\n <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>\n </svg>',spinner_small:'<svg class="spinner spinner-small" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">\n <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>\n </svg>',
mdswitch:'<input type="checkbox" id="id-name--1" name="set-name" class="switch-input">\n <label for="id-name--1" class="switch-label">Switch <span class="toggle--on">On</span><span class="toggle--off">Off</span></label>',dots:'<div class="ellipses">\n <span class="one">.</span><span class="two">.</span><span class="three">.</span>\n </div>',placeholder:"data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==",loading:'<div class="loading">\n <svg class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">\n <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle>\n </svg>\n</div>',
google:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48"><defs><path id="a" d="M44.5 20H24v8.5h11.8C34.7 33.9 30.1 37 24 37c-7.2 0-13-5.8-13-13s5.8-13 13-13c3.1 0 5.9 1.1 8.1 2.9l6.4-6.4C34.6 4.1 29.6 2 24 2 11.8 2 2 11.8 2 24s9.8 22 22 22c11 0 21-8 21-22 0-1.3-.2-2.7-.5-4z"/></defs><clipPath id="b"><use xlink:href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" fill="#FBBC05" d="M0 37V11l17 13z"/><path clip-path="url(#b)" fill="#EA4335" d="M0 11l17 13 7-6.1L48 14V0H0z"/><path clip-path="url(#b)" fill="#34A853" d="M0 37l30-23 7.9 1L48 0v48H0z"/><path clip-path="url(#b)" fill="#4285F4" d="M48 48L17 24l-4-3 35-10z"/></svg>'},
_get=function(d,a){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return d.reduce(function(a,e){return a&&a[e]?a[e]:c},a)},API_KEY="AIzaSyBLjH1zVUY5zh3NM65NqRVP3eQxZy6ifcA",PRODUCTION_HOSTNAME="twistedcore.co.uk",DISCOVERY_DOCS=["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"],SCOPES="https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.photos.readonly",CLIENT_ID=function(){return window.location.hostname==PRODUCTION_HOSTNAME?"257316982603-0jmairn23vl079i1tt4tf0nk5kmkn32t.apps.googleusercontent.com":
"257316982603-nr1g6o1icrqoiaui4rrhu31865ph11r3.apps.googleusercontent.com"},Geocoder=function(){function d(a){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;_classCallCheck(this,d);this.activeGeocodeCount=0;this.service_=c;this.BUSY_WAIT_MS=1E3;this.MAX_CONNECTIONS=10}_createClass(d,[{key:"getLocation",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function b(a){var d,f=arguments;return regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:d=
1<f.length&&void 0!==f[1]?f[1]:!1;if(!d){b.next=5;break}b.next=5;return sleep(1E3);case 5:this.executeGeocodeRequest(a);case 6:case "end":return b.stop()}},b,this)}));return function(b){return a.apply(this,arguments)}}()},{key:"executeGeocodeRequest",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function b(a){var d=this,f;return regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(!this.isBusy){b.next=5;break}b.next=3;return sleep(200);case 3:b.next=0;break;
case 5:this.activeGeocodeCount++,f={lat:a.latitude,lng:a.longitude},this.service.geocode({location:f},function(b,f){"OK"===f?b[0]?d.processGeocode(b[0],a):console.log("No results found"):f==google.maps.GeocoderStatus.OVER_QUERY_LIMIT?d.getLocation(a,isRetry=!0):console.log("Geocoder failed due to: "+f);d.activeGeocodeCount--});case 8:case "end":return b.stop()}},b,this)}));return function(b){return a.apply(this,arguments)}}()},{key:"processGeocode",value:function(a,c){var b,e,d=!0,f=!1,g=void 0;try{for(var k=
a.address_components[Symbol.iterator](),m;!(d=(m=k.next()).done);d=!0){var h=m.value;if(h.types.includes("country"))b=h.long_name;else if(h.types.includes("locality")||h.types.includes("administrative_area_level_1"))e=h.long_name}}catch(n){f=!0,g=n}finally{try{d||null==k["return"]||k["return"]()}finally{if(f)throw g;}}b&&e&&"".concat(b,", ").concat(e)}},{key:"loaded",get:function(){return null!=this.service}},{key:"service",get:function(){return this.service_},set:function(a){this.service_=a}},{key:"isBusy",
get:function(){return this.geocodeCount>=this.MAX_CONNECTIONS?!0:!1}}]);return d}(),Photo=function(){function d(a){_classCallCheck(this,d);this.id=a.id;this.url=a.thumbnailLink;this.meta=a.imageMediaMetadata?a.imageMediaMetadata:{};this.addedTime=new Date;this.THUMB_LIFETIME=9E5}_createClass(d,[{key:"hasLocation",value:function(){return void 0!=this.meta.location}},{key:"setRemoteLocation",value:function(a){}},{key:"getFormattedAddress",value:function(){}},{key:"isExpired",value:function(){return(new Date).getTime()-
this.addedTime.getTime()>this.THUMB_LIFETIME}},{key:"getSize",value:function(a){var c=function(a,c){0<b.length&&(b+="-");b+=a;c&&(b+=c)},b="";a.crop&&!a.height&&(a.height=a.width);a.width&&c("w",Math.floor(a.width));a.height&&c("h",Math.floor(a.height));a.crop&&c("p-k-nu");a.aspect&&c("no");return"https://drive.google.com/thumbnail?authuser=0&id=".concat(this.id,"&sz=").concat(b)}},{key:"camera",get:function(){var a=_get(["cameraMake"],this.meta),c=_get(["cameraModel"],this.meta);return a&&c?"".concat(a.charAt(0).toUpperCase()).concat(a.substr(1),
" ").concat(c):"None"}},{key:"height",get:function(){return this.meta.height}},{key:"width",get:function(){return this.meta.width}},{key:"latitude",get:function(){return _get(["location","latitude"],this.meta)}},{key:"longitude",get:function(){return this.meta.location.longitude}},{key:"location",get:function(){return{latitude:this.latitude,longitude:this.longitude}}}],[{key:"resize",value:function(a,c){var b=a.split("=")[0];return"".concat(b).concat(c)}}]);return d}(),MarkerClusterer=function(){function d(a,
c,b){_classCallCheck(this,d);this.extend(d,google.maps.OverlayView);this.map_=a;this.markers_=[];this.clusters_=[];this.sizes=[53,56,66,78,90];this.styles_=[];this.ready_=!1;b=b||{};this.gridSize_=b.gridSize||60;this.minClusterSize_=b.minimumClusterSize||2;this.maxZoom_=b.maxZoom||null;this.styles_=b.styles||[];this.cssClass_=b.cssClass||null;this.inivisibleMarkers=b.invisibleMarkers||!1;this.imagePath_=b.imagePath||this.MARKER_CLUSTER_IMAGE_PATH_;this.imageExtension_=b.imageExtension||this.MARKER_CLUSTER_IMAGE_EXTENSION_;
this.zoomOnClick_=!0;void 0!=b.zoomOnClick&&(this.zoomOnClick_=b.zoomOnClick);this.averageCenter_=!1;void 0!=b.averageCenter&&(this.averageCenter_=b.averageCenter);this.setupStyles_();this.setMap(a);this.prevZoom_=this.map_.getZoom();var e=this;google.maps.event.addListener(this.map_,"zoom_changed",function(){var a=e.map_.getZoom(),b=e.map_.minZoom||0,c=Math.min(e.map_.maxZoom||100,e.map_.mapTypes[e.map_.getMapTypeId()].maxZoom),a=Math.min(Math.max(a,b),c);e.prevZoom_!=a&&(e.prevZoom_=a,e.resetViewport())});
google.maps.event.addListener(this.map_,"idle",function(){e.redraw()});c&&(c.length||Object.keys(c).length)&&this.addMarkers(c,!1)}_createClass(d,[{key:"getCssClass",value:function(){return this.cssClass_}},{key:"extend",value:function(a,c){return function(a){for(var c in a.prototype)this.prototype[c]=a.prototype[c];return this}.apply(a,[c])}},{key:"onAdd",value:function(){this.setReady_(!0)}},{key:"draw",value:function(){}},{key:"setupStyles_",value:function(){if(!this.styles_.length)for(var a=0,
c;c=this.sizes[a];a++)this.styles_.push({url:"".concat(this.imagePath_+(a+1),".").concat(this.imageExtension_),height:c,width:c})}},{key:"fitMapToMarkers",value:function(){for(var a=this.getMarkers(),c=new google.maps.LatLngBounds,b=0,e;e=a[b];b++)c.extend(e.getPosition());this.map_.fitBounds(c)}},{key:"setStyles",value:function(a){this.styles_=a}},{key:"getStyles",value:function(){return this.styles_}},{key:"isZoomOnClick",value:function(){return this.zoomOnClick_}},{key:"isAverageCenter",value:function(){return this.averageCenter_}},
{key:"getMarkers",value:function(){return this.markers_}},{key:"getTotalMarkers",value:function(){return this.markers_.length}},{key:"setMaxZoom",value:function(a){this.maxZoom_=a}},{key:"getMaxZoom",value:function(){return this.maxZoom_}},{key:"calculator_",value:function(a,c){for(var b=0,e=a.length,d=e;0!==d;)d=parseInt(d/10,10),b++;b=Math.min(b,c);return{text:e,index:b}}},{key:"setCalculator",value:function(a){this.calculator_=a}},{key:"getCalculator",value:function(){return this.calculator_}},
{key:"addMarkers",value:function(a,c){if(a.length)for(var b=0,e;e=a[b];b++)this.pushMarkerTo_(e);else if(Object.keys(a).length)for(e in a)this.pushMarkerTo_(a[e]);c||this.redraw()}},{key:"pushMarkerTo_",value:function(a){a.isAdded=!1;if(a.draggable){var c=this;google.maps.event.addListener(a,"dragend",function(){a.isAdded=!1;c.repaint()})}this.markers_.push(a)}},{key:"addMarker",value:function(a,c){this.pushMarkerTo_(a);c||this.redraw()}},{key:"removeMarker_",value:function(a){var c=-1;if(this.markers_.indexOf)c=
this.markers_.indexOf(a);else for(var b=0,e;e=this.markers_[b];b++)if(e==a){c=b;break}if(-1==c)return!1;a.setMap(null);this.markers_.splice(c,1);return!0}},{key:"removeMarker",value:function(a,c){var b=this.removeMarker_(a);return!c&&b?(this.resetViewport(),this.redraw(),!0):!1}},{key:"removeMarkers",value:function(a,c){for(var b=!1,e=0,d;d=a[e];e++)d=this.removeMarker_(d),b=b||d;if(!c&&b)return this.resetViewport(),this.redraw(),!0}},{key:"setReady_",value:function(a){this.ready_||(this.ready_=a,
this.createClusters_())}},{key:"getTotalClusters",value:function(){return this.clusters_.length}},{key:"getMap",value:function(){return this.map_}},{key:"setMap",value:function(a){this.map_=a}},{key:"getGridSize",value:function(){return this.gridSize_}},{key:"setGridSize",value:function(a){this.gridSize_=a}},{key:"getMinClusterSize",value:function(){return this.minClusterSize_}},{key:"setMinClusterSize",value:function(a){this.minClusterSize_=a}},{key:"getExtendedBounds",value:function(a){var c=this.getProjection(),
b=new google.maps.LatLng(a.getNorthEast().lat(),a.getNorthEast().lng()),e=new google.maps.LatLng(a.getSouthWest().lat(),a.getSouthWest().lng()),b=c.fromLatLngToDivPixel(b);b.x+=this.gridSize_;b.y-=this.gridSize_;e=c.fromLatLngToDivPixel(e);e.x-=this.gridSize_;e.y+=this.gridSize_;b=c.fromDivPixelToLatLng(b);c=c.fromDivPixelToLatLng(e);a.extend(b);a.extend(c);return a}},{key:"isMarkerInBounds_",value:function(a,c){return c.contains(a.getPosition())}},{key:"clearMarkers",value:function(){this.resetViewport(!0);
this.markers_=[]}},{key:"resetViewport",value:function(a){for(var c=0,b;b=this.clusters_[c];c++)b.remove();for(c=0;b=this.markers_[c];c++)b.isAdded=!1,a&&b.setMap(null);this.clusters_=[]}},{key:"repaint",value:function(){var a=this.clusters_.slice();this.clusters_.length=0;this.resetViewport();this.redraw();window.setTimeout(function(){for(var c=0,b;b=a[c];c++)b.remove()},0)}},{key:"redraw",value:function(){this.createClusters_()}},{key:"distanceBetweenPoints_",value:function(a,c){if(!a||!c)return 0;
var b=(c.lat()-a.lat())*Math.PI/180,e=(c.lng()-a.lng())*Math.PI/180,b=Math.sin(b/2)*Math.sin(b/2)+Math.cos(a.lat()*Math.PI/180)*Math.cos(c.lat()*Math.PI/180)*Math.sin(e/2)*Math.sin(e/2);return 12742*Math.atan2(Math.sqrt(b),Math.sqrt(1-b))}},{key:"addToClosestCluster_",value:function(a){var c=4E4,b=null;a.getPosition();for(var e=0,d;d=this.clusters_[e];e++){var f=d.getCenter();f&&(f=this.distanceBetweenPoints_(f,a.getPosition()),f<c&&(c=f,b=d))}b&&b.isMarkerInClusterBounds(a)?b.addMarker(a):(d=new Cluster(this),
d.addMarker(a),this.clusters_.push(d))}},{key:"createClusters_",value:function(){if(this.ready_)for(var a=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),this.map_.getBounds().getNorthEast()),a=this.getExtendedBounds(a),c=0,b;b=this.markers_[c];c++)!b.isAdded&&this.isMarkerInBounds_(b,a)&&this.addToClosestCluster_(b)}}]);return d}();MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_="../images/m";MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_="png";
var Cluster=function(){function d(a){_classCallCheck(this,d);this.markerClusterer_=a;this.map_=a.getMap();this.gridSize_=a.getGridSize();this.minClusterSize_=a.getMinClusterSize();this.averageCenter_=a.isAverageCenter();this.inivisibleMarkers=a.inivisibleMarkers;this.center_=null;this.markers_=[];this.bounds_=null;this.cssClass=a.getCssClass();this.clusterIcon_=new ClusterIcon(this,a.getStyles(),a.getGridSize())}_createClass(d,[{key:"getFrontCoverStyles",value:function(){for(var a=[],c=0;5>c;c++)a.push({url:clusters_[0].markers_[0].cover,
height:64,width:64});return a}},{key:"getFrontCover",value:function(){return this.markers_[0].cover}},{key:"isMarkerAlreadyAdded",value:function(a){if(this.markers_.indexOf)return this.markers_.includes(a);for(var c=0,b;b=this.markers_[c];c++)if(b==a)return!0;return!1}},{key:"addMarker",value:function(a){if(this.isMarkerAlreadyAdded(a))return!1;if(!this.center_)this.center_=a.getPosition(),this.calculateBounds_();else if(this.averageCenter_){var c=this.markers_.length+1,b=(this.center_.lat()*(c-1)+
a.getPosition().lat())/c,c=(this.center_.lng()*(c-1)+a.getPosition().lng())/c;this.center_=new google.maps.LatLng(b,c);this.calculateBounds_()}a.isAdded=!0;this.markers_.push(a);b=this.markers_.length;b<this.minClusterSize_&&a.getMap()!=this.map_&&!this.inivisibleMarkers&&a.setMap(this.map_);if(b==this.minClusterSize_)for(c=0;c<b;c++)this.markers_[c].setMap(null);b>=this.minClusterSize_&&a.setMap(null);this.updateIcon();return!0}},{key:"getMarkerClusterer",value:function(){return this.markerClusterer_}},
{key:"getBounds",value:function(){for(var a=new google.maps.LatLngBounds(this.center_,this.center_),c=this.getMarkers(),b=0,e;e=c[b];b++)a.extend(e.getPosition());return a}},{key:"remove",value:function(){this.clusterIcon_.remove();this.markers_.length=0;delete this.markers_}},{key:"getSize",value:function(){return this.markers_.length}},{key:"getMarkers",value:function(){return this.markers_}},{key:"getCenter",value:function(){return this.center_}},{key:"calculateBounds_",value:function(){var a=
new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(a)}},{key:"isMarkerInClusterBounds",value:function(a){return this.bounds_.contains(a.getPosition())}},{key:"getMap",value:function(){return this.map_}},{key:"updateIcon",value:function(){var a=this.map_.getZoom(),c=this.markerClusterer_.getMaxZoom();if(c&&a>c)for(a=0;c=this.markers_[a];a++)c.setMap(this.map_);else this.markers_.length<this.minClusterSize_?this.clusterIcon_.hide():(a=this.markerClusterer_.getStyles().length,
a=this.markerClusterer_.getCalculator()(this.markers_,a),this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.setSums(a),this.clusterIcon_.setCover(this.getFrontCover()),this.clusterIcon_.show())}}]);return d}(),ClusterIcon=function(){function d(a,c,b){_classCallCheck(this,d);a.getMarkerClusterer().extend(d,google.maps.OverlayView);this.styles_=c;this.padding_=b||0;this.cluster_=a;this.center_=null;this.map_=a.getMap();this.sums_=this.div_=null;this.visible_=!1;this.cover="";this.setMap(this.map_)}
_createClass(d,[{key:"triggerClusterClick",value:function(){var a=this.cluster_.getMarkerClusterer();google.maps.event.trigger(a,"clusterclick",this.cluster_);a.isZoomOnClick()&&this.map_.fitBounds(this.cluster_.getBounds())}},{key:"onAdd",value:function(){this.div_=document.createElement("DIV");if(this.visible_){var a=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(a);this.div_.className=this.cluster_.cssClass;this.div_.innerHTML='<span class="_cluster_inner">'.concat(this.sums_.text,
"</span>")}this.getPanes().overlayMouseTarget.appendChild(this.div_);var c=this;google.maps.event.addDomListener(this.div_,"click",function(){c.triggerClusterClick()})}},{key:"getPosFromLatLng_",value:function(a){a=this.getProjection().fromLatLngToDivPixel(a);a.x-=parseInt(this.width_/2,10);a.y-=parseInt(this.height_/2,10);return a}},{key:"draw",value:function(){if(this.visible_){var a=this.getPosFromLatLng_(this.center_);this.div_.style.top="".concat(a.y,"px");this.div_.style.left="".concat(a.x,
"px")}}},{key:"hide",value:function(){this.div_&&(this.div_.style.display="none");this.visible_=!1}},{key:"show",value:function(){if(this.div_){var a=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(a);this.div_.style.display=""}this.visible_=!0}},{key:"remove",value:function(){this.setMap(null)}},{key:"onRemove",value:function(){this.div_&&this.div_.parentNode&&(this.hide(),this.div_.parentNode.removeChild(this.div_),this.div_=null)}},{key:"setSums",value:function(a){this.sums_=
a;this.text_=a.text;this.index_=a.index;this.div_&&(this.div_.innerHTML=a.text);this.setCover(this.cover)}},{key:"useStyle",value:function(){var a=Math.max(0,this.sums_.index-1),a=Math.min(this.styles_.length-1,a),a=this.styles_[a];this.url_=a.url;this.height_=a.height;this.width_=a.width;this.textColor_=a.textColor;this.anchor_=a.anchor;this.textSize_=a.textSize;this.backgroundPosition_=a.backgroundPosition}},{key:"setCover",value:function(a){this.url_=a;this.width_=this.height_=64}},{key:"setCenter",
value:function(a){this.center_=a}},{key:"createCss",value:function(a){var c=[];c.push("background-image:url(".concat(this.url_,");"));c.push("background-position:".concat(this.backgroundPosition_?this.backgroundPosition_:"0 0",";"));"object"===_typeof(this.anchor_)?("number"===typeof this.anchor_[0]&&0<this.anchor_[0]&&this.anchor_[0]<this.height_?c.push("height:".concat(this.height_-this.anchor_[0],"px; padding-top:").concat(this.anchor_[0],"px;")):c.push("height:".concat(this.height_,"px; line-height:").concat(this.height_,
"px;")),"number"===typeof this.anchor_[1]&&0<this.anchor_[1]&&this.anchor_[1]<this.width_?c.push("width:".concat(this.width_-this.anchor_[1],"px; padding-left:").concat(this.anchor_[1],"px;")):c.push("width:".concat(this.width_,"px; text-align:center;"))):c.push("height:".concat(this.height_,"px; line-height:").concat(this.height_,"px; width:").concat(this.width_,"px; text-align:center;"));var b=this.textColor_?this.textColor_:"black",e=this.textSize_?this.textSize_:11;c.push("cursor:pointer; top:".concat(a.y,
"px; left:").concat(a.x,"px; color:").concat(b,"; position:absolute; font-size:").concat(e,"px; font-family:Arial,sans-serif; font-weight:bold"));return c.join("")}}]);return d}(),PhotoGrouper=function(){function d(a){_classCallCheck(this,d);this.map=a;this.groups=[]}_createClass(d,[{key:"distance",value:function(a,c){if(!a||!c)return 0;var b=(c.lat()-a.lat())*Math.PI/180,e=(c.lng()-a.lng())*Math.PI/180,b=Math.sin(b/2)*Math.sin(b/2)+Math.cos(a.lat()*Math.PI/180)*Math.cos(c.lat()*Math.PI/180)*Math.sin(e/
2)*Math.sin(e/2);return 12742*Math.atan2(Math.sqrt(b),Math.sqrt(1-b))}},{key:"group",value:function(a){var c=4E4,b=null;a.getPosition();var e=!0,d=!1,f=void 0;try{for(var g=this.groups[Symbol.iterator](),k;!(e=(k=g.next()).done);e=!0){var m=k.value,h=m.getCenter();if(h){var n=this.distanceBetweenPoints_(h,a.getPosition());n<c&&(c=n,b=m)}}}catch(p){d=!0,f=p}finally{try{e||null==g["return"]||g["return"]()}finally{if(d)throw f;}}b?b.addMarker(a):((new Group(this)).addMarker(a),this.groups.push(cluster))}},
{key:"createGroups",value:function(){var a=!0,c=!1,b=void 0;try{for(var e=this.markers[Symbol.iterator](),d;!(a=(d=e.next()).done);a=!0)this.group(d.value)}catch(f){c=!0,b=f}finally{try{a||null==e["return"]||e["return"]()}finally{if(c)throw b;}}}}]);return d}(),Group=function(){function d(){_classCallCheck(this,d);this.markers=[]}_createClass(d,[{key:"addMarker",value:function(a){this.markers.push(markers)}}]);return d}(),PhotoMap=function(){function d(){_classCallCheck(this,d);this.state="unloaded";
this.status={drive:!1,maps:!1,photos:!1};this.photos=[];this.markers=[];this.infoWindows=[];this.MAX_PHOTOS=this.PAGE_SIZE=100;this.GEOCODE=this.RECURSE=!0;this.GEOCODE_ALL=!1;this.SIDEBAR=!0;this.ui=new UI(this);this.geocoder=new Geocoder(this)}_createClass(d,[{key:"loadMap",value:function(){this.map=new google.maps.Map(document.getElementById("map"),{center:{lat:0,lng:0},zoom:3});this.map.addListener("zoom_changed",function(){photoMap.resetClusters()});var a=document.createElement("script");a.onload=
function(){photoMap.status.maps=!0};a.src="dist/richmarker.js";document.head.appendChild(a);this.geocoder.service=new google.maps.Geocoder}},{key:"clearMap",value:function(){var a=!0,c=!1,b=void 0;try{for(var d=this.markers[Symbol.iterator](),l;!(a=(l=d.next()).done);a=!0)l.value.setMap(null)}catch(f){c=!0,b=f}finally{try{a||null==d["return"]||d["return"]()}finally{if(c)throw b;}}this.markers.length=0}},{key:"reset",value:function(){this.clearMap();this.photos.length=0}},{key:"search",value:function(a){""==
a&&(a=void 0);this.query=a;this.ui.load()}},{key:"processPhoto",value:function(a){this.photos.push(a);$("#content-loading").remove();a.hasLocation()&&(this.photoToMap(a),$(document).on("click",".photo-list-item[data-id='".concat(a.id,"']"),function(){var c=photoMap.markers.filter(function(b){return b.id==a.id})[0];new google.maps.event.trigger(c,"click")}),this.GEOCODE_ALL&&!this.address&&this.geocoder.getLocation(a))}},{key:"photoToMap",value:function(a){var c=this,b=new google.maps.LatLng(a.latitude,
a.longitude),d=new RichMarker({position:b,map:this.map,content:'<div><img style="height: 64px; border-radius: 5%; border: 4px solid white;" src="'.concat(a.getSize({width:256}),'"/></div>'),draggable:!1,flat:!0,anchor:RichMarkerPosition.TOP,cover:a.getSize({width:256}),id:a.id});d.id=a.id;d.addListener("click",function(){photoMap.infoWindow&&photoMap.infoWindow.close();photoMap.infoWindow=new google.maps.InfoWindow({content:'<a href="https://drive.google.com/file/d/'.concat(a.id,'/view" target="_blank"><img src="').concat(a.getSize({aspect:!0}),
'"></a>')});photoMap.infoWindow.open(c.map,d);20>photoMap.map.zoom&&photoMap.map.setZoom(21);photoMap.map.panTo(d.position)});this.markers.push(d)}},{key:"resetClusters",value:function(){this.clusterer&&this.clusterer.clearMarkers();this.clusterer=new MarkerClusterer(this.map,this.markers,{maxZoom:21,minimumClusterSize:2,cssClass:this.clusterClass,gridSize:40})}},{key:"getPhotos",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function b(a){var d=this,f;return regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=
b.next){case 0:return f=this.query?"fullText contains '".concat(this.query,"' and ").concat('mimeType contains "image/" and trashed=false'):'mimeType contains "image/" and trashed=false',b.next=4,gapi.client.init({apiKey:API_KEY,clientId:CLIENT_ID(),discoveryDocs:DISCOVERY_DOCS,scope:SCOPES}).then(function(){return gapi.client.drive.files.list({q:f,spaces:"photos, drive",fields:"nextPageToken,files(id,imageMediaMetadata,thumbnailLink)",pageToken:a,pageSize:d.PAGE_SIZE})}).then(function(b){b.result.error?
d.getPhotos(a):d.maxPhotosReached?(console.log("Reached max photo count"),d.allPhotosLoaded=!0):b.result.files&&d.addListOfPhotos(b.result)});case 4:case "end":return b.stop()}},b,this)}));return function(b){return a.apply(this,arguments)}}()},{key:"addListOfPhotos",value:function(a){var c=!0,b=!1,d=void 0;try{for(var l=a.files[Symbol.iterator](),f;!(c=(f=l.next()).done);c=!0)this.processPhoto(new Photo(f.value))}catch(g){b=!0,d=g}finally{try{c||null==l["return"]||l["return"]()}finally{if(b)throw d;
}}this.resetClusters();this.SIDEBAR&&this.updateSidebarPlaces();a.nextPageToken&&this.RECURSE?(this.getPhotos(a.nextPageToken),this.ui.statusMessage="Fetched ".concat(this.photos.length," photos...")):a.nextPageToken||(this.allPhotosLoaded=!0)}},{key:"updateSidebarPlaces",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function b(){var a,d,f,g,k,m,h;return regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.getFixedSizeGrid(1);case 2:a=b.sent,
this.ui.emptyPlaces(),d=!0,f=!1,g=void 0,b.prev=7,k=a[Symbol.iterator]();case 9:if(d=(m=k.next()).done){b.next=17;break}h=m.value;if(h.clusterIcon_.url_){b.next=13;break}return b.abrupt("continue",14);case 13:this.ui.addPhoto({latitude:h.center_.lat(),longitude:h.center_.lng(),count:_get(["clusterIcon_","sums_","text"],h),cover:Photo.resize(h.clusterIcon_.url_,512)});case 14:d=!0;b.next=9;break;case 17:b.next=23;break;case 19:b.prev=19,b.t0=b["catch"](7),f=!0,g=b.t0;case 23:b.prev=23,b.prev=24,d||
null==k["return"]||k["return"]();case 26:b.prev=26;if(!f){b.next=29;break}throw g;case 29:return b.finish(26);case 30:return b.finish(23);case 31:case "end":return b.stop()}},b,this,[[7,19,23,31],[24,,26,30]])}));return function(){return a.apply(this,arguments)}}()},{key:"getFixedSizeGrid",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function b(){var a,d;return regeneratorRuntime.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:a=new MarkerClusterer(this.map,this.markers,{maxZoom:21,
minimumClusterSize:2,cssClass:"cluster-hidden",invisibleMarkers:!0,gridSize:1});case 2:if(0!=a.clusters_.length){b.next=7;break}b.next=5;return sleep(100);case 5:b.next=2;break;case 7:return d=_toConsumableArray(a.clusters_),a.clearMarkers(),b.abrupt("return",d);case 10:case "end":return b.stop()}},b,this)}));return function(){return a.apply(this,arguments)}}()},{key:"isFirstTime",get:function(){return"false"==localStorage.getItem("isFirstTime")?!1:!0},set:function(a){localStorage.setItem("isFirstTime",
a)}},{key:"clusterClass",get:function(){return"cluster"}},{key:"loaded",get:function(){return this.status.drive&&this.status.maps?!0:!1}},{key:"maxPhotosReached",get:function(){return this.photos.length>=this.MAX_PHOTOS&&0!=this.MAX_PHOTOS}},{key:"allPhotosLoaded",set:function(a){this.status.photos=!0;this.ui.status="loaded"},get:function(){return this.status.photos}}]);return d}(),UI=function(){function d(a){_classCallCheck(this,d);this.photoMap=a;this.html={loading:'<div class="loading">\n '.concat(html.spinner_small,
' <span class="status">Fetching your Photos...</span>\n </div>'),photoList:'<div class="photo-list"></div>'};this.selectors={overlay:"#overlay",container:"#overlay .content",status:"#overlay .content .loading .status"};this.container=$(this.selectors.container);this.bindings();this.load()}_createClass(d,[{key:"bindings",value:function(){var a=this;$("".concat(this.selectors.overlay," .close-icon")).on("click",function(){$(a.selectors.overlay).toggleClass("minimised");$(".close-icon > svg").toggleClass("fa-rotate-180")});
this.bindSearch()}},{key:"bindSearch",value:function(){var a=this,c=document.getElementById("search"),b=null;c.onkeyup=function(d){clearTimeout(b);b=setTimeout(function(){a.photoMap.search(c.value)},500)}}},{key:"updateLoading",value:function(a){a&&this.container.html("");this.loading||(this.loading=$(this.html.loading).appendTo(this.container));this.loading.show();$(this.selectors.status).html(this.loadingMessage_)}},{key:"emptyPlaces",value:function(){this.photo_list.empty()}},{key:"addPhoto",value:function(a){var c=
this,b=document.createElement("div");b.className="photo-list-item";b.id=a.trim();b.innerHTML='\n <div class="photo-container">\n <div class="photo-img" style="background-image:url(\''.concat(a.cover,'\')"></div>\n </div>\n <div class="photo-meta-container">\n <div class="photo-meta-tags">\n \x3c!--<span class="photo-meta-tag-type"><i class="fas fa-question-circle"></i> Still</span>\n <span class="photo-meta-tag-camera"><i class="fas fa-camera"></i> </span>\n <span class="photo-meta-tag-resolution"><i class="fas fa-image"></i> </span>--\x3e\n </div>\n <div class="photo-meta-location-container">\n <span class="fa-layers fa-fw">\n <i class="fas fa-location-arrow"></i>\n </span> \n \n <span class="photo-meta-location">').concat(html.dots,
"</span>\n </div>\n \n </div>\n ");b.onclick=function(){c.photoMap.map.setCenter(new google.maps.LatLng(a.latitude,a.longitude));c.photoMap.map.setZoom(17)};this.photoMap.geocoder.getLocation(a);this.photo_list[0].appendChild(b)}},{key:"load",value:function(){var a=_asyncToGenerator(regeneratorRuntime.mark(function b(){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.photoMap.loaded){a.next=5;break}a.next=
3;return sleep(200);case 3:a.next=0;break;case 5:this.photoMap.reset(),this.statusMessage="Fetching photos...",this.photo_list=$(this.html.photoList).appendTo(this.container),this.photoMap.getPhotos();case 9:case "end":return a.stop()}},b,this)}));return function(){return a.apply(this,arguments)}}()},{key:"showSignIn",value:function(){this.container.html("");this.container.append('\n <div class="sign-in-container">\n <div class="sign-in-inner">\n <a class="button sign-in" href="#" onclick="signInHandler()">\n <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48"><defs><path id="a" d="M44.5 20H24v8.5h11.8C34.7 33.9 30.1 37 24 37c-7.2 0-13-5.8-13-13s5.8-13 13-13c3.1 0 5.9 1.1 8.1 2.9l6.4-6.4C34.6 4.1 29.6 2 24 2 11.8 2 2 11.8 2 24s9.8 22 22 22c11 0 21-8 21-22 0-1.3-.2-2.7-.5-4z"/></defs><clipPath id="b"><use xlink:href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" fill="#FBBC05" d="M0 37V11l17 13z"/><path clip-path="url(#b)" fill="#EA4335" d="M0 11l17 13 7-6.1L48 14V0H0z"/><path clip-path="url(#b)" fill="#34A853" d="M0 37l30-23 7.9 1L48 0v48H0z"/><path clip-path="url(#b)" fill="#4285F4" d="M48 48L17 24l-4-3 35-10z"/></svg> Sign in with Google\n </a>\n\n <a class="privacy-policy" href="privacy.html" target="blank">Privacy Policy</a>\n </div>\n </div>\n ')}},
{key:"hideSignIn",value:function(){this.container.find(".sign-in-container").remove()}},{key:"hideStatus",value:function(){this.loading.hide()}},{key:"status",set:function(a){this.status_=a;"loaded"==this.status_&&this.hideStatus()},get:function(){return this.status_}},{key:"statusMessage",set:function(a){this.loadingMessage_=a;this.updateLoading()}}]);return d}();function loadMap(){return _loadMap.apply(this,arguments)}
function _loadMap(){_loadMap=_asyncToGenerator(regeneratorRuntime.mark(function a(){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:photoMap.loadMap(),console.log("Loaded Map");case 2:case "end":return a.stop()}},a,this)}));return _loadMap.apply(this,arguments)}function signInHandler(){return _signInHandler.apply(this,arguments)}
function _signInHandler(){_signInHandler=_asyncToGenerator(regeneratorRuntime.mark(function a(){return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:photoMap.ui.hideSignIn(),photoMap.ui.statusMessage="Signing in...",gapi.auth2.authorize({client_id:CLIENT_ID(),immediate:!1,scope:SCOPES},function(){photoMap.status.drive=!0;photoMap.isFirstTime=!1;console.log("Loaded API")});case 4:case "end":return a.stop()}},a,this)}));return _signInHandler.apply(this,arguments)}
function sleep(d){return new Promise(function(a){return setTimeout(a,d)})}function init(){photoMap.isFirstTime?photoMap.ui.showSignIn():signInHandler(!0)}window.photoMap=new PhotoMap;