YUI.add("flickr-groups-admin-acceptPhoto-updater",(function(o,e){"use strict";o.namespace("ModelUpdaters")["flickr-groups-admin-acceptPhoto"]={run:function(t,s){var r,d,i=this,p=t.registryName||"group-pool-models",l=[];return t.photoID?t.photoIds=[t.photoID]:t.photoIds="string"==typeof t.photoIds?[t.photoIds]:t.photoIds,r=this._processParams(t),d={apiResponse:s.callAPI("flickr.groups.admin.acceptPhoto",r),groupPoolModel:s.getModel(p,t.groupID),photoGroupsModelRegistry:s.getModelRegistry("photo-groups-models"),photoContextsModelRegistry:s.getModelRegistry("photo-contexts-models"),pendingModelRegistry:s.getModelRegistry("photo-group-pending-models"),pendingsModelRegistry:s.getModelRegistry("photo-group-pendings-models"),adminPendingModelRegistry:s.getModelRegistry("group-admin-pending-models")},t.photoIds.forEach((function(o){l.push(s.getModel("photo-models",o))})),d.photoModels=o.Promise.all(l),t.unfilteredGroupId=r.group_id,"group-pool-models"!==p&&(d.unfilteredGroupPoolModel=s.getModel("group-pool-models",t.unfilteredGroupId)),new o.FlickrPromise(d).then((function(o){return i._processResponse(o,t)}),o.FetcherErrorLogger(e))},_processParams:function(e){return{photo_id:e.photoIds.join(","),group_id:o.Models["group-pool-models"].extractGroupFromCompoundId(e.groupID)}},_processResponse:function(o,e){var t,s=o.apiResponse,r=o.groupPoolModel,d=o.photoModels,i=o.photoGroupsModelRegistry,p=o.photoContextsModelRegistry,l=o.unfilteredGroupPoolModel,g=o.pendingModelRegistry,u=o.pendingsModelRegistry,n=o.adminPendingModelRegistry;if("ok"===s.stat)return d.forEach((function(o){r&&!r.hasPhoto(o.getValue("id"))&&r.acceptPhotoLocal(o),l&&!l.hasPhoto(o.getValue("id"))&&l.acceptPhotoLocal(o),i.exists(o.id)&&!i.getValue(o.id,"groups").getFromListByID(e.unfilteredGroupId)&&(i.getValue(o.id,"groups").unshift(r),i.setValue(o.id,"total",i.getValue(o.id,"total")+1)),p.exists(o.id)&&!p.getValue(o.id,"contexts").getFromListByID(e.unfilteredGroupId)&&(p.setValue(o.id,"totalGroups",p.getValue(o.id,"totalGroups")+1),p.getValue(o.id,"contexts").push(r)),t=[o.id,e.unfilteredGroupId].join("-"),u.exists(o.id)&&u.getValue(o.id,"pendings").getFromListByID(t)&&(u.setValue(o.id,"total",u.getValue(o.id,"total")-1),u.getValue(o.id,"pendings").removeFromList(t)),g.remove(t),n.exists(e.groupID)&&n.removePhotoLocal(e.groupID,o.id)})),r}}}),"@VERSION@",{requires:["flickr-promise","group-pool-models"],optional:[]});YUI.add("flickr-groups-admin-declinePhoto-deletor",(function(o,e){"use strict";o.namespace("ModelDeletors")["flickr-groups-admin-declinePhoto"]={run:function(t,r){var s,d,i=this,l=t.registryName||"group-pool-models",p=[];return t.photoID?t.photoIds=[t.photoID]:t.photoIds="string"==typeof t.photoIds?[t.photoIds]:t.photoIds,s=this._processParams(t),d={apiResponse:r.callAPI("flickr.groups.admin.declinePhoto",s),groupPoolModel:r.getModel(l,t.groupID),photoGroupsModelRegistry:r.getModelRegistry("photo-groups-models"),photoContextsModelRegistry:r.getModelRegistry("photo-contexts-models"),adminPendingModelRegistry:r.getModelRegistry("group-admin-pending-models")},t.photoIds.forEach((function(o){p.push(r.getModel("photo-models",o))})),d.photoModels=o.Promise.all(p),t.unfilteredGroupId=s.group_id,"group-pool-models"!==l&&(d.unfilteredGroupPoolModel=r.getModel("group-pool-models",t.unfilteredGroupId)),new o.FlickrPromise(d).then((function(o){return i._processResponse(o,t)}),o.FetcherErrorLogger(e))},_processParams:function(e){return{photo_id:e.photoIds.join(","),group_id:o.Models["group-pool-models"].extractGroupFromCompoundId(e.groupID)}},_processResponse:function(o,e){var t=o.apiResponse,r=o.groupPoolModel,s=o.photoModels,d=o.photoGroupsModelRegistry,i=o.photoContextsModelRegistry,l=o.unfilteredGroupPoolModel,p=o.adminPendingModelRegistry;if("ok"===t.stat)return s.forEach((function(o){i.exists(o.id)&&i.getValue(o.id,"contexts").getFromListByID(e.unfilteredGroupId)&&(i.setValue(o.id,"totalGroups",i.getValue(o.id,"totalGroups")-1),i.getValue(o.id,"contexts").removeFromList(e.unfilteredGroupId)),d.exists(o.id)&&d.getValue(o.id,"groups").getFromListByID(e.unfilteredGroupId)&&(d.setValue(o.id,"total",d.getValue(o.id,"total")-1),d.getValue(o.id,"groups").removeFromList(e.unfilteredGroupId)),p.exists(e.groupID)&&p.removePhotoLocal(e.groupID,o.id),r&&r.declinePhotoLocal(o),l&&l.declinePhotoLocal(o)})),r}}}),"@VERSION@",{requires:["flickr-promise","group-pool-models"],optional:[]});YUI.add("group-contributor-models",(function(t){function e(t){e.superclass.constructor.call(this,t)}t.Models[this.name]=e,t.extend(e,t.FlickrModelRegistry,{name:this.name,attributes:{nsid:{validator:function(e,r){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},dateJoined:{validator:function(e){return t.AttributeHelpers.validateDate(e)},setter:function(e){return t.AttributeHelpers.coerceDate(e)},serialize:function(t){return t.format("X")},deserialize:function(e){return t.moment(e,"X")}},groupDiscussionCount:{validator:function(e){return t.AttributeHelpers.validateInteger(e)},setter:function(e){return t.AttributeHelpers.coerceInteger(e)},defaultValue:0},groupPhotoCount:{validator:function(e){return t.AttributeHelpers.validateInteger(e)},setter:function(e){return t.AttributeHelpers.coerceInteger(e)},defaultValue:0},pathAlias:{validator:function(e,r){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},rank:{validator:function(e){return t.AttributeHelpers.validateInteger(e)},setter:function(e){return t.AttributeHelpers.coerceInteger(e)}},realname:{validator:function(e,r){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},username:{validator:function(e,r){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},latestPhotoId:{validator:function(e,r){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},latestPhotoTitle:{validator:function(e,r){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)}},buddyicon:{},latestPhotoUrl:{readOnly:!0,derivedBy:["contributorUrl","latestPhotoId"],getter:function(t,e){return!!this.getValue(e,"latestPhotoId")&&this.getValue(e,"contributorUrl")+this.getValue(e,"latestPhotoId")+"/"}},displayname:{readOnly:!0,derivedBy:["username"],getter:function(t,e){return this.getValue(e,"username")}},contributorUrl:{readOnly:!0,derivedBy:["id","pathAlias"],getter:function(t,e){return"/photos/"+(this.getValue(e,"pathAlias")||this.getValue(e,"nsid"))+"/"}},isPro:{defaultValue:!1,setter:function(e){return t.AttributeHelpers.coerceBoolean(e)}},proBadge:{defaultValue:"standard",setter:function(e){return t.AttributeHelpers.coerceString(e)}}}})}),"@VERSION@",{requires:["flickr-model-registry","flickr-promise","attribute-helpers","moment"]});YUI.add("flickr-groups-getTopContributors-fetcher",(function(o,r){"use strict";function t(r,t,e){var i={id:t+"-"+r.id+"-"+e,nsid:r.id,dateJoined:r.dateJoined?o.moment(r.dateJoined.toString(),"X"):o.moment(),groupDiscussionCount:r.groupDiscussionCount,groupPhotoCount:r.groupPhotoCount,pathAlias:r.pathAlias,rank:r.rank,realname:r.realname,username:r.username,isPro:r.isPro,proBadge:r.proBadge,buddyicon:r.iconurls};return r.latestPhoto&&(i.latestPhotoId=r.latestPhoto.id,i.latestPhotoTitle=r.latestPhoto.name),i}o.namespace("ModelFetchers")["flickr-groups-getTopContributors"]={run:function(t,e){var i=this;return o.Promise.all([e.callAPI("flickr.groups.getTopContributors",this._processParams(t),!0),e.getModelRegistry("group-top-contributors-models"),e.getModelRegistry("group-contributor-models")]).then((function(o){return i._processResponse(o,t)}),o.FetcherErrorLogger(r))},_processParams:function(o){return{group_id:o.id,type:"all",extras:"include_viewer,is_pro,icon_urls"}},_processResponse:function(o,r){var e,i,s,n=o[0],u=o[1],a=o[2];return i={photoContributors:[],discussionContributors:[],id:r.id},n&&n.contributors&&[{k:"photos",v:"photoContributors"},{k:"discussions",v:"discussionContributors"}].forEach((function(o){n.contributors[o.k]&&(e=n.contributors[o.k]).contributor&&e.contributor.forEach((function(e){s=t(e,o.k,r.id),i[o.v].push(a.addOrUpdate(s))}))})),n&&n.viewer&&0!==n.viewer.length?(s=t(n.viewer,"viewer",r.id),i.viewer=a.addOrUpdate(s)):i.viewer=null,u.addOrUpdate(i),u.proxy(i.id)}}}),"@VERSION@",{requires:["flickr-promise","api-helper","moment","url-helper"],optional:["group-top-contributors-models","group-contributor-models"]});YUI.add("group-top-contributors-models",(function(t){function r(t){r.superclass.constructor.call(this,t)}t.Models[this.name]=r,t.extend(r,t.FlickrModelRegistry,{name:this.name,remote:{read:function(r){var o=this;return t.ModelFetchers["flickr-groups-getTopContributors"].run(r,this.appContext).then((function(t){return o}))}},attributes:{viewer:{isModel:!0,defaultValue:null},contributors:{isCollection:!0},photoContributors:{isCollection:!0},discussionContributors:{isCollection:!0}}})}),"@VERSION@",{requires:["flickr-model-registry","flickr-promise","flickr-groups-getTopContributors-fetcher","attribute-helpers"]});YUI.add("group-pool-models",(function(t){function e(t){e.superclass.constructor.call(this,t)}t.Models[this.name]=e,t.extend(e,t.FlickrModelRegistry,{name:this.name,remote:{read:function(e){return t.ListFetchers["flickr-groups-pools-getPhotos"].run(e,this.appContext)},addPhoto:function(e,o){return e.registryName=this.name,t.ModelCreators["flickr-groups-pools-add"].run(e,o)},removePhoto:function(e,o){return e.registryName=this.name,t.ModelDeletors["flickr-groups-pools-remove"].run(e,o)},invitePhoto:function(e,o){return t.ModelCreators["flickr-groups-invite-photo-invite"].run(e,o)},cancelPhotoInvitation:function(e,o){return t.ModelDeletors["flickr-groups-invite-photo-cancel"].run(e,o)},acceptPhoto:function(e,o){return t.ModelUpdaters["flickr-groups-admin-acceptPhoto"].run(e,o)},declinePhoto:function(e,o){return t.ModelDeletors["flickr-groups-admin-declinePhoto"].run(e,o)}},addPhotoRemote:function(t,e){return this.remote.addPhoto.call(this,{photoID:e,groupID:t},this.appContext)},removePhotoRemote:function(t,e){return this.remote.removePhoto.call(this,{photoIds:e,groupID:t},this.appContext)},invitePhotoRemote:function(t,e){return this.remote.invitePhoto.call(this,{photoID:e,groupID:t},this.appContext)},cancelPhotoInvitationRemote:function(t,e){return this.remote.cancelPhotoInvitation.call(this,{photoID:e,groupID:t},this.appContext)},hasPhoto:function(t,e){return this.getValue(t,"photoPageList").getFromListByID(e)||this.getValue(t,"photoContextList").getFromListByID(e)},acceptPhotoRemote:function(t,e){return this.remote.acceptPhoto.call(this,{photoIds:e,groupID:t},this.appContext)},declinePhotoRemote:function(t,e){return this.remote.declinePhoto.call(this,{photoIds:e,groupID:t},this.appContext)},addPhotoLocal:function(t,e){var o=this.getValue(t,"group");return this.getValue(t,"photoPageList").unshift(e),this.getValue(t,"photoPageList").totalItems++,this.getValue(t,"photoContextList").hasMaxBoundary()&&this.getValue(t,"photoContextList").appendToList(e),o.setValue("poolCount",o.getValue("poolCount")+1),this},removePhotoLocal:function(t,e){var o=this.getValue(t,"group");return this.getValue(t,"photoPageList").removeFromList(e.getValue("id")),this.getValue(t,"photoPageList").totalItems--,this.getValue(t,"photoContextList").removeFromList(e.getValue("id")),o.setValue("poolCount",o.getValue("poolCount")-1),this},acceptPhotoLocal:function(t,e){var o=this.getValue(t,"group");return o.setValue("pendingCount",o.getValue("pendingCount")-1),this.addPhotoLocal(t,e),this},declinePhotoLocal:function(t,e){var o=this.getValue(t,"group");return o.setValue("pendingCount",o.getValue("pendingCount")-1),this},attributes:{displayType:{readOnly:!0,defaultFn:function(){return"group"}},pathAlias:{validator:function(e,o){return t.AttributeHelpers.validateString(e)},setter:function(e){return t.AttributeHelpers.coerceString(e)},defaultFn:function(t){return t}},photoPageList:{isCollection:!0,pageFetch:{listFetcher:t.ListFetchers["flickr-groups-pools-getPhotos"]}},photoContextList:{isListProxy:!0,contextFetch:{listFetcher:t.ListFetchers["flickr-groups-pools-getContext"],listItemIdField:"photoId"}},group:{isModel:!0},urlSuffix:{readOnly:!0,derivedBy:["pathAlias"],defaultFn:function(t){var e=this.getValue(t,"pathAlias");return e||(e=t),"pool-"+e}},url:{readOnly:!0,derivedBy:["group"],defaultFn:function(t){return this.getValue(t,"group").getValue("url")}},title:{readOnly:!0,derivedBy:["group"],defaultFn:function(t){return this.getValue(t,"group").getValue("title")}},poolCount:{readOnly:!0,derivedBy:["group"],defaultFn:function(t){return this.getValue(t,"group").getValue("poolCount")}},filteredPoolCount:{validator:function(e){return t.AttributeHelpers.validateInteger(e)},setter:function(e){return t.AttributeHelpers.coerceInteger(e)},defaultFn:function(t){return this.getValue(t,"group").getValue("poolCount")}},friendlyPoolCount:{readOnly:!0,derivedBy:["group"],defaultFn:function(t){return this.getValue(t,"group").getValue("friendlyPoolCount")}}}},{buildCompoundId:function(t,e){return t+"-"+e},extractGroupFromCompoundId:function(t){return t.split("-")[0]}})}),"@VERSION@",{requires:["flickr-model-registry","flickr-promise","flickr-groups-pools-getContext-fetcher","flickr-groups-pools-getPhotos-fetcher","flickr-groups-pools-add-creator","flickr-groups-pools-remove-deletor","flickr-groups-invite-photo-invite-creator","flickr-groups-invite-photo-cancel-deletor","flickr-groups-admin-acceptPhoto-updater","flickr-groups-admin-declinePhoto-deletor","attribute-helpers"],optional:["group-top-contributors-models"]});YUI.add("flickr-groups-create-creator",(function(e,r){"use strict";e.namespace("ModelCreators")["flickr-groups-create"]={run:function(o,t){var i={user_id:o.userId,name:o.name,description:o.description,grouptype:o.privacyLevel,age_restriction:o.ageRestriction,safety_level:o.safetyLevel};return t.callAPI("flickr.groups.create",i).then((function(r){return"ok"===r.stat?t.getModel("group-pool-models",r.groupNsid):e.Promise.reject(r)}),e.FetcherErrorLogger(r))}}}),"@VERSION@",{requires:["flickr-promise","group-pool-models"],optional:[]});