"use strict";(self.webpackChunkplex_web_client=self.webpackChunkplex_web_client||[]).push([[7252],{79572:(e,t,r)=>{r.d(t,{c:()=>a});var n=r(57864),o=r(16200);function a(){return(0,n.M3)(((e,{mediaSubscriptionEntityID:t})=>t),o.c,((e,t)=>t[e]))}},77252:(e,t,r)=>{r.r(t),r.d(t,{default:()=>te});var n=r(27876),o=r(57864),a=r(58756),c=r(11504),l=r(56960),i=r(44064),s=r(35456),d=r(54084),p=r(94952),u=r(79572);var m=r(19172),b=r(59396),f=r(1292),y=r(84536),O=r(82468),S=r(90064),v=r(23384),g=r(79264),w=r(13436),M=r(24808),E=r(74428),h=r(9176),C=r(17492),D=Object.defineProperty,P=Object.defineProperties,j=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,K=(e,t,r)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const _=function(e){const t=e,{errorMessage:r,isMediaSubscriptionSaving:n,prefGroups:o,className:a,onModalClose:l,onSubmit:i}=t,s=((e,t)=>{var r={};for(var n in e)x.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&k)for(var n of k(e))t.indexOf(n)<0&&I.call(e,n)&&(r[n]=e[n]);return r})(t,["errorMessage","isMediaSubscriptionSaving","prefGroups","className","onModalClose","onSubmit"]),d=(0,w.c)(n)&&!n;return(0,c.useEffect)((()=>{d&&!r&&l()}),[r,d,l]),c.createElement(y.cp,{className:a,onSubmit:i},c.createElement(g.c,null,(0,b.c)("Download Options")),r?c.createElement(h.c,{errorMessage:r}):null,c.createElement(O.c,null,c.createElement("div",{key:"advanced"},c.createElement(C.c,(p=((e,t)=>{for(var r in t||(t={}))x.call(t,r)&&K(e,r,t[r]);if(k)for(var r of k(t))I.call(t,r)&&K(e,r,t[r]);return e})({},s),u={prefs:o.advanced},P(p,j(u)))))),c.createElement(S.c,null,c.createElement(v.c,null,c.createElement(f.c,{kind:M.sT,onPress:l},(0,b.c)("Cancel")),c.createElement(E.c,{isSpinning:n,kind:M.ac,type:"submit"},(0,b.c)("Save")))));var p,u};var A=Object.defineProperty,N=Object.defineProperties,T=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,L=(e,t,r)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,W=(e,t)=>{var r={};for(var n in e)Q.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&G)for(var n of G(e))t.indexOf(n)<0&&U.call(e,n)&&(r[n]=e[n]);return r};const B=new Set(["autoDeletionItemPolicyUnwatchedLibrary","autoDeletionItemPolicyWatchedLibrary"]),F={dispatchSyncDownloadModalChangeTemplateMode:a.ox,dispatchSyncDownloadSaveSubscription:a.WO},q=(0,n.Ul)((function(){return(0,o.M3)(((e,{modal:t})=>t),(0,u.c)(),(0,o.M3)((e=>e.downloads.states),((e,{modal:t})=>t),((e,t)=>{const{sourceAttr:r,ratingKey:n}=t;return e.some((e=>e.ratingKey===n&&e.sourceAttr===r&&"saving"===e.state))})),p.c,((e,t,r,n)=>{const{hint:o}=t,a=t.target&&n[t.target.metadata],c=(0,m.c)(t.prefs,B);return{errorMessage:e.error,hint:o,isMediaSubscriptionSaving:r,prefGroups:c,target:a}}))}),F)((function(e){const t=e,{dispatchSyncDownloadModalChangeTemplateMode:r,dispatchSyncDownloadSaveSubscription:n,modal:o}=t,a=W(t,["dispatchSyncDownloadModalChangeTemplateMode","dispatchSyncDownloadSaveSubscription","modal"]),{ratingKey:l,sourceAttr:i}=o,s=(0,c.useCallback)((e=>{const t=e,{mode:r}=t,o=W(t,["mode"]);n({prefs:o,ratingKey:l,sourceAttr:i})}),[l,i,n]);return c.createElement(_,(d=((e,t)=>{for(var r in t||(t={}))Q.call(t,r)&&L(e,r,t[r]);if(G)for(var r of G(t))U.call(t,r)&&L(e,r,t[r]);return e})({},a),N(d,T({onSubmit:s}))));var d})),z=function(e){const{isOpen:t,modal:r,onSyncDownloadModalClose:n}=e,{error:o,mediaSubscription:a,ratingKey:p,sourceAttr:u}=r,m=(0,c.useCallback)((()=>{n({ratingKey:p,sourceAttr:u})}),[p,u,n]);return c.createElement(i.c,{isOpen:t,metricsPage:l._Q,onModalClose:m},o&&!a?c.createElement(d.c,{message:o,onModalClose:m}):c.createElement(s.c,{onModalClose:m},c.createElement(q,{className:"SyncDownloadModal-formContent-iDFo2i ModalContent-modalContent-_BsQSK",mediaSubscriptionEntityID:a,modal:r,onModalClose:m})))};var H=Object.defineProperty,J=Object.defineProperties,R=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,Z=(e,t,r)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const $=(0,o.M3)((function(e){return e.ui.syncDownloadModals}),(e=>({modal:e.find((e=>e.isOpen))}))),ee={onSyncDownloadModalClose:a._Q},te=(0,n.Ul)($,ee)((function(e){return e.modal?c.createElement(z,(t=((e,t)=>{for(var r in t||(t={}))X.call(t,r)&&Z(e,r,t[r]);if(V)for(var r of V(t))Y.call(t,r)&&Z(e,r,t[r]);return e})({},e),J(t,R({isOpen:!0})))):null;var t}))}}]);