YUI.add("flickr-braintree-customerDetails-fetcher",function(e,t){"use strict";function r(e){var t={account_id:e.id};return t}function s(t,r,s){var o=t[0],u=t[1],a=t[2],f=t[3],l=t[4],c=t[5],h=t[6],p={},d={},v,m,g,y;o&&o.customerDetails&&(o.customerDetails.braintreePaymentMethods&&(g=o.customerDetails.braintreePaymentMethods),o.customerDetails.paypalPaymentMethods&&(y=o.customerDetails.paypalPaymentMethods)),m=o.customerDetails.subscriptions,v=o.customerDetails.addresses,v&&v instanceof Array&&v.forEach(function(e){var t={};t={firstName:e.firstName,lastName:e.lastName,street1:e.street1,street2:e.street2,city:e.city,state:e.state,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone},l.exists(e.id)?l.setValues(e.id,t):(t.id=e.id,l.add(t))}),g&&g instanceof Array&&(p.cards=g.map(function(t){var n={};return n.type=t.cardType,n.typeString=i[t.cardType]||"",n.last4=t.paymentVendorCreditCardLastFour,n.expirationMonth=t.cardExpireMonth,n.expirationYear=t.cardExpireYear,n.isDefault=e.AttributeHelpers.coerceBoolean(t.isDefault),n.isExpired=e.moment(n.expirationYear+"-"+n.expirationMonth+"-01","YYYY-MM-DD").isBefore(),n.isDefault&&(p.defaultPaymentMethod=t.id),l.exists(t.billingAddressId)&&(n.address=l.proxy(t.billingAddressId)),a.exists(t.id)?(a.setValues(t.id,n),a.proxy(t.id)):(n.id=t.id,a.add(n))})),y&&(p.paypalPaymentMethods=y.map(function(t){var n={};return t.typeString="paypal",t.isDefault=e.AttributeHelpers.coerceBoolean(t.isDefault),t.email=unescape(t.email),t.isDefault&&(p.defaultPaymentMethod=t.id),n.dateCreate=t.dateCreate*1e3,n.dateUpdate=t.dateUpdate*1e3,n.firstName=t.firstName,n.lastName=t.lastName,n.email=t.email,n.isDefault=t.isDefault,n.typeString=t.typeString,f.exists(t.id)?(f.setValues(t.id,n),f.proxy(t.id)):(n.id=t.id,f.add(n))})),m&&m instanceof Array&&(d.subscriptions=m.map(function(t){var r={};t.status=parseInt(t.status,10),t.type=parseInt(t.type,10);if(t.status===2||t.status===7||t.status===12)a.exists(t.paymentMethodId)?(a.setValue(t.paymentMethodId,"subscriptionType",t.type),p.linkedPaymentMethod=t.paymentMethodId):f.exists(t.paymentMethodId)?(f.setValue(t.paymentMethodId,"subscriptionType",t.type),p.linkedPaymentMethod=t.paymentMethodId):n.info("Subscription tied to a payment method that does not exist.");return r.startDate=t.startDate*1e3,r.billingScheduleMonths=t.billingScheduleMonths,r.nextBillingDate=t.nextBillingDate*1e3,r.effectiveEndDate=t.effectiveEndDate*1e3,r.type=t.type,r.paymentMethodId=t.paymentMethodId,r.status=t.status,r.amountBilled=t.amountBilled,r.transactions=t.transactions,r.prettyName=t.planInfo.prettyName,r.prettyNameDuration=t.planInfo.prettyNameDuration,e.Array.each(r.transactions,function(t){t.formattedCreateDate=e.moment(t.dateCreate,"X").format("MMM Do, YYYY"),t.isRefund=!1,parseInt(t.transactionType,10)===3&&(t.isRefund=!0)}),h.exists(t.id)?(h.setValues(t.id,r),h.proxy(t.id)):(r.id=t.id,h.add(r))}),o.customerDetails.paymentHistory&&(d.oneTimePro=o.customerDetails.paymentHistory.proStatus)),c.exists(r.id)?c.setValues(r.id,d):(d.id=r.id,c.add(d)),u.exists(r.id)?u.setValues(r.id,p):(p.id=r.id,u.add(p))}function o(n,r){var i=this,s=this._processParams(n);return e.Promise.all([r.callAPI("flickr.subscriptions.braintree.getCustomerDetails",s,!0),r.getModelRegistry("products-payment-methods-list-models"),r.getModelRegistry("products-credit-card-models"),r.getModelRegistry("products-paypal-payment-models"),r.getModelRegistry("products-address-models"),r.getModelRegistry("subscription-history-list-models"),r.getModelRegistry("subscription-history-models")]).then(function(e){return i._processResponse(e,n,r)},e.PromiseCatcher(t))}var n=require("lib/flog")(t),i={1:"Visa",2:"MasterCard",3:"Discover",4:"AmEx",5:"JCB"};e.namespace("ModelFetchers")["flickr-braintree-customerDetails-fetcher"]={run:o,_processParams:r,_processResponse:s}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["products-payment-methods-list-models","products-credit-card-models","subscription-history-models","subscription-history-list-models","products-address-models"]});
YUI.add("products-payment-methods-list-models",function(e){function t(e){t.superclass.constructor.call(this,e)}e.Models[this.name]=t,e.extend(t,e.FlickrModelRegistry,{name:this.name,remote:{read:function(t){return e.ModelFetchers["flickr-braintree-customerDetails-fetcher"].run(t,this.appContext)},create:function(t){return e.ModelCreators["flickr-braintree-createSubscription-create"].run(t,this.appContext)},update:function(t,n){if("defaultPaymentMethod"in n)return e.ModelUpdaters["flickr-products-braintree-paymentDefault-updater"].run({payment_method_id:n.defaultPaymentMethod.newVal},this.appContext);if("linkedPaymentMethod"in n)return e.ModelUpdaters["flickr-subscriptions-transferSubscriptions-updater"].run({old_payment_method_id:n.linkedPaymentMethod.prevVal,new_payment_method_id:n.linkedPaymentMethod.newVal},this.appContext)}},attributes:{cards:{isListProxy:!0},paypalPaymentMethods:{isListProxy:!0},defaultPaymentMethod:{validator:function(t,n){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)||undefined},defaultFn:function(e){return""}},linkedPaymentMethod:{validator:function(t,n){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)||undefined},defaultFn:function(e){return"1"}}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-promise","flickr-braintree-customerDetails-fetcher","flickr-braintree-createSubscription-creator","flickr-subscriptions-transferSubscriptions-updater","flickr-products-braintree-paymentDefault-updater"]});
YUI.add("account-menu-view",function(e,t){"use strict";var n=require("lib/flog")(t);e.namespace("Views")[this.name]=e.Base.create("account-menu-view",e.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(e){return this},loadState:function(){var t=this,n=[],r=this.appContext.getViewer();return r.signedIn?(t.set("user",{signedIn:!0,csrf:this.appContext.auth.csrf?this.appContext.auth.csrf:""}),n.push(this.appContext.getModel("person-models",r.nsid).then(function(n){var r=n.toJSON();Object.keys(r.buddyicon||{}).forEach(function(e){r.buddyicon[e]||(r.buddyicon[e]=r.buddyicon["default"])}),t.set("user",e.merge(t.get("user"),r))})),n.push(t.appContext.getModel("person-profile-models",r.nsid).then(function(n){var r=n.toJSON();r.unreadMessages=parseInt(r.unreadMessages,10),r.storageUsed=parseInt(r.storageUsed,10),t.get("user").isPro&&!t.appContext.flipper.isFlipped("enable-new-pro")?t.get("user").hasAdfree||t.get("user").has1TB||t.get("user").has2TB?r.storageTotal=parseInt(r.storageTotal,10):r.storageTotal=-1:r.storageTotal=parseInt(r.storageTotal,10),t.set("user",e.merge(t.get("user"),r))})),e.Promise.all(n)):(t.set("user",{signedIn:!1}),e.Promise.resolve())},buildContainer:function(){return this.setContainerWithTemplate("account-menu",this.toJSON()),this},toJSON:function(){var t=e.merge(this.get("user")),n=this.appContext.lang;return parseInt(t.photoCount,10)>1?t.pluralPhotos=!0:t.pluralPhotos=!1,parseInt(t.photoCount,10)<1&&(t.photoCount=!1),t.photoCount>1e3&&(t.photoCount=Math.round(t.photoCount/1e3),t.oneK=!0),this.appContext.flipper.isFlipped("enable-new-pro")?t.hasUnlimitedStorage?t.storageTotalFormatted="":t.has1TB?t.storageTotalFormatted="1TB":t.has2TB?t.storageTotalFormatted="2TB":t.storageTotalFormatted=t.storageTotal<0?"":e.Handlebars.helpers.friendlyDataSize(t.storageTotal):t.storageTotalFormatted=t.storageTotal<0?"":e.Handlebars.helpers.friendlyDataSize(t.storageTotal),n==="zh-Hant-HK"&&(n="zh-HK"),n.toLowerCase()==="vi-vn"&&(n="vn-VN"),t.storageUsedPercentage=Math.floor(1e3*t.storageUsed/t.storageTotal)/10||"0.0",t.storageUsedFormatted=e.Handlebars.helpers.friendlyDataSize(t.storageUsed),t.barWidth=Math.floor(293*(t.storageUsedPercentage/100)),t.unreadMessages=t.unreadMessages>9999?"9999+":t.unreadMessages,{user:t,helpLocaleKey:n.replace("-","_")||"en_US",flippers:this.appContext.flipper.toJSON()}},activate:function(){setTimeout(function(){this.get("container").on("click",function(e){this.openMenu(e)},this)}.bind(this),350)},openMenu:function(t){var n=this.get("container"),r,i=this,s;return t.preventDefault(),this.fire("open"),this.accountMenuDialog||(this.appContext.flipper.isFlipped("enable-hover-account-menu")&&this.appContext.flipper.isFlipped("rebootify-group-discussions-list")?(r=this.templates("account-menu-card"),this.accountMenuDialog=new e.Views.FluidDroparound({appContext:this.appContext,dismissOnOverlayClick:!0,showDropArrow:!0,showOverlay:!1,width:322,height:"auto",anchorOffsetHorizontal:5,observePageResize:!0,anchorElement:n.one(".c-account-menu"),htmlMessage:r({attrs:this.toJSON()}),positionFixed:!0})):r=this.templates("account-menu-dialog-styleguide"),this.accountMenuDialog||(this.accountMenuDialog=e.Views.dialog.getNewInstance("dialog-tooltip",{id:"AccountMenuDialog",positioning:!1,arrow:"topright",attrs:this.toJSON(),content:r,parent:this,anchorTo:n.one(".c-account-menu"),appendCurtainTo:n.ancestor(".global-nav-content")}),s=function(){i.accountMenuDialog.get("curtain").on("click",function(){i.closeMenu.bind(i)}),this.appContext.flipper.isFlipped("enable-new-pro")&&this.showGetProButton()},this.accountMenuDialog.on("show",function(){setTimeout(s,100)})),this.appContext.flipper.isFlipped("enable-new-pro")&&this.showGetProButton()),this.accountMenuDialog.show(),this.appContext.flipper.isFlipped("enable-new-pro")&&this.on("open",this.showGetProButton),this},closeMenu:function(e){e&&e.preventDefault(),this.accountMenuDialog&&this.accountMenuDialog.hide()},showGetProButton:function(){var t=!1,r=!1,i=[],s=this.appContext.getViewer();i.push(this.appContext.getModel("subscription-info-models",s.nsid).then(function(e){e.getValue("products").forEach(function(e){if(e.canPurchase){t=!0;return}}),!t&&this.accountMenuDialog.get("container").one(".upgrade")&&this.accountMenuDialog.get("container").one(".upgrade").remove(!0)}.bind(this))),i.push(this.appContext.getModel("subscription-history-list-models",s.nsid).then(function(e){e.getValue("subscriptions")&&(e.getValue("subscriptions").toJSON().forEach(function(e){if(e.effectiveEndDate||e.nextBillingDate)if(e.status===3||e.status===12){r=!0;return}}),this.get("user").hasUnlimitedStorage&&(r=!0))}.bind(this))),e.Promise.all(i).then(function(){var e=this.templates("account-menu-card-get-pro-button")({canPurchase:r?!1:t,canResubscribe:r});this.accountMenuDialog.get("container").one(".upgrade").replace(e),this.accountMenuDialog.get("container").one(".content").setStyles({height:"auto"})}.bind(this),function(e){n.warn("Error fetching model.",{err:e})})},destructor:function(){this.accountMenuDialog&&(this.accountMenuDialog.destroy(),this.accountMenuDialog=null)}})},"@VERSION@",{requires:["flickr-view","account-menu-css","flickrui-css","dialog","account-menu-card-css","hermes-template-account-menu","hermes-template-account-menu-dialog","hermes-template-account-menu-dialog-styleguide","hermes-template-account-menu-card","hermes-template-account-menu-card-get-pro-button","fluid-droparound-view","subscription-history-list-models"],optional:["person-models","person-profile-models"],langBundles:["account-menu","common"]});
YUI.add("hermes-lang-account-menu",function(e,t){e.Intl.add("hermes/account-menu","en-US",{SPACE_USED:["Using ","${percentage}","% of ","${total}"],SPACE_USED_STYLEGUIDE:["${percentage}","% used of ","${total}"],SPACE_USED_UNLIMITED:["Using ","${used}"," of your unlimited storage"],PHOTO_COUNT_MANY:[{type:"number",valueName:"num"}," photos"],PHOTO_COUNT_ONE:["One photo"],PHOTO_COUNT_NONE:["No photos"],PHOTO_COUNT_1K:[{type:"number",valueName:"num"},"k photos"],ADDMORESPACE:["Add more space"],GOADFREE:["Go Ad Free"],GOPRO:["Go Pro"],GETPRO:["Get Pro"],RESUBSCRIBE_TO_PRO:["Re-subscribe to Pro"],GREETING_CAPTION_SPANISH:["Now you know how to greet people in Spanish"],GREETING_CAPTION_GERMAN:["Now you know how to greet people in German"],GREETING_CAPTION_AUSTRALIAN:["Now you know how to greet people in Australian"],GREETING_CAPTION_DUTCH:["Now you know how to greet people in Dutch"],GREETING_CAPTION_ENGLISH:["Now you know how to greet people in English"],GREETING_CAPTION_ARABIC:["Now you know how to greet people in Arabic"],GREETING_CAPTION_FRENCH:["Now you know how to greet people in French"],GREETING_CAPTION_ITALIAN:["Now you know how to greet people in Italian"],GREETING_CAPTION_SWEDISH:["Now you know how to greet people in Swedish"],GREETING_CAPTION_HAWAIIAN:["Now you know how to greet people in Hawaiian"],GREETING_CAPTION_TAGALOG:["Now you know how to greet people in Tagalog"],GREETING_CAPTION_HEBREW:["Now you know how to greet people in Hebrew"],GREETING_CAPTION_HINDI:["Now you know how to greet people in Hindi"],GREETING_CAPTION_MANDARIN:["Now you know how to greet people in Mandarin"],GREETING_CAPTION_PORTUGUESE:["Now you know how to greet people in Portuguese"],GREETING_CAPTION_ALBANIAN:["Now you know how to greet people in Albanian"],GREETING_CAPTION_ESTONIAN:["Now you know how to greet people in Estonian"],GREETING_CAPTION_GREEK:["Now you know how to greet people in Greek"],GREETING_CAPTION_HUNGARIAN:["Now you know how to greet people in Hungarian"],GREETING_CAPTION_LINGALA:["Now you know how to greet people in Lingala"],GREETING_CAPTION_SWAHILI:["Now you know how to greet people in Swahili"],GREETING_CAPTION_TSHILUBA:["Now you know how to greet people in Tshiluba"],GREETING_CAPTION_TURKISH:["Now you know how to greet people in Turkish"],GREETING_CAPTION_BURMESE:["Now you know how to greet people in Burmese"],GREETING_CAPTION_ICELANDIC:["Now you know how to greet people in Icelandic"],GREETING_CAPTION_ZULU:["Now you know how to greet people in Zulu"],GREETING_CAPTION_KOREAN:["Now you know how to greet people in Korean"],GREETING_CAPTION_IRISH:["Now you know how to greet people in Irish"],GREETING_CAPTION_LATVIAN:["Now you know how to greet people in Latvian"],GREETING_CAPTION_BASQUE:["Now you know how to greet people in Basque"],GREETING_CAPTION_BENGALI:["Now you know how to greet people in Bengali"],GREETING_CAPTION_BULGARIAN:["Now you know how to greet people in Bulgarian"],GREETING_CAPTION_CROATIAN:["Now you know how to greet people in Croatian"],GREETING_CAPTION_CZECH:["Now you know how to greet people in Czech"],GREETING_CAPTION_DANISH:["Now you know how to greet people in Danish"],GREETING_CAPTION_FINNISH:["Now you know how to greet people in Finnish"],GREETING_CAPTION_HOPI:["Now you know how to greet people in Hopi"],GREETING_CAPTION_INDONESIAN:["Now you know how to greet people in Indonesian"],GREETING_CAPTION_KANNADA:["Now you know how to greet people in Kannada"],GREETING_CAPTION_KURDISH:["Now you know how to greet people in Kurdish"],GREETING_CAPTION_LITHUANIAN:["Now you know how to greet people in Lithuanian"],GREETING_CAPTION_MALAYSIAN:["Now you know how to greet people in Malaysian"],GREETING_CAPTION_NORWEGIAN:["Now you know how to greet people in Norwegian"],GREETING_CAPTION_POLISH:["Now you know how to greet people in Polish"],GREETING_CAPTION_ROMANIAN:["Now you know how to greet people in Romanian"],GREETING_CAPTION_RUSSIAN:["Now you know how to greet people in Russian"],GREETING_CAPTION_SERBIAN:["Now you know how to greet people in Serbian"],GREETING_CAPTION_SLOVAKIAN:["Now you know how to greet people in Slovakian"],GREETING_CAPTION_UKRAINIAN:["Now you know how to greet people in Ukrainian"],GREETING_CAPTION_VIETNAMESE:["Now you know how to greet people in Vietnamese"]})},"@VERSION@",{requires:["intl"]});