function localStorageAvailable(){try{return"localStorage"&&window&&window.localStorage!==null}catch(n){return!1}}function readCookie(n,t){for(var u=n+"=",f=document.cookie.split(";"),i,r=0;r<f.length;r++){for(i=f[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(u)==0)return i.substring(u.length,i.length)}return t||null}function setCookie(n,t,i){var r,u;i?(r=new Date,r.setTime(r.getTime()+i*864e5),u="; expires="+r.toGMTString()):u="";document.cookie=n+"="+t+u+"; path=/"}function promiseLogger(n){console.log("Promise:",n);promisedata=n}var _sf_async_config,promisedata,isDebug,isVerbose,ApplicationConfiguration;(function(n,t){if(!t.__SV){var i,u,f,r;window.mixpanel=t;i=n.createElement("script");i.type="text/javascript";i.async=!0;i.src=("https:"===n.location.protocol?"https:":"http:")+"//cdn.mxpnl.com/libs/mixpanel-2.2.min.js";u=n.getElementsByTagName("script")[0];u.parentNode.insertBefore(i,u);t._i=[];t.init=function(n,i,u){function o(n,t){var i=t.split(".");2==i.length&&(n=n[i[0]],t=i[1]);n[t]=function(){n.push([t].concat(Array.prototype.slice.call(arguments,0)))}}var e=t;for("undefined"!=typeof u?e=t[u]=[]:u="mixpanel",e.people=e.people||[],e.toString=function(n){var t="mixpanel";return"mixpanel"!==u&&(t+="."+u),n||(t+=" (stub)"),t},e.people.toString=function(){return e.toString(1)+".people (stub)"},f="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" "),r=0;r<f.length;r++)o(e,f[r]);t._i.push([n,i,u])};t.__SV=1.2}})(document,window.mixpanel||[]);mixpanel.init("74ed528b406df79c0072817961e52d0c");_sf_async_config={uid:34276,domain:"leafly.com"},function(){function n(){window._sf_endpt=(new Date).getTime();var n=document.createElement("script");n.setAttribute("language","javascript");n.setAttribute("type","text/javascript");n.setAttribute("src",("https:"==document.location.protocol?"https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/":"https://static.chartbeat.com/")+"js/chartbeat.js");document.body.appendChild(n)}var t=window.onload;window.onload=typeof window.onload!="function"?n:function(){t();n()}}();setTimeout(function(){var n=document.createElement("script"),t=document.getElementsByTagName("script")[0];n.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0023/7341.js?"+Math.floor((new Date).getTime()/36e5);n.async=!0;n.type="text/javascript";t.parentNode.insertBefore(n,t)},1);!function(n){"use strict";function s(n){var i,t=n?n.keyCode:event.keyCode;if(!f[t]){f[t]=!0;for(i in u)u[i].keydown(t)}}function h(n){var t=n?n.keyCode:event.keyCode;f[t]=!1}function o(){var n;for(n in f)f[n]=!1}function e(n,t,i){n.addEventListener?n.addEventListener(t,i,!1):n.attachEvent&&(n["e"+t+i]=i,n[t+i]=function(){n["e"+t+i](window.event)},n.attachEvent("on"+t,n[t+i]))}var t,r,u={},c={backspace:8,tab:9,enter:13,"return":13,shift:16,"⇧":16,control:17,ctrl:17,"⌃":17,alt:18,option:18,"⌥":18,pause:19,capslock:20,esc:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,L:37,"←":37,up:38,U:38,"↑":38,right:39,R:39,"→":39,down:40,D:40,"↓":40,insert:45,"delete":46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,"⌘":91,command:91,kp_0:96,kp_1:97,kp_2:98,kp_3:99,kp_4:100,kp_5:101,kp_6:102,kp_7:103,kp_8:104,kp_9:105,kp_multiply:106,kp_plus:107,kp_minus:109,kp_decimal:110,kp_divide:111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,equal:187,"=":187,comma:188,",":188,minus:189,"-":189,period:190,".":190},i=function(){},f={};r=function(n,t,r,u){var f;for(this.str=n,this.next=t?t:i,this.fail=r?r:i,this.done=u?u:i,this.seq=n.split(" "),this.keys=[],f=0;f<this.seq.length;++f)this.keys.push(c[this.seq[f]]);this.idx=0};r.prototype.keydown=function(n){var i=this.idx;return n!==this.keys[i]?void(i>0&&(this.reset(),this.fail(this.str),t.__fail(this.str))):(this.next(this.str,this.seq[i],i,this.seq),t.__next(this.str,this.seq[i],i,this.seq),void(++this.idx===this.keys.length&&(this.done(this.str),t.__done(this.str),this.reset())))};r.prototype.reset=function(){this.idx=0};t=function(n,t){var f,e,i;"function"==typeof t?i=t:null!==t&&void 0!==t&&(f=t.next,e=t.fail,i=t.done);u[n]=new r(n,f,e,i)};t.disable=function(n){delete u[n]};e(window,"keydown",s);e(window,"keyup",h);e(window,"blur",o);e(window,"focus",o);t.__next=i;t.next=function(n){t.__next=null===n?i:n};t.__fail=i;t.fail=function(n){t.__fail=null===n?i:n};t.__done=i;t.done=function(n){t.__done=null===n?i:n};t.reset=function(n){var t=u[n];return t instanceof r?void t.reset():void console.warn("cheet: Unknown sequence: "+n)};n.cheet=t;"function"==typeof define&&define.amd?define([],function(){return t}):"undefined"!=typeof module&&null!==module&&(module.exports=t)}(this),function(){for(var n,u=function(){},t=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],i=t.length,r=window.console=window.console||{};i--;)n=t[i],r[n]||(r[n]=u)}();String.prototype.toTitleCase=function(){var n=[];return this.split(" ").forEach(function(t){n.push(t.charAt(0).toUpperCase()+t.substr(1))}),n.join(" ")};String.prototype.toLowerCaseHyphenated=function(){return this.toLowerCase().replace(/\s/g,"-").replace(/\//g,"")};Object.defineProperty(Object.prototype,"toQueryString",{enumerable:!1,value:function(){var r=this,u=[],t,i,n;if(arguments.length==0){for(n in r)r.hasOwnProperty(n)&&u.push(encodeURIComponent(n)+"="+encodeURIComponent(r[n]));return u.join("&")}for(t={},i=0;i<arguments.length;i++)t[arguments[i]]=r[arguments[i]];for(n in t)t.hasOwnProperty(n)&&u.push(encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return u.join("&")}});Object.defineProperty(Object.prototype,"toFormString",{enumerable:!1,value:function(){var t=this,r=[],n,i;for(n in t)t.hasOwnProperty(n)&&(i=t[n],r.push(encodeURIComponent(n)+"="+encodeURIComponent(i===null?"":i)));return r.join("&").replace(/%20/g,"+")}});String.prototype.encodeLocationLink=function(){return this.replace(", ","-").replace(",","-").replace(" ","-").toLowerCase()};"localStorage"in window||(window.localStorage={_data:{},setItem:function(n,t){return this._data[n]=String(t)},getItem:function(n){return this._data.hasOwnProperty(n)?this._data[n]:undefined},removeItem:function(n){return delete this._data[n]},clear:function(){return this._data={}}});promisedata=null;isDebug=function(){return localStorage.devMode==="true"}();isVerbose=function(){return localStorage.verbose==="true"}();cheet("up up down down left right left right b a",function(){var n=["scott","brian","cy"][Math.floor(3*Math.random())];location.href="https://www.leafly.com/profile/"+n});_.mixin({skipTake:function(n,t){return t=_.extend({skip:0,take:0},t||{}),_(n).chain().rest(t.skip).first(t.take||n.length-t.skip).value()}});window.isMobile=function(){var n=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(n=!0)}(navigator.userAgent||navigator.vendor||window.opera),n};window.isMobile()&&(document.getElementsByTagName("html")[0].className+=" mobile-device");ApplicationConfiguration=function(){var n="leafly",t=function(t,i){i?angular.module(t,i):angular.module(t,[]);angular.module(n).requires.push(t)};return{applicationModuleName:n,applicationModuleVendorDependencies:["angularMoment","matchmedia-ng"],registerModule:t}}();angular.module(ApplicationConfiguration.applicationModuleName,ApplicationConfiguration.applicationModuleVendorDependencies);angular.module(ApplicationConfiguration.applicationModuleName).config([function(){}]);angular.element(document).ready(function(){setTimeout(function(){angular.bootstrap(document,[ApplicationConfiguration.applicationModuleName])},100)});ApplicationConfiguration.registerModule("leafly.core",["ui.bootstrap","ngSanitize","ngRoute","ngMap","ngCookies","youtube-embed"]);angular.module("leafly.core").config(["$httpProvider","logEnhancerProvider",function(n,t){n.defaults.headers.common["X-Requested-With"]="XMLHttpRequest";t.loggingPattern="%s::[%s]> "}]).run(["$rootScope","ageGate","$locator","$log","logEnhancer","$window","$storage","$geoIp","SponsorService","$auth","$http","ReviewService","$cacheFactory","$modal",function(n,t,i,r,u,f,e,o,s,h,c,l,a,v){e.get("devMode")===!0&&angular.extend(f,{$log:r,$storage:e,$locator:i,$rootScope:n,$geoIp:o,$sponsor:s,ageGate:t,$auth:h,$http:c,$review:l,$cacheFactory:a,$modal:v});u.enhanceAngularLog(r);i.locateAndSave()}]).filter("slice",function(){return function(n,t,i){return(n||[]).slice(t,i)}});angular.element.prototype.serialize=function(){var n=this,t,r,i;if(!n||(n=n[0],!n||n.nodeName!=="FORM"))return null;for(i=[],t=n.elements.length-1;t>=0;t=t-1)if(n.elements[t].name!=="")switch(n.elements[t].nodeName){case"INPUT":switch(n.elements[t].type){case"text":case"hidden":case"password":case"button":case"reset":case"submit":i.push(n.elements[t].name+"="+encodeURIComponent(n.elements[t].value));break;case"checkbox":case"radio":n.elements[t].checked&&i.push(n.elements[t].name+"="+encodeURIComponent(n.elements[t].value))}break;case"TEXTAREA":i.push(n.elements[t].name+"="+encodeURIComponent(n.elements[t].value));break;case"SELECT":switch(n.elements[t].type){case"select-one":i.push(n.elements[t].name+"="+encodeURIComponent(n.elements[t].value));break;case"select-multiple":for(r=n.elements[t].options.length-1;r>=0;r=r-1)n.elements[t].options[r].selected&&i.push(n.elements[t].name+"="+encodeURIComponent(n.elements[t].options[r].value))}break;case"BUTTON":switch(n.elements[t].type){case"reset":case"submit":case"button":i.push(n.elements[t].name+"="+encodeURIComponent(n.elements[t].value))}}return i=i.reverse(),i.join("&")};angular.module("leafly.core").provider("ageGate",["$injector",function(){this.isAgeVerified=!1;this._savedLocations=[];this._gatedLocations=[];this.setGatedLocations=function(n){for(var i=this._gatedLocations=n,t=0;t<i.length;t++)i[t]=i[t].toUpperCase()};this.checkLoc=function(n){if(this.isAgeVerified||!n)return!1;var t=this._gatedLocations.indexOf(n.toUpperCase())===-1?!1:!0;return t&&(t=this._savedLocations.indexOf(n.toUpperCase())===-1?!0:!1),t};this.messages={};this.$get=["$injector","$log","$modal","$rootScope","$storage",function(n,t,i,r,u){var f=this;return{init:function(){this.loadLocations()},messages:f.messages,getGatedLocations:function(){return f._gatedLocations},loadLocations:function(){var i=[],t={states:[],countries:[]},n;for(_.extend(t,JSON.parse(localStorage.AgeGate||"[]")),_.extend(t,JSON.parse(readCookie("AgeGate")||"[]")),n=0;n<t.states.length;n++)i.push(t.states[n]);for(n=0;n<t.countries.length;n++)i.push(t.countries[n]);i.length>0&&u.save("isAgeVerified",!0)},verify:function(n){u.save("isAgeVerified",n)},checkLocation:function(n){var t,i;if(u.get("isAgeVerified")===!0)return!1;if(t=!1,angular.isArray(n)){for(i=0;i<n.length;i++)if(t=f.checkLoc(n[i]),t)return!0}else{if(angular.isObject(n))return f.checkLoc(this.findSpecial(n));if(angular.isString(n))return f.checkLoc(n)}return t},gate:function(n){this.checkLocation(n)&&(r.ageGate.isOpen||(r.ageGate.gateKeyword=this.findSpecial(n),r.ageGate.modalInstance=i.open({templateUrl:"m-age-gate.html",windowClass:"age-gate-window",controller:"mAgeGateController",backdrop:"static"}),r.ageGate.isOpen=!0))},findSpecial:function(n){var t=null;return angular.isObject(n)?t=this.getGatedLocations().indexOf(n.statecode)>-1?n.statecode:this.getGatedLocations().indexOf(n.countrycode)>-1?n.countrycode:null:angular.isString(n)&&(t=this.getGatedLocations().indexOf(n)>-1?n:null),t}}}]}]).config(["ageGateProvider",function(n){var t=n;n.setGatedLocations(["WA","CO","es-ES","ES"]);n.messages=window.gateMessages}]).run(["$rootScope","ageGate","$locator","$window",function(n,t){n.ageGate={isOpen:!1,modalInstance:null,gateKeyword:null};t.init()}]),function(){"use strict";angular.module("leafly.core").service("$auth",["$log","$rootScope","$http","$q","$route","$modal","$cookies","$window","$timeout","$storage",function(n,t,i,r,u,f,e,o,s,h){var c=null,l=!1;return{userObj:{},isLoggedIn:!1,modalInstance:null,authenticate:function(n){!this.isLoggedIn&&l&&(l=!1,c=null);var t=this;return c=r.defer(),l=!1,c.promise.then(function(){l=!0}),localStorage.getItem("loggedInUser")?(t.userObj.userName=localStorage.getItem("loggedInUser"),t.isLoggedIn=!0,c.resolve(!0)):(t.isLoggedIn=!1,n?(f.open({templateUrl:"/user/modal",controller:"mLoginModalInstanceCtrl",windowClass:"m-login__modal",resolve:{startIndex:function(){return 1},onSuccessfulAuth:function(){return function(){c.resolve(!0)}}}}),l=!1):c.reject(!1)),c.promise},emailValidate:function(){var n=r.defer();return i.get("/user/isemailvalidated").then(function(t){t.data.hasOwnProperty("validated")&&n.resolve(t.data.validated)}),n.promise},loggedIn:function(n){this.isLoggedIn=!0;t.$broadcast("userLoggedIn");h.save("loggedInUser",n.userName);angular.extend(this.userObj,n)},logout:function(){localStorage.removeItem("loggedInUser");localStorage.removeItem("loggedInUserCheck");var r=this;i.post("/user/logout").then(function(){r.isLoggedIn=!1;r.userObj.userName="";t.$broadcast("userLoggedOut");s(function(){o.location.href="/"},0)}).catch(function(t){n.error(t)})},register:function(){return c=r.defer(),f.open({templateUrl:"/user/modal",controller:"mLoginModalInstanceCtrl",windowClass:"m-login__modal",resolve:{startIndex:function(){return 0},onSuccessfulAuth:function(){return function(){c.resolve(!0)}}}}),c.promise},initialize:function(){var n=this;localStorage.getItem("loggedInUserCheck")?this.authenticate(!1):(h.save("loggedInUserCheck",!0),i.post("/me/isloggedin").then(function(t){t.data.hasOwnProperty("userName")&&n.loggedIn(t.data)}))}}}]).run(["$auth",function(n){n.initialize()}])}();angular.module("leafly.core").factory("FollowService",["$q","$http","$rootScope","$auth",function(n,t,i){var r={};return i.$on("userLoggedOut",function(){_.each(r,function(n){_.each(n,function(n){n.following=!1})});r={}}),{getFollowers:function(i){return r[i||"all"]||(r[i||"all"]=n.defer(),t.get("/api2/user/following-list/"+i.toLowerCase()).then(function(n){var t=_.map(n.data,function(n){return{Id:n}});i&&_.each(t,function(n){n.following=!0});r[i||"all"].resolve(t)})),r[i||"all"].promise},getItem:function(t,i){var r=n.defer();return this.getFollowers(i).then(function(n){var i=_.find(n,function(n){return n.Id===t});i||(i={Id:t+""},n.push(i));r.resolve(i)}),r.promise},addFollow:function(i,r,u){var f=n.defer(),e=this,o=u?u:"/api2/user/follow/"+i+"/"+r;return t.post(o),e.getFollowers(r).then(function(n){var t=_.find(n,function(n){return n.Id===i});t.following=!0;f.resolve(t)}),f.promise},removeFollow:function(n,i,r){var u=this,f=r?r:"/api2/user/follow/"+n+"/"+i;t.delete(f);u.getFollowers(i).then(function(t){var i=_.find(t,function(t){return t.Id===n});i.following=!1})}}}]);angular.module("leafly.core").factory("$geoIp",["$window","$q","$http",function(n,t,i){return{findMe:function(){var n=t.defer();return i.get("/geo/ip").success(function(t){n.resolve(t)}),n.promise}}}]);angular.module("leafly.core").factory("$locator",["$rootScope","$q","$http","$window","$log","ageGate","$storage","$geoIp",function(n,t,i,r,u,f,e,o){var s=null;return{getAll:function(){return e.get("locations")},mostRecent:function(){var n=this.getAll();return n.length>0?n[0]:null},locate:function(n){var u=this,i,r;return s?s:(i=t.defer(),r=this.mostRecent(),angular.isDefined(n)&&angular.isString(n)?(s=this.locateByAddress(n),s.then(function(n){s=null;i.resolve(n)})):r&&angular.isObject(r)?i.resolve(r):o.findMe().then(function(n){var t;n?(t={lat:n.latitude,lon:n.longitude,city:n.city,locationtext:u.formatLocation(n.city,n.state,n.country),countrycode:n.country,statecode:n.state},i.resolve(t)):i.reject()}),i.promise)},locateAndSave:function(n){var i=this,r=t.defer();return i.locate(n).then(function(n){i.saveLocation(n);r.resolve(n)}),r.promise},saveLocation:function(t){var i=this.getAll();i=_.filter(i,function(n){return n&&n.locationtext!=t.locationtext});i.unshift(t);i.length>10&&(i=i.splice(0,9));f.gate(t);n.currentLocation=t;n.$emit("LocationChanged",t);e.save("locations",i)},reverseGeocode:function(n,r){var f=this,u=t.defer();return i.jsonp("https://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent('SELECT * FROM geo.placefinder WHERE text="'+n+" "+r+'" and gflags="R"')+"&format=json&callback=JSON_CALLBACK").success(function(n){var t,i;if(!n.query.results){u.reject("No data");return}t=n.query.results.Result;Array.isArray(t)&&(t=t[0]);i=f.formatLocation(t.city,t.statecode,t.countrycode);u.resolve({locationtext:i,city:t.city,countrycode:t.countrycode,statecode:t.statecode})}),u.promise},formatLocation:function(n,t,i){var r=null;return n&&(r=n),t?r?r+=","+t:r=t:r?r+=","+i:r=i,r},locateByLatLong:function(n,t){return this.reverseGeocode(n,t)},locateByAddress:function(n){var u=this,r=t.defer();return i.jsonp("https://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent('SELECT * FROM geo.placefinder WHERE line1="'+n+'"')+"&format=json&callback=JSON_CALLBACK").success(function(n){var t,i;if(!n||!n.query||!n.query.results){r.reject();return}t=n.query.results.Result;Array.isArray(t)&&(t=t[0]);i={locationtext:u.formatLocation(t.city,t.statecode,t.countrycode),countrycode:t.countrycode,statecode:t.statecode,lat:t.latitude,lon:t.longitude};r.resolve(i)}),r.promise},clearHistory:function(){e.save("locations",[])}}}]);angular.module("leafly.core").provider("logEnhancer",[function(){this.loggingPattern="%s - %s: ";this.$get=function(){var n=this.loggingPattern;return{enhanceAngularLog:function(t){function i(n,i,r){return function(){var f=t.enabledContexts[i],u;(f===undefined||f)&&(u=[].slice.call(arguments),u[0]=[sprintf(r,moment().format("dddd h:mm:ss a"),i)]+u[0],n.apply(null,u))}}t.enabledContexts=[];t.getInstance=function(r){return{log:i(t.log,r,n),info:i(t.info,r,n),warn:i(t.warn,r,n),debug:i(t.debug,r,n),error:i(t.error,r,n),enableLogging:function(n){t.enabledContexts[r]=n}}}}}}}]);angular.module("leafly.core").service("ReviewService",["$log","$rootScope","$http","$auth","$modal","$q","$window",function(n,t,i,r,u,f,e){return{strainSlug:"",submitStrainReview:function(n,t){var r=f.defer(),u="/api2/strains/"+n+"/review";return i.post(u,t).then(function(n){e.latest=n.data;r.resolve(n)}).catch(function(n){r.reject(n);console.error(n)}),r.promise},submitProviderReview:function(){},openQuickReviewModal:function(n){this.strainSlug=n;u.open({templateUrl:"m-review-modal.html",windowClass:"modal--review",controller:"mReviewController"})}}}]).controller("mReviewController",["$scope","ReviewService","$location","$log","$window",function(n,t,i,r,u){r.info(t);n.submitted=!1;n.error=!1;n.reviewForm={Rating:0};n.continue=function(){n.redirectUrl&&n.redirectUrl.length>0&&(window.location.href=n.redirectUrl)};n.submit=function(i){i.Rating!==null&&typeof i.Rating!="undefined"?(n.disabled=!0,n.error=!1,i.Visible=!i.Private,u.dataLayer.push({event:"gaEvent",customCategory:"Strain Reviews",customAction:"Save Review",customLabel:t.strainSlug}),t.submitStrainReview(t.strainSlug,i).then(function(i){angular.isDefined(i.data.reviewId)&&(n.submitted=!0,n.result=i.data,n.redirectUrl="/review/"+t.strainSlug+"/"+i.data.reviewId)}).catch(function(t){n.submitted=!1;n.error=t}).finally(function(){n.busy=!1})):typeof i.Rating!="Number"&&(n.error=!0)}}]);angular.module("leafly.core").factory("SponsorService",["$q","$http","$locator",function(n,t,i){return{getProviders:function(){var r=n.defer();return i.locate().then(function(n){t.get("/home/locations?"+n.toQueryString("lat","lon")).success(function(n){r.resolve(n)})}),r.promise},getStrains:function(){var r=n.defer();return i.locate().then(function(n){var i="/home/sponsoredstrain";typeof n!="undefined"&&(i="/home/sponsoredstrain?"+n.toQueryString("lat","lon"));t.get(i).success(function(n){r.resolve(n)})}),r.promise},getProvidersForStrain:function(r){var u=n.defer();return i.locate().then(function(n){t.get("/strain/topstoresonstrain?strainId="+r+"&"+n.toQueryString("lat","lon")).success(function(n){u.resolve(n)})}),u.promise}}}]);angular.module("leafly.core").provider("$storage",[function(){this.$get=["$log",function(n){var t=this;return n.info("$storageProvider loaded"),this.getCookie=function(n,t){for(var u=n+"=",f=document.cookie.split(";"),i,r=0;r<f.length;r++){for(i=f[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(u)==0)try{return JSON.parse(i.substring(u.length,i.length))}catch(e){return e}}return t||null},this.setCookie=function(n,t,i){var r,u;angular.isObject(t)&&(t=JSON.stringify(t));i?(r=new Date,r.setTime(r.getTime()+i*864e5),u="; expires="+r.toGMTString()):u="";document.cookie=n+"="+t+u+"; path=/"},{bLocalStorage:function(){try{return localStorage.setItem("__testLocalStorageItem","testValue"),localStorage.removeItem("__testLocalStorageItem"),"localStorage"&&window&&window.localStorage!==null}catch(t){return n.error(t),!1}}(),bCookies:function(){var n=navigator.cookieEnabled?!0:!1;return typeof navigator.cookieEnabled!="undefined"||n||(document.cookie="testcookie",n=document.cookie.indexOf("testcookie")!=-1?!0:!1),n}(),save:function(i,r){this.bLocalStorage?(angular.isObject(r)&&(r=JSON.stringify(r)),localStorage.setItem(i,r)):this.bCookies?t.setCookie(i,r):n.error("Could not save data:",{key:i,val:r})},get:function(n){var t={};if(this.bLocalStorage)try{t=JSON.parse(localStorage.getItem(n));t||(t=this.getCookie(n,{}))}catch(i){return i}else this.bCookies&&(t=this.getCookie(n,{}));return t||{}},getCookie:t.getCookie}}]}]);angular.module("leafly.core").factory("VotingService",["$q","$http","$auth",function(n,t,i){var r={},u=[];return{subscribe:function(n,t,i){u.push({reviewId:n,reviewTypeId:t,callback:i})},unsubscribe:function(n,t,i){i=i||"all";u=_.filter(u,function(i){return i.reviewTypeId!==n||i.reviewId!==t})},getVotes:function(u,f){var e=(f||"all")+"-"+(u||"all");return r[e]||(r[e]=n.defer(),i.authenticate(!1).then(function(){var n="/me/reviewvotes?reviewType="+f+"&entityId="+u;t.get(n).then(function(n){r[e].resolve(n.data)})},function(){r[e].reject()})),r[e].promise},hasVotedValue:function(t,i,r,u){var f=n.defer();return this.getVotes(i,r).then(function(n){f.resolve(_.filter(n,function(n){return n.type===r&&n.id===t&&n.vote===u}).length>0)}),f.promise},vote:function(n,i,r){var f=_.filter(u,function(n){return n.reviewId===i&&n.reviewTypeId===r});return _.each(f,function(n){n.callback()}),t.put(n)}}}]);angular.module("leafly.core").controller("mAgeGateController",["$rootScope","$scope","$log","ageGate","$window","$locator","$modal",function(n,t,i,r){var u=t.locToCheck=r.findSpecial(n.currentLocation||n.ageGate.gateKeyword);t.messages=r.messages;u&&(t.message=t.messages[u.toLowerCase()]);t.answer=function(i){r.verify(i);i?(n.ageGate.modalInstance.close(),n.ageGate.isOpen=!1,n.ageGate.gateKeyword=null):t.denied=!0}}]).directive("mAgeGate",[function(){return{scope:!0,controller:"mAgeGateController",restrict:"A",templateUrl:"m-age-gate.html",replace:!0}}]).directive("mAgeGateForce",["$rootScope","ageGate",function(n,t){return{restrict:"A",link:function(n,i,r){angular.isDefined(r.mAgeGateForce)&&t.forceGate(r.mAgeGateForce)}}}]);angular.module("leafly.core").directive("mAnimate",["$document",function(n){function t(n){var t=n.getBoundingClientRect();return t.top>=0&&t.top<=(window.innerHeight||document.documentElement.clientHeight)||t.bottom>0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)}return{restrict:"A",link:function(i,r,u){var f=u.mAnimateDefault,e=u.mAnimatePlay,o;r.addClass(f);r.removeClass(e);o=function(){if(!t(r[0])){if(r.hasClass(f))return;r.addClass(f);r.removeClass(e);return}r.hasClass(e)||(r.addClass(e),r.removeClass(f))};o();n.bind("scroll",o)}}}]);angular.module("leafly.core").directive("mProgress",[function(){return{scope:{ngModel:"="},require:"ngModel",restrict:"EA",templateUrl:"m-progress-bar.html",replace:!0,link:function(){}}}]);angular.module("leafly.core").directive("dismissible",["$storage",function(n){return{restrict:"A",scope:!0,link:function(t,i,r){var u="dismissible:"+r.dismissible;i.toggleClass("visible",n.get(u)!==!0);t.dismiss=function(){n.save(u,!0);i.removeClass("visible")}}}}]);angular.module("leafly.core").directive("distance",["$filter",function(n){return{restrict:"EA",template:"",replace:!0,scope:{distanceFrom:"="},controller:["$scope","$element","$attrs","$locator",function(t,i,r,u){function e(t,i){if(!t)return 0;var r=i,u=f((t.Latitude||t.Lat)-r.lat),e=f((t.Longitude||t.Lon)-r.lon),o=Math.sin(u/2)*Math.sin(u/2)+Math.cos(f(r.lat))*Math.cos(f(t.Latitude||t.Lat))*Math.sin(e/2)*Math.sin(e/2),s=2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o)),h=6371*s;return n("number")(h*.621371,1)}function f(n){return n*(Math.PI/180)}t.$watch("distanceFrom",function(){u.locate().then(function(u){t.distanceValue=typeof t.distanceFrom!="object"||!t.distanceFrom?r.distance:e(t.distanceFrom,u);u.countrycode!="US"?(t.unitLabel="km",t.distanceValue=n("number")(t.distanceValue*1.60934,1)):t.unitLabel="mile";t.unitLabel=t.distanceValue>1?t.unitLabel+"s":t.unitLabel;i.text(t.distanceValue+" "+t.unitLabel)})})}]}}]);angular.module("leafly.core").directive("exploreDropdown",["$rootScope","$document","$window",function(n,t,i){return{transclude:!0,replace:!1,scope:{open:"@open",changed:"&",sections:"=",selectedCount:"="},link:function(r,u,f,e,o){r.sections={};o(r,function(n){u.append(n)});r.change=function(n,t){i.dataLayer.push({event:"gaEvent",customCategory:"Explore Filters",customAction:"Filter Selected",customLabel:n});n.count=_.filter(n,function(n){return n.checked===!0}).length;r.sections.selectedCount=_.reduce(_.map(r.sections,function(n){return n?_.filter(n,function(n){return n.checked===!0}).length:0}),function(n,t){return n+t},0);r.changed({value:t})};r.toggleOpen=function(){var t=r.open;n.$emit("select.opening");r.open=!t};n.$on("select.opening",function(){r.open=!1});angular.element(t[0].body).bind("click",function(){r.$apply(function(){r.open=!1})});u.bind("click",function(n){n.stopPropagation()})}}}]);angular.module("leafly.core").directive("focusMe",["$timeout",function(){return{scope:{trigger:"=focusMe"},link:function(n,t){n.$watch("trigger",function(i){i===!0&&(t[0].focus(),n.trigger=!1)});t.bind("blur",function(){n.trigger=!1})}}}]);angular.module("leafly.core").directive("mToggleFollow",["FollowService","$auth","$rootScope",function(n,t,i){return{transclude:!0,scope:{followType:"@",id:"@followId",path:"@path"},link:function(r,u,f,e,o){var h={},s;r.following=function(){return h.following&&t.isLoggedIn};r.id+="";s=function(){n.getItem(r.id,r.followType).then(function(n){h=n})};t.authenticate(!1).then(function(){s()});i.$on("userLoggedIn",function(){s()});i.$on("userLoggedIn",function(){s()});o(r,function(n){u.append(n)});r.follow=function(){t.authenticate(!0).then(function(){n.addFollow(r.id,r.followType,r.path)})};r.unfollow=function(){t.authenticate(!0).then(function(){n.removeFollow(r.id,r.followType,r.path)})}}}}]);angular.module("leafly.core").directive("mSwitch",[function(){return{restrict:"A",templateUrl:"m-switch.html",replace:!0,scope:{name:"=",ngModel:"="}}}]).directive("mAjaxForm",["$http","$compile",function(n,t){return{require:"^form",transclude:!0,scope:{beforeSubmit:"&beforeSubmit",success:"&formSuccess",failure:"&formError"},link:function(i,r,u,f,e){function o(){f.$invalid||(r.find("button").attr("disabled","disabled"),r.find("input").attr("disabled","disabled"),n({method:s,url:r.attr("action"),data:r.serialize(),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){var u=n.data;if(r.find("button").removeAttr("disabled"),r.find("input").removeAttr("disabled"),angular.isString(u)?r.replaceWith(t(u)(i.$parent)):u.html&&r.replaceWith(t(u.html)(i.$parent)),typeof u.success=="undefined"){i.success&&i.success({data:u});return}u.success===!0&&i.success?i.success({data:u}):u.success===!1&&i.failure&&i.failure({data:u})}))}e(i,function(n){r.append(n)});var s=r.attr("method")||"GET";i.submitForm=function(n){if(n&&n.preventDefault(),u.beforeSubmit){var t=i.beforeSubmit(n);if(t===!1)return;if(t&&t.then){t.then(o);return}}o()};r.bind("submit",i.submitForm)}}}]).directive("mSwitchPill",[function(){return{restrict:"A",templateUrl:"m-switch-pill.html",replace:!0,scope:{name:"=",ngModel:"="}}}]);angular.module("leafly.core").directive("gaEvent",["$window",function(n){return{restrict:"A",link:function(t,i){i.on("click",function(){var t=this.attributes.getNamedItem("ga-event-category").value,i=this.attributes.getNamedItem("ga-event-action").value,r=this.attributes.getNamedItem("ga-event-label").value;n.dataLayer.push({event:"gaEvent",customCategory:t,customAction:i,customLabel:r})})}}}]);angular.module("leafly.core").directive("locationModal",["$modal",function(n){return{restrict:"A",scope:{change:"&"},link:function(t,i){function r(){n.open({template:"<form class='m-form' ng-submit='submit($event)'><button class=\"m-button m-button--icon modal-close-button\" ng-click=\"$close($event);\"><i class=\"icon-close-x\"><\/i><\/button><h2 class='copy--centered padding-rowItem heading--md copy--bold'>Change Location<\/h2><div class='m-form--input-container l-grid'><input type='text' class='grid-2-3' placeholder='Enter ZIP code or city' ng-model='model.query' /><button type='submit' class='m-button m-button--green m-button--lg' ng-disabled='!model.query'>Save<\/button><\/div><\/form>",windowClass:"modal__location",controller:["$scope","$locator","$window",function(n,i){n.model={};n.submit=function(r){r.preventDefault();i.locateByAddress(n.model.query).then(function(n){i.saveLocation(n);t.change({location:n})}).finally(function(){n.$close()})}}]})}i.on("click",function(n){n.preventDefault();r()})}}}]);angular.module("leafly.core").directive("mFixedHeader",["$document","$timeout",function(n,t){function i(t){var i=n[0],r=t[0],u=i.documentElement||i.body,f=window.pageXOffset||u.scrollLeft,e=window.pageYOffset||u.scrollTop;return{left:r.getBoundingClientRect().left+f,top:r.getBoundingClientRect().top+e}}function r(){if(typeof pageYOffset!="undefined")return pageYOffset;var t=document.body,n=document.documentElement;return n=n.clientHeight?n:t,n.scrollTop}return{restrict:"A",scope:{animate:"=animate"},link:function(u,f){function s(){var n=r(),h=f[0].offsetHeight,s=u.animate?e.top+h:e.top;s=s<0?0:s;n>s?u.animate?(f.hasClass("l-fixed")||f.addClass("l-fixed l-fixed-animation hidden"),n<o?f.addClass("animation"):f.removeClass("animation"),t(function(){f.removeClass("hidden")},500)):f.addClass("l-fixed"):f.hasClass("l-fixed")?u.animate&&n>e.top&&n<s||f.removeClass("l-fixed l-fixed-animation animation"):e=i(f);o=n}var e=i(f),o=0;n.bind("scroll",s);s()}}}]),function(){"use strict";angular.module("leafly.core").controller("mLoginModalInstanceCtrl",["$log","$scope","$auth","$modalInstance","startIndex","onSuccessfulAuth",function(n,t,i,r,u,f){t.model={};t.error=null;t.currentTab=u;t.errorMessage=null;t.disableSubmit=!1;t.loginSuccess=function(n){n=n.model;i.loggedIn(n);f();r.close()}}]).directive("mLogin",[function(){return{controller:["$scope","$auth",function(n,t){n.$auth=t;n.user=t.userObj}],restrict:"A",link:function(n){n.isOpen=!0}}}])}();angular.module("leafly.core").directive("mMenuItem",["$q","$http","$compile","$window","$timeout",function(n,t,i,r,u){return{scope:{query:"=",itemMenuId:"@",itemImageId:"@",itemImageUrl:"@",storeDescription:"@itemStoreDescription"},link:function(r,f,e){var h=e.itemId,o=h==0,s=e.itemName.toLowerCase(),c=e.itemBodyResource,l=e.itemImageId;r.$watch("query",function(){r.query&&s.indexOf(r.query.toLowerCase())==-1&&r.query.toLowerCase().indexOf(s)==-1?f.addClass("hidden"):f.removeClass("hidden")});i(f.children())(r);r.toggleBody=function(){var e=n.defer();e.promise.then(function(){r.bodyVisible=!r.bodyVisible});o?e.resolve():t.get(c).then(function(n){var t=angular.element(f[0].querySelector(".menu__item-body")).html(n.data);i(t)(r);t.ready(function(){o=!0;e.resolve()})});u(function(){pymChild.sendHeight()},500)}}}}]);angular.module("leafly.core").directive("mPagination",["$document","$http","$compile",function(n,t,i){function r(n){var t=n.getBoundingClientRect();return t.bottom>0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)}return{restrict:"A",scope:{parameters:"=parameters"},link:function(u,f,e){function a(n){n&&n.preventDefault();l=!0;s+=1;t.get(e.pagingResource+"?page="+s+"&take="+y+w).success(function(n){n&&(n=angular.element(n),i(n)(u),f.append(n));b(n);l=!1})}function v(){if(s+1>=p){n.unbind("scroll",v);o.removeClass("hidden");return}l||r(f[0])&&a()}function b(t){var i=f[0].querySelectorAll(k),r=_.filter(i,function(n){return n.offsetParent!==null}).length;(r<y*(s+1)||!t)&&(n.unbind("scroll",v),o.unbind("click",a),o.addClass("hidden"))}var y=parseInt(e.pageSize,10),s=0,l=!1,k=e.itemClass,p=parseInt(e.pagesToAutoload||0,10),h=u.parameters,w="",o=angular.element(n[0].querySelector(e.pagingButton)),c;if(p>0&&o.addClass("hidden"),h)for(c in h)h[c]&&(w+="&"+c+"="+encodeURIComponent(h[c]));o.bind("click",a);n.bind("scroll",v);b([])}}}]);angular.module("leafly.core").controller("mRatingController",["$scope",function(n){n.ngModel.rating=Math.round(n.ngModel.rating*10)/10}]).filter("ratingCount",function(){return function(n){return"("+n+")"}}).directive("mRating",[function(){return{scope:{ngModel:"="},require:"ngModel",restrict:"A",controller:"mRatingController",templateUrl:"m-rating.html",replace:!0,link:function(n,t){n.ratingCount=t.hasClass("m-rating--short")?"("+n.ngModel.ratingCount+")":t.hasClass("m-rating--stacked")?(n.ngModel.rating+" out of 5").toUpperCase():n.ngModel.ratingCount+" Reviews";n.ratingScore=n.ngModel.rating}}}]);angular.module("leafly.core").directive("triggerReview",["ReviewService","$auth",function(n,t){return{link:function(i,r,u){var f=u.triggerReview||"";r.on("click",function(i){i.preventDefault();t.authenticate(!0).then(function(){n.openQuickReviewModal(f)})})}}}]).directive("logReportAbuse",["$http",function(n){return{restrict:"A",link:function(t,i,r){i.on("click",function(u){if(u.preventDefault(),!t.reported){t.reported=!0;var f=r.logReportAbuse;n.post(f).then(function(n){n.data.success===!0&&i.html("<em>Reported<\/em>")}).catch(function(n){console.error(n.message)})}})}}}]).directive("logVote",["$http","VotingService","$auth",function(n,t,i){return{restrict:"A",scope:!0,link:function(n,r,u){var h=u.logVote,s=u.logType,e=parseInt(u.logId||"0")||"",o=parseInt(u.logTypeId||"0")||"",c=u.logIsUpvote==="true",f=!1;t.hasVotedValue(e,o,s,c).then(function(n){f=n;f&&r.addClass("button-active")});t.subscribe(e,o,function(){r.removeClass("button-active")});r.on("click",function(n){n.preventDefault();i.authenticate(!0).then(function(){t.vote(h,e,o,s);f=!f;f&&r.addClass("button-active")})})}}}]);angular.module("leafly.core").directive("mSearch",["$q","$http","$window","$document",function(n,t,i,r){return{transclude:!0,scope:{query:"@query",latitude:"=",longitude:"="},link:function(u,f,e,o,s){function y(i){if(e.resource){if(!i){u.searchResults=null;a=null;h=[];return}i!==a&&(l&&l.resolve(),l=n.defer(),t.get(e.resource+i,{timeout:l.promise}).success(function(n){a=i;c=-1;u.searchResults=n;u.loading=!1;h=[];for(var t=0;t<n.length;t+=1)h=h.concat(n[t].results)},!1))}}var l=null,a,c,h=[],v;s(u,function(n){f.append(n)});f.bind("click touch",function(n){n.stopPropagation()});angular.element(r[0].body).bind("click touch",function(){u.searchResults&&u.$apply(function(){u.searchResults=null;a=null;h=[]})});v=angular.element(f[0].querySelector("form"));v.bind("submit",function(n){if(n.preventDefault(),u.query){var t="/search?q="+encodeURIComponent(u.query);u.latitude&&(t+="&lat="+u.latitude+"&lon="+u.longitude);i.location.href=t}});u.$watch("query",_.debounce(y,300));u.keyDown=function(n){u.searchResults&&(n.keyCode==38?(c<0&&(c=h.length),c=(c-1)%h.length,u.activeResult=h[c]):n.keyCode==40?(c=(c+1)%h.length,u.activeResult=h[c]):n.keyCode==13&&(u.activeResult?(i.location.href=u.activeResult.link,n.preventDefault()):u.submitForm()))}}}}]);angular.module("leafly.core").directive("mStrainSponsor",["$locator","$http","$window",function(n,t,i){return{restrict:"A",link:function(r,u,f){var e=n.mostRecent();e&&t.get(f.sponsorResource+"?lat="+e.lat+"&lon="+e.lon).success(function(n){n&&(r.model=n,i.dataLayer.push({event:"gaEvent",customCategory:"Strain Details",customAction:"Strain Sponsorship Impression",customLabel:r.model.DispensaryUrlName}),u.removeClass("hidden"))})}}}]);angular.module("leafly.core").directive("multiSelect",["$window","$document","$compile","$rootScope",function(n,t,i,r){return{replace:!0,scope:{change:"&",syncKey:"@",label:"@"},link:function(u,f){function o(){u.selectedCount=_.filter(f.find("option"),function(n){return n.selected}).length}var s=f.attr("name"),e=angular.element("<div class='m-select' data-ng-class='{ \"open\" : open, \"m-select--none-selected\": !selectedCount }'><button type='button' class='m-select__button' data-ng-click='toggleOpen()' ng-disabled='!options.length'><span class='copy--md'>{{label}}<\/span><i class='icon-down-arrow pull-right copy--md color--default'><\/i><span data-ng-if='selectedCount' class='copy--md m-select__count pull-right'>{{selectedCount}}<\/span><\/button><div class='m-select__dropdown' data-ng-class='{\"hidden\": isMobile }'><ul><li data-ng-repeat='option in options'><input id='"+s+"_{{$index+1}}' class='m-checkbox' type='checkbox' ng-model='option.selected' ng-change='toggleSelected(option, $index)' /><label for='"+s+"_{{$index+1}}'>{{option.key}}<\/label><\/li><\/ul><\/div><\/div>");u.isMobile=n.isMobile();o();f.removeAttr("multi-select");f.addClass(u.isMobile?"mobile-select":"hidden");f.replaceWith(e);e.append(f);i(e)(u);u.options=_.map(e.find("option"),function(n){return n=angular.element(n),{key:n.text(),value:n.val(),selected:n[0].selected}});u.toggleOpen=function(){var n=u.open;r.$emit("select.opening");u.open=u.isMobile?!1:!n};r.$on("select.opening",function(){u.open=!1});u.syncKey&&r.$on("select."+u.syncKey,function(n,t){t.sender!==f&&(_.each(t.items,function(n){var t=f.find("option")[n.index];u.options[n.index].selected=t.selected=n.selected}),o())});u.toggleSelected=function(n,t){var i=f.find("option")[t];return i.selected=n.selected,f.triggerHandler("change"),!0};f.bind("change",function(){if(o(),u.syncKey){var n={sender:f,items:_.map(e.find("option"),function(n,t){return{index:t,selected:n.selected}})};r.$emit("select."+u.syncKey,n)}u.change()});e.bind("click",function(n){n.stopPropagation()});angular.element(t[0].body).bind("click",function(){u.$apply(function(){u.open=!1})})}}}]);angular.module("leafly.core").directive("starRating",["$filter",function(){return{templateUrl:"m-rating.html",scope:{rating:"@starRating",size:"@",set:"="},link:function(n,t){n.onSrc="/public/images/assets/icon-star-filled.svg";n.offSrc="/public/images/assets/icon-star-empty.svg";n.width=n.size;n.width||(n.width=25);n.$watch("rating",function(){n.remainder=n.rating%1;n.rating=parseFloat(n.rating);n.full=_.range(0,5).slice(0,Math.floor(n.rating));n.empty=_.range(0,5).slice(0,Math.floor(5-n.rating));n.left=n.remainder*n.width;n.right=n.width-n.left;var i=t.find("span").eq(0),r=t.find("span").eq(1);i.css({display:"inline-block",verticalAlign:"top",overflow:"hidden",width:n.left+"px"});r.css({display:"inline-block",verticalAlign:"top",overflow:"hidden",direction:"rtl",width:n.right+"px"})})}}}]);angular.module("leafly.core").directive("shareWidget",["$window",function(n){return{restrict:"E",controller:["$scope","$element","$attrs","$timeout",function(t){t.openShareWindow=function(t,i){n.open(t,"share-"+i+"-dialog","width=626,height=436")}}],templateUrl:"m-share-widget.html",replace:!0}}]);angular.module("leafly.core").directive("storeReview",["$modal","$auth","$http","FollowService","$window",function(n,t,i,r,u){function f(t,f,e){n.open({templateUrl:"store-review-modal.html",windowClass:"store__review",controller:["$scope",function(n){n.model=e?{Meds:0,Service:0,PackagingQuality:0,EaseOfRegistration:0,Comments:null,FirstVisit:!1,WouldRecommend:!1}:{Meds:0,Service:0,Atmosphere:0,Comments:null,FirstVisit:!1,WouldRecommend:!1,ShopAgain:!1};n.submit=function(){n.disabled=!0;u.dataLayer.push({event:"gaEvent",customCategory:"Location Reviews",customAction:"Save Location Review",customLabel:f});i({method:"POST",url:f,headers:{Accept:"application/json"},data:n.model}).then(function(){n.submitted=!0})};n.follow=function(){r.addFollow(t,"store")};r.getItem(t,"store").then(function(t){n.following=t.following})}]})}return{scope:{storeId:"@",storeReviewUrl:"@",storeIslp:"@"},restrict:"A",link:function(i,r){r.bind("click",function(r){r.preventDefault();t.authenticate(!0).then(function(){t.emailValidate().then(function(t){t?f(i.storeId,i.storeReviewUrl,i.storeIslp):i.modalInstance=n.open({templateUrl:"email-validate-modal.html",controller:"mEmailValidateModalCtrl",windowClass:"m-login__modal"})})})})}}}]);angular.module("leafly.core").controller("AccountActivityCtrl",["$scope","$http","$locator","$auth",function(n,t,i,r){var u=0,f=20;n.allLoaded=!1;n.noResults=!1;n.results=[];n.isValidated=!0;n.loadMore=function(){t.get("/api2/user/activity?page="+u+"&perpage="+f+"&width=64").success(function(r){r.pagingContext.TotalItemCount>0?(n.results=n.results.concat(r.activity),n.allLoaded=!r.pagingContext.HasNextPage):(n.noResults=!0,i.locate().then(function(i){i&&t.post("/api2/locations",{latitude:i.lat,longitude:i.lon,page:0,take:5,excludemarquee:!0,searchradius:20}).success(function(t){n.nearbyDispensaries=t.stores})}))});u++};n.loadMore();r.emailValidate().then(function(t){n.isValidated=t});n.emailSent=!1;n.sendEmail=function(){t.post("/user/resend").success(function(){n.emailSent=!0})}}]);angular.module("leafly.core").controller("AccountSettingsCtrl",["$scope",function(n){var i,r,u,f,t;for(n.setup=function(t,i,r){n.selectedMonth=_.find(n.months,function(n){return n.value===t||t.value&&n.value===t.value});n.selectedDay=_.find(n.days,function(n){return n===i})||i;n.selectedYear=_.find(n.years,function(n){return n===r})},i=moment().lang()._months,r=[],t=0;t<i.length;t+=1)r.push({key:i[t],value:t+1});for(n.months=r,u=moment().year(),f=[],t=u;t>u-100;t-=1)f.push(t);n.years=f;n.setDays=function(t,i){for(var f=moment(t+"-"+i.key,"YYYY-MMMM").daysInMonth(),u=[],r=1;r<=f;r+=1)u.push(r);n.days=u;n.setup(n.selectedMonth,n.selectedDay,n.selectedYear)}}]);angular.module("leafly.core").controller("AssetsCtrl",["$scope","$window",function(n,t){n.sendRequestSuccess=function(){n.requestFinished=!0;this.requestType==="download"&&(t.location.href="/public/global/assets/downloads/leafly-assets.zip")}}]);angular.module("leafly.core").controller("BoothSignupCtrl",["$scope","$http",function(n,t){n.validUsername=!0;n.validEmail=!0;n.sendAppMessage=!1;n.notifications=!1;n.newsletter=!1;n.formError="";n.checkUsername=function(i){var r={Username:i};t.post("/user/checkusername",r).success(function(t){n.validUsername=t.success})};n.checkEmail=function(i){var r={e:i};t.post("/user/checkemail",r).success(function(t){n.validEmail=t.success})};n.submit=function(){var i="username="+n.username+"&password="+n.password+"&email="+n.email+"&phone="+n.phoneNumber+"&sendAppMessage="+n.sendAppMessage+"&notifications="+n.notifications+"&newsletter="+n.newsletter;t({method:"POST",url:"/boothsignup/register",headers:{"Content-Type":"application/x-www-form-urlencoded"},data:i}).success(function(t){t.registered?(n.showForm=!1,n.formError=""):n.formError="There was an error with the form submission."}).error(function(){n.formError="There was an error with the form submission."})}}]);angular.module("leafly.core").controller("ClinicCtrl",["$scope","$http","$filter","$window","$location","$locator",function(n,t,i,r,u,f){n.scheduleFormData={};n.appointmentSubmitted=!1;n.submitSchedule=function(i){var r=i+"/schedule",u=i+"/confirm";t({method:"POST",url:r,data:n.scheduleFormData,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(){n.appointmentSubmitted=!0})};n.complete=!1;n.showLoading=!1;n.clinic={subscribe:!0};n.submit=function(){n.showLoading=!0;t({method:"POST",url:"/medical/submit",data:{clinic:n.clinic,subscribe:n.clinic.subscribe},headers:{"Content-Type":"application/json; charset=utf-8"}}).success(function(){n.showLoading=!1;n.complete=!0})};n.itemVisability=[];n.filterDoctors=function(t,i){var r=_.map(_.where(n.filters,{checked:!0}),function(n){return n.filterName}),u;return(n.itemVisability[i]=!0,!r.length)?!0:(u=_.intersection(r,t.Features),n.itemVisability[i]=u.length===r.length,n.itemVisability[i])};n.getVisableCount=function(){return _.filter(n.itemVisability,function(n){return n}).length};n.setup=function(t){n.doctors=t;var i=_.union.apply(_,_.map(t,function(n){return n.Features}));n.filters=_.map(i,function(n){return{filterName:n,filterId:n.replace(" ",""),checked:!1}});n.halfFilters=Math.ceil(n.filters.length/2)};f.locate().then(function(t){n.location=t});n.changeLocation=function(t){n.location=t;var i="/doctors/"+t.locationtext.encodeLocationLink();n.storeType&&(i+="/"+n.storeType);r.location.href=i}}]);angular.module("leafly.core").controller("DoctorsCtrl",["$scope","$locator","$window","$http","$location",function(n,t,i,r,u){var f,e,o;n.itemVisability=[];n.mapLocation={};n.filterDoctors=function(t,i){var r=_.map(_.where(n.filters,{checked:!0}),function(n){return n.filterName}),u;return(n.itemVisability[i]=!0,!r.length)?!0:(u=_.intersection(r,t.Features),n.itemVisability[i]=u.length===r.length,n.itemVisability[i])};n.getVisableCount=function(){return _.filter(n.itemVisability,function(n){return n}).length};n.setup=function(i,r){n.doctors=i;n.location=r;t.locate((r||{}).FriendlyName).then(function(t){n.location=t});var u=_.union.apply(_,_.map(i,function(n){return n.Features}));n.filters=_.map(u,function(n){return{filterName:n,filterId:n.replace(" ",""),checked:!1}});n.halfFilters=Math.ceil(n.filters.length/2)};n.$on("$locationChangeSuccess",function(){n.doctorTab=u.path()});n.changeLocation=function(t){n.location=t;i.location.href="/doctors/"+t.locationtext.encodeLocationLink()};n.$on("mapInitialized",function(t,i){n.map=i;var r=new google.maps.LatLngBounds;_.each(n.doctors,function(n){r.extend(new google.maps.LatLng(n.Location.Latitude,n.Location.Longitude))});i.fitBounds(r)});n.closeWindows=function(){_.each(_.map(n.map.infoWindows),function(n){n.close()})};f=!1;n.changeMapCenter=function(){var i=n.map.getCenter();f=!0;n.mapLocation.lat=i.k;n.mapLocation.lon=i.B;e=t.reverseGeocode(n.mapLocation.lat,n.mapLocation.lon)};o=!0;n.changeMapSize=function(){if(o){o=!1;return}f=!0;var t=n.map.getBounds(),i=t.getSouthWest(),r=t.getNorthEast(),u=google.maps.geometry.spherical.computeDistanceBetween(i,r)/2;n.radius=u*.000621371192;n.changeMapCenter()};n.mapIdle=_.debounce(function(){f&&e&&e.then(function(t){(e=null,t&&n.location.locationtext!==t.locationtext)&&r({method:"GET",url:"/doctors/"+t.locationtext.encodeLocationLink()+"?radius="+n.radius,headers:{Accept:"application/json"}}).then(function(t){f=!1;n.itemVisability=[];n.doctors=t.data.doctors})})},500)}]);angular.module("leafly.core").controller("mEmailValidateModalCtrl",["$http","$scope","$modalInstance",function(n,t){t.emailSent=!1;t.sendEmail=function(){n.post("/user/resend").success(function(){t.emailSent=!0})}}]);angular.module("leafly.core").controller("ExploreCtrl",["$scope","$locator","$http","$location","$window",function(n,t,i,r,u){var f,o,e;n.sections=[];n.strains=[];n.sorts=[];n.hasFiltered=!1;f=null;o=t.locate().then(function(t){n.location=t});n.changeLocation=function(t){n.location=t};n.filterLocation=function(t){o.then(function(){var i=n.location;console.log(t);n.locationResultUrl=t.replace("{text}",i.locationtext.encodeLocationLink()).replace("1111",i.lat).replace("2222",i.lon)})};n.load=function(t){u.refreshAd();n.loading=!0;var e=t!=="/explore"?t:"/";r.path(e);i.get(t).then(function(t){n.loading=!1;n.hasFiltered=!0;var i=t.data.Model;f||(f={},_.each(n.sections,function(n){_.extend(f,n)}));_.each(i.Facets,function(n){var i=f[n.SubCategory||n.Category],t;i&&(t=i[n.Label],t.checked=n.Selected,t.hits=n.Hits,t.disabled=n.Hits===0,t.Url=n.Url)});_.each(f,function(n){_.isArray(n)&&(n.disabled=_.filter(n,function(n){return!n.disabled}).length===0)});_.each(n.sections,function(n){n.selectedCount=_.reduce(_.map(n,function(n){return!n||!_.isObject(n)?0:(n.count=_.filter(n,function(n){return n.checked===!0}).length,n.count)}),function(n,t){return n+t},0)});_.each(i.Sorts,function(t){n.sorts[t.TagId]=t.Url});n.nextPageUrl=i.NextPageUrl;n.totalResults=i.PagingContext.TotalItemCount;n.strains=i.Strains;n.sorts=i.Sorts;_.find(i.Sorts,function(t,i){return t.Selected?(n.sort=i,!0):!1});n.locationFilter=i.LocationFilter;n.filterLocation(i.LocationUrl);n.hideLoadMore=n.strains.length>=n.totalResults})};n.next=function(){n.loading=!0;i.get(n.nextPageUrl).then(function(t){n.loading=!1;var i=t.data.Model;n.nextPageUrl=i.NextPageUrl;n.strains=(n.strains||[]).concat(i.Strains);n.hideLoadMore=n.strains.length>=n.totalResults})};e=r.path();e&&e!=="/"&&(e=e.replace("/!",""),n.load(e))}]);angular.module("leafly.core").controller("FinderCtrl",["$rootScope","$scope","$http","$modal","$locator","$timeout","$window","$q","$location",function(n,t,i,r,u,f,e,o,s){var v=o.defer(),c=!1,a,h,l;t.results=[];t.specials=[];t.map=null;t.locations=e.locations;a=u.locate().then(function(n){return t.location=n,n});a.then(function(n){i.get("/ad/marquee",{params:{howMany:1,lat:n.lat,lon:n.lon,storeType:t.storeType}}).then(function(n){typeof n.data!="undefined"&&n.data.length>0&&e.dataLayer.push({marquee:{name:n.data[0].Name,slug:n.data[0].UrlName}});t.sponsoredStores=n.data})});t.$on("$locationChangeSuccess",function(){t.nearbyTab=s.path();s.path()!==""&&f(t.submitForm)});t.loadResults=function(n){var e;c&&(c=!1,t.results=[],t.specials=[]);var i=n.Results,f=i.length-1,r,u=0;_.each(i,function(n){r=f*n.MapMarkerLevel;u=r-f;n.RandomZIndex=Math.floor(Math.random()*(r-u+1))+u});t.totalResults=n.PagingContext.TotalItemCount;t.results=t.results.concat(i);t.resultsShown=t.results.length;e=_.flatten(_.map(n.Results,function(n){return _.first(_.filter(n.Specials,function(t){return t.StoreName=n.Name,t.StoreUrl=n.UrlName,t.FinderLogo=n.FinderLogo,t.Active}),2)}));t.specials=t.specials.concat(e)};t.loadMore=function(){t.currentPage+=1;f(function(){t.form.submitForm()},1)};t.reset=function(){t.hasQueried=!0;t.currentPage=0;c=!0};t.submitForm=function(){t.reset();f(function(){t.form.submitForm()},1)};t.reset();t.hasQueried=!1;t.changeLocation=function(n){t.location=n;var i="/finder/"+n.locationtext.encodeLocationLink();t.storeType&&(i+="/"+t.storeType);e.location.href=i};t.$on("mapInitialized",function(n,i){t.map=i;v.resolve()});t.closeWindows=function(){_.each(_.map(t.map.infoWindows),function(n){n.close()})};h=!1;t.changeMapCenter=function(){var n=t.map.getCenter();h=!0;t.mapLocation.lat=n.lat();t.mapLocation.lon=n.lng()};t.changeMapSize=function(){h=!0;var n=t.map.getBounds(),i=n.getSouthWest(),r=n.getNorthEast(),u=google.maps.geometry.spherical.computeDistanceBetween(i,r)/2;t.radius=u*.000621371192;t.changeMapCenter()};l=!1;t.mapIdle=_.debounce(function(){if(!l){l=!0;return}h&&(f(t.submitForm),h=!1)},500);t.buildIconPath=function(n){var r="",t,i;switch(n.MapMarkerLevel){case 3:case 2:t="pro";i={w:66,h:76};break;case 1:t="standard";i={w:52,h:61};break;case 0:t="basic";i={w:38,h:45};break;default:t="informational";i={w:22,h:22}}return r=n.Storefront?n.IconPath2x&&n.MapMarkerLevel==3?n.IconPath2x:"/public/images/finder/dispensary-"+t+".png?v2":n.CanadaLP?n.IconPath2x&&n.MapMarkerLevel==3?n.IconPath2x:"/public/images/finder/lp-"+t+".png?v2":n.IconPath2x&&n.MapMarkerLevel==3?n.IconPath2x:"/public/images/finder/delivery-"+t+".png?v2",{url:r,scaledSize:new google.maps.Size(i.w,i.h)}};t.selectedCountry="";t.selectedState="";t.selectedCity="";t.changeCityDropdown=function(){var n="/finder/"+u.formatLocation(t.selectedCity,t.selectedState).encodeLocationLink();t.storeType&&(n+="/"+t.storeType);e.location.href=n};t.sendTextModal=function(n,i){t.specialId=n.toString();t.slug=i;t.modalInstance=r.open({templateUrl:"send-special-to-phone-modal.html",windowClass:"m-view-modal",controller:["$scope","$modal","specialId","slug",function(n,i,r,u){n.specialId=r;n.slug=u;n.sendText=t.sendText}],resolve:{specialId:function(){return t.specialId},slug:function(){return t.slug},sendText:function(){return t.sendText}}})};t.sendText=function(){var n="/dispensary-info/"+t.slug+"/specialssms",r=t.specialId,u=document.getElementsByName("__RequestVerificationToken")[0].value,f=document.getElementsByName("phoneNumber")[0].value;n:{t:"getdataajax"};i({method:"POST",url:n,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:"sId="+r+"&phone="+f+"&__RequestVerificationToken="+u}).success(function(){t.textSent=!0;t.modalInstance.close()}).error(function(){t.textSent=!1;t.modalInstance.close()})}}]);angular.module("leafly.core").controller("globalListSubscribeCtrl",["$scope","$http",function(n,t){n.showConfirmation=!1;n.subscribe=function(){t.post("/home/subscribe",{email:n.listEmail});n.showConfirmation=!0}}]);angular.module("leafly.core").controller("HomeCtrl",["$scope","$locator","$http",function(n,t,i){t.locate().then(function(t){t&&i.get("/home/locations?lat="+t.lat+"&lon="+t.lon).success(function(t){n.nearbyDispensaries=t})});n.firstLoad=!0;n.playerVars={modestbranding:1,rel:0};n.changeVideo=function(t){n.firstLoad=!1;n.videoId=t};n.$on("youtube.player.ready",function(){n.firstLoad||n.videoPlayer.playVideo()});n.$on("youtube.player.ended",function(){});n.videoId=InitialVideoId}]);angular.module("leafly.core").controller("MainCtrl",["$rootScope","$scope","$locator","$window","$http","$auth","$location","$document","$anchorScroll",function(n,t,i,r,u,f,e,o,s){function a(n,t){h.locationtext=t.locationtext;h.locationEncoded=t.locationtext.encodeLocationLink();h.latitude=t.lat;h.longitude=t.lon}var h=this,c,l;t.signedUp=!1;t.hideLogin=!0;n.focusSearch=!1;this.changeUrl=function(n){r.location.href=n};t.optimizelyTrigger=function(){window.optimizely.push(["activate",2853750544])};t.scrollTo=function(n){e.hash(n);s()};t.newsletterSignup=function(){u.post("/home/subscribe",{email:t.emailAddress});t.signedUp=!0};this.submitLocationForm=function(n,t){(n.preventDefault(),h.locationQuery)&&i.locateByAddress(h.locationQuery).then(function(n){i.saveLocation(n);r.location.href=(t||r.location.href)+"/"+n.locationtext.encodeLocationLink()})};this.isLoggedIn=function(){return f.isLoggedIn};this.userName=function(){return f.userObj.userName};n.$on("LocationChanged",a);t.$on("$locationChangeSuccess",function(){e.path()==="/specials"?(t.dealsActive=!0,t.activeOverride=!0):t.dealsActive=!1;e.path()==="/list"&&(t.activeOverride=!0)});c=document.referrer;l=window.location.href;c.indexOf("mantis.link")>-1&&(t.contentMessage=!0,t.redirectUrl=l.toString())}]);angular.module("leafly.core").controller("PhotosCtrl",["$scope","$modal",function(n,t){n.openPhotoModal=function(i){i.Uploaded=new Date(parseInt(i.Uploaded.replace(/\/Date\((\d+)\)\//gi,"$1")));n.photoInfo=i;t.open({templateUrl:"m-photo-modal.html",windowClass:"m-view-modal",controller:["$scope","photoInfo",function(n,t){n.photoInfo=t}],resolve:{photoInfo:function(){return n.photoInfo}}})}}]);angular.module("leafly.core").controller("ServicesCtrl",["$scope","$auth","$timeout","$http",function(n,t){n.currentTab=1;n.createAccountBeforeSubmit=function(){return n.businessType==="3"?!0:t.authenticate(!0)};n.businessTypeChanged=function(){n.currentTab=n.businessType};n.referralFormValid=!0;n.validateReferralForm=function(){n.referralFormValid=!0;n.source!="Referral"||n.referralEmail||n.referralName&&n.referralPhone||(n.referralFormValid=!1)}}]);angular.module("leafly.core").controller("StorefrontCtrl",["$scope","$http","$filter","$window","$location","$locator","$modal",function(n,t,i,r,u,f,e){n.showPreview=function(){var t=u.$$path,i="//s3.amazonaws.com/leafly-s3"+t;n.previewUrl=t?i:""};n.specialId="";n.sendTextModal=function(t,i){n.specialId=t;n.slug=i;n.modalInstance=e.open({templateUrl:"send-special-to-phone-modal.html",windowClass:"m-view-modal",controller:["$scope","specialId","sendText",function(n,t,i){n.specialId=t;n.sendText=i}],resolve:{specialId:function(){return n.specialId},sendText:function(){return n.sendText}}})};n.loginSuccess=function(){$modalInstance.close()};n.sendText=function(){var i="/dispensary-info/"+n.slug+"/specialssms",r=n.specialId,u=document.getElementsByName("__RequestVerificationToken")[0].value,f=document.getElementsByName("phoneNumber")[0].value;t({method:"POST",url:i,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:"sId="+r+"&phone="+f+"&__RequestVerificationToken="+u}).success(function(){n.modalInstance.close()}).error(function(){n.modalInstance.close()})}}]);angular.module("leafly.core").controller("StrainAvailabilityCtrl",["$scope","$locator","$window",function(n,t,i){var r=t.mostRecent();n.filterItem="All";r&&(n.query=r.locationtext);n.submitLocation=function(r){r.preventDefault();t.locateByAddress(n.query).then(function(r){t.saveLocation(r);i.location.href=n.urlBase+"/"+r.locationtext.encodeLocationLink()})}}]);angular.module("leafly.core").controller("StrainDetailsCtrl",["$rootScope","$scope","$attrs","SponsorService",function(n,t,i,r){function u(){r.getProvidersForStrain(i.strainId).then(function(n){function f(n,t){return Math.floor(Math.random()*t+n)}var i;if(t.totalDispensaries=n.TotalResults,n.Model){var r=n.Model.length,u=[],e=r>2?2:r;for(i=0;i<e;i++)u[i]=n.Model[f(0,r-1)];t.nearbyDispensaries=u}else t.nearbyDispensaries=!1})}n.$on("LocationChanged",u);t.nearbyDispensaries=[];t.date=new Date}]);angular.module("leafly.core").controller("StrainFullReviewCtrl",["$scope","$http","$window",function(n,t,i){function r(n,t){_.each(n,function(n){n.selected=_.find(t,function(t){return n.Id===t})!=null})}function u(n){return _.pluck(_.filter(n,function(n){return n.selected}),"Id")}n.setup=function(t,i){n.reviewId=t.Id;n.rating=t.Rating/2;n.notes=t.Notes;n.isFlower=i!=="Topical"&&i!=="Edible";n.strainForm=t.Form;n.strainConsumption=t.Method;n.dispensary={key:t.StoreUrlName,value:t.StoreName};n.dispensaryName=f=t.StoreName;n.isPrivate=!t.Visible;r(n.effects,t.Tags);r(n.negatives,t.NegativeEffects);r(n.conditions,t.Conditions);r(n.symptoms,t.Symptoms);r(n.flavors,t.Flavors);n.otherEffects=t.CustomTags;n.otherSymptoms=t.CustomSymptoms;n.otherConditions=t.CustomConditions;n.potencies=_.map(t.Potency,function(n,t){return{name:t,value:n}})};n.count=function(n){return _.where(n,{selected:!0}).length};n.addToCollection=function(t,i){n[t].push(i)};n.removeFromCollection=function(t,i){n[t]=_.filter(n[t],function(n){return n!=i})};n.addPotency=function(){var t=_.findWhere(n.potencies,{name:n.potencyType});t||(t={name:n.potencyType},n.potencies.push(t));t.value=n.potencyValue;n.potencyValue=null};var f;n.$watch("dispensaryName",function(){n.dispensaryName&&n.dispensaryName!==f&&(f=n.dispensaryName,n.dispensary=null,t.get("/api2/search/autocomplete?searchType=dispensary&term="+n.dispensaryName).success(function(t){n.dispensaries=t[0].results}))});n.setDispensary=function(t){n.dispensary=t;n.dispensaryName=f=t.text;n.dispensaries=null};n.submitReview=function(){var r={};r.Id=n.reviewId;r.Rating=n.rating;r.Notes=n.notes;n.dispensary&&(r.StoreUrlName=n.dispensary.key);r.Visible=!n.isPrivate;r.Tags=u(n.effects);r.NegativeEffects=u(n.negatives);r.Conditions=u(n.conditions);r.Symptoms=u(n.symptoms);r.Flavors=u(n.flavors);r.CustomConditions=n.otherConditions;r.CustomSymptoms=n.otherSymptoms;r.CustomTags=n.otherEffects;r.Potency=_.object(_.map(n.potencies,_.values));n.isFlower&&(r.Form=n.strainForm,r.Method=n.strainConsumption);t.post(n.postUrl,r).success(function(){i.location.href="/me/reviews/strain"})}}]);angular.module("leafly.core").controller("StrainReviewCtrl",["$scope","$http","$q","$window","ReviewService",function(n,t,i,r){function e(){n.review.Rating=0;n.newItem=!1;n.newItemType=null;n.newStrainType=null}n.searchName=location.hash.substr(location.hash.indexOf("filter=")+7)||"";n.strainSearchResults=[];n.selectedStrain=null;n.review={};var f=null,u;n.searchStrains=function(){if(n.searchName!==f){if(n.searchName.length<=2){f=null;n.strainSearchResults=[];n.selectedStrain=null;e();return}f=n.searchName;u&&u.resolve();u=i.defer();t.get("/api2/search/autocomplete?searchType=strain&size=20&term="+n.searchName,{timeout:u.promise}).success(function(t){if(!t||!t.length){n.strainSearchResults=[];return}n.strainSearchResults=t[0].results;n.selectedStrain=null;n.strainSearchResults.length==0&&(n.selected.strain="")})}};n.$watch("searchName",n.searchStrains);n.selectStrain=function(t){n.selectedStrain=t;e()};n.startReview=function(){if(!n.newItem){r.location.href="/review/"+n.selectedStrain.slug;return}t.post("/review",{name:n.searchName,category:n.newStrainType||n.newItemType}).success(function(n){r.location.href="/review/"+n.UrlName})};n.searchName!==""&&n.searchStrains()}]);angular.module("leafly.core").controller("StrainReviewsCtrl",["$scope","$document","$timeout",function(n,t,i){n.setup=function(t,i){n.queryParameters={q:t,sort:i};n.query=t};n.submitForm=function(){i(function(){t[0].forms.reviewForm.submit()},100)}}])