YUI.add("standard-comment-list-view",(function(e,t){require("hermes-core/flog")(t);e.namespace("Views")[this.name]=e.Base.create(this.name,e.Views["comment-list-view"],[],{langBundles:this.details.langBundles,initializer:function(e){this.constructor.superclass.initializer.call(this,e)},buildContainer:function(){this.setContainerWithTemplate("standard-comment-list-view",this.params)},activate:function(){var e=this.get("container");this.listContainerNode=e.one(".comment-list-container"),this.loadMoreButton=e.one(".load-more-button"),this.registerEventHandler(this.loadMoreButton.on("click",this.handleLoadMoreClick.bind(this))),this.constructor.superclass.activate.call(this)},setLoading:function(e){this.isLoading=e,this.listContainerNode.toggleClass("loading",e)},handleLoadCommentsComplete:function(){this.listContainerNode.removeClass("loading")},showCommentLoading:function(e){e?this.showBalls(!1):this.hideBalls()},showCommentAddLoading:function(e){e?this.showBalls(!0):this.hideBalls()},updateComments:function(t){return t?(this.updateLoadButton(),this.prependComments(t)):e.Promise.resolve()},prependComments:function(t){var i=[],o=[];return t.forEach((t=>{var n={appContext:this.appContext,comment:t.toJSON(),commentsViewHelper:this.commentsViewHelper},s=new e.Views["comment-item-view"](n),a=s.initialize(n).then((function(){s.activate()}));o.push(s),i.push(a)})),e.Promise.all(i).then((()=>{this.prependCommentViewsToDom(o)}))},prependCommentViewsToDom:function(t){var i,o=this;t.forEach((function(t){(i=e.Node.create('<li class="comment-list-item"></li>')).append(t.get("container")),o.commentsListNode.prepend(i)})),this.commentsViewHelper.commentsObj.flimojiParser.emojifyTarget({inputElements:["["+e.config.flickr.emojis.parserAttr+"]"],useSprites:!1,iconsPath:e.config.flickr.urls.assetRoot+"/images/joypixels",container:this.get("container").getDOMNode()})},handleLoadMoreClick:function(){var e=this;this.config.loadMoreOpensModal&&this.config.showCommentsModal?this.config.showCommentsModal():this.isFetchingComments||this.getMoreComments().then((function(){e.updateLoadButton()}))},updateLoadButton:function(){var e;e=this.commentsViewHelper.getLoadButtonMessage(),this.loadMoreButton.toggleClass("hidden",!!this.commentsViewHelper.commentsObj.endOfComments),this.loadMoreButton.set("text",e)}})}),"@VERSION@",{requires:["flickr-view","comment-list-view","hermes-template-standard-comment-list-view"],optionalRequires:["hermes-core"],langBundles:["common","comments","photo-page-scrappy"]});YUI.add("hermes-template-photo-comments-view",(function(e,n){var l=e.Template.Handlebars.revive({1:function(e,n,l,t,o){return" scrollable"},3:function(e,n,l,t,o){var a=null!=n?n:e.nullContext||{},r=e.hooks.helperMissing,s=e.escapeExpression,i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return'\t\t<header class="comments-header">\n\t\t\t<h1>'+s((i(l,"intlMessage")||n&&i(n,"intlMessage")||r).call(a,{name:"intlMessage",hash:{intlName:"stats.COMMENTS"},data:o,loc:{start:{line:6,column:7},end:{line:6,column:48}}}))+' (<span class="comments-header-count">'+s((i(l,"intlNumber")||n&&i(n,"intlNumber")||r).call(a,null!=n?i(n,"totalCount"):n,{name:"intlNumber",hash:{},data:o,loc:{start:{line:6,column:86},end:{line:6,column:111}}}))+'</span>)</h1>\n\t\t\t<svg class="close-x-button"><use xlink:href="#icon-close"></use></svg>\n\t\t</header>\n'},5:function(e,n,l,t,o){return" standard"},7:function(e,n,l,t,o){var a=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return"\t\t\t"+e.escapeExpression((a(l,"outlet")||n&&a(n,"outlet")||e.hooks.helperMissing).call(null!=n?n:e.nullContext||{},null!=n?a(n,"scrollable-comment-list-view"):n,{name:"outlet",hash:{},data:o,loc:{start:{line:13,column:3},end:{line:13,column:42}}}))+"\n"},9:function(e,n,l,t,o){var a=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return"\t\t\t"+e.escapeExpression((a(l,"outlet")||n&&a(n,"outlet")||e.hooks.helperMissing).call(null!=n?n:e.nullContext||{},null!=n?a(n,"standard-comment-list-view"):n,{name:"outlet",hash:{},data:o,loc:{start:{line:15,column:3},end:{line:15,column:40}}}))+"\n"},compiler:[8,">= 4.3.0"],main:function(e,n,l,t,o){var a,r=null!=n?n:e.nullContext||{},s=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return'<div class="photo-comments with-emoji-picker\n\t'+(null!=(a=s(l,"if").call(r,null!=n?s(n,"isScrollable"):n,{name:"if",hash:{},fn:e.program(1,o,0),inverse:e.noop,data:o,loc:{start:{line:2,column:1},end:{line:2,column:39}}}))?a:"")+'">\n\n'+(null!=(a=s(l,"if").call(r,null!=n?s(n,"hasHeader"):n,{name:"if",hash:{},fn:e.program(3,o,0),inverse:e.noop,data:o,loc:{start:{line:4,column:1},end:{line:9,column:8}}}))?a:"")+'\n\t<section class="comments-list-section'+(null!=(a=s(l,"if").call(r,null!=n?s(n,"isScrollable"):n,{name:"if",hash:{},fn:e.program(1,o,0),inverse:e.program(5,o,0),data:o,loc:{start:{line:11,column:38},end:{line:11,column:93}}}))?a:"")+'">\n'+(null!=(a=s(l,"if").call(r,null!=n?s(n,"isScrollable"):n,{name:"if",hash:{},fn:e.program(7,o,0),inverse:e.program(9,o,0),data:o,loc:{start:{line:12,column:2},end:{line:16,column:9}}}))?a:"")+'\t</section>\n\n\t<section class="add-comment-section">\n\t\t'+e.escapeExpression((s(l,"outlet")||n&&s(n,"outlet")||e.hooks.helperMissing).call(r,null!=n?s(n,"add-comment-view"):n,{name:"outlet",hash:{},data:o,loc:{start:{line:20,column:2},end:{line:20,column:29}}}))+"\n\t</section>\n</div>\n"},useData:!0}),t={};e.Array.each([],(function(n){var l=e.Template.get("hermes/"+n);l&&(t[n]=l)})),e.Template.register("hermes/photo-comments-view",(function(n,o){return(o=o||{}).partials=o.partials?e.merge(t,o.partials):t,l(n,o)}))}),"@VERSION@",{requires:["template-base","handlebars-base"]});YUI.add("hermes-template-comment-edit",(function(e,t){var n=e.Template.Handlebars.revive({compiler:[8,">= 4.3.0"],main:function(e,t,n,a,l){var r,o=null!=t?t:e.nullContext||{},i=e.hooks.helperMissing,c=e.escapeExpression,s=e.lookupProperty||function(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return e[t]};return'<div class="comment-edit">\n\t<div class="text-area-wrapper">\n\t\t<textarea class="edit-field">'+c("function"==typeof(r=null!=(r=s(n,"content")||(null!=t?s(t,"content"):t))?r:i)?r.call(o,{name:"content",hash:{},data:l,loc:{start:{line:3,column:31},end:{line:3,column:42}}}):r)+"</textarea>\n\t\t"+c((s(n,"outlet")||t&&s(t,"outlet")||i).call(o,null!=t?s(t,"emoji-picker-view"):t,{name:"outlet",hash:{},data:l,loc:{start:{line:4,column:2},end:{line:4,column:30}}}))+"\n\t</div>\n\t"+c((s(n,"outlet")||t&&s(t,"outlet")||i).call(o,null!=t?s(t,"basic-confirm-actions-view"):t,{name:"outlet",hash:{},data:l,loc:{start:{line:6,column:1},end:{line:6,column:38}}}))+"\n</div>\n"},useData:!0}),a={};e.Array.each([],(function(t){var n=e.Template.get("hermes/"+t);n&&(a[t]=n)})),e.Template.register("hermes/comment-edit",(function(t,l){return(l=l||{}).partials=l.partials?e.merge(a,l.partials):a,n(t,l)}))}),"@VERSION@",{requires:["template-base","handlebars-base"]});YUI.add("comments-view-helper",(function(e,t){require("hermes-core/flog")(t);var n=e.mix({langBundles:["common","comments","photo-page-scrappy"]},e.Localizable);e.CommentsViewHelper=function(t,o){var i=o,s=o.commentListConfig,r=(o.addCommentConfig,{commentsObj:new{photo:function(){return{load:function(){var n,o=this,r=/#comment/g;YUI.Env.isServer||(n=e.config.win.location.hash),this.renderedCommentModels=[],this.commentingEnabled=!0,this.perPage=s.modelConfig.perPage,this.firstPerPage=s.modelConfig.firstPerPage,this.permalinkHash=n;var m=[t.getModelRegistry(s.modelConfig.commentModelRegistryName).then((function(e){o.commentModelRegistry=e})),t.getModel("photo-engagement-models",i.photoId).then(function(e){o.engagementModel=e,n&&r.test(n)&&(o.perPage=this.engagementModel.getValue("commentCount"),o.firstPerPage=this.engagementModel.getValue("commentCount"))}.bind(this)),t.getModel("photo-models",{id:i.photoId}).then((function(e){o.photoModel=e,o.commentingEnabled=!t.getViewer().signedIn||o.photoModel.getValue("canComment")}))];if(t.getViewer().signedIn&&m.push(t.getModel("person-models",{id:t.getViewer().nsid}).then((function(e){o.userModel=e}))),!this.flimojis){var l=require("@flickr/flimojis");this.flimojiParser=new l.EmojiParser}return e.Promise.all(m)},loadComments:function(){var n=this,o=[];return o.push(t.getModel(s.modelConfig.listRegistryName,{id:s.modelConfig.modelId}).then((function(e){n.listModel=e}))),o.push(t.getModel("photo-models",s.modelConfig.modelId).then((function(e){n.isSubjectOwner=t.getViewer().nsid===e.getValue("owner").getValue("nsid")}))),o.push(t.getModel("photo-engagement-models",i.photoId).then((function(e){n.engagementModel=e}))),e.Promise.all(o)},getLoadButtonMessage:function(){var e=this.calculateRemainingCount();return n.intlMessage({intlName:"photo-page-scrappy.VIEW_MORE_PREVIOUS_COMMENTS",count:e})},calculateRemainingCount:function(){this.listModel.getValue(s.modelConfig.collectionName);var e=this.getTotalCount(),t=this.renderedCommentModels.length||0;return e>t+s.modelConfig.perPage?s.modelConfig.perPage:e<=t+s.modelConfig.perPage?e-t:0},getTotalCount:function(){return this.engagementModel.getValue("commentCount")||0},getPlaceholderMessage:function(){return n.intlMessage({intlName:"comments.ADD_PHOTO_COMMENT",mediaType:this.photoModel.getValue("mediaType")})},deleteComment:function(e){return this.commentModelRegistry.remoteDelete(e)},updateComment:function(e,t){var n=this;return this.commentModelRegistry.get(e).then((function(o){return o.setValue("content",t),n.commentModelRegistry.remoteUpdate(e)}))},addComment:function(e){return this.commentModelRegistry.remoteCreate({photoId:i.photoId,commentText:e})},getMoreComments:function(){var t=this,n=this.isFirstPageRendered?this.perPage:this.firstPerPage,o=this.renderedCommentModels.length,i=this.renderedCommentModels.length,r=t.listModel.getValue(s.modelConfig.collectionName).getList(),m=[],l=this.engagementModel.getValue("commentCount");if(0===this.engagementModel.getValue("commentCount"))return this.endOfComments=!0,e.Promise.resolve();if(r.length>=o+n||r.length>=l){for(var d=o;d<o+n;d++)r[d]&&(m.push(r[d]),this.renderedCommentModels.push(r[d]));return this.isFirstPageRendered=!0,o+m.length>=l&&(this.endOfComments=!0),e.Promise.resolve(m)}let a={offset:i,limit:n};return s.useInitialCache&&!this.didFirstLoad||(a.shouldBustCache=!0),this.listModel.getValue(s.modelConfig.collectionName).getRange(a).then((e=>((e.length<n||this.listModel.getValue(s.modelConfig.collectionName).getList().length>=t.engagementModel.getValue("commentCount"))&&(this.endOfComments=!0),e.forEach((e=>{this.renderedCommentModels.push(e)})),this.isFirstPageRendered=!0,this.didFirstLoad=!0,e)))},reset:function(){this.renderedCommentModels=[],this.isFirstPageRendered=!1,this.endOfComments=!1;var e=this.listModel.getValue(s.modelConfig.collectionName);e.getList().forEach((function(t){e.removeFromList(t.id)}))}}},gallery:function(){return{load:function(){var n=this;this.renderedCommentModels=[],this.commentingEnabled=!0;var o=[t.getModelRegistry(s.modelConfig.commentModelRegistryName).then((function(e){n.commentModelRegistry=e})),t.getModel("gallery-info-models",{id:i.galleryId}).then((function(e){n.galleryInfoModel=e}))];if(t.getViewer().signedIn&&o.push(t.getModel("person-models",{id:t.getViewer().nsid}).then((function(e){n.userModel=e}))),!this.flimojis){var r=require("@flickr/flimojis");this.flimojiParser=new r.EmojiParser}return e.Promise.all(o)},loadComments:function(){var e=this;return t.getModel(s.modelConfig.listRegistryName,{id:s.modelConfig.modelId}).then((function(n){return e.listModel=n,e.isSubjectOwner=t.getViewer().signedIn&&t.getViewer().nsid===n.getValue("owner").getValue("nsid"),n}))},getLoadButtonMessage:function(){var e=this.calculateRemainingCount();return n.intlMessage({intlName:"photo-page-scrappy.VIEW_MORE_PREVIOUS_COMMENTS",count:e})},calculateRemainingCount:function(){var e=this.getTotalCount(),t=this.renderedCommentModels.length||0,n=e>t?e-t:0;return n>s.modelConfig.perPage?s.modelConfig.perPage:n},getTotalCount:function(){return this.galleryInfoModel.getValue("commentCount")||0},getPlaceholderMessage:function(){return n.intlMessage({intlName:"comments.ADD_GALLERY_COMMENT"})},deleteComment:function(e){return this.commentModelRegistry.deleteRemote(e)},updateComment:function(e,t){return this.commentModelRegistry.updateRemote(e,t)},addComment:function(e){return this.commentModelRegistry.remoteCreate({galleryId:this.listModel.getValue("id"),galleryOwnerId:this.listModel.getValue("owner").getValue("id"),commentText:e,authorId:this.userModel.getValue("id")})},getMoreComments:function(){var t=this,n=this.isFirstPageRendered?s.modelConfig.perPage:s.modelConfig.firstPerPage,o=this.listModel.getValue(s.modelConfig.collectionName),i=o.getList(),r=this.renderedCommentModels.length,m=[];if(i.length>=r+n||i.length>=o.totalItems){for(var l=r;l<r+n;l++)i[l]&&(m.push(i[l]),this.renderedCommentModels.push(i[l]));return this.isFirstPageRendered=!0,r+m.length>=o.totalItems&&(this.endOfComments=!0),e.Promise.resolve(m)}return this.listModel.getCommentsByContinuation(n).then((function(e){return"-1"===t.listModel.getValue(s.modelConfig.listRegistryContinuationName)&&(t.endOfComments=!0),e.forEach((function(e){t.renderedCommentModels.push(e)})),t.isFirstPageRendered=!0,e}))},reset:function(){this.renderedCommentModels=[],this.isFirstPageRendered=!1,this.endOfComments=!1;var e=this.listModel.getValue(s.modelConfig.collectionName);e.getList().forEach((function(t){e.remove(t.id)})),this.listModel.setValue(s.modelConfig.listRegistryContinuationName,"0")}}}}[i.type],config:i,loadPromise:void 0,load:function(){return this.loadPromise||(this.loadPromise=this.commentsObj.load()),this.loadPromise},loadComments:function(){return this.commentsObj.loadComments()},addComment:function(e){return this.commentsObj.addComment(e)},deleteComment:function(e){return this.commentsObj.deleteComment(e)},updateComment:function(e,t){return this.commentsObj.updateComment(e,t)},getLoadButtonMessage:function(){return this.commentsObj.getLoadButtonMessage()},getTotalCount:function(){return this.commentsObj.getTotalCount()},getPlaceholderMessage:function(){return this.commentsObj.getAddPlaceholderMessage()},getMoreComments:function(){return this.commentsObj.getMoreComments()},reset:function(){return this.commentsObj.reset()}});return e.augment(r,e.EventTarget),r}}),"@VERSION@",{requires:["event-custom"],optionalRequires:["flimojis","hermes-core"],langBundles:["common","comments","photo-page-scrappy"]});YUI.add("photo-comments-view",(function(e,t){require("hermes-core/flog")(t);e.namespace("Views")[this.name]=e.Base.create(this.name,e.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(t){var o;YUI.Env.isServer||(o=e.config.win.location.hash),this.params=t,this.config=this.params||{},this.signedIn=this.appContext.getViewer().signedIn,this.commentsViewHelper=new e.CommentsViewHelper(this.appContext,{photoId:this.config.photoId,type:"photo",commentListConfig:{type:"photo",isScrollable:this.config.isScrollable,showPermalinks:this.config.showPermalinks,loadMoreOpensModal:this.config.loadMoreOpensModal,useInitialCache:this.config.useInitialCache,showCommentsModal:this.showCommentsModal.bind(this),modelConfig:{listRegistryName:"photo-comments-models",modelId:this.config.photoId,collectionName:"comments",commentModelRegistryName:"comment-models",perPage:this.config.perPage||200,firstPerPage:this.config.firstPerPage||16,loadAllInitially:o&&/#comment/g.test(o)}},addCommentConfig:{type:"photo",addCommentText:this.config.addCommentText,alwaysExpanded:this.config.alwaysExpanded,focusWithShortcut:this.config.focusWithShortcut,modelConfig:{commentModelRegistryName:"comment-models"}}}),this.params.commentListConfig=Object.assign({commentsViewHelper:this.commentsViewHelper},this.commentsViewHelper.config.commentListConfig),this.params.addCommentConfig=Object.assign({commentsViewHelper:this.commentsViewHelper},this.commentsViewHelper.config.addCommentConfig),this.params.mentionsApiConfig={type:"photos",params:{photo_id:null}}},subviewConfig:{"scrollable-comment-list-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!1},"standard-comment-list-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!1},"add-comment-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!1}},loadState:function(){return this.commentsViewHelper.load()},buildContainer:function(){this.setContainerWithTemplate("photo-comments-view",{user:this.signedIn?this.commentsViewHelper.commentsObj.userModel.toJSON():null,signedIn:this.signedIn,isScrollable:this.config.isScrollable,hasHeader:this.config.hasHeader,totalCount:this.commentsViewHelper.getTotalCount()})},activate:function(){var e=this,t=this.get("container");return this.config.isScrollable?this.commentListView=this.subviews["scrollable-comment-list-view"]:this.commentListView=this.subviews["standard-comment-list-view"],this.addCommentView=this.subviews["add-comment-view"],this.closeXButton=t.one(".close-x-button"),this.closeXButton&&this.registerEventHandler(this.closeXButton.on("click",(function(){e.fire("readyToClose")}))),this},updateHeaderCount:function(){var e=this.get("container").one(".comments-header-count");e&&e.set("innerText",this.commentsViewHelper.commentsObj.engagementModel.getValue("commentCount"))},onSubviewEvent:function(e,t){var o;if(t&&t[0])switch((o=t[0]).eventName){case"replyClicked":this.addCommentView.addReplyMessage(o.pathAliasOrNSID,!1);break;case"emptyCommentContainer":this.addCommentView.focusCommentBox();break;case"commentAddLoading":this.commentListView.showCommentAddLoading(o.isLoading);break;case"commentAdded":this.commentListView.appendNewComment(o.commentModel),this.commentsViewHelper.commentsObj.listModel.getValue(this.params.commentListConfig.modelConfig.collectionName).prependToList(o.commentModel),this.commentsViewHelper.commentsObj.engagementModel.setValue("commentCount",this.commentsViewHelper.commentsObj.engagementModel.getValue("commentCount")+1),this.updateHeaderCount();break;case"commentDeleted":this.commentsViewHelper.commentsObj.listModel.getValue(this.params.commentListConfig.modelConfig.collectionName).removeFromList(o.commentModelId),this.commentsViewHelper.commentsObj.engagementModel.setValue("commentCount",this.commentsViewHelper.commentsObj.engagementModel.getValue("commentCount")-1),this.updateHeaderCount()}},resetComments:function(){return this.commentListView.resetComments()},showCommentsModal:function(){var t,o=new e.Views["photo-comments-view"]({appContext:this.appContext,photoId:this.commentsViewHelper.commentsObj.photoModel.id,isScrollable:!0,addCommentText:this.intlMessage({intlName:"comments.ADD_PHOTO_COMMENT",mediaType:this.commentsViewHelper.commentsObj.photoModel.getValue("mediaType")})});t=new e.Views.FluidModal({appContext:this.appContext,focusOnFirstTabPress:!1,height:550,autoSizeToContent:!0,subview:o,flexLayout:!0,hasSubviewConfigRefactor:!0}),this.registerEventHandler(t.on("close",(()=>{e.fire("photoCommentModalClosed",{photoId:this.commentsViewHelper.commentsObj.photoModel.id})}))),this.registerEventHandler(e.on("addComment:showingSignupModal",(function(){t.close()}))),t.show()}})}),"@VERSION@",{requires:["flickr-view","comment-item-view","add-comment-view","scrollable-comment-list-view","standard-comment-list-view","hermes-template-photo-comments-view","hermes-template-comment-edit","comments-view-helper"],optionalRequires:["hermes-core"],langBundles:["gallery","stats","comments","common"]});YUI.add("photo-card-helper",(function(e,t){e.mix({langBundles:["common","feed","feed-new"]},e.Localizable);var a=require("justified-layout");e.PhotoCardHelper=function(t){var o={layoutValues:{large:{BATCH_CARD_SPACING:4,BATCH_TARGET_ROW_HEIGHT:150,BATCH_TARGET_ROW_HEIGHT_TOLERANCE:.3,BATCH_ROW_HEIGHT_RATIO:.5},medium:{BATCH_CARD_SPACING:4,BATCH_TARGET_ROW_HEIGHT_TOLERANCE:.3},compact:{BATCH_CARD_SPACING:8,BATCH_TARGET_ROW_HEIGHT:180,BATCH_TARGET_ROW_HEIGHT_TOLERANCE:.3,SINGLE_PHOTO_HEIGHT:250}},ATTRIBUTION_HEADER_HEIGHT:58,DETAILS_FOOTER_HEIGHT:70,INFO_BAR_HEIGHT:52,MAX_PHOTO_AR:2.5,MIN_PHOTO_AR:.5,MANUAL_PORTRAIT_AR:.75,MANUAL_LANDSCAPE_AR:2,getCappedPhotoHeight:function(e){e.height;return Math.min(e.height,Math.max(t.viewportData.getHeight()*e.viewportProportion-e.additionalCardHeight,e.minHeight))},getClampedPhotoAspectRatio:function(e){return Math.min(Math.max(e,this.MIN_PHOTO_AR),this.MAX_PHOTO_AR)},generateCompactBatchLayout:function(e){var t,o,i=this,n=1===e.photoItems.length?this.layoutValues.compact.SINGLE_PHOTO_HEIGHT:this.layoutValues.compact.BATCH_TARGET_ROW_HEIGHT;t=e.photoItems.map((function(e){return i.getClampedPhotoAspectRatio(e.aspectRatio)})),(o=a(t,{containerWidth:e.width,containerPadding:0,boxSpacing:{horizontal:this.layoutValues.compact.BATCH_CARD_SPACING,vertical:this.layoutValues.compact.BATCH_CARD_SPACING},targetRowHeight:n,targetRowHeightTolerance:this.layoutValues.compact.BATCH_TARGET_ROW_HEIGHT_TOLERANCE})).width=e.width;var u=o.boxes[0].top,l=[0],s=0;return o.boxes.some((function(e,t){if(e.top>u){if(s+=o.boxes[l[l.length-1]].height+i.layoutValues.compact.BATCH_CARD_SPACING,l.push(t),l.length>3)return!0;u=e.top}})),l.length>3&&(o.boxes=o.boxes.slice(0,l[l.length-1]),o.containerHeight=s),o},generateThreeMaxLayout:function(e){var a=this,o={},i=[],n=[],u=e.photoItems.length;return 2===(n=(n=e.photoItems.map((function(e){return a.getClampedPhotoAspectRatio(e.aspectRatio)}))).slice(0,3)).length?n[0]>1&&n[1]>1?(i.push(n.slice(0,1)),i.push(n.slice(1,2)),o=this.buildCustomRowsLayout(i,e)):(i.push(n.slice(0,2)),o=this.buildCustomRowsLayout(i,e)):3===n.length&&(n[0]>1&&n[1]>1&&n[2]>1||n[0]>1&&n[1]>1&&n[2]<=1||n[0]>1&&n[1]<=1&&n[2]>1||n[0]>1&&n[1]<=1&&n[2]<=1?(i.push(n.slice(0,1)),i.push(n.slice(1,3)),o=this.buildCustomRowsLayout(i,e)):n[0]<=1&&n[1]>1&&n[2]>1?(u>3?i.push(n.slice(0,2)):(i.push(n.slice(0,2)),i.push(n.slice(2,3))),o=this.buildCustomRowsLayout(i,e)):n[0]<=1&&n[1]>1&&n[2]<=1?(i.push(n.slice(0,2)),o=this.buildCustomRowsLayout(i,e)):n[0]<=1&&n[1]<=1&&n[2]>1?(u>3?i.push(n.slice(0,2)):(i.push(n.slice(0,2)),i.push(n.slice(2,3))),o=this.buildCustomRowsLayout(i,e)):n[0]<=1&&n[1]<=1&&n[2]<=1&&(i.push(n.slice(0,3)),o=this.buildCustomRowsLayout(i,e))),Math.max.apply(Math,o.boxes.map((function(e){return e.height})))>.8*t.viewportData.getHeight()&&((i=[]).push(n.slice(0,2)),o=this.buildCustomRowsLayout(i,e)),o},buildCustomRowsLayout:function(e,t){var a=this,o=0,i={boxes:[]};return e.forEach((function(n,u){var l={horizontal:a.layoutValues.large.BATCH_CARD_SPACING,vertical:a.layoutValues.large.BATCH_CARD_SPACING},s=a.generateCustomJustifiedRow(n,{containerWidth:t.width,padding:l.horizontal,top:0===u?0:o});i.boxes=i.boxes.concat(s),o+=u!==e.length-1?s[0].height+l.vertical:s[0].height})),i.containerHeight=o,i},generateCustomJustifiedRow:function(e,t){var a=e.reduce((function(e,t,a){return e+t}),0),o=(t.containerWidth-t.padding*(e.length-1))/a,i=0;return e.map((function(e,a){var n=i;return i+=o*e+t.padding,{aspectRatio:e,width:o*e,height:o,left:n,top:t.top}}))},scaleLayout:function(e,t,a,o,i){var n,u=0,l=0,s=[];return e.boxes.forEach((function(e,a){o||(e.width*=t,e.left*=t),i||(e.height*=t,e.top*=t)})),s.push([]),e.boxes.forEach((function(e,t){e.top>l&&(u++,l=e.top,s.push([])),s[u].push(e)})),n=0,s.forEach((function(u,l){var r=a,h=r*t,g=0;u.forEach((function(e,t){o||(e.width-=(r-h)*(u.length-1)/u.length,e.left=g+t*r,g+=e.width),i||(e.height-=(r-h)*(s.length-1)/s.length,e.top=n+l*r,t===u.length-1&&(n+=u[0].height))})),o||(e.width=g+(u.length-1)*r)})),i||(e.containerHeight=n+(s.length-1)*a),e},convertPhotoModel:function(t){var a,o=t.getValue("owner"),i=t.getValue("engagement"),n=o.getValue("isPro");return"photo-lite-models"===t.registry.name?(a=this.convertEngagementModel(t),{id:e.guid(),layoutRenderType:"photo",photoId:t.getValue("id"),aspectRatio:t.getValue("aspectRatio"),sizes:t.getValue("sizes"),url:t.getValue("url"),title:t.getValue("title"),description:t.getValue("description"),mediaType:t.getValue("mediaType"),contentType:t.getValue("contentType"),isVideo:t.getValue("isVideo"),owner:{nsid:o.getValue("nsid"),url:o.getValue("url"),displayname:o.getValue("displayname"),pathAlias:o.getValue("pathAlias"),isPro:n,proBadgeType:n?o.getValue("proBadge"):void 0,model:t.getValue("owner")},engagement:a,isOwner:t.getValue("isOwner"),needsInterstitial:t.getValue("needsInterstitial"),model:t,engagementModel:i}):(a=this.convertEngagementModel(i),{id:e.guid(),layoutRenderType:"photo",photoId:t.getValue("id"),aspectRatio:t.getValue("aspectRatio"),sizes:t.getValue("sizes"),url:t.getValue("url"),title:t.getValue("title"),description:t.getValue("description"),mediaType:t.getValue("mediaType"),contentType:t.getValue("contentType"),isVideo:t.getValue("isVideo"),owner:{nsid:o.getValue("nsid"),url:o.getValue("url"),displayname:o.getValue("displayname"),buddyicon:o.getValue("buddyicon"),pathAlias:o.getValue("pathAlias"),isPro:n,proBadgeType:n?o.getValue("proBadge"):void 0,model:t.getValue("owner")},engagement:a,isOwner:t.getValue("isOwner"),needsInterstitial:t.getValue("needsInterstitial"),safetyLevel:t.getValue("safetyLevel"),model:t,engagementModel:i})},convertEngagementModel:function(e){return"photo-lite-models"===e.registry.name?{photoId:e.getValue("id"),isFaved:e.getValue("isFaved"),faveCount:e.getValue("faveCount"),commentCount:e.getValue("commentCount"),canFave:e.getValue("canFave"),reactions:t.flipper.isFlipped("enable-likes")?e.getValue("reactions"):void 0,model:e}:{photoId:e.getValue("id"),isFaved:e.getValue("isFaved"),faveCount:e.getValue("faveCount"),commentCount:e.getValue("commentCount"),viewCount:e.getValue("viewCount"),canFave:e.getValue("canFave"),reactions:t.flipper.isFlipped("enable-likes")?e.getValue("reactions"):void 0,model:e}}};return e.augment(o,e.EventTarget),o}}),"@VERSION@",{requires:["event-custom","storage-helper"],optionalRequires:["hermes-core"]});YUI.add("photo-engagement-view",(function(e,t){require("hermes-core/flog")(t);e.FlickrView.create(this.name,e.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(t){return t.showFaveCount=t.isResponsiveMobile,this.photoId=t.photoId,this.nsid=t.nsid,""===this.get("container").get("innerHTML")&&this.setContainerHTML(""),this.signinPendingQueue=t.signinPendingQueue,this.isResponsiveMobile=t.isResponsiveMobile,this.photoPrintsHelper=new e.PhotoPrintsHelper(this.appContext),this.signedIn=this.appContext.getViewer().signedIn,this.photoCardHelper=new e.PhotoCardHelper(this.appContext),this.curationHelper=new e.CurationHelper(this.appContext,{view:this}),this.downloadLink="",t.subviewParams={"like-engagement-item-view":{photoId:t.photoId,showCount:!1,size:"medium",isPadded:!0}},this},subviewConfig:{"fave-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!0,hideWhoFaved:!0,additionalViewClasses:["engagement-item"],disabled:function(){return this.appContext.flipper.isFlipped("enable-likes")}},"like-engagement-item-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!0,additionalViewClasses:["engagement-item"],theme:"light",disabled:function(){return!this.appContext.flipper.isFlipped("enable-likes")}},"photo-well-scrappy-edit-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!0,additionalViewClasses:["engagement-item"]},"fluid-share-photo-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!0,additionalViewClasses:["engagement-item"],theme:"light"},"print-button-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!0,additionalViewClasses:["engagement-item"]}},loadState:function(){return this.appContext.getModel("photo-models",this.photoId).then((e=>{var t=e.getValue("owner");return this.set("photo",e),this.downloadButtonEnabled=!1,e.getValue("isVideo")?(this.appContext.flipper.isFlipped("disable-video-playback")?this.downloadButtonEnabled=!1:(this.appContext.flipper.isFlipped("enable-album-download")&&(this.downloadButtonEnabled=e.getValue("engagement").getValue("canDownload")),t.getValue("isMe")&&(this.downloadButtonEnabled=!0)),this.downloadLink="/video_download.gne?id="+e.getValue("id")):(this.downloadButtonEnabled=!0,this.downloadLink=e.getValue("url")+"/sizes/l/"),this.appContext.getModel("person-relationship-models",e.getValue("owner").getValue("nsid"))})).then((e=>{this.set("relationshipModel",e)}))},buildContainer:function(){var e,t=this.get("photo"),o=t.getValue("owner"),n=this.get("container"),i=this.photoCardHelper.convertPhotoModel(t);return e={"share-view":this.subviews["fluid-share-photo-view"]?this.subviews["fluid-share-photo-view"].get("container"):"",photoId:t.getValue("id"),ownerId:t.getValue("owner").getValue("id"),isVideo:t.getValue("isVideo"),viewerIsOwner:o.getValue("isMe"),downloadingAvailable:this.downloadButtonEnabled,downloadLink:this.downloadLink,showPrintButton:this.photoPrintsHelper.canPrintPhoto(t,this.get("relationshipModel")),photoItem:i,signedIn:this.signedIn,faveCount:t.getValue("engagement").getValue("faveCount"),commentCount:t.getValue("engagement").getValue("commentCount"),isResponsiveMobile:this.isResponsiveMobile},this.appContext.forceServerRender&&(e.downloadItems=this.getDownloadMenuItems()),this.setContainerWithTemplate("photo-engagement",e),this.isResponsiveMobile&&n.addClass("responsive-mobile"),this},activate:function(){this.get("photo").getValue("license");var t=this.get("container");if(this.engagementModel=this.get("photo").getValue("engagement"),this.signinPendingQueue&&this.signinPendingQueue.length>0)for(var o=this.signinPendingQueue,n=0;n<o.length;n++)"download"===o[n].key&&o[n].value&&o[n].value.id===this.photoId&&this.downloadItem(o[n].value.imageUrl);return this.engagementModel.getValue("canDownload")&&this.registerEventHandler(e.one("body").delegate("click",this.handleDownloadItemClick.bind(this),".sizes li a.download-image-size")),this.attachKeyEvent("down:68",this.handleDownloadMenuButtonClick.bind(this)),this.registerEventHandler(t.delegate("click",this.handleDownloadMenuButtonClick.bind(this),".download a")),this.curateNode=t.one(".engagement-item.curate"),this.curateNode&&this.registerEventHandler(this.curateNode.on("click",this.handleCurateClick.bind(this))),this.commentNode=t.one(".engagement-item.comment"),this.commentNode&&(this.commentTextNode=this.commentNode.one(".engagement-count"),this.registerEventHandler(this.commentNode.on("click",this.showCommentsModal.bind(this)))),this.faveTextNode=t.one(".fave-count"),this.registerEventHandler(this.engagementModel.on("valuesChanged",this.handleEngagementModelValuesChanged.bind(this))),this},getDownloadMenuItems:function(t){var o,n=this.get("photo"),i=e.clone(n.getValue("sizes")),a=[],s=n.getValue("engagement").getValue("canDownload"),l=this;for(["q","sq"].some((function(e){if(i[e])return i[e].label=l.intlMessage({intlName:"photo-page-scrappy.SQUARE"}),a.push(i[e])})),["w","n","s","t"].some((function(e){if(i[e])return i[e].label=l.intlMessage({intlName:"photo-page-scrappy.SMALL"}),a.push(i[e])})),["c","z","m"].some((function(e){if(i[e])return i[e].label=l.intlMessage({intlName:"photo-page-scrappy.MEDIUM"}),a.push(i[e])})),["k","h","l"].some((function(e){if(i[e])return i[e].label=l.intlMessage({intlName:"photo-page-scrappy.LARGE"}),a.push(i[e])})),["6k","5k","4k","3k"].some((function(e){if(i[e])return i[e].label=l.intlMessage({intlName:"common.XLARGE"}),a.push(i[e])})),i.o&&(i.o.label=this.intlMessage({intlName:"photo-page-scrappy.ORIGINAL"}),a.push(i.o)),o=0;o<a.length;o++)a[o].url=a[o].displayUrl.replace(/^(.+)(\..+)$/,"$1_d$2");return this.templates("scrappy-download-menu")({photoURL:n.getValue("url"),sizes:a,showDownloadSizes:s})},createDownloadDialog:function(t){var o=this.get("container");this.downloadMenu&&(this.downloadMenu.close(),this.downloadMenu=null),this.downloadMenu=new e.Views.FluidDroparound({appContext:this.appContext,dismissOnOverlayClick:!0,preferTop:!0,showDropArrow:!0,anchorOffsetVertical:5,width:200,anchorElement:o.one(".download"),htmlMessage:t,closeOnScroll:!1,classList:"download-dialog-tooltip",autoSizeToContent:!0}),this.downloadMenu.show()},handleDownloadMenuButtonClick:function(e){var t=this.get("photo");if(this.downloadButtonEnabled)if(t.getValue("isVideo")){if(this.appContext.flipper.isFlipped("enable-album-download"))e.preventDefault(),this.downloadItem(this.downloadLink);else if(!t.getValue("owner").getValue("isMe"))return e.preventDefault(),!1}else e.halt(),this.createDownloadDialog(this.getDownloadMenuItems());else e.preventDefault()},handleDownloadItemClick:function(t){t.preventDefault(),this.downloadItem(t.currentTarget.getAttribute("href"));let o=t.currentTarget;if(o){let t=o.getAttribute("data-size"),n=o.getAttribute("data-res-width"),i=o.getAttribute("data-res-height");t&&n&&i&&e.Snowplough.sendSelfDescribingEvent({schema:e.Snowplough.SCHEMAS.DOWNLOAD,data:{photoId:[parseInt(this.get("photo").getValue("id"),10)],size:t.toLowerCase(),width:parseInt(n,10),height:parseInt(i,10),license:parseInt(this.get("photo").getValue("license"),10),ownerNsid:this.get("photo").getValue("owner").id,isBatch:!1}},e.Snowplough.getPhotoContextFromModel(this.get("photo")))}this.downloadMenu&&(this.downloadMenu.close(),this.downloadMenu=null)},downloadItem:function(e){document.location=e},handleCurateClick:function(){var t=this,o=this.get("photo").getValue("isOwner");"fluid-droparound-view"===this.curationHelper.showAddToCuration({photoId:this.get("photo").getValue("id"),showAlbums:o,showGalleries:!o,anchorNode:this.curateNode}).name&&(this.fire("menuOpened"),this.curationHelper.on("curateDroparoundClosed",(function(){t.fire("menuClosed"),t.curateNode.removeClass("active")})),this.curateNode.addClass("active")),e.Snowplough.sendStructuredEvent({category:"photopageinteractions",action:"curateClick"},e.Snowplough.getPhotoContextFromModel(this.get("photo")))},showCommentsModal:function(){var t={appContext:this.appContext,photoId:this.photoId,isScrollable:!0,addCommentText:this.intlMessage({intlName:"comments.ADD_PHOTO_COMMENT",mediaType:this.get("photo").getValue("mediaType")}),hasHeader:!0},o=new e.ModalDroparoundHelper(this.appContext,{useViewportType:!1,containerType:"modal",configs:{common:{subviewName:"photo-comments-view",subviewParams:t},modal:{height:550,flexLayout:!0}}});this.registerEventHandler(o.on("close",(()=>{e.fire("photoCommentModalClosed",{photoId:this.photoId})}))),this.registerEventHandler(e.on("addComment:showingSignupModal",(()=>{o.close()}))),o.show()},handleEngagementModelValuesChanged:function(t){var o,n;t.commentCount?(o=t.commentCount.newVal,this.commentTextNode&&(this.commentTextNode.set("text",e.IntlNumber.format(o,this.appContext.lang,1)),this.commentTextNode.toggleClass("hidden",0===o))):t.faveCount&&(n=t.faveCount.newVal,this.faveTextNode&&(this.faveTextNode.set("text",e.IntlNumber.format(n,this.appContext.lang,1)),this.faveTextNode.toggleClass("hidden",0===n)))}})}),"@VERSION@",{requires:["flickr-view","hermes-template-photo-engagement","hermes-template-scrappy-download-menu","signup-modal-view","fluid-share-photo-view","fluid-droparound-view","print-button-view","photo-comments-view","better-throttle","photo-prints-helper","photo-card-helper"],optionalRequires:["hermes-core"],optional:["photo-models"],langBundles:["common","photo-page-scrappy","comments"]});YUI.add("flickr-route",(function(r,e){var t=require("hermes-core/flog")(e),i=require("hermes-core/type-validator");r.Routes=r.Routes||{},r.FlickrRoute=function(r){this.appContext=r},r.FlickrRoute.prototype={run:function(){},setRouteDataOnHistory:function(e,t){return r.HistoryHelper.setData(this.name,e,t)},getRouteDataFromHistory:function(e){return r.HistoryHelper.getData(this.name,e)},getRouteMetaValue:function(r,e){return this.appContext.routeConfig.meta?e?this.appContext.routeConfig.meta[r]?this.appContext.routeConfig.meta[r]:e:this.appContext.routeConfig.meta[r]?this.appContext.routeConfig.meta[r]:null:null},displayServerErrorOrClientRedirect:function(e,t,i){return YUI.Env.isServer?this.displayRouteErrors(e,new r.RouteError(404,t)):r.Promise.resolve({redirect:i||e.url})},detectRouteErrors:function(){var e=r.Array(arguments);return e.filter((function(e,t){return e instanceof r.RouteError})).sort((function(r,e){return r.type-e.type}))},displayRouteErrors:function(e,t){var i=r.Lang.isArray(t)?t[0]:t;return r.Promise.resolve(this["display"+i.type+"Error"](e,i))},display500Error:function(e,i){var a,s,o;return a={view:"error-500-page-view",params:{},headers:{statusCode:500}},(r.config.flickr.error.show_debugging_info||e.isPossiblyAdminUser||this.appContext&&this.appContext.auth&&this.appContext.auth.isPossiblyAdminUser)&&(a.params.source="flickrRoute#display500Error",a.params.message=i.message,a.params.stack=i.stack,a.params.apiMethod=i.apiMethod),YUI.Env.isServer||(a.params.message=i.message,a.params.apiMethod=i.apiMethod),e.id&&(a.params.requestID=e.id),i&&"SiteAuth"===i.type&&(i.redirect?(s=YUI.Env.isServer?e.protocol+"://"+e.hostname+e.originalUrl:e.url,o=r.url("/siteauth/?redirect_url="+encodeURIComponent(s)),YUI.Env.isServer&&t.info("Redirecting to siteauth"),a={redirect:o}):YUI.Env.isServer&&(a.params.siteAuthFailure=!0)),void 0===a.redirect?t.info("render",{status:500,req:e,err:i,isBot:this.appContext.getUA().isBot}):t.info("redirect",{status:302,req:e,location:a.redirect,isBot:this.appContext.getUA().isBot}),a},display303Error:function(r,e){return{redirect:e.options.redirect,headers:{statusCode:303}}},display403Error:function(r,e){return this.displayStandardErrorPage(r,e,403)},display404Error:function(r,e){return e=e||new Error("404"),t.info("render",{status:404,url:r.url,err:e,isBot:this.appContext.getUA().isBot}),this.displayStandardErrorPage(r,e,404)},display410Error:function(r,e){return this.displayStandardErrorPage(r,e,410)},displayStandardErrorPage:function(e,t,i){var a;return t=t||{},a={view:"fluid-error-page-view",params:{statusCode:i,url:e.url,message:t.message,catchAll:t.catchAll||!1},headers:{statusCode:i}},t.data&&(a.params=r.merge(a.params,t.data)),(r.config.flickr.error.show_debugging_info||e.isPossiblyAdminUser||this.appContext&&this.appContext.auth&&this.appContext.auth.isPossiblyAdminUser)&&(a.params.source="flickrRoute#display"+i+"Error",a.params.message=t.message),e.id&&(a.params.requestID=e.id),a},getPageNumber:function(r,e){var t=parseInt(r.params[e||"page_number"],10);return(isNaN(t)||t<=1)&&(t=1),t},getNSIDOrPathAlias:function(r){var e;return i.nsid(r)?e=r:i.pathAlias(r)?e={pathAlias:r}:t.warn("Couldn't identify "+r+" as an nsid or path alias."),e}},r.RouteError=function(r,e,t){this.type=r,this.message=e||"",this.data=t||{}}}),"@VERSION@",{requires:["flickr-promise","moment","url","history-helper"],optionalRequires:["hermes-core"]});YUI.add("seo",(function(e,t){e.Seo={appContext:{},stripTags:function(e){return e?String(e).replace(/<\/?[^>]+>/g,""):""},collapseWhitespace:function(e){return e.trim().replace(/\s+/g," ")},decodeEntities:function(e){return e.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&nbsp;/g," ")},cleanText:function(e){return this.collapseWhitespace(this.decodeEntities(this.stripTags(e)))},getSEOTitleForPhoto:function(e){var t=this.cleanText(e.getValue("title")),l=this.cleanText(e.getValue("description")),n=this.cleanText(e.getValue("owner").getValue("displayname")),g=70-(t.length+"| Flickr".length+5);return t.length>=50?t.slice(0,58)+(t.length<58?" ":"… "):t.length>20&&t.length<50?l.length>20?t+" | "+l.slice(0,g)+(l.length<g?" ":"… "):l.length>0?t+" | "+l.slice(0,g)+(l.length<g?" ":"… ")+"| "+n+" ":t+" | "+n+" ":t.length<=20&&t.length>0?l.length>50?t+" | "+l.slice(0,g)+(l.length<g?" ":"… "):l.length>0?t+" | "+l.slice(0,g)+(l.length<g?" ":"… ")+"| "+n+" ":t+" | "+n+" ":l.length>50?l.slice(0,g)+(l.length<g?" ":"… "):l.length>0?l.slice(0,g)+(l.length<g?" ":"… ")+"| "+n+" ":"Untitled | "+n+" "},generateSEODescriptionForPhoto:function(e,t,l,n,g){var i=e.getValue("og:title"),h=e.getValue("og:description"),c="";return"Untitled"===i&&(i=n),h.length>120?c=h.slice(0,120)+(h.length<120?" ":"… ")+l+" "+g+".":h.length>60&&h.length<120?c=h+("."===h.slice(h.length-1,h.length)?" ":". ")+i.slice(0,40)+(i.length<40?" ":"… ")+l+" "+g+".":h.length<=60&&(c=i+("."===i.slice(i.length-1,i.length)?" ":". ")+h.slice(0,160-i.length)+(h.length<160-i.length?" ":"… ")+l+" "+g+"."),c}}}),"@VERSION@",{requires:[]});