"use strict";(globalThis.webpackChunkesf_youtube_dashboard=globalThis.webpackChunkesf_youtube_dashboard||[]).push([[342],{202(e,a,s){s.d(a,{A:()=>l});var t=s(573),o=s(728);const l=(0,o.jsx)(t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,o.jsx)(t.Path,{d:"m11.3 17.2-5-5c-.1-.1-.1-.3 0-.4l2.3-2.3-1.1-1-2.3 2.3c-.7.7-.7 1.8 0 2.5l5 5H7.5v1.5h5.3v-5.2h-1.5v2.6zm7.5-6.4-5-5h2.7V4.2h-5.2v5.2h1.5V6.8l5 5c.1.1.1.3 0 .4l-2.3 2.3 1.1 1.1 2.3-2.3c.6-.7.6-1.9-.1-2.5z"})})},251(e,a,s){s.d(a,{A:()=>l});var t=s(609),o=s(783);const l=({children:e,text:a})=>(0,t.createElement)(o.A,{text:a,wrapperClassName:"esf-dsh-tooltip",textClassName:"esf-dsh-tooltip-text"},e)},342(e,a,s){s.r(a),s.d(a,{default:()=>f});var t=s(609),o=s(723),l=s(87),c=s(427),i=s(573),n=s(728);const r=(0,n.jsx)(i.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,n.jsx)(i.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z"})});var u=s(202),b=s(251),d=s(478);const _=[{value:3600,label:(0,o.__)("Every 1 hour","easy-facebook-likebox")},{value:10800,label:(0,o.__)("Every 3 hours","easy-facebook-likebox")},{value:21600,label:(0,o.__)("Every 6 hours","easy-facebook-likebox")},{value:43200,label:(0,o.__)("Every 12 hours","easy-facebook-likebox")},{value:86400,label:(0,o.__)("Every 24 hours","easy-facebook-likebox")},{value:604800,label:(0,o.__)("Every 7 days","easy-facebook-likebox")}],y=()=>{if("undefined"==typeof window)return 43200;const e=window.esfYouTubeData?.youtubeSettings?.cache_duration,a=Number(e);return _.map(e=>e.value).includes(a)?a:43200},f=({addNotice:e})=>{const[a,s]=(0,l.useState)(y),[i,n]=(0,l.useState)(!1),[f,v]=(0,l.useState)(!1),m=(0,l.useCallback)(async()=>{n(!0);try{await(0,d.Xx)({cache_duration:a}),e((0,o.__)("Settings saved successfully.","easy-facebook-likebox"),"success")}catch(a){e(a?.message||(0,o.__)("Failed to save settings. Please try again.","easy-facebook-likebox"),"error")}finally{n(!1)}},[a,e]),h=(0,l.useCallback)(async()=>{v(!0);try{const a=await(0,d.IL)(),s="number"==typeof a?.deleted?a.deleted:0;e(s>0?(0,o.sprintf)(/* translators: %d: number of cache entries cleared */ /* translators: %d: number of cache entries cleared */
(0,o.__)("Cache cleared. %d item(s) removed.","easy-facebook-likebox"),s):(0,o.__)("Cache cleared. Fresh data will load on next visit.","easy-facebook-likebox"),"success")}catch(a){e(a?.message||(0,o.__)("Failed to clear cache. Please try again.","easy-facebook-likebox"),"error")}finally{v(!1)}},[e]),k=(0,l.useMemo)(()=>_.map(e=>({value:String(e.value),label:e.label})),[]);return(0,t.createElement)("div",{className:"esf-youtube-settings"},(0,t.createElement)("div",{className:"esf-youtube-settings__section"},(0,t.createElement)("div",{className:"esf-youtube-settings__row"},(0,t.createElement)("div",{className:"esf-youtube-settings__label-wrap"},(0,t.createElement)("label",{htmlFor:"esf-youtube-cache-duration",className:"esf-youtube-settings__label"},(0,o.__)("Caching","easy-facebook-likebox")),(0,t.createElement)(b.A,{text:(0,o.__)("How long feed data is stored before being refreshed from YouTube.","easy-facebook-likebox")},(0,t.createElement)("span",{className:"esf-youtube-settings__label-icon"},(0,t.createElement)(c.Icon,{icon:r,size:18})))),(0,t.createElement)("div",{className:"esf-youtube-settings__controls"},(0,t.createElement)(c.SelectControl,{id:"esf-youtube-cache-duration",value:String(a),options:k,onChange:e=>s(Number(e)),className:"esf-youtube-settings__select",hideLabelFromVision:!0}),(0,t.createElement)(c.Button,{variant:"secondary",isBusy:f,disabled:f,onClick:h,className:"esf-youtube-settings__btn-clear",icon:u.A,iconPosition:"left"},f?(0,o.__)("Clearing…","easy-facebook-likebox"):(0,o.__)("Clear All Caches","easy-facebook-likebox"))))),(0,t.createElement)("div",{className:"esf-youtube-settings__footer"},(0,t.createElement)(c.Button,{variant:"primary",isBusy:i,disabled:i,onClick:m,className:"esf-youtube-settings__btn-save"},i?(0,o.__)("Saving…","easy-facebook-likebox"):(0,o.__)("Save settings","easy-facebook-likebox"))))}}}]);