"use strict";(self.webpackChunkfl_assistant=self.webpackChunkfl_assistant||[]).push([[89],{3344:(e,t,n)=>{n.r(t),n.d(t,{default:()=>d});var a=n(8168),s=n(1594),l=n.n(s),u=n(9489),i=n(2470),r=n(2405),o=n(6075),p=n(9558);var c=n(7561);const d=e=>l().createElement(r.App.Config,(0,a.A)({pages:{default:g,"plugin/:id":r.Page.Plugin,"theme/:id":r.Page.Theme}},e)),g=({handle:e})=>{const t=(0,o.getUpdaterStore)(),{setUpdateQueueItems:n}=(0,o.getUpdaterActions)(),{updatingAll:a,updateType:d,listStyle:g}=(0,o.useAppState)(e),{setUpdatingAll:m,setUpdateType:h,setListStyle:_}=(0,o.getAppActions)(e),{getContent:f}=(0,u.getWpRest)(),{plugins:y,themes:S,total:b,hasUpdates:E}=((e=0)=>{const t=(0,o.getSystemStore)(),[n,a]=(0,s.useState)(e),l=e=>{const{counts:t}=e,n=t["update/plugins"]?t["update/plugins"]:0,a=t["update/themes"]?t["update/themes"]:0;return{plugins:n,themes:a,combined:a+n}};(0,s.useLayoutEffect)((()=>{const{combined:e}=l(t.getState());return a(e),t.subscribe((()=>{const{combined:e}=l(t.getState());n!==e&&a(e)}))}),[]);const{plugins:u,themes:i,combined:r}=l(t.getState());return{total:r,hasUpdates:0<r,plugins:u,themes:i}})(),A=()=>{m(!0),f("updates").then((e=>{const{items:t}=e.data;n(t)})).catch((e=>{console.log(e),m(!1),alert((0,i.__)("Something went wrong. Please try again."))}))},U=()=>{const{updateQueue:e}=t.getState();Object.values(e).length||m(!1)};(0,s.useEffect)((()=>{U();const e=t.subscribe(U);return()=>e()}),[]);const C=()=>E?a?l().createElement(r.Button.Loading,null,(0,i.__)("Updating")):l().createElement(r.Button,{onClick:A},(0,i.__)("Update All")):null,v=()=>{const e={all:(0,i.sprintf)("All (%s)",b),plugins:(0,i.sprintf)("Plugin (%s)",y),themes:(0,i.sprintf)("Theme (%s)",S)},t={card:(0,i.__)("Cards"),list:(0,i.__)("Compact")};return l().createElement(r.Filter,{isSticky:!0},l().createElement(r.Filter.RadioGroupItem,{title:(0,i.__)("Type"),items:e,value:d,defaultValue:p.n.updateType,onChange:e=>h(e)}),l().createElement(r.Filter.RadioGroupItem,{title:(0,i.__)("Display As"),items:t,value:g,defaultValue:p.n.listStyle,onChange:e=>_(e)}),l().createElement(r.Filter.Button,{onClick:()=>{h(p.n.updateType),_(p.n.listStyle)}},(0,i.__)("Reset Filter")))};return l().createElement(r.Page,{title:(0,i.__)("Updates"),icon:l().createElement(c.A,null),shouldShowBackButton:!1,actions:l().createElement(C,null),padY:!1,shouldScroll:!1},!E&&l().createElement(r.Layout.Box,null,(0,i.__)("You have no updates.")),E&&l().createElement(r.List.Updates,{updateType:d,getItemProps:(t,n)=>({...n,to:{pathname:`/${e}/${t.type}/${t.id}`,state:{item:t}}}),before:l().createElement(v,null),listStyle:g}))}},8168:(e,t,n)=>{function a(){return a=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},a.apply(null,arguments)}n.d(t,{A:()=>a})}}]);