YUI.add("photo-selector-sets-photolist-interaction-view",function(t){var e=require("hermes-core/type-validator");t.namespace("Views")[this.name]=t.Base.create(this.name,t.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(t){return""===this.get("container").get("innerHTML")&&this.setContainerHTML(""),this.publicOnlyPhotos=t.publicOnlyPhotos,this},loadState:function(){return this.appContext.getModel(this.get("engagementModelName"),this.get("id")).then(function(t){this.set("engagement",t)}.bind(this))},buildContainer:function(){return this.setContainerWithTemplate("photo-selector-sets-photolist-set-interaction",{album:this.get("model").toJSON(),publicOnlyPhotos:this.publicOnlyPhotos,albumPageUrl:this.get("albumPageUrl")}),this},activate:function(){return this.registerEventHandler(this.get("container").on("click",this.selectSet.bind(this))),this},selectSet:function(e){e.halt(),t.fire("photoSelector:subviewEvent",{eventName:"selectSetFromPhotoList",id:this.get("id"),title:this.get("model").getValue("title")})},destructor:function(){}},{ATTRS:{id:{writeOnce:"initOnly",validator:function(t,i){return e.photoId(t)}},model:{writeOnce:"initOnly"},albumPageUrl:{writeOnce:"initOnly"},engagement:{value:null},engagementModelName:{writeOnce:"initOnly",value:null,validator:function(e,i){return t.AttributeHelpers.validateString(e)}}}})},"@VERSION@",{requires:["flickr-view","hermes-template-photo-selector-sets-photolist-set-interaction","attribute-helpers"],optionalRequires:["fluid"],langBundles:["album-page"]});YUI.add("hermes-lang-album-page",function(e,o){e.Intl.add("hermes/album-page","en-US",{PHOTOS_COUNT:[{type:"plural",valueName:"selectedCount",options:{one:"${#} photo",other:"${#} photos"}}],PUBLIC_PHOTOS_COUNT:[{type:"plural",valueName:"selectedCount",options:{one:"${#} public photo",other:"${#} public photos"}}],PUBLIC_ITEMS_COUNT:[{type:"plural",valueName:"selectedCount",options:{one:"${#} public item",other:"${#} public items"}}],VIDEOS_COUNT:[{type:"plural",valueName:"selectedCount",options:{one:"${#} video",other:"${#} videos"}}],VIEWS_COUNT:[{type:"plural",valueName:"selectedCount",options:{one:"${#} view",other:"${#} views"}}],BACK_TO_ALBUMS:["Back to albums list"],EDIT_IN_ORGANIZR:["Edit in Organizr"],EDIT_COVER:["Edit cover"],SELECT_COVER_PHOTO:["Select a cover photo"],SELECT:["Select"],ERROR_COVER_PHOTO:["There was a problem trying to set your cover photo. Please try again."],ERROR_UPDATING_ALBUM_TITLE_DESCRIPTION:["There was an error updating the album's title and description."],ALBUM_ADD_DESCRIPTION:["Click here to enter a description for this album"],ERROR_CREATING_PHOTOBOOK_FROM_ALBUM:["There was a problem creating the book for this album. Please try again later."],ALBUM_DESCRIPTION:["Album description"],CREATE_BOOK_FROM_ALBUM:["Make a book from this Album"],DOWNLOAD_PHOTOS_AND_VIDEO:["Download ",{type:"plural",valueName:"photoCount",options:{one:"${#} photo",other:"${#} photos"}}," & ",{type:"plural",valueName:"videoCount",options:{one:"${#} video",other:"${#} videos"}}],DOWNLOAD_PHOTOS:["Download ",{type:"plural",valueName:"photoCount",options:{one:"${#} photo",other:"${#} photos"}}],DOWNLOAD_VIDEOS:["Download ",{type:"plural",valueName:"videoCount",options:{one:"${#} video",other:"${#} videos"}}],DOWNLOAD_ZIP:["Download zip"],DOWNLOAD_ZIP_PART:["Download zip part ","${partSequence}"],ALOT_OF_PHOTOS:["Wow, that's a lot of photos! Click to download each batch as a zip file."],DOWNLOAD_ALBUM_NOT_AVAILABLE_ERROR:["There are no photos or videos available in this album for you to download."],DOWNLOAD_ALBUM_DISABLED_ERROR:["Album downloading is currently unavailable. Please try again in a minute."],DOWNLOAD_ALBUM_GENERIC_ERROR:["There was an error downloading this album. Please try again."],DOWNLOAD_ALBUM_LICENSE_MESSAGE:["These photos may have one or more license types. Please visit the individual photo page for more information about the license prior to downloading this album."],DOWNLOAD_ALBUM_LICENSE_MESSAGE_ALT:["These photos may have one or more license types. Prior to downloading this album, please visit the individual photo pages to understand the designated license type for each image"],DOWNLOAD_ALBUM_LICENSE_MESSAGE_ALT_2:["These photos may have one or more license types or their rights may be reserved. Prior to downloading this album, please visit the individual photo pages to understand the designated license type for each image."],DOWNLOAD_ALBUM_LEARN_MORE:['Learn more at Creative Commons'],CONFIRM_ALBUM_DELETE_NO_CONTENTS_DELETED:["Do you really want to delete this album? (Don't worry, none of the contents will be deleted.)"],DELETE_THIS_ALBUM:["Delete this album"],SHARE_THIS_ALBUM:["Share this album"],CREATE_NEW_ALBUM:["Create new album"],NEW_ALBUM:["New album"],NEW_COLLECTION:["New collection"],VIEW_COLLECTIONS:["View collections"],VIEW_MY_COLLECTIONS:["View my collections"],SORT:["Sort"],SORT_DATE_TAKEN_OLDEST:["Sort by date taken (oldest first)"],SORT_DATE_TAKEN_NEWEST:["Sort by date taken (newest first)"],SORT_DATE_UPLOADED_OLDEST:["Sort by date uploaded (oldest first)"],SORT_DATE_UPLOADED_NEWEST:["Sort by date uploaded (newest first)"],SORT_ALPHABETICALLY:["Alphabetically"],SORT_RANDOMLY:["Randomly"],SORT_REVERSE:["Reverse current order"],SORT_ALMOST_DONE:["Almost done..."],TIMEOUT_FAILURE:["We're having some trouble displaying this album at the moment. Please try again."],OPENGRAPH_DESCRIPTION:["Explore this photo album by ","${owner}"," on Flickr!"]})},"@VERSION@",{requires:["intl"]});YUI.add("photo-selector-view",function(t,e){var o=require("hermes-core/flog")(e),i={};i={horizontal:20,vertical:20},t.FlickrView.create(this.name,t.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(t){return""===this.get("container").getHTML()&&this.setContainerWithTemplate("flickr-balls"),this.photoListView,this.searchPhotoListViews=[],this.publicOnlyGroups=t.publicOnlyGroups,this.publicOnlyPhotos=t.publicOnlyPhotos,this.enableMultiSelect=t.enableMultiSelect||!1,this.multiSelectLimit=void 0===t.multiSelectLimit?1:t.multiSelectLimit,this.preSelectedPhotos=t.preSelectedPhotos||[],this.clearRegistriesOnDestroy=t.clearRegistriesOnDestroy||!1,this.selectedModels=[],t.enableVideos&&this.set("itemFilterFunction",!1),this.isUploading=!1,this},loadState:function(){var e=this.appContext.getViewer().nsid;return this.publicOnlyPhotos&&(e+="-public"),this.appContext.getModelRegistry("profile-selected-photos-models").then(function(o){o.removeAll();var i={selectionModel:this.appContext.getModel("profile-selected-photos-models",this.appContext.getViewer().nsid),photostreamModel:this.appContext.getModel("photostream-models",e,this.publicOnlyPhotos?{viewAs:"public"}:void 0),setModelRegistry:this.appContext.getModelRegistry("set-models"),setsModel:this.appContext.getModel("sets-models",this.appContext.getViewer().nsid,{page:1,perPage:25}),profileModel:this.appContext.getModel("person-profile-models",this.appContext.getViewer().nsid)};return new t.FlickrPromise(i).then(this.onLoadStateResolved.bind(this))}.bind(this))},onLoadStateResolved:function(e){if(this.set("selectionModel",e.selectionModel),this.set("photostreamModel",e.photostreamModel),this.set("setsModel",e.setsModel),this.set("setModelRegistry",e.setModelRegistry),this.set("profileModel",e.profileModel),this.preSelectedPhotos&&this.preSelectedPhotos.length>0&&this.get("selectionModel").setValue("photos",this.preSelectedPhotos?this.preSelectedPhotos:[]),0===this.get("photostreamModel").getValue("totalItems")?this.set("photostreamEmpty",!0):this.set("photostreamEmpty",!1),this.get("groupId"))return this.appContext.getModel("group-pool-models",this.get("groupId")).then(function(t){this.set("groupModel",t)}.bind(this),function(t){o.error("error loading group model",{err:t})});this.canUpload=this.get("hasUploadCapabilities")&&!t.UserLimitsHelper.hasReachedUploadLimit(this.get("profileModel"),this.appContext)},moveElementToFirstInArray:function(t,e,o){var i;return t.forEach(function(t,s){t[o]===e&&(i=s)}),t.unshift(t.splice(i,1)[0]),t},buildContainer:function(){return this.setContainerWithTemplate("photo-selector",{hasUploadCapabilities:this.get("hasUploadCapabilities"),canUpload:this.canUpload,searchable:this.get("searchable"),publicOnlyPhotos:this.get("publicOnlyPhotos"),photostreamEmpty:this.get("photostreamEmpty"),hasGroupCapabilities:this.get("groupId")}),this},loadPhotoList:function(e,s){var a,r=this,l=this.get("container"),n=l.one(".photo-selector-photos-wrapper");this.photoListView&&this.photoListView.destroy(),s||(s=!1),a={modelParams:e,fetchParams:e.fetchParams,parentName:this.name,hasMultiSelect:this.enableMultiSelect,multiSelectLimit:this.multiSelectLimit,paginateOnScroll:!0,parentContainer:n,relayoutOnResize:!0,interactionViewName:this.get("interactionViewName"),galleryId:this.get("galleryId"),type:this.get("defaultSelected").type},this.get("itemFilterFunction")&&(a.itemFilterFunction=this.get("itemFilterFunction")),a.layout={targetRowHeight:150,containerWidth:a.parentContainer.get("offsetWidth"),containerPadding:{top:10,right:20,bottom:10,left:20},itemSpacing:i,forceAspectRatio:1,alwaysDisplayOrphans:!1,awakeBoundsToViewportSizeRatio:5,viewportContainerNodeHeight:n.get("offsetHeight")},this.appContext.params.primaryPhotoListConfig=a,this.appContext.getView(this.get("photoListViewName"),{appContext:this.appContext,publicOnlyPhotos:this.publicOnlyPhotos,primaryPhotoListConfig:a,isActiveViewAgnostic:!0,container:l.one(".photo-selector-photos-container")}).then(function(e){return e.initialize().then(function(e){var o,i=l.one(".photo-selector-photos-container"),a=i.one(".photo-list-view"),h=l.one(".loader");n.getDOMNode().scrollTop=0,r.photoListView=e,h&&h.addClass("loaded"),a.hasChildNodes()||(o=s?t.Node.create('
'+r.intlMessage({intlName:"search.NO_MATCHES_FOR_QUERY_TERM_YOUR"})+"
"):r.publicOnlyPhotos?t.Node.create(''+r.intlMessage({intlName:"common.PHOTO_SELECTOR_EMPTY_PUBLIC_PHOTOS"})+"
"):t.Node.create(''+r.intlMessage({intlName:"common.PHOTO_SELECTOR_EMPTY_PHOTOS"})+"
"),a.empty(),i.prepend(o)),r.addPhotoToSelection(null)})},function(t){o.error("Error getting view",{err:t})})},loadSelectionPhotoList:function(){var e,s=this,a=this.get("container"),r=a.one(".photo-selector-photos-wrapper");this.photoListView&&this.photoListView.destroy(),(e={parentName:this.name,hasMultiSelect:this.enableMultiSelect,multiSelectLimit:this.multiSelectLimit,paginateOnScroll:!0,initialItems:this.get("selectionModel").getValue("photos").getList(),parentContainer:r,relayoutOnResize:!0,interactionViewName:"photo-selector-selection-interaction-view"}).layout={targetRowHeight:150,containerWidth:e.parentContainer.get("offsetWidth"),containerPadding:{top:10,right:20,bottom:10,left:20},itemSpacing:i,forceAspectRatio:1,alwaysDisplayOrphans:!0,awakeBoundsToViewportSizeRatio:5,viewportContainerNodeHeight:r.get("offsetHeight")},this.get("itemFilterFunction")&&(e.itemFilterFunction=this.get("itemFilterFunction")),this.appContext.params.primaryPhotoListConfig=e,this.appContext.getView(this.get("photoListViewName"),{appContext:this.appContext,publicOnlyPhotos:this.publicOnlyPhotos,primaryPhotoListConfig:e,isActiveViewAgnostic:!0,nsid:this.appContext.getViewer().nsid,container:a.one(".photo-selector-photos-container")}).then(function(e){return e.initialize().then(function(e){var o,i=a.one(".photo-selector-photos-container"),l=i.one(".photo-list-view"),n=a.one(".loader");i.addClass("photo-selector-selection-photolist"),r.getDOMNode().scrollTop=0,s.photoListView=e,n&&n.addClass("loaded"),l.hasChildNodes()||(o=t.Node.create(''+s.intlMessage({intlName:"profile.NO_PHOTOS_SELECTED"})+"
"),l.empty(),i.prepend(o))})},function(t){o.error("Error getting view",{err:t})})},loadGroupPhotoList:function(e){var s,a=this,r=this.get("container"),l=r.one(".group-photo-selector-photos-wrapper");this.photoListView&&this.photoListView.destroy(),s={modelParams:e,parentName:this.name,paginateOnScroll:!0,parentContainer:l,relayoutOnResize:!0,interactionViewName:this.get("interactionViewName")},this.get("itemFilterFunction")&&(s.itemFilterFunction=this.get("itemFilterFunction")),s.layout={targetRowHeight:150,containerWidth:s.parentContainer.get("offsetWidth"),containerPadding:{top:10,right:20,bottom:10,left:20},itemSpacing:i,forceAspectRatio:1,alwaysDisplayOrphans:!1,awakeBoundsToViewportSizeRatio:5,viewportContainerNodeHeight:l.get("offsetHeight")},this.appContext.params.primaryPhotoListConfig=s,this.appContext.getView(this.get("photoListViewName"),{appContext:this.appContext,publicOnlyPhotos:this.publicOnlyPhotos,primaryPhotoListConfig:s,isActiveViewAgnostic:!0,container:l}).then(function(e){return e.initialize().then(function(e){var o,i=r.one(".group-photo-selector-photos-container"),s=i.one(".photo-list-view");l.getDOMNode().scrollTop=0,a.photoListView=e,r.one(".loader").addClass("loaded"),s.hasChildNodes()||(o=t.Node.create(''+a.intlMessage({intlName:"groups.GROUP_POOL_CONTAINS_NO_PUBLIC_PHOTOS"})+"
"),s.empty(),i.prepend(o)),a.addPhotoToSelection(null)})},function(t){o.error("Error getting view",{err:t})})},loadSetsPhotoList:function(t){var e,s=this,a=this.get("container");this.photoListView&&this.photoListView.destroy(),(e={modelParams:t,parentName:this.name,paginateOnScroll:!0,parentContainer:a.one(".photo-selector-photos-wrapper"),relayoutOnResize:!0,interactionViewName:this.get("setsInteractionViewName"),engagementModelName:"set-models",viewBeaconRestrictedAttribute:"primaryNeedsInterstitial"}).layout={targetRowHeight:200,containerWidth:e.parentContainer.get("offsetWidth"),containerPadding:{top:10,right:20,bottom:10,left:20},itemSpacing:i,forceAspectRatio:1,alwaysDisplayOrphans:!1,awakeBoundsToViewportSizeRatio:5,viewportContainerNodeHeight:a.one(".photo-selector-photos-wrapper").get("offsetHeight")},this.appContext.params.primaryPhotoListConfig=e,this.appContext.getView(this.get("photoListViewName"),{appContext:this.appContext,publicOnlyPhotos:this.publicOnlyPhotos,primaryPhotoListConfig:e,isActiveViewAgnostic:!0,container:a.one(".photo-selector-photos-container")}).then(function(t){return t.initialize().then(function(t){var e=a.one(".loader");a.one(".photo-selector-photos-container .photo-list-view");a.one(".photo-selector-photos-wrapper").getDOMNode().scrollTop=0,s.photoListView=t,e&&a.one(".loader").addClass("loaded"),s.addPhotoToSelection(null)})},function(t){o.error("Error getting view",{err:t})})},loadSearchPhotoList:function(t){var e,s=this,a=this.get("container"),r=t.photoListContainerSelector?a.one(t.photoListContainerSelector):a.one(".photo-selector-photos-container"),l=t.parentContainerSelector?a.one(t.parentContainerSelector):a.one(".photo-selector-photos-wrapper"),n=t.maxNumRows?this.get("limitedRowsPhotoListViewName"):this.get("photoListViewName");this.searchPhotoListViews&&this.searchPhotoListViews[t.listId]&&this.searchPhotoListViews[t.listId].destroy(),e={modelParams:t.modelParams,parentName:this.name,paginateOnScroll:!0,parentContainer:l,relayoutOnResize:!0,interactionViewName:this.get("interactionViewName"),engagementModelName:"photo-lite-models"},this.get("itemFilterFunction")&&(e.itemFilterFunction=this.get("itemFilterFunction")),e.layout={targetRowHeight:150,containerWidth:e.parentContainer.get("offsetWidth"),containerPadding:{top:10,right:0,bottom:10,left:0},itemSpacing:i,forceAspectRatio:1,maxNumRows:t.maxNumRows?t.maxNumRows:Number.POSITIVE_INFINITY,alwaysDisplayOrphans:!!t.alwaysDisplayOrphans&&t.alwaysDisplayOrphans,awakeBoundsToViewportSizeRatio:5,viewportContainerNodeHeight:l.get("offsetHeight")},this.appContext.params.primaryPhotoListConfig=e,this.appContext.getView(n,{appContext:this.appContext,publicOnlyPhotos:this.publicOnlyPhotos,primaryPhotoListConfig:e,isActiveViewAgnostic:!0,container:r,searchUrl:t.searchUrl,listId:t.listId}).then(function(e){return e.initialize().then(function(e){s.registerEventHandler(e.on("subviewViewEvent",s.handleSubviewEvent,s)),a.one(".photo-selector-search-lists-wrapper").getDOMNode().scrollTop=0,t.parentContainerSelector&&(a.one(t.parentContainerSelector).getDOMNode().scrollTop=0),s.searchPhotoListViews[t.listId]=e,a.one(".loader").addClass("loaded"),s.addPhotoToSelection(null)})},function(t){o.error("Error getting view",{err:t})})},activate:function(){var e,o=this.get("container"),i=this.get("defaultSelected");return this.registerEventHandler(o.on("click",this.handleClick,this)),this.canUpload&&this.registerEventHandler(o.one(".file-select").on("change",this.handleFileSelect,this)),this.registerEventHandler(t.on("photoSelector:subviewEvent",this.handleSubviewEvent,this)),i?"group"===i.type?(e={registryName:"group-pool-models",modelIdOrAttributes:this.get("groupId")+"-public",collectionAttributeName:"photoPageList"},this.publicOnlyGroups&&(e.fetchParams={privacyFilter:1},e.modelIdOrAttributes+="-public"),this.toggleGroupSelector(),this.loadGroupPhotoList(e),this.toggleTitleBar(i.title,"group")):"gallery"===i.type?(e={registryName:"gallery-info-models",modelIdOrAttributes:i.id,collectionAttributeName:"photoList"},this.loadPhotoList(e)):"galleryFaves"===i.type?(e={registryName:"gallery-faves-models",modelIdOrAttributes:this.get("defaultSelected").id,collectionAttributeName:"photoList",fetchParams:{galleryId:this.get("galleryId")}},this.loadPhotoList(e)):(e={registryName:"set-models",modelIdOrAttributes:this.publicOnlyPhotos?i.id+"-public":i.id,collectionAttributeName:"photoPageList"},this.publicOnlyPhotos&&(e.fetchParams={filter:1}),this.loadPhotoList(e),this.toggleTitleBar(i.title,"set")):0===this.get("photostreamModel").getValue("totalItems")?this.get("hasUploadCapabilities")?(this.toggleUploader(),this.hideTitleBar()):this.toggleTitleBar(this.intlMessage({intlName:"common.PHOTO_SELECTOR_EMPTY_PUBLIC_PHOTOS"},"empty",!1)):(e={registryName:"photostream-models",modelIdOrAttributes:this.publicOnlyPhotos?this.appContext.getViewer().nsid+"-public":this.appContext.getViewer().nsid,collectionAttributeName:"photoPageList"},this.publicOnlyPhotos&&(e.fetchParams={viewAs:"public"}),this.loadPhotoList(e,!1)),this},toggleUploader:function(){this.get("hasUploadCapabilities")&&(this.get("container").one(".photo-selector-photos-wrapper").addClass("is-hiding"),this.photoListView&&this.get("container").one(".photo-selector-photos-container").empty().append(this.templates("flickr-balls")({})),this.get("container").one(".photo-selector-search-lists-wrapper").addClass("is-hiding"),this.get("container").one(".photo-selector-upload").removeClass("is-hiding"),this.get("groupId")&&this.get("container").one(".group-photo-selector-photos-wrapper").addClass("is-hiding"))},toggleSelector:function(){this.get("hasUploadCapabilities")&&this.get("container").one(".photo-selector-upload").addClass("is-hiding"),this.get("container").one(".photo-selector-search-lists-wrapper").addClass("is-hiding"),this.get("groupId")&&this.get("container").one(".group-photo-selector-photos-wrapper").addClass("is-hiding"),this.get("container").one(".photo-selector-photos-wrapper").removeClass("is-hiding")},toggleSearchListsSelector:function(){this.get("hasUploadCapabilities")&&this.get("container").one(".photo-selector-upload").addClass("is-hiding"),this.get("container").one(".photo-selector-photos-wrapper").addClass("is-hiding"),this.photoListView&&this.get("container").one(".photo-selector-photos-container").empty().append(this.templates("flickr-balls")({})),this.get("container").one(".photo-selector-search-lists-wrapper").removeClass("is-hiding"),this.get("groupId")&&this.get("container").one(".group-photo-selector-photos-wrapper").addClass("is-hiding")},toggleGroupSelector:function(){var t=this.get("container").one(".photo-selector-upload");t&&t.addClass("is-hiding"),this.get("container").one(".photo-selector-photos-wrapper").addClass("is-hiding"),this.photoListView&&this.get("groupId")&&this.get("container").one(".group-photo-selector-photos-wrapper").empty().append(this.templates("flickr-balls")({})),this.get("container").one(".photo-selector-search-lists-wrapper").addClass("is-hiding"),this.get("groupId")&&this.get("container").one(".group-photo-selector-photos-wrapper").removeClass("is-hiding")},toggleTitleBar:function(e,o,i){var s=this.get("container"),a=s.one(".photo-selector-title-bar"),r=a.one(".back-to-list"),l="";void 0===i&&(i=!0),"search"===o&&e&&(e='"'+e+'"'),"set"===o?l=this.intlMessage({intlName:"common.PHOTO_SELECTOR_BACK_TO_ALBUM_LIST"}):"search"===o&&(l=this.intlMessage({intlName:"common.PHOTO_SELECTOR_BACK_TO_SEARCH_LIST"})),i?r.removeClass("hidden"):r.addClass("hidden"),r.one(".back-to-list-text").set("text",l),a.one(".title").set("text",t.Handlebars.helpers.truncate(e,120)),a.removeClass("hidden"),s.one(".photo-selector-photos-wrapper").addClass("showing-title"),s.one(".photo-selector-search-lists-wrapper").addClass("showing-title"),this.get("groupId")&&s.one(".group-photo-selector-photos-wrapper").addClass("showing-title")},hideTitleBar:function(){var t=this.get("container");t.one(".photo-selector-title-bar").addClass("hidden"),t.one(".photo-selector-photos-wrapper").removeClass("showing-title"),this.get("groupId")&&t.one(".group-photo-selector-photos-wrapper").removeClass("showing-title")},onParentViewEvent:function(e,o){var i,s,a,r=o[1],l={},n=this.get("searchable"),h=this.get("container").one(".no-results");if("navigation"===o[0])if("upload"===(i=r.target._node.dataset.value))this.get("hasUploadCapabilities")&&(this.toggleUploader(),this.hideTitleBar()),this.get("fileDragDrop")?this.get("fileDragDrop").reset():this.canUpload&&(this.set("fileDragDrop",new t.HtmlFileDragDrop({dropZone:".photo-selector-upload > .drop-zone"})),this.get("fileDragDrop").on("drop",this.handleFileDrop,this));else{if(this.get("hasUploadCapabilities")&&this.toggleSelector(),"group"===i)s={registryName:"group-pool-models",modelIdOrAttributes:this.get("groupId"),collectionAttributeName:"photoPageList"},this.publicOnlyGroups&&(s.fetchParams={privacyFilter:1},s.modelIdOrAttributes+="-public"),this.toggleGroupSelector(),this.loadGroupPhotoList(s);else if("photostream"===i){if(0===this.get("photostreamModel").getValue("totalItems"))return h&&h.remove(),void(this.get("hasUploadCapabilities")?(this.toggleUploader(),this.hideTitleBar()):this.toggleTitleBar(this.intlMessage({intlName:"common.PHOTO_SELECTOR_EMPTY_PUBLIC_PHOTOS"},"empty",!1)));s={registryName:"photostream-models",modelIdOrAttributes:this.publicOnlyPhotos?this.appContext.getViewer().nsid+"-public":this.appContext.getViewer().nsid,collectionAttributeName:"photoPageList"},this.publicOnlyPhotos&&(s.fetchParams={viewAs:"public"}),this.loadPhotoList(s)}else if("sets"===i){if(0===this.get("setsModel").getValue("totalItems")){var p=this.get("container").one(".photo-list-view");return h&&h.remove(),this.toggleTitleBar(this.intlMessage({intlName:"common.PHOTO_SELECTOR_NO_ALBUMS"},"empty",!1)),void p.empty()}s={registryName:"sets-models",modelIdOrAttributes:this.appContext.getViewer().nsid,collectionAttributeName:"albumsList"},this.loadSetsPhotoList(s)}else"gallery"===i?(s={registryName:"gallery-info-models",modelIdOrAttributes:this.get("galleryId"),collectionAttributeName:"photoList"},this.loadPhotoList(s)):"galleryFaves"===i?(s={registryName:"gallery-faves-models",modelIdOrAttributes:this.get("defaultSelected").id,collectionAttributeName:"photoList",fetchParams:{galleryId:this.get("galleryId")}},this.loadPhotoList(s)):this.loadSelectionPhotoList();this.hideTitleBar()}else"search"===o[0]&&(a=new t.SearchUrl(r.apiParams,this.appContext),this.toggleSearchListsSelector(),n.yours&&(this.searchUrlYourPhotos=new t.SearchUrl(r.apiParams,this.appContext),this.searchUrlYourPhotos.setAPIParam("user_id",this.appContext.getViewer().nsid),n.contacts||n.everyone?(l.listId="yours",l.photoListContainerSelector=".photo-selector-search-list-yours .photo-selector-search-list-container",l.parentContainerSelector=".photo-selector-search-list-yours",l.maxNumRows=1,l.alwaysDisplayOrphans=!0,l.searchUrl=this.searchUrlYourPhotos,l.modelParams={registryName:"search-photos-lite-models",modelIdOrAttributes:this.searchUrlYourPhotos.getId(),collectionAttributeName:"photos",fetchParams:{apiParams:this.searchUrlYourPhotos.getAPIParams()}},this.publicOnlyPhotos&&(s.fetchParams.privacyFilter=1),this.loadSearchPhotoList(l)):(this.toggleSelector(),s={registryName:"search-photos-lite-models",modelIdOrAttributes:this.searchUrlYourPhotos.getId(),collectionAttributeName:"photos",fetchParams:{apiParams:this.searchUrlYourPhotos.getAPIParams(),additionalExtras:["o_dims"]}},this.publicOnlyPhotos&&(s.fetchParams.privacyFilter=1),this.loadPhotoList(s,!0))),n.contacts&&(this.searchUrlContactsPhotos=new t.SearchUrl(r.apiParams,this.appContext),this.searchUrlContactsPhotos.setAPIParam("user_id",this.appContext.getViewer().nsid),this.searchUrlContactsPhotos.setAPIParam("contacts","all"),l.listId="contacts",l.photoListContainerSelector=".photo-selector-search-list-contacts .photo-selector-search-list-container",l.parentContainerSelector=".photo-selector-search-list-contacts",l.maxNumRows=1,l.alwaysDisplayOrphans=!0,l.searchUrl=this.searchUrlContactsPhotos,l.modelParams={registryName:"search-photos-lite-models",modelIdOrAttributes:this.searchUrlContactsPhotos.getId(),collectionAttributeName:"photos",fetchParams:{apiParams:this.searchUrlContactsPhotos.getAPIParams()}},this.loadSearchPhotoList(l)),n.everyone&&(this.searchUrlEveryonePhotos=new t.SearchUrl(r.apiParams,this.appContext),l.listId="everyone",l.photoListContainerSelector=".photo-selector-search-list-everyone .photo-selector-search-list-container",l.parentContainerSelector=".photo-selector-search-list-everyone",l.maxNumRows=1,l.alwaysDisplayOrphans=!0,l.searchUrl=this.searchUrlEveryonePhotos,l.modelParams={registryName:"search-photos-lite-models",modelIdOrAttributes:r.id,collectionAttributeName:"photos",fetchParams:{apiParams:this.searchUrlEveryonePhotos.getAPIParams()}},this.loadSearchPhotoList(l)),this.toggleTitleBar(a.getAPIParams().text,"search",!1))},handleSubviewEvent:function(e){var o,i,s;return"selectPhotoFromPhotoList"===e.eventName?(o={photoModel:this.appContext.getModel("photo-models",e.id)},new t.FlickrPromise(o).then(function(t){t.photoModel.isOwner&&this.set("photoSource",this.get("photoSourceOwnImage")),this.enableMultiSelect&&this.hasReachMultiSelectLimit()||this.addPhotoToSelection(t.photoModel.id,t.photoModel)}.bind(this))):"unselectPhotoFromPhotoList"===e.eventName?(o={photoModel:this.appContext.getModel("photo-models",e.id)},new t.FlickrPromise(o).then(function(t){t.photoModel.isOwner&&this.set("photoSource",this.get("photoSourceOwnImage")),this.removePhotoFromSelection(t.photoModel.id,t.photoModel)}.bind(this))):"selection:remove"===e.eventName?(o={photoModel:this.appContext.getModel("photo-models",e.model.getValue("id"))},new t.FlickrPromise(o).then(function(t){t.photoModel.isOwner&&this.set("photoSource",this.get("photoSourceOwnImage")),this.removePhotoFromSelection(t.photoModel.id,t.photoModel,!0)}.bind(this))):void("selectSetFromPhotoList"===e.eventName?(i={registryName:"set-models",modelIdOrAttributes:this.publicOnlyPhotos?e.id+"-public":e.id,collectionAttributeName:"photoPageList"},this.publicOnlyPhotos&&(i.fetchParams={filter:1}),this.loadPhotoList(i,!1),this.toggleTitleBar(e.title,"set")):e.details&&"viewEntireSearchList"===e.details[0]&&(i={registryName:"search-photos-lite-models",modelIdOrAttributes:e.details[1].searchUrl.getId(),collectionAttributeName:"photos",fetchParams:{apiParams:e.details[1].searchUrl.getAPIParams()}},this.publicOnlyPhotos&&(i.fetchParams.privacyFilter=1),this.toggleSelector(),this.loadPhotoList(i),s="search.YOUR_PHOTOS","contacts"===e.details[1].list?s="search.FROM_YOUR_CONTACTS":"everyone"===e.details[1].list&&(s="search.EVERYONES_PHOTOS"),s=this.intlMessage({intlName:s}),this.toggleTitleBar(s+": "+e.details[1].searchUrl.getAPIParams().text,"search")))},handleClick:function(t){var e=t.target;this.isUploading||(e.ancestor(".back-to-list",!0)?this.fire("subviewViewEvent","backToList"):e.ancestor(".simulate-file-select",!0)&&(t.halt(),this.get("container").one(".file-select").set("value",""),this.get("container").one(".file-select").getDOMNode().click()))},handleSelectPhoto:function(e){var o;if(o={photoModel:this.appContext.getModel("photo-models",e.getData("photo-id"))},!e.hasClass("invalid"))return this.set("photoSource",this.get("photoSourceOwnImage")),new t.FlickrPromise(o).then(function(t){this.addPhotoToSelection(t.photoModel.id,t.photoModel)}.bind(this))},hasReachMultiSelectLimit:function(){return this.get("selectionModel").getValue("photos").size()===this.multiSelectLimit},addPhotoToSelection:function(e,o){if(null===e)this.set("selected",null),t.fire("photoSelector:unselected");else if(e&&this.enableMultiSelect){var i=this.get("selectionModel").getValue("photos");this.hasReachMultiSelectLimit()||i.find(o)||(i.push(o),t.fire("photoSelector:selected",{hasWarning:!1,photoId:e}),this.updateSelectCountText(i.size()))}else e&&(this.set("selected",e),t.fire("photoSelector:selected",{hasWarning:!1,photoId:e}))},updateSelectCountText:function(e){var o=this.multiSelectLimit-e;t.fire("photoSelector:updateCount",{count:o})},removePhotoFromSelection:function(e,o,i){var s=this.get("selectionModel").getValue("photos");if(s.find(o)){s.removeFromList(e)&&(t.fire("photoSelector:unselected",{hasWarning:!1,photoId:e,wasLastPhotoSelected:0===s.size()}),this.updateSelectCountText(s.size()),i&&this.loadSelectionPhotoList())}},handlePhotoSetSelector:function(t){var e;this.get("hasUploadCapabilities")&&this.toggleSelector(),e={registryName:"set-models",modelIdOrAttributes:this.publicOnlyPhotos?t+"-public":t,collectionAttributeName:"photoPageList"},this.publicOnlyPhotos&&(e.fetchParams={filter:1}),this.loadPhotoList(e)},handlePhotoUploaded:function(t){this.appContext.getModelRegistry("photostream-models").then(function(e){e.attributeSearch({normalizedId:this.appContext.getViewer().nsid},!0).forEach(function(t){e.remove(t)}),this.addPhotoToSelection(t.id,t),this.fire("actionClick",t),this.resetUploader()}.bind(this),function(t){this.appContext.err(t)}.bind(this))},handleFileSelect:function(t){var e;(e=t.target.getDOMNode().files[0])&&e.name&&this.uploadFile(e)},pollTicket:function(e){if(this.uploadTimer){if(t.moment().diff(this.uploadTimer,"seconds")>this.get("maxUploadTimeAllowed"))return this.showUploadError("GENERIC")}else this.uploadTimer=t.moment();this.appContext.callAPI("flickr.photos.upload.checkTickets",{tickets:e}).then(function(t){var o;t&&t.stat&&("ok"!==t.stat&&this.showUploadError("GENERIC"),t.uploader&&t.uploader.ticket instanceof Array&&(o=t.uploader.ticket[0])&&o.id===e&&(1===o.complete?this.appContext.getModel("photo-models",o.photoid).then(this.handlePhotoUploaded.bind(this),function(t){this.showUploadError("GENERIC")}):2===o.complete?this.showUploadError("FILE_TYPE"):setTimeout(function(){this.pollTicket(e)}.bind(this),1e3)))}.bind(this),function(t){this.showUploadError("GENERIC")}.bind(this))},resetUploader:function(){this.clearUploadError(),this.get("container").one(".drop-zone").removeClass("uploading"),this.get("container").removeClass("uploading"),this.isUploading=!1,this.uploadTimer=void 0},uploadFile:function(e){var i,s,a,r=new FormData,l=t.config.flickr.api.hostname_client_upload;this.clearUploadError(),this.get("container").one(".drop-zone").addClass("uploading"),this.get("container").addClass("uploading"),this.isUploading=!0,r.append("api_key",t.config.flickr.api.site_key),r.append("csrf",t.config.flickr.csrf.token),r.append("photo",e,e.name),r.append("async","1"),r.append("is_public","0"),r.append("is_friend","0"),r.append("is_family","0"),r.append("content_type","1"),(i=this._imgFileXhr=new XMLHttpRequest).open("POST",l,!0),i.withCredentials=!0,s=function(t){var e="object"==typeof t?t.target.statusText:t+"";o.error("Error during upload",{statusText:e}),this.resetUploader(),this.showUploadError("GENERIC")},a=function(e){var o,i,a,r;try{r=t.one(e.currentTarget.responseXML),i=r.one("rsp").getAttribute("stat")}catch(t){i="",o=""}return"ok"!==i?s((i||"empty")+": "+(o||"no message")):(a=r.one("ticketid").get("text"),this.pollTicket(a))},i.addEventListener("load",a.bind(this)),i.addEventListener("error",s.bind(this)),i.send(r)},clearUploadError:function(){this.get("container").one(".upload-error").setHTML("")},showUploadError:function(t){this.resetUploader(),this.get("container").one(".upload-error").setHTML(this.intlMessage({intlName:this.get("errorMessages")[t]})),this.get("fileDragDrop").showError()},handleFileDrop:function(t){this.isUploading||(t instanceof Error?this.showUploadError(t.message):this.uploadFile(t))},destructor:function(){this.photoListView&&this.photoListView.destroy()}},{ATTRS:{maxUploadTimeAllowed:{readOnly:!0,value:20},errorMessages:{readOnly:!0,value:{GENERIC:"common.PHOTO_SELECTOR_ERROR_MESSAGE_GENERIC",FILE_TYPE:"common.PHOTO_SELECTOR_ERROR_MESSAGE_FILE_TYPE",FILE_SIZE:"common.PHOTO_SELECTOR_ERROR_MESSAGE_FILE_SIZE",FILE_COUNT:"common.PHOTO_SELECTOR_ERROR_MESSAGE_FILE_COUNT",LOW_QUALITY:"common.PHOTO_SELECTOR_ERROR_MESSAGE_LOW_QUALITY",COLOR_SPACE:"common.PHOTO_SELECTOR_ERROR_MESSAGE_COLOR_SPACE"}},photoSourceOwnImage:{readOnly:!0,value:1},hasUploadCapabilities:{value:!0},photoListViewName:{value:"photo-selector-photolist-view"},limitedRowsPhotoListViewName:{value:"photo-selector-limited-rows-photolist-view"},searchable:{value:{yours:!0,contacts:!0,everyone:!0}},interactionViewName:{value:"photo-selector-photolist-interaction-view"},setsInteractionViewName:{value:"photo-selector-sets-photolist-interaction-view"},itemFilterFunction:{value:function(t){return!t.getValue("isVideo")}},defaultSelected:{value:!1},selected:{},groupId:{},galleryId:{}}})},"@VERSION@",{requires:["flickr-view","flickr-promise","flickr-api","html-file-dragdrop","hermes-template-photo-selector","photo-selector-photolist-view","photo-selector-limited-rows-photolist-view","photo-selector-photolist-interaction-view","photo-selector-sets-photolist-interaction-view","user-limits-helper"],optional:["search-photos-lite-models"],langBundles:["common","wallart","search","groups","profile","upload-blocking"]});YUI.add("hermes-lang-wallart",function(e,o){e.Intl.add("hermes/wallart","en-US",{WALL_ART:["Wall Art"],YOU_CANCELLED_THIS_ITEM_ON_DATE:["You cancelled this item order on ",{type:"date",valueName:"date",format:"monthYear"}],YOU_ORDERED_THIS_ITEM_ON_DATE:["You ordered this item on ",{type:"date",valueName:"date",format:"monthYear"}],RETURN_TO_YOUR_ORDER_HISTORY:["Return to your order history"],SELECT_A_PHOTO:["Select a photo"],SELECT_PRODUCT:["Select product"],PHOTO_MOUNT:["Photo Mount"],CANVAS:["Canvas"],CANVAS_WRAP:["Canvas Wrap"],PREMIUM_LUSTRE:["Premium Lustre"],GLOSSY:["Glossy"],MATTE:["Matte"],SIZE:["Size"],CHECKOUT:["Checkout"],REORDER:["Reorder"],TOTAL:["Total"],UPLOAD:["Upload"],CURATED_COLLECTIONS:["Curated Collections"],CREATIVE_COMMONS:["Creative Commons"],NASA:["NASA"],ABSTRACT:["Abstract"],ANIMALS:["Animals"],PATTERNS:["Patterns"],FOOD:["Food"],LANDSCAPES:["Landscapes"],TRAVEL:["Travel"],MY_ALBUMS:["My Albums"],PRODUCT_DROPUP_CANVAS:['Artist-grade canvas wrapped around 1.25" wood frame'],PRODUCT_DROPUP_MOUNTED:['Archival photo paper finished with 1" wood-textured edge'],MATERIAL_DROPUP_LUSTRE:["Professional Crystal Archive - Premium Lustre"],MATERIAL_DROPUP_GLOSSY:["Professional Crystal Archive - Glossy"],MATERIAL_DROPUP_MATTE:["Professional Crystal Archive - Matte"],SIZES_MODAL_SIZES_NOT_AVAILABLE:["Some sizes not available due to the resolution of the photo. Learn More."],MOUNTED_SAFE_AREA:["The area outside of the solid-line will not be printed.