@databrainhq/plugin 0.16.32-uat → 0.16.32-uat3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/Filters-DXW6z__P.mjs +1 -0
  2. package/dist/PivotTableV2-3gC-7gNU.mjs +1 -0
  3. package/dist/SingleValueChart-D2elYl22.mjs +1 -0
  4. package/dist/{ViewFilter-DyhG4OqC.mjs → ViewFilter-DAYlSxo6.mjs} +1 -1
  5. package/dist/{filters.module-DvRKsLtd.mjs → filters.module-DO9_GPJP.mjs} +1 -1
  6. package/dist/{index-DLyuXer2.mjs → index--4LE8Mrd.mjs} +1 -1
  7. package/dist/{index-0GHze8gd.mjs → index-B-xrDNSO.mjs} +1 -1
  8. package/dist/index-BJGdplie.mjs +2 -0
  9. package/dist/{index-CEsAcXUs.mjs → index-BPFwW5P9.mjs} +2 -2
  10. package/dist/{index-DpEkTTGy.mjs → index-BVVZ3pSW.mjs} +1 -1
  11. package/dist/{index-BrAIxh5d.mjs → index-BhM2t3wa.mjs} +2 -2
  12. package/dist/index-BiMI_dbj.mjs +1 -0
  13. package/dist/index-CkLwxeXs.mjs +1 -0
  14. package/dist/index-DNYOyn8z.mjs +1 -0
  15. package/dist/index-DU90Y3sj.mjs +1 -0
  16. package/dist/{index-BQbziR94.mjs → index-DUlFjESK.mjs} +2 -2
  17. package/dist/index-DbmP77Z2.mjs +210 -0
  18. package/dist/index-DrRYExCZ.mjs +1 -0
  19. package/dist/{index-COSqdCry.mjs → index-P6u6A5Zw.mjs} +1 -1
  20. package/dist/{index-DjqXwAmE.mjs → index-YrNE6uv_.mjs} +2 -2
  21. package/dist/index-_vhBjF9o.mjs +2 -0
  22. package/dist/index-ePAlWlBN.mjs +1 -0
  23. package/dist/{index-Ch5eBAUy.mjs → index-pmQOLCdm.mjs} +1 -1
  24. package/dist/webcomponents.es.js +2 -2
  25. package/dist/webcomponents.umd.js +253 -253
  26. package/package.json +1 -1
  27. package/dist/Filters-CnVs7ku1.mjs +0 -1
  28. package/dist/PivotTableV2-D2tQaLvo.mjs +0 -1
  29. package/dist/SingleValueChart-hf3V0jXM.mjs +0 -1
  30. package/dist/index-5q1CwqoG.mjs +0 -2
  31. package/dist/index-B9kcwysa.mjs +0 -210
  32. package/dist/index-BSg1oUFN.mjs +0 -1
  33. package/dist/index-BqzWn58g.mjs +0 -2
  34. package/dist/index-D0q6ipWQ.mjs +0 -1
  35. package/dist/index-DYmSWGcW.mjs +0 -1
  36. package/dist/index-GlA8hWII.mjs +0 -1
  37. package/dist/index-MRVxF3rD.mjs +0 -1
  38. package/dist/index-uXWPKe1a.mjs +0 -1
@@ -1 +1 @@
1
- import{j as t}from"./ui-vendor-DuTfa2UR.mjs";import{useMemo as Fe,useEffect as Ne,useState as O}from"react";import{u as Ee,C as te}from"./react-utils-DgU8eu9z.mjs";import{u as Se,a as ke,b as _e,S as we}from"./index-DOjiRxyH.mjs";import{W as K,y as De,z as le,F as V,H as Ie,J as We,K as Ae}from"./metricOptions-eMjyT9mw.mjs";import{r as ye,T as He}from"./index-B-Bb04Ow.mjs";import{E as Ce}from"./index-DwYE0XjC.mjs";import{B as E}from"./index-DhbU7Mia.mjs";import{I as U}from"./index-CXxcrvqq.mjs";import{F as L}from"./index-B1NuJ0kR.mjs";import{I as je}from"./index-DzlWCFpe.mjs";import{M as fe}from"./index-BlNXCmSV.mjs";import{T as Z}from"./index-zxPTeqmL.mjs";import{N as pe}from"./index-5q1CwqoG.mjs";import{F as oe}from"./index-C26NEE4H.mjs";import{D as Oe}from"./index-0GHze8gd.mjs";import{a as Te,M as qe}from"./ModalFooter-DN5Z9yNl.mjs";import"react-dom";import"./editor-vendor-DzeR_zKV.mjs";import"./chart-vendor-DLB-rMJR.mjs";import"./webcomponents.es.js";import"./index-BRqJa8kU.mjs";import"./data-vendor-eZSTXlsm.mjs";import"./index-BLh5Cmay.mjs";import"./index-BkMSEw_J.mjs";import"./index-DafPJT-X.mjs";import"./index-D3hhF5t0.mjs";const ze="_formWrapper_48444_1",he={formWrapper:ze,"time-element":"_time-element_48444_16","schedule-time":"_schedule-time_48444_19"},Ve=r=>De[De.findIndex(f=>f.value===r)].timezoneOffset*-1,Le=(r,n)=>{let f=0;for(let s=0;s<r.length;s++)if(r[s]>=n)return f=s,f;return f},Me=r=>{const n=new Date,f=n.getMonth(),s=n.getFullYear();return(r==null?void 0:r.map(o=>{switch(o==null?void 0:o.value){case"firstDay":return 1;case"lastDay":return new Date(s,f+1,0).getDate();case"firstMonday":{const S=new Date(s,f,1);return S.getDay()===0?2:(9-S.getDay())%7+1}case"15OfMonth":return 15;default:return null}})).filter(o=>o).sort((o,S)=>o-S)},Pe=r=>{var M,o,S;let n=new Date;n=new Date(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds()),n.setMinutes(n.getMinutes()+1);const f=Ve(r.timezone);n.setTime(n.getTime()-f*6e4);let s=null;switch(r.frequency){case"oneTime":s=new Date(((M=r==null?void 0:r.oneTimeDate)==null?void 0:M.startDate)||"");break;case"Daily":s=new Date(n),s.setDate(n.getDate());break;case"Weekly":{const j=Object.keys(r.weekDays).filter(x=>r.weekDays[x]);let p=null;j.forEach(x=>{const N=(K.findIndex(J=>J.value===x)+7-n.getDay())%7,b=new Date(n);b.setDate(n.getDate()+N),b.toDateString()===n.toDateString()&&b.setDate(b.getDate()+7),(!p||b<p)&&(p=b)}),s=p;break}case"Monthly":{const j=r.newDate?Me(r.newDate):(o=r.date)==null?void 0:o.map(x=>parseInt(x.value,10));let p=null;j.forEach(x=>{const u=new Date(n.getFullYear(),n.getMonth(),x);u<n&&u.setMonth(n.getMonth()),(!p||u<p)&&(p=u)}),s=p;break}}if(s!==null)switch(s.setHours(parseInt(r.hours,10),0,0,0),r.time==="PM"&&r.hours==="12"?s.setHours(12):r.time==="PM"?s.setHours(parseInt(r.hours,10)+12):r.time==="AM"&&r.hours==="12"&&s.setHours(0),r.frequency){case"Daily":case"oneTime":s.getHours()<=n.getHours()&&s.setDate(s.getDate()+1);break;case"Weekly":{Object.keys(r.weekDays).filter(p=>r.weekDays[p]).includes(K[n.getDay()].value)&&s.getHours()>n.getHours()&&s.setDate(n.getDate());break}case"Monthly":{const j=r.newDate?Me(r.newDate):(S=r.date)==null?void 0:S.map(x=>parseInt(x.value,10)).sort((x,u)=>x-u),p=Le(j,n.getDate());s.setDate(j[p]),s.getDate()<=n.getDate()&&s.getHours()<=n.getHours()&&s.setDate(j[(p+1)%j.length]),s.getMonth()===n.getMonth()&&s.getDate()<=n.getDate()&&s.getHours()<=n.getHours()&&(s.setMonth(s.getMonth()+1),s.setDate(j[0])),s.getMonth()===n.getMonth()&&s.getDate()<n.getDate()&&s.setMonth(s.getMonth()+1);break}}return`${s==null?void 0:s.getDate()}/${(s==null?void 0:s.getMonth())+1}/${s==null?void 0:s.getFullYear()}, ${s==null?void 0:s.toLocaleTimeString()}`},Ue=({onCancel:r,getInternalToken:n,scheduleReportConfig:f,externalDashboardId:s,sharingSettingsId:B,onComplete:M,clientState:o})=>{const{register:S,handleSubmit:j,watch:p,control:x,setValue:u,getValues:N,reset:b,formState:{errors:J}}=Ee(),{data:m,token:I}=Se(),g=Fe(()=>{if(f)return f},[f]);Ne(()=>{var e,T;g?b({...g==null?void 0:g.timeConfigurations}):(u("time","PM"),u("timezone","Asia/Kolkata"),u("frequency","Daily"),u("subject",""),u("downloadFileFormat",(T=(e=le)==null?void 0:e[0])==null?void 0:T.value))},[g]);const[W,l]=O(!1),[de,a]=O(""),[Q,d]=O(!1),[X,$]=O(!1),R="",se=ke(),P=_e(),q=(e,T,i)=>{var w,y,D,c,k,_;if(!((w=e==null?void 0:e.charts)!=null&&w.length)&&!i)return a("please select at least one chart to share"),l(!1),d(!1),!1;if(!((y=e==null?void 0:e.emails)!=null&&y.length))return a("please add at least one email address"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="Weekly"&&!(Object!=null&&Object.values({...e==null?void 0:e.weekDays}).includes(!0)))return a("please select atleast one day"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="Monthly"&&!((D=e==null?void 0:e.newDate)!=null&&D.length))return a("please select at least one date option"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"&&!((c=e==null?void 0:e.oneTimeDate)!=null&&c.startDate))return a("please select date for one time schedule"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"){const A=(k=e==null?void 0:e.oneTimeDate)==null?void 0:k.startDate;if(!A)return!1;const z=typeof A=="string"?new Date(A):new Date(A.getTime());if(isNaN(z.getTime()))return a("invalid date selected"),l(!1),d(!1),!1;const F=Number(e==null?void 0:e.hours);if(Number.isNaN(F)||F<1||F>12)return a("invalid hour"),l(!1),d(!1),!1;const h=(e==null?void 0:e.time)==="PM"&&F!==12?F+12:(e==null?void 0:e.time)==="AM"&&F===12?0:F,H=new Date(z.getTime());if(H.setHours(h,0,0,0),H.getTime()<=Date.now())return a("please select valid time for one time schedule"),l(!1),d(!1),!1}return T?o!=null&&o.isRequiredClient&&!((_=o==null?void 0:o.clients)!=null&&_.length)?(a("please select at least one client"),l(!1),d(!1),!1):!0:(a("invalid time configurations"),l(!1),d(!1),!1)},ne=e=>{var T,i,w;if((e==null?void 0:e.frequency)==="Weekly"&&!(Object!=null&&Object.values({...e==null?void 0:e.weekDays}).includes(!0)))return a("please select atleast one day"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="Monthly"&&!((T=e==null?void 0:e.newDate)!=null&&T.length))return a("please select at least one date option"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"&&!((i=e==null?void 0:e.oneTimeDate)!=null&&i.startDate))return a("please select date for one time schedule"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"){const y=(w=e==null?void 0:e.oneTimeDate)==null?void 0:w.startDate;if(!y)return!1;const D=typeof y=="string"?new Date(y):new Date(y.getTime());if(isNaN(D.getTime()))return a("invalid date selected"),l(!1),d(!1),!1;const c=Number(e==null?void 0:e.hours);if(Number.isNaN(c)||c<1||c>12)return a("invalid hour"),l(!1),d(!1),!1;const k=(e==null?void 0:e.time)==="PM"&&c!==12?c+12:(e==null?void 0:e.time)==="AM"&&c===12?0:c,_=new Date(D.getTime());if(_.setHours(k,0,0,0),_.getTime()<=Date.now())return a("please select valid time for one time schedule"),l(!1),d(!1),!1}return!0},ce=async e=>{var be,ge;a(""),l(!0),d(!1);const{subject:T,emails:i,frequency:w,weekDays:y,date:D,hours:c,time:k,timezone:_,newDate:A,isDownloadFile:z,downloadFileFormat:F}=e,h=await(n==null?void 0:n(g==null?void 0:g.guestToken,!!(o!=null&&o.isDisableClient)));if(!ne(e))return;const G=Pe({date:D,frequency:w,hours:c,time:k,timezone:_,weekDays:y,newDate:A,oneTimeDate:e==null?void 0:e.oneTimeDate});if(!q(e,G,!!h))return;const Y=(be=e==null?void 0:e.charts)==null?void 0:be.map(C=>({externalMetricId:C}));g?P==null||P.mutate({id:g==null?void 0:g.id,token:h||I},{onSuccess(C){var ee,xe;(ee=C==null?void 0:C.delete_scheduleEmailReports_by_pk)!=null&&ee.id?se.mutate({data:{embedId:(m==null?void 0:m.embedDataAppId)||null,emails:i,externalDashboardId:s||((xe=m==null?void 0:m.externalDashboard)==null?void 0:xe.id),data:Y,guestToken:h||I,nextScheduledAt:G,sharingSettingsId:B||(m==null?void 0:m.sharingSettingsId),subject:T,isDownloadFile:z,downloadFileFormat:F,timeConfigurations:{...e,clients:(o==null?void 0:o.clients)||[],isDisableClient:!!(o!=null&&o.isDisableClient),isSelectAll:e==null?void 0:e.isSelectAll,isShowViewDashboardBtn:e==null?void 0:e.isShowViewDashboardBtn},isInternal:!!h},token:h||I},{onSuccess(me){var ue;(ue=me==null?void 0:me.insert_scheduleEmailReports_one)!=null&&ue.id?(a(""),l(!1),d(!0),M==null||M(),r()):(a(V),l(!1),d(!1))},onError(){a(V),l(!1),d(!1)}}):(a(V),l(!1),d(!1))},onError(){a(V),l(!1),d(!1)}}):se.mutate({data:{embedId:(m==null?void 0:m.embedDataAppId)||null,emails:i,externalDashboardId:s||((ge=m==null?void 0:m.externalDashboard)==null?void 0:ge.id),data:Y,guestToken:h||I,nextScheduledAt:G,sharingSettingsId:B||(m==null?void 0:m.sharingSettingsId),subject:T,isDownloadFile:z,downloadFileFormat:F,timeConfigurations:{...e,clients:(o==null?void 0:o.clients)||[],isDisableClient:!!(o!=null&&o.isDisableClient),isSelectAll:e==null?void 0:e.isSelectAll,isShowViewDashboardBtn:e==null?void 0:e.isShowViewDashboardBtn},isInternal:!!h},token:h||I},{onSuccess(C){var ee;(ee=C==null?void 0:C.insert_scheduleEmailReports_one)!=null&&ee.id?(a(""),l(!1),d(!0),M==null||M(),r()):(a(V),l(!1),d(!1))},onError(){a(V),l(!1),d(!1)}})},ie=async()=>{const e=await(n==null?void 0:n(g==null?void 0:g.guestToken));a(""),l(!0),$(!1),d(!1),P.mutate({id:g==null?void 0:g.id,token:e||I},{onSuccess(T){var i;(i=T==null?void 0:T.delete_scheduleEmailReports_by_pk)!=null&&i.id?(a(""),l(!1),b(),$(!0),M==null||M(),r()):(a(V),l(!1),$(!1))},onError(){a(V),l(!1),$(!1)}})},ae=j(ce),re=j(ie);return{register:S,handleSubmit:j,watch:p,control:x,setValue:u,getValues:N,reset:b,dashboardName:R,onSave:ae,isLoading:W,isSuccess:Q,error:de,scheduleReportConfig:g,onDelete:re,isDeleted:X,errors:J}},gt=({onCancel:r,getInternalToken:n,scheduleReportConfig:f,chartOptions:s,externalDashboardId:B,sharingSettingsId:M,onComplete:o,clientDropDown:S,clientState:j,isEmbed:p})=>{var ie,ae,re,e,T;const{control:x,register:u,setValue:N,watch:b,onSave:J,isLoading:m,error:I,isSuccess:g,scheduleReportConfig:W,onDelete:l,isDeleted:de,errors:a}=Ue({onCancel:r,getInternalToken:n,scheduleReportConfig:f,externalDashboardId:B,sharingSettingsId:M,onComplete:o,clientState:j}),[Q,d]=O(!0),[X,$]=O(!0),[R,se]=O(!0),[P,q]=O({showDelete:!1,deleteFunction:()=>{}}),[ne,ce]=O("");return t.jsx(t.Fragment,{children:t.jsxs("form",{className:"dbn-w-full",style:{height:"calc(100% - 44px)"},onSubmit:J,children:[t.jsx("div",{className:he.formWrapper,children:t.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-px-5 dbn-w-full dbn-h-full dbn-gap-4",children:[t.jsx(E,{variant:"popover",leftIcon:t.jsx("span",{className:Q?"":"-dbn-rotate-90",children:t.jsx(U,{name:"caret-down-fill"})}),onClick:()=>d(!Q),children:"General"}),Q&&t.jsxs(L,{direction:"col",className:"dbn-gap-2 dbn-border-b dbn-border-secondary dbn-pb-5",children:[t.jsx(je,{label:"Subject Line",placeholder:"Weekly Report - Sales Overview 2023",register:u("subject",ye),error:(ie=a.subject)==null?void 0:ie.message,isImportant:!0}),t.jsx(He,{control:x,type:"text",label:"Send to",placeholder:"Enter email addresses",register:u("emails",{validate:i=>i&&i.length>0||"At least one email is required"}),error:(ae=a.emails)==null?void 0:ae.message,onChange:()=>{a!=null&&a.emails&&(a.emails.message="")},onChangeTags:i=>N("emails",i),defaultTagValue:((re=f==null?void 0:f.timeConfigurations)==null?void 0:re.emails)||((e=W==null?void 0:W.timeConfigurations)==null?void 0:e.emails),width:"",regexStr:new RegExp("^(?![.])[a-zA-Z0-9._%+-]+(?<![.])@(?:(?!-)[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}$"),tagType:"Email address",tagError:ne,setTagError:ce,isImportant:!0})]}),t.jsx(E,{variant:"popover",leftIcon:t.jsx("span",{className:X?"":"-dbn-rotate-90",children:t.jsx(U,{name:"caret-down-fill"})}),onClick:()=>$(!X),children:"Report Content Settings"}),X&&t.jsxs(L,{direction:"col",className:"dbn-gap-2 dbn-border-b dbn-border-secondary dbn-pb-5",children:[" ",t.jsx(te,{control:x,name:"charts",rules:{validate:i=>i&&i.length>0?!0:"Please select at least one chart"},render:({field:i,fieldState:w})=>{var y;return t.jsxs(t.Fragment,{children:[t.jsx(fe,{label:"Charts to Attach",selectedOption:s.filter(D=>{var c;return(c=i.value)==null?void 0:c.some(k=>k===D.value)}),options:s,onChange:D=>{N("isSelectAll",(D==null?void 0:D.length)===(s==null?void 0:s.length)),i.onChange(D==null?void 0:D.map(c=>c.value||[]))},buttonWidth:"100%",menuWidth:"100%",isSearchEnabled:!0,isSelectAllEnabled:!0,isImportant:!0}),((y=a.charts)==null?void 0:y.message)&&t.jsx(Z,{variant:"body-text-2",color:"alert",children:`${a.charts.message}`})]})}}),S,n&&t.jsxs(L,{className:"dbn-gap-2",alignItems:"center",children:[t.jsx(we,{onChange:i=>{N("isShowViewDashboardBtn",i)},enabled:!!b("isShowViewDashboardBtn"),placeholder:"Include 'View Full Dashboard' Button",name:"enableDashboardView"}),t.jsx(pe,{text:"Adds a ‘View Full Dashboard’ button in the email, allowing recipients to access metrics in detail.",position:"bottom",isSingleLineTxt:!1,children:t.jsx(U,{name:"info"})})]}),t.jsxs(L,{className:"dbn-gap-2",alignItems:"center",children:[t.jsx(we,{onChange:i=>{N("isDownloadFile",i)},enabled:!!b("isDownloadFile"),placeholder:"Share Download file",name:"isDownloadFile"}),t.jsx(pe,{text:"Share the files in the email, allowing recipients to download.",position:"bottom",isSingleLineTxt:!1,children:t.jsx(U,{name:"info"})})]}),!!b("isDownloadFile")&&t.jsx(te,{control:x,name:"downloadFileFormat",rules:{validate:i=>i?!0:"Please select file format"},render:({field:i,fieldState:w})=>{var y,D;return t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:"Download File Format",selectedOption:le.find(c=>i.value===c.value)||le[0],options:le,onChange:c=>{i.onChange(c==null?void 0:c.value)},buttonWidth:"100%",menuWidth:"100%",isSearchEnabled:!0,isImportant:!0}),((y=a==null?void 0:a.downloadFileFormat)==null?void 0:y.message)&&t.jsx(Z,{variant:"body-text-2",color:"alert",children:`${(D=a==null?void 0:a.downloadFileFormat)==null?void 0:D.message}`})]})}})]}),t.jsx(E,{variant:"popover",leftIcon:t.jsx("span",{className:R?"":"-dbn-rotate-90",children:t.jsx(U,{name:"caret-down-fill"})}),onClick:()=>se(!R),children:"Schedule Settings"}),R&&t.jsxs(L,{direction:"col",className:"dbn-gap-2 dbn-pb-5",children:[" ",t.jsx(te,{control:x,name:"frequency",render:({field:i})=>t.jsx(oe,{label:"Frequency of emails",options:Ie,selectedOption:{value:i.value,label:i.value},onChange:w=>i.onChange(w.value),buttonWidth:"100%",menuWidth:"100%",isImportant:!0})}),(()=>{var w,y,D,c,k,_,A,z,F;const i=(w=b())==null?void 0:w.frequency;return i==="oneTime"?t.jsx(Oe,{label:"Date",isEnableSingleDate:!0,minDate:new Date,isImportant:!0,onChange:h=>N("oneTimeDate",h),defaultValues:(D=(y=b())==null?void 0:y.oneTimeDate)!=null&&D.startDate?{startDate:new Date((k=(c=b())==null?void 0:c.oneTimeDate)==null?void 0:k.startDate),endDate:new Date((A=(_=b())==null?void 0:_.oneTimeDate)==null?void 0:A.startDate),timeGrainValue:"between"}:void 0}):i==="Monthly"?t.jsx("div",{children:t.jsx(fe,{label:"Send on",options:We,selectedOption:(z=b("newDate"))!=null&&z.length?b("newDate"):[],onChange:h=>{N("newDate",h)},buttonWidth:"100%",menuWidth:"100%"})}):i==="Daily"?null:t.jsx("div",{children:t.jsx(fe,{label:"Send on",options:K,selectedOption:(F=K)==null?void 0:F.filter(h=>{var H;return(H=b("weekDays"))==null?void 0:H[h.value]}),onChange:h=>{var H,G;h!=null&&h.length?(H=K)==null||H.forEach(v=>N(`weekDays.${v.value}`,h==null?void 0:h.some(Y=>v.value===(Y==null?void 0:Y.value)))):(G=K)==null||G.forEach(v=>N(`weekDays.${v.value}`,!1))},buttonWidth:"100%",menuWidth:"100%"})})})(),t.jsxs("div",{className:he["schedule-time"],children:[t.jsxs(Z,{variant:"input-label",children:["Scheduled Time",t.jsx("span",{className:"dbn-text-alert",children:"*"})]}),t.jsxs("div",{className:he["time-element"],"data-testid":"schedule-time",children:[t.jsx(je,{type:"number",min:1,max:12,register:u("hours",ye),defaultValue:5,error:(T=a.hours)==null?void 0:T.message,id:"hours"}),t.jsx(te,{control:x,name:"time",render:({field:i})=>t.jsx(oe,{options:Ae,selectedOption:{value:i.value,label:i.value},onChange:w=>i.onChange(w.value),buttonWidth:n?"120px":"150px",menuWidth:n?"120px":"150px",id:"am-pm"})}),t.jsx(te,{control:x,name:"timezone",render:({field:i})=>t.jsx(oe,{options:De,selectedOption:{value:i.value,label:i.value},onChange:w=>i.onChange(w.value),buttonWidth:n?"120px":"150px",menuWidth:n?"120px":"150px",id:"timezone"})})]})]})]}),I&&t.jsx(Ce,{message:I}),g&&t.jsx(Z,{variant:"body-text-2",color:"success",children:"Scheduled successfully!"}),de&&t.jsx(Z,{variant:"body-text-2",color:"success",children:"Deleted successfully!"})]})}),n&&t.jsx(L,{direction:"row",justify:"end",className:"dbn-w-full dbn-border-t dbn-border-secondary dbn-py-3 dbn-h-[60px] dbn-px-5 dbn-items-center",children:t.jsxs(L,{className:"dbn-gap-2",children:[f||W?t.jsx(E,{type:"button",variant:"secondary",onClick:()=>{q({showDelete:!0,deleteFunction:l})},isDisabled:m,className:"dbn-bg-gray dbn-border-secondary",children:"Delete"}):t.jsx(E,{type:"reset",variant:"tab",onClick:()=>r(),isDisabled:m,children:"Cancel"}),t.jsx(E,{variant:"primary",type:"submit",isDisabled:m||!!ne,children:f||W?"Update":"Save"})]})}),!n&&t.jsxs(Te,{children:[f||W?t.jsx(E,{type:"button",variant:"secondary",onClick:()=>{q({showDelete:!0,deleteFunction:l})},isDisabled:m,children:"Delete"}):t.jsx(E,{type:"reset",variant:"tab",onClick:()=>r(),isDisabled:m,children:"Cancel"}),t.jsx(E,{variant:"primary",type:"submit",isDisabled:m,children:f||W?"Update":"Save"})]}),t.jsxs(qe,{customHeader:t.jsxs("div",{className:"dbn-w-full dbn-flex dbn-items-center dbn-justify-between",children:[t.jsxs("div",{className:"dbn-flex dbn-items-center dbn-gap-2",children:[t.jsx(U,{name:"delete",color:"alert"}),"Irreversible action"]}),t.jsx(E,{variant:"tertiary",type:"button",onClick:()=>q({showDelete:!1,deleteFunction:()=>{}}),leftIcon:t.jsx(U,{name:"cross",size:"sm"}),style:{padding:"0",height:"20px"}})]}),size:"sm",isOpen:P.showDelete,onClose:()=>q({showDelete:!1,deleteFunction:()=>{}}),children:[t.jsx("div",{className:"dbn-pt-4 dbn-pb-8 dbn-pl-6",children:t.jsx(L,{justify:"start",alignItems:"center",className:"dbn-gap-2",children:t.jsx(Z,{variant:"body-text-2",children:"Are you sure you want to delete this schedule?"})})}),t.jsx(Te,{className:"dbn-justify-between",children:t.jsxs("div",{className:"dbn-ml-auto dbn-flex dbn-gap-4",children:[t.jsx(E,{type:"reset",size:"small",variant:"tab",onClick:()=>q({showDelete:!1,deleteFunction:()=>{}}),children:"Cancel"}),t.jsx(E,{type:"button",size:"small",variant:"primary",onClick:()=>{P.deleteFunction(),q({showDelete:!1,deleteFunction:()=>{}})},className:"dbn-bg-alert hover:dbn-bg-discard-hover",children:"Delete"})]})})]})]})})};export{gt as ScheduleEmailForm,gt as default};
1
+ import{j as t}from"./ui-vendor-DuTfa2UR.mjs";import{useMemo as Fe,useEffect as Ne,useState as O}from"react";import{u as Ee,C as te}from"./react-utils-DgU8eu9z.mjs";import{u as Se,a as ke,b as _e,S as we}from"./index-DOjiRxyH.mjs";import{W as K,y as De,z as le,F as V,H as Ie,J as We,K as Ae}from"./metricOptions-eMjyT9mw.mjs";import{r as ye,T as He}from"./index-B-Bb04Ow.mjs";import{E as Ce}from"./index-DwYE0XjC.mjs";import{B as E}from"./index-DhbU7Mia.mjs";import{I as U}from"./index-CXxcrvqq.mjs";import{F as L}from"./index-B1NuJ0kR.mjs";import{I as je}from"./index-DzlWCFpe.mjs";import{M as fe}from"./index-BlNXCmSV.mjs";import{T as Z}from"./index-zxPTeqmL.mjs";import{N as pe}from"./index-BJGdplie.mjs";import{F as oe}from"./index-C26NEE4H.mjs";import{D as Oe}from"./index-B-xrDNSO.mjs";import{a as Te,M as qe}from"./ModalFooter-DN5Z9yNl.mjs";import"react-dom";import"./editor-vendor-DzeR_zKV.mjs";import"./chart-vendor-DLB-rMJR.mjs";import"./webcomponents.es.js";import"./index-BRqJa8kU.mjs";import"./data-vendor-eZSTXlsm.mjs";import"./index-BLh5Cmay.mjs";import"./index-BkMSEw_J.mjs";import"./index-DafPJT-X.mjs";import"./index-D3hhF5t0.mjs";const ze="_formWrapper_48444_1",he={formWrapper:ze,"time-element":"_time-element_48444_16","schedule-time":"_schedule-time_48444_19"},Ve=r=>De[De.findIndex(f=>f.value===r)].timezoneOffset*-1,Le=(r,n)=>{let f=0;for(let s=0;s<r.length;s++)if(r[s]>=n)return f=s,f;return f},Me=r=>{const n=new Date,f=n.getMonth(),s=n.getFullYear();return(r==null?void 0:r.map(o=>{switch(o==null?void 0:o.value){case"firstDay":return 1;case"lastDay":return new Date(s,f+1,0).getDate();case"firstMonday":{const S=new Date(s,f,1);return S.getDay()===0?2:(9-S.getDay())%7+1}case"15OfMonth":return 15;default:return null}})).filter(o=>o).sort((o,S)=>o-S)},Pe=r=>{var M,o,S;let n=new Date;n=new Date(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds()),n.setMinutes(n.getMinutes()+1);const f=Ve(r.timezone);n.setTime(n.getTime()-f*6e4);let s=null;switch(r.frequency){case"oneTime":s=new Date(((M=r==null?void 0:r.oneTimeDate)==null?void 0:M.startDate)||"");break;case"Daily":s=new Date(n),s.setDate(n.getDate());break;case"Weekly":{const j=Object.keys(r.weekDays).filter(x=>r.weekDays[x]);let p=null;j.forEach(x=>{const N=(K.findIndex(J=>J.value===x)+7-n.getDay())%7,b=new Date(n);b.setDate(n.getDate()+N),b.toDateString()===n.toDateString()&&b.setDate(b.getDate()+7),(!p||b<p)&&(p=b)}),s=p;break}case"Monthly":{const j=r.newDate?Me(r.newDate):(o=r.date)==null?void 0:o.map(x=>parseInt(x.value,10));let p=null;j.forEach(x=>{const u=new Date(n.getFullYear(),n.getMonth(),x);u<n&&u.setMonth(n.getMonth()),(!p||u<p)&&(p=u)}),s=p;break}}if(s!==null)switch(s.setHours(parseInt(r.hours,10),0,0,0),r.time==="PM"&&r.hours==="12"?s.setHours(12):r.time==="PM"?s.setHours(parseInt(r.hours,10)+12):r.time==="AM"&&r.hours==="12"&&s.setHours(0),r.frequency){case"Daily":case"oneTime":s.getHours()<=n.getHours()&&s.setDate(s.getDate()+1);break;case"Weekly":{Object.keys(r.weekDays).filter(p=>r.weekDays[p]).includes(K[n.getDay()].value)&&s.getHours()>n.getHours()&&s.setDate(n.getDate());break}case"Monthly":{const j=r.newDate?Me(r.newDate):(S=r.date)==null?void 0:S.map(x=>parseInt(x.value,10)).sort((x,u)=>x-u),p=Le(j,n.getDate());s.setDate(j[p]),s.getDate()<=n.getDate()&&s.getHours()<=n.getHours()&&s.setDate(j[(p+1)%j.length]),s.getMonth()===n.getMonth()&&s.getDate()<=n.getDate()&&s.getHours()<=n.getHours()&&(s.setMonth(s.getMonth()+1),s.setDate(j[0])),s.getMonth()===n.getMonth()&&s.getDate()<n.getDate()&&s.setMonth(s.getMonth()+1);break}}return`${s==null?void 0:s.getDate()}/${(s==null?void 0:s.getMonth())+1}/${s==null?void 0:s.getFullYear()}, ${s==null?void 0:s.toLocaleTimeString()}`},Ue=({onCancel:r,getInternalToken:n,scheduleReportConfig:f,externalDashboardId:s,sharingSettingsId:B,onComplete:M,clientState:o})=>{const{register:S,handleSubmit:j,watch:p,control:x,setValue:u,getValues:N,reset:b,formState:{errors:J}}=Ee(),{data:m,token:I}=Se(),g=Fe(()=>{if(f)return f},[f]);Ne(()=>{var e,T;g?b({...g==null?void 0:g.timeConfigurations}):(u("time","PM"),u("timezone","Asia/Kolkata"),u("frequency","Daily"),u("subject",""),u("downloadFileFormat",(T=(e=le)==null?void 0:e[0])==null?void 0:T.value))},[g]);const[W,l]=O(!1),[de,a]=O(""),[Q,d]=O(!1),[X,$]=O(!1),R="",se=ke(),P=_e(),q=(e,T,i)=>{var w,y,D,c,k,_;if(!((w=e==null?void 0:e.charts)!=null&&w.length)&&!i)return a("please select at least one chart to share"),l(!1),d(!1),!1;if(!((y=e==null?void 0:e.emails)!=null&&y.length))return a("please add at least one email address"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="Weekly"&&!(Object!=null&&Object.values({...e==null?void 0:e.weekDays}).includes(!0)))return a("please select atleast one day"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="Monthly"&&!((D=e==null?void 0:e.newDate)!=null&&D.length))return a("please select at least one date option"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"&&!((c=e==null?void 0:e.oneTimeDate)!=null&&c.startDate))return a("please select date for one time schedule"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"){const A=(k=e==null?void 0:e.oneTimeDate)==null?void 0:k.startDate;if(!A)return!1;const z=typeof A=="string"?new Date(A):new Date(A.getTime());if(isNaN(z.getTime()))return a("invalid date selected"),l(!1),d(!1),!1;const F=Number(e==null?void 0:e.hours);if(Number.isNaN(F)||F<1||F>12)return a("invalid hour"),l(!1),d(!1),!1;const h=(e==null?void 0:e.time)==="PM"&&F!==12?F+12:(e==null?void 0:e.time)==="AM"&&F===12?0:F,H=new Date(z.getTime());if(H.setHours(h,0,0,0),H.getTime()<=Date.now())return a("please select valid time for one time schedule"),l(!1),d(!1),!1}return T?o!=null&&o.isRequiredClient&&!((_=o==null?void 0:o.clients)!=null&&_.length)?(a("please select at least one client"),l(!1),d(!1),!1):!0:(a("invalid time configurations"),l(!1),d(!1),!1)},ne=e=>{var T,i,w;if((e==null?void 0:e.frequency)==="Weekly"&&!(Object!=null&&Object.values({...e==null?void 0:e.weekDays}).includes(!0)))return a("please select atleast one day"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="Monthly"&&!((T=e==null?void 0:e.newDate)!=null&&T.length))return a("please select at least one date option"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"&&!((i=e==null?void 0:e.oneTimeDate)!=null&&i.startDate))return a("please select date for one time schedule"),l(!1),d(!1),!1;if((e==null?void 0:e.frequency)==="oneTime"){const y=(w=e==null?void 0:e.oneTimeDate)==null?void 0:w.startDate;if(!y)return!1;const D=typeof y=="string"?new Date(y):new Date(y.getTime());if(isNaN(D.getTime()))return a("invalid date selected"),l(!1),d(!1),!1;const c=Number(e==null?void 0:e.hours);if(Number.isNaN(c)||c<1||c>12)return a("invalid hour"),l(!1),d(!1),!1;const k=(e==null?void 0:e.time)==="PM"&&c!==12?c+12:(e==null?void 0:e.time)==="AM"&&c===12?0:c,_=new Date(D.getTime());if(_.setHours(k,0,0,0),_.getTime()<=Date.now())return a("please select valid time for one time schedule"),l(!1),d(!1),!1}return!0},ce=async e=>{var be,ge;a(""),l(!0),d(!1);const{subject:T,emails:i,frequency:w,weekDays:y,date:D,hours:c,time:k,timezone:_,newDate:A,isDownloadFile:z,downloadFileFormat:F}=e,h=await(n==null?void 0:n(g==null?void 0:g.guestToken,!!(o!=null&&o.isDisableClient)));if(!ne(e))return;const G=Pe({date:D,frequency:w,hours:c,time:k,timezone:_,weekDays:y,newDate:A,oneTimeDate:e==null?void 0:e.oneTimeDate});if(!q(e,G,!!h))return;const Y=(be=e==null?void 0:e.charts)==null?void 0:be.map(C=>({externalMetricId:C}));g?P==null||P.mutate({id:g==null?void 0:g.id,token:h||I},{onSuccess(C){var ee,xe;(ee=C==null?void 0:C.delete_scheduleEmailReports_by_pk)!=null&&ee.id?se.mutate({data:{embedId:(m==null?void 0:m.embedDataAppId)||null,emails:i,externalDashboardId:s||((xe=m==null?void 0:m.externalDashboard)==null?void 0:xe.id),data:Y,guestToken:h||I,nextScheduledAt:G,sharingSettingsId:B||(m==null?void 0:m.sharingSettingsId),subject:T,isDownloadFile:z,downloadFileFormat:F,timeConfigurations:{...e,clients:(o==null?void 0:o.clients)||[],isDisableClient:!!(o!=null&&o.isDisableClient),isSelectAll:e==null?void 0:e.isSelectAll,isShowViewDashboardBtn:e==null?void 0:e.isShowViewDashboardBtn},isInternal:!!h},token:h||I},{onSuccess(me){var ue;(ue=me==null?void 0:me.insert_scheduleEmailReports_one)!=null&&ue.id?(a(""),l(!1),d(!0),M==null||M(),r()):(a(V),l(!1),d(!1))},onError(){a(V),l(!1),d(!1)}}):(a(V),l(!1),d(!1))},onError(){a(V),l(!1),d(!1)}}):se.mutate({data:{embedId:(m==null?void 0:m.embedDataAppId)||null,emails:i,externalDashboardId:s||((ge=m==null?void 0:m.externalDashboard)==null?void 0:ge.id),data:Y,guestToken:h||I,nextScheduledAt:G,sharingSettingsId:B||(m==null?void 0:m.sharingSettingsId),subject:T,isDownloadFile:z,downloadFileFormat:F,timeConfigurations:{...e,clients:(o==null?void 0:o.clients)||[],isDisableClient:!!(o!=null&&o.isDisableClient),isSelectAll:e==null?void 0:e.isSelectAll,isShowViewDashboardBtn:e==null?void 0:e.isShowViewDashboardBtn},isInternal:!!h},token:h||I},{onSuccess(C){var ee;(ee=C==null?void 0:C.insert_scheduleEmailReports_one)!=null&&ee.id?(a(""),l(!1),d(!0),M==null||M(),r()):(a(V),l(!1),d(!1))},onError(){a(V),l(!1),d(!1)}})},ie=async()=>{const e=await(n==null?void 0:n(g==null?void 0:g.guestToken));a(""),l(!0),$(!1),d(!1),P.mutate({id:g==null?void 0:g.id,token:e||I},{onSuccess(T){var i;(i=T==null?void 0:T.delete_scheduleEmailReports_by_pk)!=null&&i.id?(a(""),l(!1),b(),$(!0),M==null||M(),r()):(a(V),l(!1),$(!1))},onError(){a(V),l(!1),$(!1)}})},ae=j(ce),re=j(ie);return{register:S,handleSubmit:j,watch:p,control:x,setValue:u,getValues:N,reset:b,dashboardName:R,onSave:ae,isLoading:W,isSuccess:Q,error:de,scheduleReportConfig:g,onDelete:re,isDeleted:X,errors:J}},gt=({onCancel:r,getInternalToken:n,scheduleReportConfig:f,chartOptions:s,externalDashboardId:B,sharingSettingsId:M,onComplete:o,clientDropDown:S,clientState:j,isEmbed:p})=>{var ie,ae,re,e,T;const{control:x,register:u,setValue:N,watch:b,onSave:J,isLoading:m,error:I,isSuccess:g,scheduleReportConfig:W,onDelete:l,isDeleted:de,errors:a}=Ue({onCancel:r,getInternalToken:n,scheduleReportConfig:f,externalDashboardId:B,sharingSettingsId:M,onComplete:o,clientState:j}),[Q,d]=O(!0),[X,$]=O(!0),[R,se]=O(!0),[P,q]=O({showDelete:!1,deleteFunction:()=>{}}),[ne,ce]=O("");return t.jsx(t.Fragment,{children:t.jsxs("form",{className:"dbn-w-full",style:{height:"calc(100% - 44px)"},onSubmit:J,children:[t.jsx("div",{className:he.formWrapper,children:t.jsxs("div",{className:"dbn-flex dbn-flex-col dbn-px-5 dbn-w-full dbn-h-full dbn-gap-4",children:[t.jsx(E,{variant:"popover",leftIcon:t.jsx("span",{className:Q?"":"-dbn-rotate-90",children:t.jsx(U,{name:"caret-down-fill"})}),onClick:()=>d(!Q),children:"General"}),Q&&t.jsxs(L,{direction:"col",className:"dbn-gap-2 dbn-border-b dbn-border-secondary dbn-pb-5",children:[t.jsx(je,{label:"Subject Line",placeholder:"Weekly Report - Sales Overview 2023",register:u("subject",ye),error:(ie=a.subject)==null?void 0:ie.message,isImportant:!0}),t.jsx(He,{control:x,type:"text",label:"Send to",placeholder:"Enter email addresses",register:u("emails",{validate:i=>i&&i.length>0||"At least one email is required"}),error:(ae=a.emails)==null?void 0:ae.message,onChange:()=>{a!=null&&a.emails&&(a.emails.message="")},onChangeTags:i=>N("emails",i),defaultTagValue:((re=f==null?void 0:f.timeConfigurations)==null?void 0:re.emails)||((e=W==null?void 0:W.timeConfigurations)==null?void 0:e.emails),width:"",regexStr:new RegExp("^(?![.])[a-zA-Z0-9._%+-]+(?<![.])@(?:(?!-)[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}$"),tagType:"Email address",tagError:ne,setTagError:ce,isImportant:!0})]}),t.jsx(E,{variant:"popover",leftIcon:t.jsx("span",{className:X?"":"-dbn-rotate-90",children:t.jsx(U,{name:"caret-down-fill"})}),onClick:()=>$(!X),children:"Report Content Settings"}),X&&t.jsxs(L,{direction:"col",className:"dbn-gap-2 dbn-border-b dbn-border-secondary dbn-pb-5",children:[" ",t.jsx(te,{control:x,name:"charts",rules:{validate:i=>i&&i.length>0?!0:"Please select at least one chart"},render:({field:i,fieldState:w})=>{var y;return t.jsxs(t.Fragment,{children:[t.jsx(fe,{label:"Charts to Attach",selectedOption:s.filter(D=>{var c;return(c=i.value)==null?void 0:c.some(k=>k===D.value)}),options:s,onChange:D=>{N("isSelectAll",(D==null?void 0:D.length)===(s==null?void 0:s.length)),i.onChange(D==null?void 0:D.map(c=>c.value||[]))},buttonWidth:"100%",menuWidth:"100%",isSearchEnabled:!0,isSelectAllEnabled:!0,isImportant:!0}),((y=a.charts)==null?void 0:y.message)&&t.jsx(Z,{variant:"body-text-2",color:"alert",children:`${a.charts.message}`})]})}}),S,n&&t.jsxs(L,{className:"dbn-gap-2",alignItems:"center",children:[t.jsx(we,{onChange:i=>{N("isShowViewDashboardBtn",i)},enabled:!!b("isShowViewDashboardBtn"),placeholder:"Include 'View Full Dashboard' Button",name:"enableDashboardView"}),t.jsx(pe,{text:"Adds a ‘View Full Dashboard’ button in the email, allowing recipients to access metrics in detail.",position:"bottom",isSingleLineTxt:!1,children:t.jsx(U,{name:"info"})})]}),t.jsxs(L,{className:"dbn-gap-2",alignItems:"center",children:[t.jsx(we,{onChange:i=>{N("isDownloadFile",i)},enabled:!!b("isDownloadFile"),placeholder:"Share Download file",name:"isDownloadFile"}),t.jsx(pe,{text:"Share the files in the email, allowing recipients to download.",position:"bottom",isSingleLineTxt:!1,children:t.jsx(U,{name:"info"})})]}),!!b("isDownloadFile")&&t.jsx(te,{control:x,name:"downloadFileFormat",rules:{validate:i=>i?!0:"Please select file format"},render:({field:i,fieldState:w})=>{var y,D;return t.jsxs(t.Fragment,{children:[t.jsx(oe,{label:"Download File Format",selectedOption:le.find(c=>i.value===c.value)||le[0],options:le,onChange:c=>{i.onChange(c==null?void 0:c.value)},buttonWidth:"100%",menuWidth:"100%",isSearchEnabled:!0,isImportant:!0}),((y=a==null?void 0:a.downloadFileFormat)==null?void 0:y.message)&&t.jsx(Z,{variant:"body-text-2",color:"alert",children:`${(D=a==null?void 0:a.downloadFileFormat)==null?void 0:D.message}`})]})}})]}),t.jsx(E,{variant:"popover",leftIcon:t.jsx("span",{className:R?"":"-dbn-rotate-90",children:t.jsx(U,{name:"caret-down-fill"})}),onClick:()=>se(!R),children:"Schedule Settings"}),R&&t.jsxs(L,{direction:"col",className:"dbn-gap-2 dbn-pb-5",children:[" ",t.jsx(te,{control:x,name:"frequency",render:({field:i})=>t.jsx(oe,{label:"Frequency of emails",options:Ie,selectedOption:{value:i.value,label:i.value},onChange:w=>i.onChange(w.value),buttonWidth:"100%",menuWidth:"100%",isImportant:!0})}),(()=>{var w,y,D,c,k,_,A,z,F;const i=(w=b())==null?void 0:w.frequency;return i==="oneTime"?t.jsx(Oe,{label:"Date",isEnableSingleDate:!0,minDate:new Date,isImportant:!0,onChange:h=>N("oneTimeDate",h),defaultValues:(D=(y=b())==null?void 0:y.oneTimeDate)!=null&&D.startDate?{startDate:new Date((k=(c=b())==null?void 0:c.oneTimeDate)==null?void 0:k.startDate),endDate:new Date((A=(_=b())==null?void 0:_.oneTimeDate)==null?void 0:A.startDate),timeGrainValue:"between"}:void 0}):i==="Monthly"?t.jsx("div",{children:t.jsx(fe,{label:"Send on",options:We,selectedOption:(z=b("newDate"))!=null&&z.length?b("newDate"):[],onChange:h=>{N("newDate",h)},buttonWidth:"100%",menuWidth:"100%"})}):i==="Daily"?null:t.jsx("div",{children:t.jsx(fe,{label:"Send on",options:K,selectedOption:(F=K)==null?void 0:F.filter(h=>{var H;return(H=b("weekDays"))==null?void 0:H[h.value]}),onChange:h=>{var H,G;h!=null&&h.length?(H=K)==null||H.forEach(v=>N(`weekDays.${v.value}`,h==null?void 0:h.some(Y=>v.value===(Y==null?void 0:Y.value)))):(G=K)==null||G.forEach(v=>N(`weekDays.${v.value}`,!1))},buttonWidth:"100%",menuWidth:"100%"})})})(),t.jsxs("div",{className:he["schedule-time"],children:[t.jsxs(Z,{variant:"input-label",children:["Scheduled Time",t.jsx("span",{className:"dbn-text-alert",children:"*"})]}),t.jsxs("div",{className:he["time-element"],"data-testid":"schedule-time",children:[t.jsx(je,{type:"number",min:1,max:12,register:u("hours",ye),defaultValue:5,error:(T=a.hours)==null?void 0:T.message,id:"hours"}),t.jsx(te,{control:x,name:"time",render:({field:i})=>t.jsx(oe,{options:Ae,selectedOption:{value:i.value,label:i.value},onChange:w=>i.onChange(w.value),buttonWidth:n?"120px":"150px",menuWidth:n?"120px":"150px",id:"am-pm"})}),t.jsx(te,{control:x,name:"timezone",render:({field:i})=>t.jsx(oe,{options:De,selectedOption:{value:i.value,label:i.value},onChange:w=>i.onChange(w.value),buttonWidth:n?"120px":"150px",menuWidth:n?"120px":"150px",id:"timezone"})})]})]})]}),I&&t.jsx(Ce,{message:I}),g&&t.jsx(Z,{variant:"body-text-2",color:"success",children:"Scheduled successfully!"}),de&&t.jsx(Z,{variant:"body-text-2",color:"success",children:"Deleted successfully!"})]})}),n&&t.jsx(L,{direction:"row",justify:"end",className:"dbn-w-full dbn-border-t dbn-border-secondary dbn-py-3 dbn-h-[60px] dbn-px-5 dbn-items-center",children:t.jsxs(L,{className:"dbn-gap-2",children:[f||W?t.jsx(E,{type:"button",variant:"secondary",onClick:()=>{q({showDelete:!0,deleteFunction:l})},isDisabled:m,className:"dbn-bg-gray dbn-border-secondary",children:"Delete"}):t.jsx(E,{type:"reset",variant:"tab",onClick:()=>r(),isDisabled:m,children:"Cancel"}),t.jsx(E,{variant:"primary",type:"submit",isDisabled:m||!!ne,children:f||W?"Update":"Save"})]})}),!n&&t.jsxs(Te,{children:[f||W?t.jsx(E,{type:"button",variant:"secondary",onClick:()=>{q({showDelete:!0,deleteFunction:l})},isDisabled:m,children:"Delete"}):t.jsx(E,{type:"reset",variant:"tab",onClick:()=>r(),isDisabled:m,children:"Cancel"}),t.jsx(E,{variant:"primary",type:"submit",isDisabled:m,children:f||W?"Update":"Save"})]}),t.jsxs(qe,{customHeader:t.jsxs("div",{className:"dbn-w-full dbn-flex dbn-items-center dbn-justify-between",children:[t.jsxs("div",{className:"dbn-flex dbn-items-center dbn-gap-2",children:[t.jsx(U,{name:"delete",color:"alert"}),"Irreversible action"]}),t.jsx(E,{variant:"tertiary",type:"button",onClick:()=>q({showDelete:!1,deleteFunction:()=>{}}),leftIcon:t.jsx(U,{name:"cross",size:"sm"}),style:{padding:"0",height:"20px"}})]}),size:"sm",isOpen:P.showDelete,onClose:()=>q({showDelete:!1,deleteFunction:()=>{}}),children:[t.jsx("div",{className:"dbn-pt-4 dbn-pb-8 dbn-pl-6",children:t.jsx(L,{justify:"start",alignItems:"center",className:"dbn-gap-2",children:t.jsx(Z,{variant:"body-text-2",children:"Are you sure you want to delete this schedule?"})})}),t.jsx(Te,{className:"dbn-justify-between",children:t.jsxs("div",{className:"dbn-ml-auto dbn-flex dbn-gap-4",children:[t.jsx(E,{type:"reset",size:"small",variant:"tab",onClick:()=>q({showDelete:!1,deleteFunction:()=>{}}),children:"Cancel"}),t.jsx(E,{type:"button",size:"small",variant:"primary",onClick:()=>{P.deleteFunction(),q({showDelete:!1,deleteFunction:()=>{}})},className:"dbn-bg-alert hover:dbn-bg-discard-hover",children:"Delete"})]})})]})]})})};export{gt as ScheduleEmailForm,gt as default};