PageSourceSearch

https://avada-blog-app.firebaseapp.com/assets/index-vuYNMf3d.js

js avada-blog-app.firebaseapp.com collected 2026-10-03 14:05:23 UTC 28,415 bytes, 1 lines download raw bytes

1import{c as l,eM as xa,eN as ga,j as e,m as re,P as de,f as ce,d as T,eO as ja,F as s,eP as Ne,eQ as ae,eR as je,x as oe,l as M,R as Aa,D as ya,n as b,V as We,eS as _a,eT as wa,eU as Ge,C as ue,ad as Ma,ai as he,u as Ke,M as W,aF as Da,a1 as Me,eV as Xe,o as Na,t as Ea,aA as Ca,bx as Ta,p as Pa,eW as F,at as De,ay as Be,s as Ae,U as Ra,H as Ia,dz as La,eX as Oe,dv as ka,ah as qa,eY as Ua,eZ as Fe,e_ as He,c8 as Ba,e$ as Oa,h as Fa,ba as Ha,f0 as $a,dT as $e,dU as Ve,dV as ye,f1 as Ye,f2 as Qe,co as Z,f3 as Va}from"./app-DkDOFxbL.js";import{S as Ya}from"./FilterIcon.svg-fSdE69dJ.js";import{S as me}from"./CalendarIcon.svg-BC9Wd-ET.js";import{S as Se}from"./EditIcon.svg-pSsXIAFj.js";import{D as Ee,T as Ce}from"./TimePickerInput-o7z9tYcC.js";import"./DatePicker-C5owzK72.js";import"./ClockIcon.svg-bBa8NLBM.js";function Ze({month:t,year:i,filter:u,i18n:n,onMonthChange:r,onYearChange:D,onFilterChange:N}){var x;const[A,o]=l.useState(!1),[_,h]=l.useState(!1),[P,y]=l.useState(!1),m=xa(n),j=ja(i),E=ga(n),g=((x=m.find(d=>d.value===String(t)))==null?void 0:x.label)||"";return e.jsxs("div",{className:"Avada-Schedule__toolbar",children:[e.jsxs(re,{gap:"300",blockAlign:"center",children:[e.jsx(de,{active:A,activator:e.jsx(T,{disclosure:"down",onClick:()=>o(d=>!d),children:`${n.translate("Schedule.toolbar.month")}: ${g}`}),onClose:()=>o(!1),children:e.jsx(ce,{actionRole:"menuitemradio",items:m.map(d=>({content:d.label,active:d.value===String(t),onAction:()=>{r(Number(d.value)),o(!1)}}))})}),e.jsx(de,{active:_,activator:e.jsx(T,{disclosure:"down",onClick:()=>h(d=>!d),children:`${n.translate("Schedule.toolbar.year")}: ${i}`}),onClose:()=>h(!1),children:e.jsx(ce,{actionRole:"menuitemradio",items:j.map(d=>({content:d.label,active:d.value===String(i),onAction:()=>{D(Number(d.value)),h(!1)}}))})})]}),e.jsx("div",{className:"Avada-Schedule__toolbarFilters",children:e.jsx(de,{active:P,activator:e.jsx(T,{icon:Ya,accessibilityLabel:n.translate("Schedule.toolbar.filter"),onClick:()=>y(d=>!d)}),onClose:()=>y(!1),preferredAlignment:"right",children:e.jsx(ce,{actionRole:"menuitemradio",items:E.map(d=>({content:d.label,active:d.value===u,onAction:()=>{N(d.value),y(!1)}}))})})})]})}Ze.propTypes={month:s.number.isRequired,year:s.number.isRequired,filter:s.string.isRequired,i18n:s.object.isRequired,onMonthChange:s.func.isRequired,onYearChange:s.func.isRequired,onFilterChange:s.func.isRequired};function Je({event:t,i18n:i,onViewDetails:u}){const n=Ne(t.date),r=t.status===ae.PUBLISHED;return e.jsxs("button",{type:"button",className:`Avada-Schedule__event${r?" Avada-Schedule__event--published":""}`,onClick:()=>u(t),children:[e.jsx("span",{className:"Avada-Schedule__eventTitle",children:t.title||i.translate("Schedule.untitled")}),n&&e.jsx("span",{className:"Avada-Schedule__eventTime",children:n})]})}Je.propTypes={event:s.shape({id:s.string,title:s.string,date:s.instanceOf(Date),status:s.string}).isRequired,i18n:s.object.isRequired,onViewDetails:s.func.isRequired};function Te({day:t,events:i,isToday:u,i18n:n,onViewDetails:r,onContextMenu:D}){const[N,A]=l.useState(!1),o=l.useRef(null),_=i.length>je,h=_?i.slice(0,je-1):i,P=_?i.slice(je-1):[],y=P.length,m=l.useCallback(()=>{o.current&&clearTimeout(o.current),A(!0)},[]),j=l.useCallback(()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>A(!1),120)},[]),E=d=>{d.preventDefault(),D({date:t.date,x:d.clientX,y:d.clientY})},g=d=>{d.target.closest("button")||(d.stopPropagation(),D({date:t.date,x:d.clientX,y:d.clientY}))},x=e.jsx("button",{type:"button",className:"Avada-Schedule__more",onMouseEnter:m,onMouseLeave:j,children:n.translate("Schedule.morePosts",{count:y})});return e.jsxs("div",{className:["Avada-Schedule__day",!t.inMonth&&"Avada-Schedule__day--outside",u&&"Avada-Schedule__day--today"].filter(Boolean).join(" "),onContextMenu:E,onClick:g,children:[e.jsx("span",{className:"Avada-Schedule__dayNumber",children:String(t.date.getDate()).padStart(2,"0")}),e.jsxs("div",{className:"Avada-Schedule__dayEvents",children:[h.map(d=>e.jsx(Je,{event:d,i18n:n,onViewDetails:r},d.id)),y>0&&e.jsx("div",{className:"Avada-Schedule__moreCell",children:e.jsx(de,{active:N,activator:x,onClose:()=>A(!1),preferredPosition:"below",autofocusTarget:"none",children:e.jsx("div",{onMouseEnter:m,onMouseLeave:j,children:e.jsx(oe,{minWidth:"240px",children:e.jsx(M,{gap:"0",children:P.map((d,H)=>{const q=Ne(d.date);return e.jsxs(Aa.Fragment,{children:[H>0&&e.jsx(ya,{}),e.jsx(oe,{padding:"300",children:e.jsxs(M,{gap:"050",children:[e.jsx(b,{variant:"bodyMd",as:"p",children:d.title||n.translate("Schedule.untitled")}
1),q&&e.jsx(b,{variant:"bodySm",tone:"subdued",as:"p",children:q}),e.jsx("div",{children:e.jsx(T,{variant:"plain",onClick:()=>r(d),children:n.translate("Schedule.viewDetails")})})]})})]},d.id)})})})})})})]})]})}Te.propTypes={day:s.shape({date:s.instanceOf(Date).isRequired,inMonth:s.bool,key:s.string}).isRequired,events:s.array,isToday:s.bool,i18n:s.object.isRequired,onViewDetails:s.func.isRequired,onContextMenu:s.func.isRequired};Te.defaultProps={events:[],isToday:!1};function ea({weeks:t,eventsByDay:i,today:u,loading:n,i18n:r,onViewDetails:D,onAddSchedule:N,onCreatePost:A}){const[o,_]=l.useState(null),h=l.useCallback(()=>_(null),[]);l.useEffect(()=>{if(!o)return;const m=()=>h();return window.addEventListener("click",m),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("click",m),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[o,h]);const P=l.useCallback(m=>_(m),[]),y=[{content:r.translate("Schedule.contextMenu.addSchedule"),icon:me,onAction:()=>{N(o==null?void 0:o.date),h()}},{content:r.translate("Schedule.contextMenu.createPost"),icon:Se,onAction:()=>{A(o==null?void 0:o.date),h()}}];return e.jsxs("div",{className:"Avada-Schedule__calendar",children:[n&&e.jsx("div",{className:"Avada-Schedule__loadingOverlay",children:e.jsx(We,{size:"large",accessibilityLabel:r.translate("Schedule.modal.loading")})}),e.jsx("div",{className:"Avada-Schedule__weekHeader",children:_a.map(m=>e.jsx("div",{className:"Avada-Schedule__weekHeaderCell",children:e.jsx(b,{variant:"bodySm",tone:"subdued",as:"span",children:r.translate(`Schedule.weekdays.${m}`)})},m))}),t.map((m,j)=>e.jsx("div",{className:"Avada-Schedule__week",children:m.map(E=>e.jsx(Te,{day:E,events:i[Ge(E.date)]||[],isToday:wa(E.date,u),i18n:r,onViewDetails:D,onContextMenu:P},E.key))},j)),o&&e.jsx("div",{className:"Avada-Schedule__contextMenu",style:{top:o.y,left:o.x},onClick:m=>m.stopPropagation(),children:e.jsx(ce,{actionRole:"menuitem",items:y})})]})}ea.propTypes={weeks:s.array.isRequired,eventsByDay:s.object.isRequired,today:s.instanceOf(Date).isRequired,loading:s.bool,i18n:s.object.isRequired,onViewDetails:s.func.isRequired,onAddSchedule:s.func.isRequired,onCreatePost:s.func.isRequired};function Pe({posts:t,loading:i,i18n:u,onSchedule:n,onPreview:r,onDelete:D}){const[N,A]=l.useState(null),o=()=>A(null),_=()=>{N&&D(N),o()};return e.jsxs(ue,{children:[e.jsxs(M,{gap:"400",children:[e.jsx(b,{variant:"headingSm",as:"h2",children:u.translate("Schedule.unpublished.title")}),i?e.jsx(oe,{padding:"200",children:e.jsx(Ma,{lines:3})}):t.length===0?e.jsx(oe,{padding:"400",children:e.jsx(b,{tone:"subdued",alignment:"center",as:"p",children:u.translate("Schedule.unpublished.empty")})}):e.jsx("div",{className:"Avada-Schedule__unpublished",children:t.map(h=>e.jsxs("div",{className:"Avada-Schedule__unpublishedCard",children:[e.jsxs(re,{align:"space-between",blockAlign:"start",wrap:!1,gap:"200",children:[e.jsxs(M,{gap:"050",children:[e.jsx("div",{className:"Avada-Schedule__unpublishedTitle",children:e.jsx(b,{variant:"bodyMd",fontWeight:"bold",as:"p",children:h.title||u.translate("Schedule.untitled")})}),e.jsx(b,{variant:"bodySm",tone:"subdued",as:"p",children:h.category||u.translate("Schedule.unpublished.noCategory")})]}),e.jsx(T,{variant:"tertiary",icon:he,accessibilityLabel:u.translate("Schedule.unpublished.preview"),onClick:()=>r(h)})]}),e.jsxs(re,{align:"space-between",blockAlign:"center",wrap:!1,gap:"200",children:[e.jsx(T,{onClick:()=>n(h),children:u.translate("Schedule.unpublished.schedulePost")}),e.jsx(T,{variant:"tertiary",icon:Ke,accessibilityLabel:u.translate("Schedule.unpublished.delete"),onClick:()=>A(h)})]})]},h.id))})]}),e.jsx(W,{open:!!N,onClose:o,title:u.translate("Schedule.unpublished.deleteTitle"),primaryAction:{content:u.translate("Schedule.unpublished.deletePost"),destructive:!0,onAction:_},secondaryActions:[{content:u.translate("Schedule.unpublished.cancel"),onAction:o}],children:e.jsx(W.Section,{children:e.jsx(b,{as:"p",children:u.translate("Schedule.unpublished.confirmDelete")})})})]})}Pe.propTypes={posts:s.array,loading:s.bool,i18n:s.object.isRequired,onSchedule:s.func.isRequired,onPreview:s.func.isRequired,onDelete:s.func.isRequired};Pe.defaultProps={posts:[],loading:!1};const Qa=20,ze={limit:Qa,order:"UPDATED_AT desc",status:"unpublished"};function Re({open:t,initialDate:i,excludePost:u,i18n:n,onClose:r,onConfirm:D,onEditPost:N}){const[A,o]=l.useState(""),_=Da(A,400),[h,P]=l.useState({}),[y,m]=l.useState(""),[j,E]=l.useState("preview"),[g,x]=l.useState(""),[d,H]=l.useState(!1),{data:q,loading:G,fetched:ee,pageInfo:O,fetchApi:J,setFetched:p}=Me({url:"/articles",initLoad:!1,initQueries:ze}),v=l.useMemo(()=>Array.isArray(q)?q.filter(f=>!u(f)).map(Xe):[],[q,u]),L=f=>{const R=_.trim();return{...ze,...R?{searchKey:R}:{},...f}};l.useEffect(()=>{if(!t)return;o(""),P({}),m(""),E("preview"),p(!1);const f=i?new Date(i):new Date;f.setHours(9,0,0,0);let R=f;if(!i){const V=new Date;f<V&&(R=V)}const B=900*1e3;x(new Date(Math.ceil(R.getTime()/B)*B).toISOString())},[t,i]),l.useEffect(()=>{t&&J("/articles",L())},[t,_]);const I=!!(O!=null&&O.hasNextPage),Y=async()=>{d||!I||!(O!=null&&O.endCursor)||(H(!0),await J("/articles",L({after:O.endCursor}),!0,!0),H(!1))},U=l.useMemo(()=>v.find(f=>String(f.id)===String(y))||v[0]||null,[v,y]),te=Object.keys(h),se=f=>{const R=String(f.id);P(B=>{if(B[R]){const V={...B};return delete V[R],V}return{...B,[R]:f}})},K=()=>{const f=Object.values(h);f.length&&D(f,g)},pe=n.translate("Schedule.modal.selectedCount",{count:String(te.length).padStart(2,"0")}),le=e.jsx("div",{className:"Avada-Schedule__modalLoading",children:e.jsx(We,{size:"small",accessibilityLabel:n.translate("Schedule.modal.loading")})}),$=G||!ee,X=new Date;return e.jsx(W,{open:t,onClose:r,size:"large",title:n.translate("Schedule.modal.title"),footer:e.jsx("span",{className:"Avada-Schedule__selectedPill",children:e.jsx(De,{children:pe})}),primaryAction:{content:n.translate("Schedule.modal.confirm"),onAction:K,disabled:te.length===0},secondaryActions:[{content:n.translate("Schedule.modal.cancel"),onAction:r}],children:e.jsx(W.Section,{flush:!0,children:e.jsxs("div",{className:"Avada-Schedule__modalBody",children:[e.jsxs("div",{className:"Avada-Schedule__modalList",children:[e.jsx("div",{className:"Avada-Schedule__modalSearch",children:e.jsx(Na,{labelHidden:!0,label:n.translate("Schedule.modal.searchPlaceholder"),placeholder:n.translate("Schedule.modal.searchPlaceholder"),value:A,onChange:o,autoComplete:"off",prefix:e.jsx(Ea,{source:Ca,tone:"subdued"})})}),e.jsx(Ta,{className:"Avada-Schedule__modalScroll",shadow:!0,children:$?le:v.length===0?e.jsx("div",{className:"Avada-Schedule__modalEmpty",children:e.jsx(b,{tone:"subdued",as:"p",children:n.translate("Schedule.modal.empty")})}):e.jsxs(e.Fragment,{children:[v.map(f=>{const R=String(f.id),B=R===String(y);return e.jsxs("div",{className:`Avada-Schedule__postRow${B?" Avada-Schedule__postRow--active":""}`,onClick:()=>m(R),children:[e.jsx("span",{onClick:V=>V.stopPropagation(),children:e.jsx(Pa,{labelHidden:!0,label:f.title||n.translate("Schedule.untitled"),checked:!!h[R],onChange:()=>se(f)})}),e.jsx("span",{className:"Avada-Schedule__postRowTitle",children:e.jsx(b,{as:"span",children:f.title||n.translate("Schedule.untitled")})})]},R)}),I&&e.jsx("div",{className:"Avada-Schedule__modalLoadMore",children:e.jsx(T,{fullWidth:!0,variant:"tertiary",loading:d,onClick:Y,children:n.translate("Schedule.modal.loadMore")})})]})})]}),e.jsx("div",{className:"Avada-Schedule__previewScroll",children:e.jsx(ue,{children:$?le:U?e.jsxs(M,{gap:"300",children:[e.jsxs("div",{className:"Avada-Schedule__previewToolbar",children:[e.jsxs("div",{className:"Avada-Schedule__tabGroup",children:[e.jsx("span",{className:`Avada-Schedule__tab${j==="preview"?" Avada-Schedule__tab--active":""}`,children:e.jsx(T,{icon:he,accessibilityLabel:n.translate("Schedule.modal.view"),variant:"tertiary",onClick:()=>E("preview")})}),e.jsx("span",{className:`Avada-Schedule__tab${j==="schedule"?" Avada-Schedule__tab--active":""}`,children:e.jsx(T,{icon:me,accessibilityLabel:n.translate("Schedule.modal.addToSchedule"),variant:"tertiary",onClick:()=>E("schedule")})})]}),e.jsx(T,{icon:Se,accessibilityLabel:n.translate("Schedule.modal.edit"),onClick:()=>N(U)})]}),j==="preview"?e.jsxs(M,{gap:"300",children:[e.jsx(b,{variant:"headingMd",as:"h3",children:U.title||n.translate("Schedule.untitled")}),F(U.summary)&&e.jsx(b,{variant:"headingMd",as:"p",children:F(U.summary)}),U.image?e.jsx("img",{className:"Avada-Schedule__previewImage",src:U.image,alt:U.title||""}):e.jsx("div",{className:"Avada-Schedule__previewImage Avada-Schedule__previewImage--empty"}),F(U.body)&&e.jsx(b,{tone:"subdued",as:"p",children:F(U.body).slice(0,600)})]}):e.jsxs(M,{gap:"300",children:[e.jsxs(M,{gap:"100",children:[e.jsx(b,{as:"p",children:n.translate("Schedule.modal.publishDate")}),e.jsx(Ee,{value:g,setValue:x})]}),e.jsxs(M,{gap:"100",children:[e.jsx(b,{as:"p",children:n.translate("Schedule.modal.publishTime")}
1),e.jsx(Ce,{value:g,setValue:x,minDate:X,interval:15})]})]})]}):e.jsx("div",{className:"Avada-Schedule__modalEmpty",children:e.jsx(b,{tone:"subdued",as:"p",children:n.translate("Schedule.modal.empty")})})})})]})})})}Re.propTypes={open:s.bool,initialDate:s.instanceOf(Date),excludePost:s.func,i18n:s.object.isRequired,onClose:s.func.isRequired,onConfirm:s.func.isRequired,onEditPost:s.func.isRequired};Re.defaultProps={open:!1,initialDate:null,excludePost:()=>!1};function Ie({open:t,post:i,initialTab:u,i18n:n,onClose:r,onConfirm:D,onEdit:N}){const[A,o]=l.useState(u),[_,h]=l.useState("");l.useEffect(()=>{if(!t)return;o(u||"schedule");const m=new Date,j=new Date;j.setHours(9,0,0,0);const E=j<m?m:j,g=900*1e3;h(new Date(Math.ceil(E.getTime()/g)*g).toISOString())},[t,u]);const P=new Date,y=()=>{i&&_&&D(i,_)};return e.jsx(W,{open:t,onClose:r,title:(i==null?void 0:i.title)||n.translate("Schedule.untitled"),primaryAction:{content:n.translate("Schedule.unpublished.schedulePost"),onAction:y,disabled:!i},secondaryActions:[{content:n.translate("Schedule.modal.cancel"),onAction:r}],children:e.jsx(W.Section,{flush:!0,children:i&&e.jsx("div",{className:"Avada-Schedule__postModalBody",children:e.jsxs("div",{className:"Avada-Schedule__postModalCard",children:[e.jsxs("div",{className:"Avada-Schedule__previewToolbar",children:[e.jsxs("div",{className:"Avada-Schedule__tabGroup",children:[e.jsx("span",{className:`Avada-Schedule__tab${A==="preview"?" Avada-Schedule__tab--active":""}`,children:e.jsx(T,{icon:he,variant:"tertiary",accessibilityLabel:n.translate("Schedule.dayModal.view"),onClick:()=>o("preview")})}),e.jsx("span",{className:`Avada-Schedule__tab${A==="schedule"?" Avada-Schedule__tab--active":""}`,children:e.jsx(T,{icon:me,variant:"tertiary",accessibilityLabel:n.translate("Schedule.dayModal.schedule"),onClick:()=>o("schedule")})})]}),e.jsx(T,{icon:Se,accessibilityLabel:n.translate("Schedule.dayModal.edit"),onClick:()=>N(i)})]}),e.jsx("div",{className:"Avada-Schedule__postModalContent",children:A==="preview"?e.jsxs(M,{gap:"300",children:[e.jsx(b,{variant:"headingMd",as:"h3",children:i.title||n.translate("Schedule.untitled")}),F(i.summary)&&e.jsx(b,{variant:"headingMd",as:"p",children:F(i.summary)}),i.image?e.jsx("img",{className:"Avada-Schedule__previewImage",src:i.image,alt:i.title||""}):e.jsx("div",{className:"Avada-Schedule__previewImage Avada-Schedule__previewImage--empty"}),F(i.body)&&e.jsx(b,{tone:"subdued",as:"p",children:F(i.body).slice(0,600)})]}):e.jsxs(M,{gap:"300",children:[e.jsxs(M,{gap:"100",children:[e.jsx(b,{as:"p",children:n.translate("Schedule.modal.publishDate")}),e.jsx(Ee,{value:_,setValue:h})]}),e.jsxs(M,{gap:"100",children:[e.jsx(b,{as:"p",children:n.translate("Schedule.modal.publishTime")}),e.jsx(Ce,{value:_,setValue:h,minDate:P,interval:15})]})]})})]})})})})}Ie.propTypes={open:s.bool,post:s.object,initialTab:s.oneOf(["preview","schedule"]),i18n:s.object.isRequired,onClose:s.func.isRequired,onConfirm:s.func.isRequired,onEdit:s.func.isRequired};Ie.defaultProps={open:!1,post:null,initialTab:"schedule"};const za=t=>{if(!(t instanceof Date)||Number.isNaN(t.getTime()))return"";const i=String(t.getDate()).padStart(2,"0"),u=t.toLocaleString("en-US",{month:"long"});return`${i} ${u}, ${t.getFullYear()}`},Wa=(t,i)=>t===ae.PUBLISHED?e.jsx(De,{children:i.translate("Schedule.filters.published")}):e.jsx(De,{tone:"info",children:i.translate("Schedule.filters.scheduled")});function Le({open:t,date:i,events:u,selectedId:n,i18n:r,onClose:D,onEdit:N,onRemove:A,onReschedule:o,onAddSchedule:_}){const[h,P]=l.useState(n),[y,m]=l.useState("preview"),[j,E]=l.useState({}),g=l.useMemo(()=>{const p=v=>(v==null?void 0:v.date)instanceof Date?v.date.getTime():NaN;return[...u].sort((v,L)=>{const I=p(v),Y=p(L);return Number.isNaN(I)?1:Number.isNaN(Y)?-1:I-Y})},[u]);l.useEffect(()=>{if(!t)return;const p=g[0]?g[0].id:"";P(g.some(v=>v.id===n)?n:p)},[t,n,g]),l.useEffect(()=>{t&&(m("preview"),E({}))},[t]);const x=l.useMemo(()=>g.find(p=>p.id===h)||g[0]||null,[g,h]),d=p=>{const v=p==null?void 0:p.date;return v instanceof Date&&!Number.isNaN(v.getTime())?v.toISOString():""},H=x?j[x.id]??d(x):"",q=p=>{x&&E(v=>({...v,[x.id]:p}))},G=l.useMemo(()=>g.map(p=>{const v=j[p.id];if(v==null)return null;const L=p.date instanceof Date?p.date.getTime():NaN,I=new Date(v).getTime();return Number.isNaN(I)||I===L?null:{event:p,publishAt:v}}
1).filter(Boolean),[g,j]),ee=G.length>0,O=()=>{G.forEach(({event:p,publishAt:v})=>o(p,v)),D()},J=new Date;return e.jsx(W,{open:t,onClose:D,size:"large",title:za(i),primaryAction:{content:r.translate("Schedule.dayModal.save"),onAction:O,disabled:!ee},secondaryActions:[{content:r.translate("Schedule.dayModal.cancel"),onAction:D}],footer:e.jsx("span",{className:"Avada-Schedule__selectedPill",children:e.jsx(T,{onClick:_,children:r.translate("Schedule.addSchedulePost")})}),children:e.jsx(W.Section,{flush:!0,children:e.jsxs("div",{className:"Avada-Schedule__modalBody",children:[e.jsx("div",{className:"Avada-Schedule__modalList",children:e.jsx("div",{className:"Avada-Schedule__modalScroll",children:g.length===0?e.jsx(Be,{heading:r.translate("Schedule.dayModal.empty"),image:""}):g.map(p=>{const v=p.id===h,L=Ne(p.date);return e.jsxs("div",{className:`Avada-Schedule__dayRow${v?" Avada-Schedule__dayRow--active":""}`,onClick:()=>P(p.id),children:[e.jsxs(M,{gap:"100",children:[e.jsx(b,{variant:"bodyMd",fontWeight:"medium",as:"p",children:p.title||r.translate("Schedule.untitled")}),e.jsxs(re,{gap:"200",blockAlign:"center",children:[L&&e.jsx(b,{variant:"bodySm",tone:"subdued",as:"span",children:L}),Wa(p.status,r)]})]}),p.status===ae.SCHEDULED&&v&&e.jsx("span",{onClick:I=>I.stopPropagation(),children:e.jsx(Ae,{content:r.translate("Schedule.dayModal.remove"),children:e.jsx(T,{icon:Ke,variant:"tertiary",tone:"critical",accessibilityLabel:r.translate("Schedule.dayModal.remove"),onClick:()=>A(p)})})})]},p.id)})})}),e.jsx("div",{className:"Avada-Schedule__previewScroll",children:e.jsx(ue,{children:x?e.jsxs(M,{gap:"300",children:[e.jsxs("div",{className:"Avada-Schedule__previewToolbar",children:[e.jsxs("div",{className:"Avada-Schedule__tabGroup",children:[e.jsx("span",{className:`Avada-Schedule__tab${y==="preview"?" Avada-Schedule__tab--active":""}`,children:e.jsx(Ae,{content:e.jsx("span",{className:"Avada-Schedule__nowrapTooltip",children:r.translate("Schedule.dayModal.view")}),children:e.jsx(T,{icon:he,variant:"tertiary",accessibilityLabel:r.translate("Schedule.dayModal.view"),onClick:()=>m("preview")})})}),e.jsx("span",{className:`Avada-Schedule__tab${y==="schedule"?" Avada-Schedule__tab--active":""}`,children:e.jsx(Ae,{content:e.jsx("span",{className:"Avada-Schedule__nowrapTooltip",children:r.translate("Schedule.dayModal.schedule")}),children:e.jsx(T,{icon:me,variant:"tertiary",accessibilityLabel:r.translate("Schedule.dayModal.schedule"),onClick:()=>m("schedule")})})})]}),e.jsx(T,{icon:Se,accessibilityLabel:r.translate("Schedule.dayModal.edit"),onClick:()=>N(x)})]}),y==="preview"?e.jsxs(M,{gap:"300",children:[e.jsx(b,{variant:"headingMd",as:"h3",children:x.title||r.translate("Schedule.untitled")}),F(x.summary)&&e.jsx(b,{variant:"headingMd",as:"p",children:F(x.summary)}),x.image?e.jsx("img",{className:"Avada-Schedule__previewImage",src:x.image,alt:x.title||""}):e.jsx("div",{className:"Avada-Schedule__previewImage Avada-Schedule__previewImage--empty"}),F(x.body)&&e.jsx(b,{tone:"subdued",as:"p",children:F(x.body).slice(0,600)})]}):e.jsxs(M,{gap:"300",children:[e.jsxs(M,{gap:"100",children:[e.jsx(b,{as:"p",children:r.translate("Schedule.modal.publishDate")}),e.jsx(Ee,{value:H,setValue:q})]}),e.jsxs(M,{gap:"100",children:[e.jsx(b,{as:"p",children:r.translate("Schedule.modal.publishTime")}),e.jsx(Ce,{value:H,setValue:q,minDate:J,interval:15})]})]})]}):e.jsx(Be,{heading:r.translate("Schedule.dayModal.empty"),image:""})})})]})})})}Le.propTypes={open:s.bool,date:s.instanceOf(Date),events:s.array,selectedId:s.string,i18n:s.object.isRequired,onClose:s.func.isRequired,onEdit:s.func.isRequired,onRemove:s.func.isRequired,onReschedule:s.func.isRequired,onAddSchedule:s.func.isRequired};Le.defaultProps={open:!1,date:null,events:[],selectedId:""};const ie=t=>{var i;return((i=String(t??"").match(/\d+/))==null?void 0:i[0])||""},_e=t=>{if(!t||t.isPublished)return!1;const i=t.scheduledAt||t.publishOn||t.publishedAt;if(!i)return!1;const u=new Date(i).getTime();return!Number.isNaN(u)&&u>Date.now()},we=t=>new Date(t).getTime()<=Date.now()?ae.PUBLISHED:ae.SCHEDULED;function aa({i18n:t}){const i=Ia(),{openPageInMaxModal:u}=l.useContext(La),n=l.useMemo(()=>new Date,[]),[r,D]=l.useState(()=>n.getMonth()),[N,A]=l.useState(()=>n.getFullYear()),[o,_]=l.useState(Oe.ALL),[h,P]=l.useState([]),[y,m]=l.useState([]),[j,E]=l.useState([]),[g,x]=l.useState({open:!1,initialPostId:"",initialDate:null}),[d,H]=l.useState({open:!1,date:null,selectedId:""}),[q,G]=l.useState({open:!1,post:null,tab:"schedule"}),[ee,O]=l.useState(!1),[J,p]=l.useState(null),v=ka(a=>{var c;return(c=a.settings.data)==null?void 0:c.sidebarAds}),L=Me({url:"/articles",initLoad:!1,initQueries:{limit:100,order:"PUBLISHED_AT desc",status:"published"}}),I=Me({url:"/articles",initQueries:{limit:50,order:"UPDATED_AT desc",status:"unpublished"}}),{handlePut:Y}=qa({url:"/article",useToast:!1}),U=async(a,c,S=ye)=>{const k=ie(a),w=new Date(c);if(!k||Number.isNaN(w.getTime()))return!1;const z=w.getTime()<=Date.now()?{publishedAt:w.toISOString(),isPublished:!0}:{publishedAt:w.toISOString()},C=await Y({apiUrl:`/article/${k}`,data:z});return C?$e(Ve.EVENT_TYPE.FEATURE_COMPLETED,{menu:Qe,card:Ye,scope:S}):Z(t.translate("Home.failedToSave"),!0),C},te=async a=>{const c=ie(a);if(!c)return!1;const S=await Y({apiUrl:`/article/${c}`,data:{publishedAt:null,isPublished:!1}});return S||Z(t.translate("Home.failedToSave"),!0),S},se=l.useMemo(()=>Array.isArray(L.data)?L.data:[],[L.data]),K=l.useMemo(()=>Array.isArray(I.data)?I.data:[],[I.data]),pe=I.loading,le=L.loading,$=l.useMemo(()=>new Set(h.map(a=>a.originArticleId)),[h]),X=l.useMemo(()=>Ua(N,r),[N,r]),f=l.useMemo(()=>{var z,C,ne;const a=(C=(z=X[0])==null?void 0:z[0])==null?void 0:C.date,c=X[X.length-1],S=(ne=c==null?void 0:c[c.length-1])==null?void 0:ne.date;if(!a||!S)return null;
1const k=new Date(a);k.setHours(0,0,0,0);const w=new Date(S);return w.setHours(23,59,59,999),{start:k.getTime(),end:w.getTime()}},[X]),R=l.useMemo(()=>K.filter(_e).map(Fe).filter(Boolean).filter(a=>{if(!f)return!0;const c=a.date instanceof Date?a.date.getTime():NaN;return!Number.isNaN(c)&&c>=f.start&&c<=f.end}).filter(a=>!$.has(a.id)).filter(a=>!j.includes(a.id)),[K,$,j,f]),B=l.useMemo(()=>{const a=se.map(Fe).filter(Boolean).filter(S=>!$.has(S.id)),c=new Map;return[...a,...R,...h].forEach(S=>c.set(S.id,S)),[...c.values()]},[se,R,h,$]),V=l.useMemo(()=>B.filter(a=>o===Oe.ALL||a.status===o),[B,o]),ta=l.useMemo(()=>He(V),[V]),ke=l.useMemo(()=>He(B),[B]),sa=l.useMemo(()=>d.date?ke[Ge(d.date)]||[]:[],[ke,d.date]),Q=l.useMemo(()=>f?{publishedAtMin:new Date(f.start).toISOString(),publishedAtMax:new Date(f.end).toISOString()}:null,[f]);l.useEffect(()=>{Q&&L.fetchApi("/articles",{limit:100,order:"PUBLISHED_AT desc",status:"published",...Q})},[Q==null?void 0:Q.publishedAtMin,Q==null?void 0:Q.publishedAtMax]);const la=l.useMemo(()=>K.filter(a=>!_e(a)||j.includes(String(a.id))).filter(a=>!$.has(String(a.id))).filter(a=>!y.includes(String(a.id))).map(Xe),[K,$,y,j]),na=a=>{const c=String((a==null?void 0:a.id)??"");return y.includes(c)||$.has(c)?!0:j.includes(c)?!1:_e(a)},ve=a=>{const c=ie(a);c&&i.push(`/articles/edit/${c}`)},ia=a=>H({open:!0,date:a.date,selectedId:a.id}),fe=()=>H(a=>({...a,open:!1})),{posting:da,handlePost:ca}=Ba({url:"/article/create",successCallback:a=>i.push(`/articles/edit/${a.data}`),successMsg:"Created successfully",errorMsg:"Failed to create"}),ra=a=>{p(a||null),O(!0)},oa=()=>I.fetchApi("/articles",{limit:50,order:"UPDATED_AT desc",status:"unpublished"}),ua=async a=>{const c=ie(a.id);if(!c)return;m(w=>[...w,String(a.id)]),Z(t.translate("Schedule.toast.deleted"));const S=K.find(w=>String(w.id)===String(a.id))||a;await Y({apiUrl:`/article/moveToTrash/${c}`,data:S})?oa():(m(w=>w.filter(z=>z!==String(a.id))),Z(t.translate("Home.failedToSave"),!0))},ha=a=>{const c=a.originArticleId||a.id;P(S=>S.filter(k=>k.id!==a.id)),E(S=>S.includes(a.id)?S:[...S,a.id]),Z(t.translate("Schedule.toast.removed")),te(c)},ma=a=>{fe(),ve(a.id)},Sa=(a,c)=>{if(!a||!c)return;const S=new Date(c);Number.isNaN(S.getTime())||(P(k=>k.some(w=>w.id===a.id)?k.map(w=>w.id===a.id?{...w,date:S,status:we(S)}:w):[...k,{id:a.id,originArticleId:a.originArticleId||a.id,title:a.title,category:a.category||"",date:S,status:we(S),image:a.image||"",summary:a.summary||"",body:a.body||"",isLocal:!0}]),Z(t.translate("Schedule.toast.rescheduled")),U(a.originArticleId||a.id,S))},pa=()=>{const a=d.date;fe(),be({date:a})},be=({postId:a="",date:c=null}={})=>x({open:!0,initialPostId:a?String(a):"",initialDate:c}),xe=()=>x(a=>({...a,open:!1})),va=a=>{xe(),ve(a.id)},qe=(a,c="schedule")=>G({open:!0,post:a,tab:c}),ge=()=>G(a=>({...a,open:!1})),fa=(a,c)=>{Ue([a],c),ge()},ba=a=>{ge(),ve(a.id)},Ue=(a,c)=>{if(!a.length)return;const S=c?new Date(c):g.initialDate||n,k=a.map(C=>String(C.id)),w=a.map(C=>({id:String(C.id),originArticleId:String(C.id),title:C.title,category:C.category||"",date:new Date(S),status:we(S),image:C.image||"",summary:C.summary||"",body:C.body||"",isLocal:!0}));P(C=>[...C.filter(ne=>!k.includes(ne.originArticleId)),...w]),D(S.getMonth()),A(S.getFullYear()),xe(),Z(t.translate("Schedule.toast.scheduled"));const z=a.length>1?Va:ye;a.forEach(C=>U(C.id,S,z))};return e.jsxs(Fa,{fullWidth:!0,title:t.translate("Schedule.title"),subtitle:t.translate("Schedule.subtitle"),primaryAction:{content:t.translate("Schedule.addSchedulePost"),onAction:()=>{$e(Ve.EVENT_TYPE.FEATURE_STARTED,{menu:Qe,card:Ye,scope:ye}),be()}},children:[e.jsxs(M,{gap:"400",children:[e.jsxs(ue,{padding:"0",children:[e.jsx(Ze,{month:r,year:N,filter:o,i18n:t,onMonthChange:D,onYearChange:A,onFilterChange:_}),e.jsx(ea,{weeks:X,eventsByDay:ta,today:n,loading:le,i18n:t,onViewDetails:ia,onAddSchedule:a=>be({date:a}),onCreatePost:ra})]}),e.jsx(Pe,{posts:la,loading:pe,i18n:t,onSchedule:a=>qe(a,"schedule"),onPreview:a=>qe(a,"preview"),onDelete:ua}),e.jsx(Ha,{})]}),e.jsx($a,{open:ee,initialDate:J,onClose:()=>O(!1),sidebarAds:v,handleCreateArticle:ca,creatingArticle:da}),e.jsx(Re,{open:g.open,initialDate:g.initialDate,excludePost:na,i18n:t,onClose:xe,onConfirm:Ue,onEditPost:va}),e.jsx(Le,{open:d.open,date:d.date,events:sa,selectedId:d.selectedId,i18n:t,onClose:fe,onEdit:ma,onRemove:ha,onReschedule:Sa,onAddSchedule:pa}),e.jsx(Ie,{open:q.open,post:q.post,initialTab:q.tab,i18n:t,onClose:ge,onConfirm:fa,onEdit:ba})]})}aa.propTypes={i18n:s.object};const tt=Ra()(aa);export{tt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.