import{fH as e,bL as d,iv as T,hi as R,iG as w,il as A,j8 as C,iQ as S,e$ as z,an as L,aZ as x,aw as D,jG as E,h1 as F,ck as U,aD as G,cz as j,ft as H,hU as B,cI as l,dJ as V,f6 as _}from"./strapi-ye6TfKul.js";import{u as m}from"./hooks-CtIibOju.js";import{S as N}from"./schemas-xpBv1dp3.js";const k=()=>{const{formatMessage:s}=T(),{formatAPIError:o}=R(),{toggleNotification:i}=w(),{data:c,isLoading:a}=A(),[t,{isLoading:v}]=C(),y=m(r=>r.admin_app.permissions.settings?.releases),{allowedActions:{canUpdate:b}}=S(y),{timezoneList:M}=z(new Date),I=async(r,{setErrors:u})=>{const{defaultTimezone:g}=r,p=g,h=M.some(n=>n.value===p);if(!h&&g){const n=s({id:"components.Input.error.validation.combobox.invalid",defaultMessage:"The value provided is not valid"});u({defaultTimezone:n}),i({type:"danger",message:n});return}const P=!g||!h?{defaultTimezone:null}:{defaultTimezone:p};try{const n=await t(P);"data"in n?i({type:"success",message:s({id:"content-releases.pages.Settings.releases.setting.default-timezone-notification-success",defaultMessage:"Default timezone updated."})}):H(n.error)?i({type:"danger",message:o(n.error)}):i({type:"danger",message:s({id:"notification.error",defaultMessage:"An error occurred"})})}catch{i({type:"danger",message:s({id:"notification.error",defaultMessage:"An error occurred"})})}};if(a)return e.jsx(d.Loading,{});const f=s({id:"content-releases.pages.Releases.title",defaultMessage:"Releases"});return e.jsxs(e.Fragment,{children:[e.jsx(d.Title,{children:s({id:"Settings.PageTitle",defaultMessage:"Settings - {name}"},{name:f})}),e.jsx(d.Main,{"aria-busy":a,tabIndex:-1,children:e.jsx(L,{method:"PUT",initialValues:{defaultTimezone:c?.data.defaultTimezone},onSubmit:I,validationSchema:N,children:({modified:r,isSubmitting:u})=>e.jsxs(e.Fragment,{children:[e.jsx(x.Header,{primaryAction:b?e.jsx(E,{disabled:!r||v,loading:u,startIcon:e.jsx(F,{}),type:"submit",fullWidth:!0,children:s({id:"global.save",defaultMessage:"Save"})}):null,secondaryAction:e.jsx(D,{label:s({id:"components.premiumFeature.title",defaultMessage:"Premium feature"})}),title:f,subtitle:s({id:"content-releases.pages.Settings.releases.description",defaultMessage:"Create and manage content updates"})}),e.jsx(x.Content,{children:e.jsxs(U,{direction:"column",background:"neutral0",alignItems:"stretch",padding:6,gap:6,shadow:"filterShadow",hasRadius:!0,children:[e.jsx(G,{variant:"delta",tag:"h2",children:s({id:"content-releases.pages.Settings.releases.preferences.title",defaultMessage:"Preferences"})}),e.jsx(j.Root,{children:e.jsx(j.Item,{col:6,xs:12,direction:"column",alignItems:"stretch",children:e.jsx(Q,{})})})]})})]})})})]})},Q=()=>{const s=m(t=>t.admin_app.permissions.settings?.releases),{allowedActions:{canUpdate:o}}=S(s),{formatMessage:i}=T(),{timezoneList:c}=z(new Date),a=B("defaultTimezone");return e.jsxs(l.Root,{name:"defaultTimezone",hint:i({id:"content-releases.pages.Settings.releases.timezone.hint",defaultMessage:"The timezone of every release can still be changed individually."}),error:a.error,children:[e.jsx(l.Label,{children:i({id:"content-releases.pages.Settings.releases.timezone.label",defaultMessage:"Default timezone"})}),e.jsx(V,{autocomplete:{type:"list",filter:"contains"},onTextValueChange:t=>a.onChange("defaultTimezone",t),onChange:t=>{(a.value&&t||!a.value)&&a.onChange("defaultTimezone",t)},onClear:()=>a.onChange("defaultTimezone",""),value:a.value,disabled:!o,children:c.map(t=>e.jsx(_,{value:t.value,children:t.value.replace(/&/," ")},t.value))}),e.jsx(l.Hint,{}),e.jsx(l.Error,{})]})},$=()=>{const s=m(o=>o.admin_app.permissions.settings?.releases?.read);return e.jsx(d.Protect,{permissions:s,children:e.jsx(k,{})})};export{$ as ProtectedReleasesSettingsPage};
