"use strict";(globalThis.webpackChunkadvajra=globalThis.webpackChunkadvajra||[]).push([[101],{2733(e,t,a){a.r(t),a.d(t,{default:()=>u});var s=a(1609),i=a.n(s),l=a(7723),n=a(6427),r=a(3988),d=a(5573);const c=(0,s.createElement)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(d.Path,{d:"M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"}));var o=a(790);const u=({data:e,schema:t,onEdit:a})=>{const[d,u]=(0,s.useState)(-5),[v]=(0,s.useState)(35),m=(0,s.useMemo)(()=>{const e=[],t=new Date;t.setHours(0,0,0,0);for(let a=0;a<v;a++){const s=new Date(t);s.setDate(t.getDate()+(d+a)),e.push(s)}return e},[d,v]),g=e=>{u(t=>t+e)};return(0,o.jsxs)("div",{className:"av-timeline-view",children:[(0,o.jsxs)("div",{className:"av-timeline-controls",children:[(0,o.jsx)("div",{className:"av-current-month",children:m[0].toLocaleDateString(void 0,{month:"long",year:"numeric"})}),(0,o.jsxs)("div",{className:"av-nav-group",children:[(0,o.jsx)(n.Button,{icon:r.A,size:"small",onClick:()=>g(-7),label:(0,l.__)("Previous Week","advajra")}),(0,o.jsx)(n.Button,{variant:"secondary",size:"small",onClick:()=>u(-5),children:(0,l.__)("Today","advajra")}),(0,o.jsx)(n.Button,{icon:c,size:"small",onClick:()=>g(7),label:(0,l.__)("Next Week","advajra")})]})]}),(0,o.jsx)("div",{className:"av-timeline-scroll-area",children:(0,o.jsxs)("div",{className:"av-timeline-grid",style:{gridTemplateColumns:`240px repeat(${m.length}, 40px)`},children:[(0,o.jsx)("div",{className:"av-timeline-corner",children:(0,l.__)("Campaign Name","advajra")}),m.map((e,t)=>{const a=(new Date).toDateString()===e.toDateString(),s=0===e.getDay()||6===e.getDay();return(0,o.jsxs)("div",{className:`av-timeline-header-cell ${a?"is-today":""} ${s?"is-weekend":""}`,children:[(0,o.jsx)("div",{className:"av-day-num",children:e.getDate()}),(0,o.jsx)("div",{className:"av-day-name",children:e.toLocaleDateString("en-US",{weekday:"narrow"})})]},t)}),e.map(e=>{const t=e.title&&e.title.raw?e.title.raw:(0,l.__)("(No Title)","advajra");return(0,o.jsxs)(i().Fragment,{children:[(0,o.jsx)(n.Tooltip,{text:t,children:(0,o.jsx)("div",{className:"av-timeline-sidebar-cell",onClick:()=>a&&a(e.id),children:(0,o.jsx)("div",{className:"av-ad-title",children:t})})}),m.map((t,s)=>{const i=((e,t)=>{if("draft"===e.status||"trash"===e.status)return null;const a=new Date;a.setHours(0,0,0,0);const s=new Date(t);s.setHours(0,0,0,0);let i=e.start_date?new Date(e.start_date):null,n=e.end_date?new Date(e.end_date):null;i&&i.setHours(0,0,0,0),n&&n.setHours(0,0,0,0);const r=s.getTime()<a.getTime(),d=s.getTime()===a.getTime();if(s.getTime(),a.getTime(),!i&&!n)return"paused"===e.status?{type:"always-on",state:r?"past":d?"today":"future",cssStatus:"paused",tooltipText:(0,l.__)("Paused","advajra")}:{type:"always-on",state:r?"past":d?"today":"future",cssStatus:r?"was-active":"active",tooltipText:r?(0,l.__)("Was Active","advajra"):(0,l.__)("Active","advajra")};if(i&&s.getTime()<i.getTime())return null;if(n&&s.getTime()>n.getTime())return null;if("paused"===e.status)return{type:"scheduled",state:r?"past":d?"today":"future",cssStatus:"paused",tooltipText:(0,l.__)("Paused","advajra")};const c=!i||a.getTime()>=i.getTime();let o,u;return r?(o="was-active",u=(0,l.__)("Was Active","advajra")):d?(o="active",u=(0,l.__)("Active Now","advajra")):c?(o="active",u=(0,l.__)("Active","advajra")):(o="scheduled",u=(0,l.__)("Scheduled","advajra")),{type:"scheduled",state:r?"past":d?"today":"future",cssStatus:o,tooltipText:u}})(e,t),r=(new Date).toDateString()===t.toDateString(),d=0===t.getDay()||6===t.getDay();return(0,o.jsx)("div",{className:`av-timeline-cell ${r?"is-today":""} ${d?"is-weekend":""}`,children:i&&(0,o.jsx)(n.Tooltip,{text:i.tooltipText,children:(0,o.jsx)("div",{className:`av-timeline-bar status-${i.cssStatus} type-${i.type} state-${i.state}`,onClick:()=>a&&a(e.id)})})},s)})]},e.id)})]})})]})}},3988(e,t,a){a.d(t,{A:()=>l});var s=a(1609),i=a(5573);const l=(0,s.createElement)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,s.createElement)(i.Path,{d:"M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"}))}}]);