YUI.add("flickr-photos-setMeta-updater",(function(t,e){"use strict";var o=require("hermes-core/flog")(e);t.namespace("ModelUpdaters")["flickr-photos-setMeta"]={run:function(r,i){var s={};return r.fullResponse?(s.full_response=1,s.photo_ids=r.photoId):s.photo_id=r.photoId,void 0!==r.title&&(s.title=r.title),void 0!==r.description&&(s.description=r.description),t.Promise.all([i.callAPI("flickr.photos.setMeta",s),i.getModelRegistry("photo-models")]).then((function(t){var e=t[0],i=t[1];if(r.fullResponse){if("errors"in e)return e.api="setMeta",e}else{if(!i.exists(r.photoId))throw new Error("[flickr-photos-setMeta-updater] - Photo model can not be updated if it does not exist");e.photo&&e.photo.title&&e.photo.description?i.setValues(r.photoId,{title:e.photo.title.content,description:e.photo.description.content}):o.warn("No updated data returned from API.")}}),(function(t){throw r.fullResponse&&(t.photoIds=r.photoId,t.returnApi="setMeta"),t})).then(null,t.FetcherErrorLogger(e))}}}),"@VERSION@",{requires:["flickr-promise"],optionalRequires:["hermes-core"],optional:[]});YUI.add("flickr-photos-licenses-setLicense-updater",(function(e,s){"use strict";e.namespace("ModelUpdaters")["flickr-photos-licenses-setLicense"]={run:function(o,n){var t={};return o.fullResponse?(t.photo_ids=o.photoId,t.full_response=1):t.photo_id=o.photoId,t.license_id=o.license,n.callAPI("flickr.photos.licenses.setLicense",t).then((function(e){if("errors"in e)return e.api="setLicense",e}),(function(e){throw o.fullResponse&&(e.photoIds=o.photoId,e.returnApi="setLicense"),e})).then(null,e.FetcherErrorLogger(s))}}}),"@VERSION@",{requires:["flickr-promise"]});YUI.add("flickr-photos-setSafetyLevel-updater",(function(e,t){"use strict";e.namespace("ModelUpdaters")["flickr-photos-setSafetyLevel"]={run:function(o,r){var s={};return o.fullResponse?(s.photo_ids=o.photoId,s.full_response=1):s.photo_id=o.photoId,s.safety_level=o.safetyLevel+1,r.callAPI("flickr.photos.setSafetyLevel",s).then((function(e){if("errors"in e)return e.api="setSafety",e}),(function(e){throw o.fullResponse&&(e.photoIds=o.photoId,e.returnApi="setSafety"),e})).then(null,e.FetcherErrorLogger(t))}}}),"@VERSION@",{requires:["flickr-promise"]});YUI.add("flickr-photos-setContentType-updater",(function(t,e){"use strict";t.namespace("ModelUpdaters")["flickr-photos-setContentType"]={run:function(o,n){var r={};return o.fullResponse?(r.photo_ids=o.photoId,r.full_response=1):r.photo_id=o.photoId,r.content_type=o.contentType+1,n.callAPI("flickr.photos.setContentType",r).then((function(t){if("errors"in t)return t.api="setContentType",t}),(function(t){throw o.fullResponse&&(t.photoIds=o.photoId,t.returnApi="setContentType"),t})).then(null,t.FetcherErrorLogger(e))}}}),"@VERSION@",{requires:["flickr-promise"]});YUI.add("photo-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-photos-getInfo"].run(t,this.appContext)},update:function(t,o){var r=[];return("title"in o||"description"in o)&&r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,title:o.title?o.title.newVal:this.getValue(t,"title"),description:o.description?o.description.newVal:this.getValue(t,"description")},this.appContext)),"license"in o&&r.push(e.ModelUpdaters["flickr-photos-licenses-setLicense"].run({photoId:t,license:o.license.newVal},this.appContext)),"safetyLevel"in o&&r.push(e.ModelUpdaters["flickr-photos-setSafetyLevel"].run({photoId:t,safetyLevel:o.safetyLevel.newVal},this.appContext)),"contentType"in o&&r.push(e.ModelUpdaters["flickr-photos-setContentType"].run({photoId:t,contentType:o.contentType.newVal},this.appContext)),e.Promise.all(r)},batchUpdate:function(t,o){var r=[];return"safetyLevel"in o&&r.push(e.ModelUpdaters["flickr-photos-setSafetyLevel"].run({photoId:t,safetyLevel:parseInt(o.safetyLevel,10),fullResponse:1},this.appContext)),"title"in o&&"description"in o?r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,title:o.title,description:o.description,fullResponse:1},this.appContext)):"title"in o?r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,title:o.title,fullResponse:1},this.appContext)):"description"in o&&r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,description:o.description,fullResponse:1},this.appContext)),"license"in o&&r.push(e.ModelUpdaters["flickr-photos-licenses-setLicense"].run({photoId:t,license:o.license,fullResponse:1},this.appContext)),e.Promise.all(r)}},getLargestSize:e.PhotoModelHelper.getLargestSize,getSizeToFit:e.PhotoModelHelper.getSizeToFit,getSizeIfExact:e.PhotoModelHelper.getSizeIfExact,isSizeSquare:e.PhotoModelHelper.isSizeSquare,isPhotoSquare:e.PhotoModelHelper.isPhotoSquare,getSizeForCanvas:e.PhotoModelHelper.getSizeForCanvas,getGuestpass:function(t){var o=this;return new e.Promise((function(e,r){o.getValue(t,"guestpass")?e():o.appContext.callAPI("flickr.sharing.createGuestpass",{photo:t}).then((function(r){o.setValue(t,"guestpass",r.guestpass.url),e()}))}))},canVr:function(t){var o,r=!1;return this.appContext.flipper.isFlipped("enable-vr")?(this&&(o=this.getValue(t,"aspectRatio"))&&o>=1.99&&o<=2.01&&(r=!0),r?e.Promise.all([this.appContext.callAPI("flickr.vr.isEquirectangular",{photo_id:t})]).then((function(t){return e.Promise.resolve(!!t[0].is_equirectangular)})):e.Promise.resolve(!1)):e.Promise.resolve(!1)},attributes:{title:e.PhotoModelHelper.attributes.title,description:e.PhotoModelHelper.attributes.description,mediaType:e.PhotoModelHelper.attributes.mediaType,contentType:e.PhotoModelHelper.attributes.contentType,license:e.PhotoModelHelper.attributes.license,isVideo:e.PhotoModelHelper.attributes.isVideo,isOwner:e.PhotoModelHelper.attributes.isOwner,sizes:e.PhotoModelHelper.attributes.sizes,descendingSizes:e.PhotoModelHelper.attributes.descendingSizes,ascendingSizes:e.PhotoModelHelper.attributes.ascendingSizes,aspectRatio:e.PhotoModelHelper.attributes.aspectRatio,needsInterstitial:e.PhotoModelHelper.attributes.needsInterstitial,canComment:e.PhotoModelHelper.attributes.canComment,canPublicComment:e.PhotoModelHelper.attributes.canPublicComment,url:e.PhotoModelHelper.attributes.url,rotation:e.PhotoModelHelper.attributes.rotation,owner:{isModel:!0},engagement:{isModel:!0},secret:{},canAddMeta:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!0},oWidth:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:0},oHeight:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:0},safetyLevel:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},guestpass:{},sizesForAlbum:{readOnly:!0,derivedBy:["sizes"],defaultFn:function(t){var o=this.getValue(t,"sizes");return e.Object.each(o,(function(e,t){e.src=e.url})),o}},stats:{isModel:!0},visibilitySource:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:1},isVideoPending:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},isVideoFailed:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},systemModerated:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1}}})}),"@VERSION@",{requires:["flickr-model-registry","flickr-promise","photo-model-helper","flickr-photos-getInfo-fetcher","flickr-photos-setPerms-updater","flickr-photos-setMeta-updater","flickr-photos-licenses-setLicense-updater","flickr-photos-setSafetyLevel-updater","flickr-photos-setContentType-updater","attribute-helpers"]});YUI.add("flickr-groups-pools-getContext-fetcher",(function(e,o){"use strict";e.namespace("ListFetchers")["flickr-groups-pools-getContext"]={run:function(t,s){var r=this;return e.Promise.all([s.callAPI("flickr.groups.pools.getContext",this._processParams(t),!0),s.getModelRegistry("group-pool-models"),s.getModelRegistry("photo-models"),s.getModelRegistry("person-models"),s.getModelRegistry("photo-engagement-models"),s.getModelRegistry("photo-stats-models")]).then((function(e){return r._processResponse(e,t)}),(function(e){throw 2===e.code&&"Photo not in pool"===e.message&&(e.notInContext=!0),e})).then(null,e.FetcherErrorLogger(o))},_processParams:function(o){var t={photo_id:o.photoId,extras:e.APIHelper.request.getRebootPhotoExtras()+",datecreate",num_prev:o.numNext,num_next:o.numPrev,get_group_info:1};if(o.id)t.group_id=o.id;else{if(!o.pathAlias)throw new Error("[flickr-groups-pools-getPhotos-fetcher] `id` or `pathAlias` is required.");t.group_path_alias=o.pathAlias}return t},_processResponse:function(o,t){var s,r,n,p,i,a,l,h,g=o[0],d=o[1],u=o[2],m=o[3],c=o[4],x=o[5],y=[],M=u.proxy(t.photoId);return r=g.prevphotos,n=g.nextphotos,s=e.APIHelper.response.parsePhotos({photos:r.photo,personModelRegistry:m,photoModelRegistry:u,photoEngagementModelRegistry:c,photoStatsModelRegistry:x}),y=e.APIHelper.response.parsePhotos({photos:n.photo,personModelRegistry:m,photoModelRegistry:u,photoEngagementModelRegistry:c,photoStatsModelRegistry:x}),i=!!(l=d.getValue(t.id,"photoContextList")).hasMinBoundary&&l.hasMinBoundary(),a=!!l.hasMaxBoundary&&l.hasMaxBoundary(),p=l.getList(),h=e.APIHelper.response.addOrReplaceListByContext({model:M,next:s,prev:y.reverse(),current:p,hasMin:i,hasMax:a,numNext:t.numNext,numPrev:t.numPrev}),d.setValue(t.id,"photoContextList",h),{next:s,previous:y.reverse()}}}}),"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["photo-models","photo-engagement-models","photo-stats-models","group-models"]});YUI.add("flickr-groups-pools-add-creator",(function(o,e){"use strict";o.namespace("ModelCreators")["flickr-groups-pools-add"]={run:function(t,r){var p=this,s=this._processParams(t),l=t.registryName||"group-pool-models",u={apiResponse:r.callAPI("flickr.groups.pools.add",s),groupPoolModel:r.getModel(l,t.groupID),photoModel:r.getModel("photo-models",t.photoID),photoGroupsModelRegistry:r.getModelRegistry("photo-groups-models"),photoContextsModelRegistry:r.getModelRegistry("photo-contexts-models")};return t.unfilteredGroupId=s.group_id,"group-pool-models"!==l&&(u.unfilteredGroupPoolModel=r.getModel("group-pool-models",t.unfilteredGroupId)),new o.FlickrPromise(u).then((function(o){return p._processResponse(o,t)}),o.FetcherErrorLogger(e))},_processParams:function(e){return{photo_id:e.photoID,group_id:o.Models["group-pool-models"].extractGroupFromCompoundId(e.groupID),detailed_errors:1}},_processResponse:function(e,t){var r=e.apiResponse,p=e.groupPoolModel,s=e.photoModel,l=e.photoGroupsModelRegistry,u=e.photoContextsModelRegistry,d=e.unfilteredGroupPoolModel;if("ok"===r.stat){if(p&&!p.hasPhoto(s.getValue("id"))&&p.addPhotoLocal(s),d&&!d.hasPhoto(s.getValue("id"))&&d.addPhotoLocal(s),l.exists(t.photoID)&&!l.getValue(t.photoID,"groups").getFromListByID(t.unfilteredGroupId)&&(l.getValue(t.photoID,"groups").unshift(p),l.setValue(t.photoID,"total",l.getValue(t.photoID,"total")+1)),u.exists(t.photoID)&&!u.getValue(t.photoID,"contexts").getFromListByID(t.unfilteredGroupId)&&(u.setValue(t.photoID,"totalGroups",u.getValue(t.photoID,"totalGroups")+1),u.getValue(t.photoID,"contexts").push(p)),o.Snowplough){var g={id:p.getValue("id")},a=[];a=(a=a.concat(o.Snowplough.getGroupContext(g))).concat(o.Snowplough.getPhotoContextFromModel(s)),o.Snowplough.sendStructuredEvent({category:"group",action:"add_photo"},a)}return p}}}}),"@VERSION@",{requires:["flickr-promise","group-pool-models"],optional:[]});