"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[5236,5375,6899,7018,9436],{46899:(e,t,o)=>{o.r(t),o.d(t,{default:()=>r});var l=o(86087),n=o(47143),a=o(40309),s=o(57018),c=o(60742);o(27723);const r=()=>{const{data:e}=(0,n.useSelect)(e=>e(a.settings).getSettingsState(),[]),{setGoogleState:t}=(0,n.useDispatch)(s.googleStoreName),[o]=c.A.useForm(),r=e=>o.setFieldsValue(e),{google_client_id:g,google_secret_key:i,google_redirect_url:d}=e,u={google_client_id:g,google_secret_key:i,google_redirect_url:d,block_booking_during_google_events:e?.block_booking_during_google_events||!1};return(0,l.useEffect)(()=>{t({setFields:r,form:o})},[]),{Form:c.A,form:o,initialValues:u}}},55375:(e,t,o)=>{o.r(t),o.d(t,{default:()=>s});var l=o(47143),n=o(11534),a=o(40309);const s=()=>{const{setSettingsState:e}=(0,l.useDispatch)(a.settings),{data:t}=(0,l.useSelect)(e=>e(a.settings).getSettingsState(),[]),{google_calendar_connected:o}=t||{},{singleTeamMember:s,profileInfo:c}=(0,l.useSelect)(e=>e(a.team).getTeamState(),[]),{setTeamState:r}=(0,l.useDispatch)(a.team),g=async(o={})=>{try{(await n.A.google.disconnectGoogle(o)).success&&(o?.team_member_id?r({singleTeamMember:{...s,google_calendar_connected:!1}}):e({data:{...t,google_calendar_connected:!1}}))}catch(e){console.log(e)}};return{adminGoogleSettings:e=>{const{google_redirect_url:t,...l}=e;o?g():(async e=>{try{const{google_redirect_url:t,...o}=e,l=await n.A.google.configureGoogle(o);l.success&&window.location.replace(l?.data?.auth_url,"noopener,noreferrer")}catch(e){console.log(e)}})(l)},teamGoogleSettings:()=>{if(!t?.google_calendar_connected)return;const e={team_member_id:s?.id||c.id};s?.google_calendar_connected?g(e):(async(e={})=>{try{const t=await n.A.google.connectGoogle(e);t.success&&window.location.replace(t?.data?.auth_url,"noopener,noreferrer")}catch(e){console.log(e)}})(e)}}}},57018:(e,t,o)=>{o.r(t),o.d(t,{googleStoreName:()=>l});const l="booktics/google"},79436:(e,t,o)=>{o.r(t),o.d(t,{default:()=>u});var l=o(51609),n=o(47143),a=o(22564),s=o(88802),c=o(46899),r=o(85236),g=o(55375),i=o(57018),d=o(27723);const u=e=>{const{keys:t=[],children:o,title:u}=e,{data:m}=(0,n.useSelect)(e=>e(s.settingsStore).getSettingsState(),[]),{isModalOpen:_,editLoading:S}=(0,n.useSelect)(e=>e(i.googleStoreName).getGoogleState(),[]),{Form:f,form:h,initialValues:b}=(0,c.default)(),{handleOpen:k,handleClose:p,handleClear:y}=(0,r.default)(),{adminGoogleSettings:C}=(0,g.default)();return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(a.ConfigureBtn,{text:(0,d.__)("Configure","booktics"),onClick:k}),(0,l.createElement)(a.Modal,{title:u,open:_,onCancel:p,footer:null,className:"bkt-config-modal",centered:!0},(0,l.createElement)(f,{layout:"vertical",form:h,initialValues:b||{},onFinish:C},o,(0,l.createElement)(a.Flex,{justify:"flex-end",gap:"small"},(0,l.createElement)(a.SecondaryButton,{size:"middle",onClick:()=>y({keys:t}),text:(0,d.__)("Clear","booktics"),className:"bkt-neutral-soft-light-btn"}),(0,l.createElement)(a.PrimaryButton,{size:"middle",htmlType:"submit",text:(0,d.__)(m?.google_calendar_connected?"Disconnect":"Connect","booktics"),loading:S})))))}},85236:(e,t,o)=>{o.r(t),o.d(t,{default:()=>a});var l=o(47143),n=o(57018);const a=()=>{const{setFields:e}=(0,l.useSelect)(e=>e(n.googleStoreName).getGoogleState(),[]),{setGoogleState:t}=(0,l.useDispatch)(n.googleStoreName);return{handleOpen:()=>t({isModalOpen:!0}),handleClose:()=>t({isModalOpen:!1}),handleClear:({keys:t})=>{const o=Object.fromEntries(t.map(e=>[e,""]));e(o)}}}}}]);