"use strict";(globalThis.webpackChunk_plex_client_qt=globalThis.webpackChunk_plex_client_qt||[]).push([["packages_app_screens_reactions_ReactionsListScreen_tsx"],{40890:(t,e,i)=>{i.r(e),i.d(e,{default:()=>L});var s=i(3493),n=i(36725),a=i(82357),r=i(87429),o=i(95794),c=i(11381),h=i(81190),l=i(12367),u=i(99346),d=i(68482),_=i(80038),g=i(50709),p=i(58944),m=i(86384);const f={hasNextPage:!1,items:[],cursor:""};class v{constructor(t){this.isStale=!1,this.totalSize=0,this._items=[],this._needsToLoad=!0,this._hasNextPage=!1,this._activityUuid="",this._fetchReactions=async t=>{var e;const{data:i}=await(0,_.JT)(_.Ie,{first:15,after:t,id:this._activityUuid,types:[_.lo.Applaud,_.lo.Dislike,_.lo.Laugh,_.lo.Like,_.lo.Love,_.lo.Question]},"cache-and-network"),{pageInfo:s,nodes:n}=(null==i?void 0:i.activityReactions)||{nodes:[]};return{hasNextPage:!(null==s||!s.hasNextPage),cursor:null!==(e=null==s?void 0:s.endCursor)&&void 0!==e?e:"",items:n}},this.refresh=()=>{if(!this.isStale&&!this._needsToLoad)return(0,g.Zq)();let t;this._hasNextPage=!0,this._cursor=void 0;return{promise:new Promise((async(e,i)=>{t=i;try{const t=Math.ceil(this._items.length/15)||1;for(let e=0;e<t;e++)if(this._hasNextPage||this._needsToLoad||this.isStale){const{items:t,cursor:i,hasNextPage:s}=await this._fetchReactions(this._cursor);this._items.splice(15*e,this._items.length,...t),this._hasNextPage=s,this._cursor=i}this.totalSize=this._items.length}catch(t){return void i(t)}finally{this._needsToLoad=!1,this.isStale=!1}e()})),cancel:()=>{t(new m.Z)}}},this.page=t=>{let e;if(t===p.T.Append&&this._hasNextPage){return{promise:new Promise((async(t,i)=>{e=i;const s={...f};try{const{items:t,cursor:e,hasNextPage:i}=await this._fetchReactions(this._cursor);s.items=t,s.hasNextPage=i,this._cursor=e,this._hasNextPage=i}catch(t){return void i(t)}this._items.push(...s.items),t(s)})),cancel:()=>{e(new m.Z)},startIndex:this._items.length,size:this._items.length}}if(t!==p.T.Append||this._hasNextPage)return(0,g.Zq)();{const t={...f};return{promise:Promise.resolve(t),cancel:()=>{e(new m.Z)},startIndex:0,size:0}}},this._activityUuid=t}getRefreshWindow(){return{index:0,size:this._items.length}}get items(){return this._items}get allowsPaging(){return this._hasNextPage}}var y=function(t,e,i,s){var n,a=arguments.length,r=a<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(r=(a<3?n(r):a>3?n(e,i,r):n(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r},P=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};const{screenHeight:x,screenWidth:w}=u.default;class L extends c.Z{constructor(){super(...arguments),this._screenType=l.Z.Community}static _template(){return{y:100,BusyIndicator:{type:s.$j,mount:.5,x:w/2,y:(x-200)/2,zIndex:d.Z.busyStatus,visible:!0},Container:{type:s.sg,x:u.default.sidebarCollapsedWidth,gap:"m",Title:{type:s.ij,fontName:"heading1",colorName:"primaryForeground80"},FriendsItemList:{type:h.Z}}}}_getFocused(){return this._friendsItemList}async _init(){var t,e,i;const{activityUuid:s,reactionsCount:a}=null!==(t=this.initialData)&&void 0!==t?t:{activityUuid:"",reactionsCount:""};this._viewModel=new v(s),await Promise.all([this._viewModel.refresh().promise,this._profileManager.updatePeopleData()]),this._container.patch({FriendsItemList:{type:h.Z,model:this._viewModel}}),this._title.content="1"===a?(0,n.ZP)("1 Reaction"):(0,n.ZP)("{count} Reactions",{count:a}),this._spinner.visible=!1,(0,r.Z)({page:this.metricsPage,origin:null===(e=this.initialData)||void 0===e?void 0:e.metricsOrigin,pane:null===(i=this.initialData)||void 0===i?void 0:i.metricsPane})}get metricsPage(){return a.GJ.ActivityReactionsList}get _spinner(){var t;return null!==(t=this._spinnerElement)&&void 0!==t?t:this._spinnerElement=this.tag("BusyIndicator")}get _container(){return this.tag("Container")}get _title(){var t;return null!==(t=this._titleElement)&&void 0!==t?t:this._titleElement=this._container.tag("Title")}get _friendsItemList(){var t;return null!==(t=this._friendsListElement)&&void 0!==t?t:this._friendsListElement=this._container.tag("FriendsItemList")}}y([(0,o.Z)("profileManager"),P("design:type",Object)],L.prototype,"_profileManager",void 0)}}]);