YUI.add("flickr-photos-addNotes-creator",function(e,t){"use strict";function n(e){return{photo_id:e.photoId,note_x:e.left,note_y:e.top,note_w:e.width,note_h:e.height,note_text:e.text}}function r(e,t){var n=e[0],r=e[1],i=e[2],s=[];return i.exists(n.note.id)||i.add({id:n.note.id,left:t.left,top:t.top,width:t.width,height:t.height,text:t.text,author:t.author,authorName:t.authorName}),s.push(i.proxy(n.note.id)),r.exists(t.photoId)?s.forEach(function(e){r.getValue(t.photoId,"notes").appendToList(e)}):r.add({id:t.photoId,notes:s}),s}function i(n,r){var i=this;return e.Promise.all([r.callAPI("flickr.photos.notes.add",this._processParams(n)),r.getModelRegistry("photo-notes-models"),r.getModelRegistry("note-models")]).then(function(e){return i._processResponse(e,n)},e.FetcherErrorLogger(t))}e.namespace("ModelCreators")["flickr-photos-addNotes"]={run:i,_processParams:n,_processResponse:r}},"@VERSION@",{requires:["flickr-promise"],optional:["photo-notes-models","note-models"]});
YUI.add("flickr-photos-editNote-updater",function(e,t){"use strict";function n(e){return{note_id:e.noteId,note_x:e.noteX,note_y:e.noteY,note_w:e.noteW,note_h:e.noteH,note_text:e.noteText}}function r(n,r){return r.callAPI("flickr.photos.notes.edit",this._processParams(n)).then(null,e.FetcherErrorLogger(t))}e.namespace("ModelUpdaters")["flickr-photos-editNote"]={run:r,_processParams:n}},"@VERSION@",{requires:["flickr-promise"]});
YUI.add("flickr-photos-deleteNote-deletor",function(e,t){"use strict";function n(n,r){var i={note_id:n};return r.callAPI("flickr.photos.notes.delete",i).then(null,e.FetcherErrorLogger(t))}e.namespace("ModelDeletors")["flickr-photos-deleteNote"]={run:n}},"@VERSION@",{requires:["flickr-promise"],optional:[]});
YUI.add("note-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:{create:function(t){return e.ModelCreators["flickr-photos-addNotes"].run(t,this.appContext)},update:function(t,n){var r;return r={noteId:t,noteX:this.getValue(t,"left"),noteY:this.getValue(t,"top"),noteW:this.getValue(t,"width"),noteH:this.getValue(t,"height"),noteText:this.getValue(t,"text")},e.ModelUpdaters["flickr-photos-editNote"].run(r,this.appContext)},"delete":function(t){return e.ModelDeletors["flickr-photos-deleteNote"].run(t,this.appContext)}},attributes:{authorName:{setter:function(e){return e}},author:{setter:function(e){return e}},left:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},top:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},width:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},height:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},text:{setter:function(e){return e}}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-photos-addNotes-creator","flickr-photos-editNote-updater","flickr-photos-deleteNote-deletor","attribute-helpers"]});
YUI.add("flickr-photos-deleteAutotags-deletor",function(e,t){"use strict";function n(n,r){return r.callAPI("flickr.photos.deleteAutotags",n).then(null,e.FetcherErrorLogger(t))}e.namespace("ModelDeletors")["flickr-photos-deleteAutotags"]={run:n}},"@VERSION@",{requires:["flickr-promise"],optional:[]});
YUI.add("autotag-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:{"delete":function(t){return e.ModelDeletors["flickr-photos-deleteAutotags"].run(t,this.appContext)}},attributes:{autotagValue:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)}},score:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)}},isPrivate:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},searchUrl:{derivedBy:["autotagValue"],readOnly:!0,defaultFn:function(e){var t=this.getValue(e,"autotagValue");return"/search/?q="+t}}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-photos-deleteAutotags-deletor"]});
YUI.add("photo-autotags-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:{"delete":function(t){return e.ModelDeletors["flickr-photos-deleteAutotags"].run(t,this.appContext)}},attributes:{autotags:{isCollection:!0}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-photos-deleteAutotags-deletor"]});
YUI.add("flickr-photos-setPerms-updater",function(e,t){"use strict";function n(e,t){var n=e[0],r=e[1],i;i=r.attributeSearch({normalizedId:t.nsid},!0),i.forEach(function(e){r.remove(e)});if(t.full_response)return n.photoIdsSent=t.photo_ids,n}function r(n,r){var i=this;return n.nsid=r.getViewer().nsid,e.Promise.all([r.callAPI("flickr.photos.setPerms",n),r.getModelRegistry("photostream-models")]).then(function(e){return i._processResponse(e,n)},e.FetcherErrorLogger(t))}e.namespace("ModelUpdaters")["flickr-photos-setPerms"]={run:r,_processResponse:n}},"@VERSION@",{requires:["flickr-promise"]});
YUI.add("flickr-photos-setMeta-updater",function(e,t){"use strict";function r(r,i){var s={};return r.fullResponse?(s.full_response=1,s.photo_ids=r.photoId):s.photo_id=r.photoId,typeof r.title!="undefined"&&(s.title=r.title),typeof r.description!="undefined"&&(s.description=r.description),e.Promise.all([i.callAPI("flickr.photos.setMeta",s),i.getModelRegistry("photo-models")]).then(function(e){var t=e[0],i=e[1];if(r.fullResponse){if("errors"in t)return t.api="setMeta",t}else{if(!i.exists(r.photoId))throw new Error("[flickr-photos-setMeta-updater] - Photo model can not be updated if it does not exist");!t.photo||!t.photo.title||!t.photo.description?n.warn("No updated data returned from API."):i.setValues(r.photoId,{title:t.photo.title.content,description:t.photo.description.content})}},function(e){throw r.fullResponse&&(e.photoIds=r.photoId,e.returnApi="setMeta"),e}).then(null,e.FetcherErrorLogger(t))}var n=require("lib/flog")(t);e.namespace("ModelUpdaters")["flickr-photos-setMeta"]={run:r}},"@VERSION@",{requires:["flickr-promise"],optional:[]});
YUI.add("flickr-photos-licenses-setLicense-updater",function(e,t){"use strict";function n(n,r){var i={};return n.fullResponse?(i.photo_ids=n.photoId,i.full_response=1):i.photo_id=n.photoId,i.license_id=n.license,r.callAPI("flickr.photos.licenses.setLicense",i).then(function(e){if("errors"in e)return e.api="setLicense",e},function(e){throw n.fullResponse&&(e.photoIds=n.photoId,e.returnApi="setLicense"),e}).then(null,e.FetcherErrorLogger(t))}e.namespace("ModelUpdaters")["flickr-photos-licenses-setLicense"]={run:n}},"@VERSION@",{requires:["flickr-promise"]});
YUI.add("flickr-photos-setSafetyLevel-updater",function(e,t){"use strict";function n(n,r){var i={};return n.fullResponse?(i.photo_ids=n.photoId,i.full_response=1):i.photo_id=n.photoId,i.safety_level=n.safetyLevel+1,r.callAPI("flickr.photos.setSafetyLevel",i).then(function(e){if("errors"in e)return e.api="setSafety",e},function(e){throw n.fullResponse&&(e.photoIds=n.photoId,e.returnApi="setSafety"),e}).then(null,e.FetcherErrorLogger(t))}e.namespace("ModelUpdaters")["flickr-photos-setSafetyLevel"]={run:n}},"@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,n){var r=[];return("title"in n||"description"in n)&&r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,title:n.title?n.title.newVal:this.getValue(t,"title"),description:n.description?n.description.newVal:this.getValue(t,"description")},this.appContext)),"license"in n&&r.push(e.ModelUpdaters["flickr-photos-licenses-setLicense"].run({photoId:t,license:n.license.newVal},this.appContext)),"safetyLevel"in n&&r.push(e.ModelUpdaters["flickr-photos-setSafetyLevel"].run({photoId:t,safetyLevel:n.safetyLevel.newVal},this.appContext)),e.Promise.all(r)},batchUpdate:function(t,n){var r=[];return"safetyLevel"in n&&r.push(e.ModelUpdaters["flickr-photos-setSafetyLevel"].run({photoId:t,safetyLevel:parseInt(n.safetyLevel,10),fullResponse:1},this.appContext)),"title"in n&&"description"in n?r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,title:n.title,description:n.description,fullResponse:1},this.appContext)):"title"in n?r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,title:n.title,fullResponse:1},this.appContext)):"description"in n&&r.push(e.ModelUpdaters["flickr-photos-setMeta"].run({photoId:t,description:n.description,fullResponse:1},this.appContext)),"license"in n&&r.push(e.ModelUpdaters["flickr-photos-licenses-setLicense"].run({photoId:t,license:n.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 n=this;return new e.Promise(function(e,r){n.getValue(t,"guestpass")?e():n.appContext.callAPI("flickr.sharing.createGuestpass",{photo:t}).then(function(r){n.setValue(t,"guestpass",r.guestpass.url),e()})})},canVr:function(t){var n=this,r,i=!1;return this.appContext.flipper.isFlipped("enable-vr")?(n&&(r=n.getValue(t,"aspectRatio"),r&&r>=1.99&&r<=2.01&&(i=!0)),i?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,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},isHD:{},secret:{},canAddMeta:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!0},isMarketplacePrintable:{defaultFn:function(e){return!1}},isMarketplaceLicensable:e.PhotoModelHelper.attributes.isMarketplaceLicensable,marketplaceLicensingUrl:e.PhotoModelHelper.attributes.marketplaceLicensingUrl,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:{},hasInvalidColorspaceForPrint:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},sizesForAlbum:{readOnly:!0,derivedBy:["sizes"],defaultFn:function(t){var n=this.getValue(t,"sizes");return e.Object.each(n,function(e,t){e.src=e.url}),n}},stats:{isModel:!0},curation:{isModel:!0},visibilitySource:{validator:function(t){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:1}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-promise","photo-model-helper","photo-curation-models","flickr-photos-getInfo-fetcher","flickr-photos-setPerms-updater","flickr-photos-setMeta-updater","flickr-photos-licenses-setLicense-updater","flickr-photos-setSafetyLevel-updater","attribute-helpers"]});
YUI.add("flickr-photos-getInfo-fetcher",function(e,t){"use strict";function n(t){var n,r;return n=["sizes","icon_urls","ignored","rev_ignored","venue","datecreate"].join(","),n=n+","+e.APIHelper.request.getRebootPhotoExtras(),r={datecreate:1,extras:n,photo_id:t.id,get_contexts:1,primary_photo_extras:"url_sq, url_t, url_s, url_m"},t.userId?r.user_id=t.userId:t.pathAlias&&(r.path_alias=t.pathAlias),t.context&&(r.context=t.context,r.num_prev=1,r.num_next=1),t.scrappy&&(e.APIHelper.request.addStaticMapsParams(r),delete r.get_contexts,delete r.primary_photo_extras,delete r.context),r}function r(t,n,r){var s=t.apiResponse,o=t.photoRegistry,u=t.personRegistry,a=t.personRelationshipRegistry,f=t.photoEngagementRegistry,l=t.photoStatsRegistry,c=t.photoPrivacyRegistry,h=t.photoNotesRegistry,p=t.noteRegistry,d=t.photoGeoRegistry,v=t.photoLocationRegistry,m=t.photoHeadMetaRegistry,g=t.groupRegistry,y,b={},w,E,S,x,T,N,C=[],k,L,A;if(!s.photo.sizes)throw new Error("Missing photo sizes from flickr.photos.getInfo call.");w={id:s.photo.id,title:s.photo.title.content,description:s.photo.description.content,sizes:e.APIHelper.response.parsePhotoSize(s.photo.sizes.size,!0),needsInterstitial:s.photo.needsInterstitial,canComment:s.photo.editability.cancomment,canPublicComment:s.photo.publiceditability.cancomment,canAddMeta:s.photo.editability.canaddmeta,safetyLevel:s.photo.safetyLevel,license:s.photo.license,mediaType:s.photo.media,secret:s.photo.secret,isHD:e.APIHelper.response.isHD(s.photo.sizes.size),rotation:s.photo.rotation,hasInvalidColorspaceForPrint:s.photo.hasInvalidColorspaceForPrint,isMarketplacePrintable:s.photo.isMarketplacePrintable,isMarketplaceLicensable:s.photo.isMarketplaceLicensable?s.photo.isMarketplaceLicensable:!1,marketplaceLicensingUrl:s.photo.marketplaceLicensingUrl?s.photo.marketplaceLicensingUrl:"",oWidth:s.photo.oWidth?parseInt(s.photo.oWidth,10):"",oHeight:s.photo.oHeight?parseInt(s.photo.oHeight,10):"",visibilitySource:s.photo.visibilitySource},E={id:s.photo.owner.nsid,username:s.photo.owner.username,realname:s.photo.owner.realname,pathAlias:s.photo.owner.pathAlias,buddyicon:e.APIHelper.response.agnosticizeFarmPathTransferProtocol(s.photo.owner.iconurls),isAdFree:s.photo.owner.isAdFree,isPro:s.photo.owner.ispro,dateCreated:s.photo.owner.datecreate,location:s.photo.owner.location},S={id:s.photo.owner.nsid,pathAlias:s.photo.owner.pathAlias,isContact:s.photo.contactIscontact,isFamily:s.photo.contactIsfamily,isFriend:s.photo.contactIsfriend,isIgnored:s.photo.owner.isignored,isIgnoredBy:s.photo.owner.revIgnored},x={id:s.photo.id,ownerNsid:s.photo.owner.nsid,isFaved:s.photo.isfavorite||!1,canShare:s.photo.usage.canshare,canDownload:s.photo.usage.candownload,commentCount:s.photo.comments.content,noteCount:s.photo.notes&&s.photo.notes.note&&s.photo.notes.note.length,faveCount:s.photo.countFaves,viewCount:s.photo.views},T={id:s.photo.id,dateTaken:s.photo.dates.taken,datePosted:s.photo.dates.posted,takenGranularity:s.photo.dates.takengranularity,isDateTakenUnknown:s.photo.datetakenunknown||s.photo.datetakenunknown==="1"||s.photo.datetakenunknown===1},k={id:s.photo.id,title:s.photo.HTMLMETA["og:title"],noindexfollow:s.photo.owner.noindexfollow,keywords:s.photo.HTMLMETA.keywords,"og:title":s.photo.HTMLMETA["og:title"],"og:description":s.photo.HTMLMETA["og:description"],"og:type":s.photo.HTMLMETA["og:type"],"og:url":s.photo.HTMLMETA["og:url"],"og:image":s.photo.HTMLMETA["og:image"],"og:image:width":s.photo.HTMLMETA["og:image:width"],"og:image:height":s.photo.HTMLMETA["og:image:height"],"flickr_photos:by":s.photo.HTMLMETA["flickr_photos:by"],"flickr_photos:camera":s.photo.HTMLMETA["flickr_photos:camera"],"flickr_photos:sets":s.photo.HTMLMETA["flickr_photos:sets"],"flickr_photos:groups":s.photo.HTMLMETA["flickr_photos:groups"],"flickr_photos:galleries":s.photo.HTMLMETA["flickr_photos:galleries"],"twitter:card":s.photo.HTMLMETA["twitter:card"],"twitter:description":s.photo.HTMLMETA["twitter:description"],"twitter:app:url:iphone":s.photo.HTMLMETA["twitter:app:url:iphone"],"twitter:creator":s.photo.HTMLMETA["twitter:creator"],pinterest:s.photo.HTMLMETA.pinterest},N={id:s.photo.id,isPublic:s.photo.visibility.ispublic,isVisibleByFriends:s.photo.visibility.isfriend,isVisibleByFamily:s.photo.visibility.isfamily,permAddMeta:s.photo.permissions?s.photo.permissions.permaddmeta:0,permComment:s.photo.permissions?s.photo.permissions.permcomment:0},s.photo&&s.photo.notes&&s.photo.notes.note&&e.Array(s.photo.notes.note).forEach(function(e){C.push(p.addOrUpdate({id:e.id,authorName:e.authorname,author:e.author,left:e.x,top:e.y,width:e.w,height:e.h,text:e.content}))}),L=e.ModelFetchers["flickr-photos-getLocation"].mapResponse(s,d),w.owner=u.addOrUpdate(E),w.engagement=f.addOrUpdate(x),a.addOrUpdate(S),A=o.addOrUpdate(w),s.photo.isMarketplacePrintable&&A.setValue("isMarketplacePrintable",!0),s.photo.isMarketplaceLicensable&&A.setValue("isMarketplaceLicensable",!0),l.addOrUpdate(T),c.addOrUpdate(N),h.addOrUpdate({id:w.id,notes:C}),m.addOrUpdate(k),v.addOrUpdate(L),s.photo.contexts&&(y=t.contextsRegistry,b.faves=t.favoriteRegistry,b.gallery=t.galleryRegistry,b.pool=t.groupsPoolRegistry,b.set=t.setRegistry,b.stream=t.photostreamRegistry,i({photoModel:A,contextRegistries:b,contextsResponse:s.photo.contexts,personRegistry:u,contextsRegistry:y,photoEngagementRegistry:f,photoStatsRegistry:l,groupRegistry:g,apiParams:r}))}function i(t){var n=t.photoModel,r=t.contextRegistries,i=t.contextsResponse,s=t.personRegistry,o=t.contextsRegistry,u=t.photoEngagementRegistry,a=t.photoStatsRegistry,f=t.photoCurationModelRegistry,l=t.groupRegistry,c=t.apiParams,h=[];e.Object.each(r,function(t,r){i[r]&&e.Array.each(i[r],function(r){e.APIHelper.response.addContextToRegistry(r,t,s,l),h.push(t.proxy(r.id)),c.context&&function(){var i,o,l,h,p,d,v,m,g;i=t.getValue(r.id,"photoContextList"),o=i.hasMinBoundary?i.hasMinBoundary():!1,l=i.hasMaxBoundary?i.hasMaxBoundary():!1,h=i.getList(),d=r.nextphotos,v=r.prevphotos,m=d?e.APIHelper.response.parsePhotos
({photos:d.photo,personModelRegistry:s,photoModelRegistry:n.registry,photoEngagementModelRegistry:u,photoStatsModelRegistry:a,photoCurationModelRegistry:f}):[],g=v?e.APIHelper.response.parsePhotos({photos:v.photo,personModelRegistry:s,photoModelRegistry:n.registry,photoEngagementModelRegistry:u,photoStatsModelRegistry:a,photoCurationModelRegistry:f}):[];if(g.length||m.length)p=e.APIHelper.response.addOrReplaceListByContext({model:n,next:m,prev:g.reverse(),current:h,hasMin:o,hasMax:l,numNext:c.num_next,numPrev:c.num_prev});t.setValue(r.id,"photoContextList",p)}()})}),o.exists(n.id)||(o.add({id:n.id,totalGroups:i.pool?i.pool.length:0,totalSets:i.set?i.set.length:0,totalGalleries:i.gallery?i.gallery.length:0}),o.setValue(n.id,"contexts",h))}function s(n,r){var i=this,s,o;return r.flipper.isFlipped("enable-scrappy-photo-page")&&(n.scrappy=!0),o=!0,s=this._processParams(n),(new e.FlickrPromise({apiResponse:r.callAPI("flickr.photos.getInfo",s,o),photoRegistry:r.getModelRegistry("photo-models"),personRegistry:r.getModelRegistry("person-models"),personRelationshipRegistry:r.getModelRegistry("person-relationship-models"),photoEngagementRegistry:r.getModelRegistry("photo-engagement-models"),photoStatsRegistry:r.getModelRegistry("photo-stats-models"),photoCurationModelRegistry:r.getModelRegistry("photo-curation-models"),photoPrivacyRegistry:r.getModelRegistry("photo-privacy-models"),photoNotesRegistry:r.getModelRegistry("photo-notes-models"),noteRegistry:r.getModelRegistry("note-models"),photoGeoRegistry:r.getModelRegistry("photo-geo-models"),photoLocationRegistry:r.getModelRegistry("photo-location-models"),photoHeadMetaRegistry:r.getModelRegistry("photo-head-meta-models"),groupRegistry:r.getModelRegistry("group-models"),contextsRegistry:r.getModelRegistry("photo-contexts-models"),favoriteRegistry:r.getModelRegistry("favorite-models"),galleryRegistry:r.getModelRegistry("gallery-models"),groupsPoolRegistry:r.getModelRegistry("group-pool-models"),setRegistry:r.getModelRegistry("set-models"),photostreamRegistry:r.getModelRegistry("photostream-models")})).then(function(e){return i._processResponse(e,r.flipper,s)},e.FetcherErrorLogger(t))}e.namespace("ModelFetchers")["flickr-photos-getInfo"]={run:s,_processParams:n,_processResponse:r}},"@VERSION@",{requires:["flickr-promise","api-helper","flickr-photos-getLocation-fetcher"],optional:["photo-models","person-models","person-relationship-models","photo-engagement-models","photo-stats-models","photo-curation-models","photo-geo-models","photo-location-models","photo-head-meta-models","note-models","photo-notes-models","autotag-models","photo-autotags-models"]});
YUI.add("photo-geo-models",function(e){function r(e){r.superclass.constructor.call(this,e)}var t=1,n=16;e.Models[this.name]=r,e.extend(r,e.FlickrModelRegistry,{name:this.name,remote:{read:function(t){return e.ModelFetchers["flickr-photos-getInfo"].run(t,this.appContext).then(function(e){return e},function(){})},update:function(t,n){var r={photo_id:t,lat:this.getValue(t,"latitude"),lon:this.getValue(t,"longitude")};n.hasOwnProperty("accuracy")&&(r.accuracy=this.getValue(t,"accuracy"));if(n.hasOwnProperty("isPublic")||n.hasOwnProperty("isContact")||n.hasOwnProperty("isFriend")||n.hasOwnProperty("isFamily"))r.is_public=Number(this.getValue(t,"isPublic")),r.is_contact=Number(this.getValue(t,"isContact")),r.is_friend=Number(this.getValue(t,"isFriend")),r.is_family=Number(this.getValue(t,"isFamily"));return e.ModelUpdaters["flickr-photos-geo-setLocation"].run(r,this.appContext)}},attributes:{hasGeo:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},latitude:{validator:function(t,n){return e.AttributeHelpers.validateFloat(t)},setter:function(t){return e.AttributeHelpers.coerceFloat(t)||undefined},defaultValue:undefined},longitude:{validator:function(t,n){return e.AttributeHelpers.validateFloat(t)},setter:function(t){return e.AttributeHelpers.coerceFloat(t)||undefined},defaultValue:undefined},accuracy:{validator:function(t,n){return e.AttributeHelpers.validateInteger(t)},setter:function(r){return e.AttributeHelpers.coerceInteger(Math.max(t,Math.min(r,n)))||undefined},defaultValue:t},isPublic:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},isContact:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},isFriend:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},isFamily:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-photos-getInfo-fetcher","attribute-helpers","flickr-photos-geo-setLocation-updater"]});
YUI.add("flickr-photos-removeTag-deletor",function(e,t){"use strict";function n(n,r){var i={};return typeof n=="string"?i.tag_id=n:typeof n=="object"&&(i.global_tag_ids=n.globalTagIds.join(","),i.photo_ids=n.photoIds.join(",")),r.callAPI("flickr.photos.removeTag",i).then(null,e.FetcherErrorLogger(t))}e.namespace("ModelDeletors")["flickr-photos-removeTag"]={run:n}},"@VERSION@",{requires:["flickr-promise"],optional:[]});
YUI.add("tag-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:{create:function(t){return e.ModelCreators["flickr-photos-addTags"].run(t,this.appContext)},"delete":function(t){return e.ModelDeletors["flickr-photos-removeTag"].run(t,this.appContext)}},attributes:{tagValue:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t.trim().replace(/\s/g,""))}},tagRaw:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)}},tagAuthorNSID:{},isMachineTag:{validator:function(t){return e.AttributeHelpers.validateBoolean(t)},setter:function(t){return e.AttributeHelpers.coerceBoolean(t)},defaultValue:!1},url:{derivedBy:["tagValue","tagRaw"],readOnly:!0,defaultFn:function(e){var t=this.getValue(e,"tagRaw"),n=this.getValue(e,"tagValue");return t?"/photos/tags/"+t:n?"/photos/tags/"+n:undefined}},searchUrl:{derivedBy:["tagValue","tagRaw","isMachineTag"],readOnly:!0,defaultFn:function(e){var t=this.getValue(e,"tagRaw"),n=this.getValue(e,"tagValue"),r=this.getValue(e,"isMachineTag"),i;return t&&r?(t.indexOf(" ")>0&&(i=t.indexOf("=")+1,t=t.substring(0,i)+'"'+t.substring(i)+'"'),"/search/?tags="+t):t?"/search/?tags="+t:n?"/search/?tags="+n:undefined}},duplicateAutotagId:{validator:function(t){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)}}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-photos-addTags-creator","flickr-photos-removeTag-deletor"]});
YUI.add("flickr-tags-getListPhoto-fetcher",function(e,t){"use strict";function n(t,n,r){var i=t[0],s=t[1],o=t[2],u=i.photo&&i.photo.tags&&typeof i.photo.tags.tag!="undefined"?i.photo.tags.tag.length:0,a=[],f=t[3],l=t[4],c=0,h=[],p;return u>0&&e.Array.each(i.photo.tags.tag,function(e){typeof e.content=="string"&&a.push(o.addOrUpdate({id:e.id,tagRaw:e.raw,tagValue:e.content,tagAuthorNSID:e.author,isMachineTag:e.machineTag,duplicateAutotagId:e.duplicateAutotag}))}),s.exists(n)?s.setValue(n,"tags",a):s.add({id:n,tags:a}),p={id:n},i.photo&&i.photo.autotags&&typeof i.photo.autotags.autotag!="undefined"&&(c=i.photo.autotags.autotag.length),c>0&&e.Array.each(i.photo.autotags.autotag,function(e){typeof e.content=="string"&&h.push(l.addOrUpdate({id:e.id,autotagValue:e.content,score:e.confidence,isPrivate:e.private}))}),p.autotags={page:1,perPage:1e3,pageContent:h,totalItems:c},f.exists(n)?f.setValue(n,"autotags",p.autotags):f.add(p),s.proxy(n)}function r(n,r){var i=n.id,s={photo_id:i,extras:"autotags",lang:r.lang},o=this;return e.Promise.all([r.callAPI("flickr.tags.getListPhoto",s),r.getModelRegistry("photo-tags-models"),r.getModelRegistry("tag-models"),r.getModelRegistry("photo-autotags-models"),r.getModelRegistry("autotag-models")]).then(function(e){return o._processResponse(e,i,r.flipper)},e.FetcherErrorLogger(t))}e.namespace("ModelFetchers")["flickr-tags-getListPhoto"]={run:r,_processResponse:n}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["tag-models","photo-tags-models"]});
YUI.add("photo-tags-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-tags-getListPhoto"].run(t,this.appContext)},create:function(t){return e.ModelCreators["flickr-photos-addTags"].run(t,this.appContext)},"delete":function(t){return e.ModelDeletors["flickr-photos-removeTag"].run(t,this.appContext)}},attributes:{tags:{isCollection:!0}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-tags-getListPhoto-fetcher","flickr-photos-addTags-creator","flickr-photos-removeTag-deletor"]});
YUI.add("flickr-photos-addTags-creator",function(e,t){"use strict";function n(e){e.tags=e.tags||[];var t={};return t.photo_ids=e.photoId.join(","),t.tags=e.tags.join(","),e.fullResponse&&(t.full_response=1),t.extras="is_autotag",t}function r(e,t){var n=e[0],r,i=e[1],s=e[2],o=[],u,a;r=n.errors;if(!t.fullResponse){n.tags.tag.forEach(function(e){s.exists(e.id)||s.add({id:e.id,tagRaw:e.raw,tagValue:e.content.replace(/\s/g,""),tagAuthorNSID:e.author,duplicateAutotagId:e.duplicateAutotag}),o.push(s.proxy(e.id))});for(u=0;u<t.photoId.length;u++)a=t.photoId[u],i.exists(a)?o.forEach(function(e){typeof e!="undefined"&&i.getValue(a,"tags").push(e)}):i.add({id:a,tags:o});return o}if(r&&r.length>0)return r}function i(n,r){var i=this;return e.Promise.all([r.callAPI("flickr.photos.addTags",this._processParams(n)),r.getModelRegistry("photo-tags-models"),r.getModelRegistry("tag-models")]).then(function(e){return i._processResponse(e,n)},function(e){throw n.fullResponse&&(e.photoIds=n.photoId),e}).then(null,e.FetcherErrorLogger(t))}e.namespace("ModelCreators")["flickr-photos-addTags"]={run:i,_processParams:n,_processResponse:r}},"@VERSION@",{requires:["flickr-promise"],optional:["photo-tags-models","tag-models"]});
YUI.add("flickr-favorites-getContext-fetcher",function(e,t){"use strict";function n(t){var n={photo_id:t.photoId,num_prev:t.numNext,num_next:t.numPrev,extras:e.APIHelper.request.getRebootPhotoExtras()};return t.id?n.user_id=t.id:n.path_alias=t.pathAlias,n}function r(t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=t[6],l=[],c=[],h=s.proxy(n.photoId),p,d,v,m,g,y,b=[];return p=r.prevphotos,d=r.nextphotos,c=e.APIHelper.response.parsePhotos({photos:p.photo,personModelRegistry:o,photoModelRegistry:s,photoEngagementModelRegistry:u,photoStatsModelRegistry:a,photoCurationModelRegistry:f}),l=e.APIHelper.response.parsePhotos({photos:d.photo,personModelRegistry:o,photoModelRegistry:s,photoEngagementModelRegistry:u,photoStatsModelRegistry:a,photoCurationModelRegistry:f}),y=i.getValue(n.id,"photoContextList"),m=y.hasMinBoundary?y.hasMinBoundary():!1,g=y.hasMaxBoundary?y.hasMaxBoundary():!1,v=y.getList(),b=e.APIHelper.response.addOrReplaceListByContext({model:h,next:c,prev:l.reverse(),hasMax:g,hasMin:m,current:v,numNext:n.numNext,numPrev:n.numPrev}),i.setValue(n.id,"photoContextList",b),{next:c,previous:l.reverse()}}function i(n,r){var i=this;return e.Promise.all([r.callAPI("flickr.favorites.getContext",this._processParams(n),!0),r.getModelRegistry("favorite-models"),r.getModelRegistry("photo-models"),r.getModelRegistry("person-models"),r.getModelRegistry("photo-engagement-models"),r.getModelRegistry("photo-stats-models"),r.getModelRegistry("photo-curation-models")]).then(function(e){return i._processResponse(e,n)},function(e){throw e.code===3&&e.message==="Photo not a favorite"&&(e.notInContext=!0),e}).then(null,e.FetcherErrorLogger(t))}e.namespace("ListFetchers")["flickr-favorites-getContext"]={run:i,_processParams:n,_processResponse:r}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["favorite-models","photo-models","person-models","photo-engagement-models","photo-stats-models","photo-curation-models"]});
YUI.add("flickr-favorites-getList-fetcher",function(e,t){"use strict";function n(t){var n={extras:e.APIHelper.request.getRebootPhotoExtras(),per_page:t.perPage||20,page:t.page||1,get_user_info:1,jump_to:t.withPhotoId||""};if(t.id||t.userId)n.user_id=(t.id||t.userId).split("-")[0];else{if(!t.pathAlias)throw new Error("[flickr-favorites-getList-fetcher] `id` or `pathAlias` is required.");n.path_alias=t.pathAlias}return n}function r(t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=t[6],l,c={id:r.user.nsid,pathAlias:r.user.pathAlias,totalItems:r.photos.total},h,p=n.id||n.userId;return p&&p!==c.id&&(c.id=p),h=e.APIHelper.response.parsePerson(r.user),c.owner=s.addOrUpdate(h),l=e.APIHelper.response.parsePhotos({photos:r.photos.photo,personModelRegistry:s,photoModelRegistry:i,photoEngagementModelRegistry:u,photoStatsModelRegistry:a,photoCurationModelRegistry:f}),c.photoPageList={perPage:r.photos.perpage,page:r.photos.page,pageContent:l,totalItems:r.photos.total},o.addOrUpdate(c),l}function i(n,r){var i=this;return e.Promise.all([r.callAPI("flickr.favorites.getList",this._processParams(n)),r.getModelRegistry("photo-models"),r.getModelRegistry("person-models"),r.getModelRegistry("favorite-models"),r.getModelRegistry("photo-engagement-models"),r.getModelRegistry("photo-stats-models"),r.getModelRegistry("photo-curation-models")]).then(function(e){return i._processResponse(e,n)},e.FetcherErrorLogger(t))}e.namespace("ListFetchers")["flickr-favorites-getList"]={run:i,_processParams:n,_processResponse:r}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["photo-models","person-models","favorite-models","photo-engagement-models","photo-stats-models","photo-curation-models"]});
YUI.add("favorite-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.ListFetchers["flickr-favorites-getList"].run(t,this.appContext)}},attributes:{normalizedId:{readOnly:!0,defaultFn:function(e){return e.split("-")[0]}},displayType:{readOnly:!0,defaultFn:function(){return"favorites"}},title:{readOnly:!0,derivedBy:["owner","normalizedId"],defaultFn:function(e){var t=this.appContext.getViewer(),n=this.getValue(e,"normalizedId"),r;return t&&t.nsid===n?"Your favorites":(r=this.getValue(e,"owner"),r?r.getValue("displayname")+"'s favorites":"Favorites")}},pathAlias:{validator:function(t,n){return e.AttributeHelpers.validateString(t)},setter:function(t){return e.AttributeHelpers.coerceString(t)||undefined},defaultFn:function(e){return this.getValue(e,"normalizedId")}},owner:{isModel:!0},isOwner:e.PhotoModelHelper.attributes.isOwner,photoPageList:{isCollection:!0,pageFetch:{listFetcher:e.ListFetchers["flickr-favorites-getList"]}},photoContextList:{isListProxy:!0,contextFetch:{listFetcher:e.ListFetchers["flickr-favorites-getContext"],listItemIdField:"photoId"}},url:{readOnly:!0,derivedBy:["owner","normalizedId"],defaultFn:function(e){var t=this.getValue(e,"owner"),n=this.getValue(e,"normalizedId"),r=t?t.getValue("pathAlias"):n;return"/photos/"+r+"/favorites/"}},totalItems:{defaultFn:function(){return null}},urlSuffix:{readOnly:!0,derivedBy:["owner"],defaultFn:function(e){var t=this.getValue(e,"owner"),n=t.getValue("pathAlias");return"faves-"+n}}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-promise","flickr-favorites-getContext-fetcher","flickr-favorites-getList-fetcher","photo-model-helper"]});
YUI.add("flickr-galleries-getPhotos-fetcher",function(e,t){"use strict";function n(t){var n={gallery_id:t.compoundId,extras:e.APIHelper.request.getRebootPhotoExtras(),per_page:t.perPage||1,page:t.page||20,get_user_info:1,get_gallery_info:1,primary_photo_extras:"url_sq, url_t, url_s, url_m"};return n}function r(t,n){var r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=t[6],l;if(r&&r.gallery)return r.gallery.owner=r.user,r.gallery.title=r.gallery.title&&r.gallery.title.content,r.gallery.description=r.gallery.description&&r.gallery.description.content,r.gallery.photoCount=r.gallery.countPhotos,r.gallery.videoCount=r.gallery.countVideos,e.APIHelper.response.addContextToRegistry(r.gallery,o,s),l=e.APIHelper.response.parsePhotos({photos:r.photos.photo,personModelRegistry:s,photoModelRegistry:i,photoEngagementModelRegistry:u,photoStatsModelRegistry:a,photoCurationModelRegistry:f}),o.setValue(n.id,"photoPageList",l),l}function i(n,r){var i=this;return e.Promise.all([r.callAPI("flickr.galleries.getPhotos",this._processParams(n),!0),r.getModelRegistry("photo-models"),r.getModelRegistry("person-models"),r.getModelRegistry("gallery-models"),r.getModelRegistry("photo-engagement-models"),r.getModelRegistry("photo-stats-models"),r.getModelRegistry("photo-curation-models")]).then(function(e){return i._processResponse(e,n)},e.FetcherErrorLogger(t))}e.namespace("ListFetchers")["flickr-galleries-getPhotos"]={run:i,_processResponse:r,_processParams:n}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["photo-models","person-models","gallery-models","photo-engagement-models","photo-stats-models","photo-curation-models"]});