PageSourceSearch

https://app.rankauthority.com/assets/AIVisibilityCalendar-F6n2VZ5K.js

js rankauthority.com collected 2026-09-25 14:12:53 UTC 45,173 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-motion-DUZozfy1.js";import{a as l}from"./vendor-charts-CHn1wSbK.js";import{d as C,aB as Cs,aA as Ss,L as ue,p as St,$ as As,a0 as At,a1 as Dt,a2 as Mt,a3 as ce,e as Je,a4 as Ds,K as Ms,l as pt,n as xt,o as gt,m as bt,u as Ps,a as ks,N as Ts,Q as _s,V as $s,Y as Is,by as Es,dz as Fs,O as Ie,P as Bs,g as ft,D as we,r as Ne,s as Ce,v as Se,w as Ee,cn as yt,q as jt,bu as Ls,a6 as Rs,a5 as Os,X as vt,M as Ge,i as Us,dD as Ys}from"./index-Bb8a9cml.js";import{C as Be}from"./checkbox-ELS1sVik.js";import{C as wt}from"./calendar-B08u_o41.js";import{u as Hs,P as zs,A as Gs}from"./ArtifactPublishScheduleModals-CH4lv21G.js";import{a as qs,u as Vs,b as Js,A as Ws,C as Qs,M as Xs,c as Zs}from"./CalendarLegend-BBRA3_q8.js";import{M as Ks,g as qe,a as I,f as Ve}from"./artifactCalendarUtils-BuKC5v0G.js";import{P as ea,a as ta,b as Nt,c as sa,d as aa,e as ra}from"./pagination-emVFJKlt.js";import{T as la,a as ia,b as Ct,c as Ae,d as na,e as oe}from"./table-CdmCdqO4.js";import{C as Le}from"./calendar-C35cV26U.js";import{A as Fe}from"./arrow-up-down-2ZZmT4gM.js";import{E as da}from"./ellipsis-vertical-WADWKqhQ.js";import{A as oa}from"./archive-CZsukdM4.js";import{A as ca}from"./AutopilotBanner-DlN2F5S_.js";import{u as ua}from"./autopilotHooks-CyymjQ1x.js";import{C as ha}from"./CMSConnectionBanner-BwHvGbhb.js";import{P as ma}from"./PublishSuccessModal-vOBIh6K0.js";import{S as pa}from"./ScheduleResultModal-I_Mziedj.js";import{u as xa}from"./usePublishErrorHandler-lK7yDnFP.js";import{P as ga}from"./PageLayout-CNh5Cs5f.js";import"./vendor-sentry-RcVmeTqv.js";import"./vendor-radix-c9D4YKig.js";import"./index.esm-Dfs_rq7k.js";import"./en-US-dVR5b0_k.js";import"./format-BAaKANpQ.js";import"./ban-BCNPWiCX.js";(function(){try{var c=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};c.SENTRY_RELEASE={id:"82232f0163efc9ba5bbf9cf2945540a486567b75"};var n=new c.Error().stack;
1n&&(c._sentryDebugIds=c._sentryDebugIds||{},c._sentryDebugIds[n]="267dadb9-0093-4ce2-a4b5-16ac0195dab8",c._sentryDebugIdIdentifier="sentry-dbid-267dadb9-0093-4ce2-a4b5-16ac0195dab8")}catch{}})();function ba(c){const n=[],f=new Date,d=new Date(f.getFullYear(),f.getMonth(),f.getDate()),E=30;if(c<=E){const M=Math.floor(E/c);for(let S=0;S<c;S++){const P=new Date(d);P.setDate(d.getDate()+S*M);const F=P.toISOString().split("T")[0];n.push(F)}}else{let M=c;for(let S=0;S<E&&M>0;S++){const P=new Date(d);P.setDate(d.getDate()+S);const F=P.toISOString().split("T")[0],R=Math.ceil(M/(E-S));for(let U=0;U<R&&M>0;U++)n.push(F),M--}}return n}function fa(c,n){const[f,d]=l.useState(!1),[E,M]=l.useState(0),[S,P]=l.useState(0),[F,R]=l.useState(!1),[U,h]=l.useState(""),N=l.useRef(!1),K=l.useCallback(()=>{d(!1),M(0),P(0)},[]);return l.useEffect(()=>{const $=sessionStorage.getItem(`artifacts_just_created_${c}`),y=sessionStorage.getItem(`pending_artifacts_data_${c}`);if($==="true"&&y&&!N.current){N.current=!0;const k=JSON.parse(y),ee=localStorage.getItem(`ai_visibility_artifacts_${c}`),he=(ee?JSON.parse(ee):[]).length,me=Math.max(0,n.artifactLimit-he),pe=Math.min(k.length,me);P(pe),sessionStorage.removeItem(`artifacts_just_created_${c}`),sessionStorage.removeItem(`pending_artifacts_data_${c}`),d(!0);const te=Date.now(),x=45e3,j=()=>{const se=Date.now()-te,G=Math.min(se/x*100,100);if(M(G),G>=100){const q=localStorage.getItem(`ai_visibility_artifacts_${c}`),O=q?JSON.parse(q):[],v=O.length,g=k.length,b=v+g;if(v>=n.artifactLimit){d(!1);const m=v-n.artifactLimit;h(m>0?`You've already created ${v} artifacts this month and exceeded your ${n.name} plan limit of ${n.artifactLimit}.`:`You've reached your ${n.name} plan limit of ${n.artifactLimit} artifacts per month.`),R(!0);return}if(b>n.artifactLimit){const m=n.artifactLimit-v;k.splice(m),setTimeout(()=>{d(!1),h(`You already have ${v} artifact${v===1?"":"s"} this month. You've reached your ${n.name} plan limit of ${n.artifactLimit} artifacts per month. Only ${m} of your ${g} requested artifacts were created (${v} existing + ${m} new = ${n.artifactLimit} total).`),R(!0)},600)}const B=O.length>0?Math.max(...O.map(m=>m.id)):0,L=ba(k.length),V=new Date,A=k.map((m,u)=>{const ae=L[u];return{id:B+u+1,title:m.title,status:"scheduled",dateCreated:V.toISOString().split("T")[0],lastModified:V.toISOString().split("T")[0],scheduledDate:ae,wordCount:Math.floor(Math.random()*2e3)+2e3,author:"AI Writer"}}),i=[...O,...A];localStorage.setItem(`ai_visibility_artifacts_${c}`,JSON.stringify(i));const J=localStorage.getItem(`aivisibility_prompts_${c}`);if(J){const m=JSON.parse(J),u=k.map(Y=>Y.id),ae=m.map(Y=>u.includes(Y.id)?{...Y,usedForArtifact:!0}:Y);localStorage.setItem(`aivisibility_prompts_${c}`,JSON.stringify(ae))}setArtifacts(i),O.length+k.length<=n.artifactLimit&&setTimeout(()=>{d(!1)},500)}else requestAnimationFrame(j)};requestAnimationFrame(j)}},[]),{showCreationBanner:f,creationProgress:E,creatingArtifactCount:S,showUpgradeModal:F,upgradeModalMessage:U,resetCreationBanner:K}}function ya({viewMode:c,setViewMode:n,isTableFetching:f,tableBlogsData:d,goToPreviousMonth:E,goToNextMonth:M,goToToday:S,currentMonth:P,currentYear:F,isAllSelected:R,handleSelectAll:U,calSortColumn:h,handleCalSort:N,filteredArtifacts:K,highlightedArtifactId:$,artifactLoadingStates:y,artifactRowRefs:k,handleCalendarArtifactClick:ee,selectedArtifacts:De,handleSelectArtifact:he,getStatusBadge:me,getStatusLabel:pe,checkCMSConnection:te,setShowCMSRequiredModal:x,handlePublishFromCalendar:j,setSchedulingArtifactId:se,handleMoveToDraft:G,handleArchive:q,handleDeleteFromCalendar:O,totalPages:v,totalItems:g,currentPage:b,ITEMS_PER_PAGE:B,setCurrentPage:L,handlePreviousPage:V,handleNextPage:A}){return c!=="table"?null:e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-8 mb-6 relative",children:[f&&d&&e.jsx("div",{className:"absolute top-0 left-0 right-0 h-0.5 bg-[rgb(var(--brand-primary-rgb)/0.08)] overflow-hidden rounded-t-lg z-10",children:e.jsx("div",{className:"h-full bg-[var(--brand-primary)] animate-pulse w-full"})}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(C,{variant:"outline",size:"sm",onClick:E,"data-testid":"button-prev-month-table",children:e.jsx(Cs,{className:"w-4 h-4"})}),e.jsxs("h2",{className:"text-base font-semibold text-gray-900 text-left",children:[Ks[P]," ",F]}),e.jsx(C,{variant:"outline",size:"sm",onClick:M,"data-testid":"button-next-month-table",children:e.jsx(Ss,{className:"w-4 h-4"})}),e.jsxs(C,{variant:"outline",size:"sm",onClick:S,"data-testid":"button-today-table",children:[e.jsx(Le,{className:"w-4 h-4 mr-2"}),"Today"]})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(C,{onClick:()=>n(c==="calendar"?"table":"calendar"),variant:"outline",className:"border border-gray-300 text-gray-700 hover:bg-gray-50",size:"sm","data-testid":"button-view-toggle-table",children:[e.jsx(Le,{className:"w-4 h-4 mr-2 text-gray-600"}),"Calendar View"]})})]}),e.jsxs("div",{className:`rounded-lg border border-gray-200 overflow-hidden transition-opacity duration-150 ${f&&d?"opacity-60":"opacity-100"}`,children:[e.jsxs(la,{children:[e.jsx(ia,{children:e.jsxs(Ct,{children:[e.jsx(Ae,{className:"w-[30%] pl-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Be,{checked:R,onCheckedChange:U,"data-testid":"checkbox-select-all",className:"border-gray-400 data-[state=checked]:bg-gray-500 data-[state=checked]:border-gray-500"}),e.jsxs("button",{type:"button",onClick:()=>N("title"),className:"flex items-center gap-1 hover:text-gray-900 transition-colors",children:[e.jsx("span",{children:"Title"}),e.jsx(Fe,{className:`w-4 h-4 text-gray-400 ${h==="title"?"text-gray-600":""}`})]})]})}),e.jsx(Ae,{className:"w-[10%]",children:e.jsxs("button",{type:"button",onClick:()=>N("status"),className:"flex items-center gap-1 hover:text-gray-900 transition-colors",children:[e.jsx("span",{children:"Status"}),e.jsx(Fe,{className:`w-4 h-4 text-gray-400 ${h==="status"?"text-gray-600":""}`})]})}),e.jsx(Ae,{className:"w-[15%]",children:e.jsxs("button",{type:"button",onClick:()=>N("date"),className:"flex items-center gap-1 hover:text-gray-900 transition-colors",children:[e.jsx("span",{children:"Date Published"}),e.jsx(Fe,{className:`w-4 h-4 text-gray-400 ${h==="date"?"text-gray-600":""}`})]})}),e.jsx(Ae,{className:"w-[12%] text-right",children:e.jsxs("button",{type:"button",onClick:()=>N("wordcount"),className:"flex items-center gap-1 justify-end hover:text-gray-900 transition-colors ml-auto",children:[e.jsx("span",{children:"Word Count"}),e.jsx(Fe,{className:`w-4 h-4 text-gray-400 ${h==="wordcount"?"text-gray-600":""}`})]})}),e.jsx(Ae,{className:"w-[10%] text-right",children:"Actions"})]})}),e.jsx(na,{children:K.map(i=>{const J=$===i.id,m=y[i.id]?.moveToDraft;return e.jsx(Ct,{ref:u=>k.current[i.id]=u,className:`${J?"bg-[rgb(var(--brand-primary-rgb)/0.08)] ring-2 ring-[var(--brand-primary)] ring-inset":""} cursor-pointer hover:bg-gray-50 ${m?"pointer-events-none":""}`,onClick:()=>ee(i.id),"data-testid":`artifact-row-${i.id}`,children:m?e.jsx(oe,{colSpan:5,className:"relative p-6",style:{height:"auto"},children:e.jsx("div",{className:"absolute inset-0 bg-white/50 z-10 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 bg-white px-4 py-2 rounded-full shadow-lg",children:[e.jsx(ue,{className:"w-4 h-4 animate-spin text-[var(--brand-primary)]"}),e.jsx("span",{className:"text-sm text-gray-600",children:"Moving to draft..."})]})})}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"pl-6",onClick:u=>u.stopPropagation(),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Be,{checked:De.includes(i.id),onCheckedChange:()=>he(i.id),"data-testid":`checkbox-artifact-${i.id}`,className:"border-gray-400 data-[state=checked]:bg-gray-500 data-[state=checked]:border-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-900",children:i.title})]})}),e.jsx(oe,{children:e.jsx(St,{className:`${me(i.status)} text-xs`,children:pe(i.status)})}),e.jsx(oe,{children:i.publishedDate?(()=>{const u=As(i.publishedDate);return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-shrink-0 w-10 h-10 rounded-full bg-[var(--brand-primary)] flex flex-col items-center justify-center gap-0",children:[e.jsx("div",{className:"text-white text-sm font-bold leading-tight",children:u.dayNumber}),e.jsx("div",{className:"text-white text-[10px] font-medium leading-tight",children:u.dayAbbrev})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900",children:u.dayFull}),e.jsx("div",{className:"text-sm text-gray-600",children:u.formattedDate})]})]})})():e.jsx("span",{className:"text-sm text-gray-400",children:"—"})}),e.jsx(oe,{className:"text-sm text-gray-600 text-right",children:i?.wordCount?i.wordCount.toLocaleStr
1ing():"—"}),e.jsx(oe,{className:"text-right",onClick:u=>u.stopPropagation(),children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[(i.status==="draft"||i.status==="scheduled")&&e.jsx(C,{variant:"default",size:"sm",className:"bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90",disabled:y[i.id]?.publish,onClick:u=>{if(u.stopPropagation(),!te()){x(!0);return}j(i.id,u)},"data-testid":`button-publish-table-${i.id}`,children:y[i.id]?.publish?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 animate-spin mr-1"}),"Publishing..."]}):"Publish"}),e.jsxs(At,{children:[e.jsx(Dt,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"sm","data-testid":`button-actions-${i.id}`,children:e.jsx(da,{className:"w-4 h-4"})})}),e.jsxs(Mt,{align:"end",children:[(i.status==="draft"||i.status==="scheduled")&&e.jsxs(ce,{onClick:u=>{if(u.stopPropagation(),!te()){x(!0);return}se(i.id)},children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),i.status==="scheduled"?"Reschedule":"Schedule"]}),i.status!=="draft"&&e.jsxs(ce,{onClick:u=>{u.stopPropagation(),G(i.id)},disabled:y[i.id]?.moveToDraft,className:"flex items-center gap-2",children:[e.jsx(Ds,{className:"w-4 h-4"}),e.jsx("span",{children:"Move to Draft"}),y[i.id]?.moveToDraft&&e.jsx(ue,{className:"w-3 h-3 animate-spin ml-1"})]}),e.jsxs(ce,{onClick:u=>{u.stopPropagation(),q(i.id)},"data-testid":`button-archive-${i.id}`,children:[e.jsx(oa,{className:"w-4 h-4 mr-2"}),"Archive"]}),e.jsxs(ce,{className:"text-red-400",onClick:u=>O(i.id,u),"data-testid":`button-delete-${i.id}`,children:[e.jsx(Ms,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]})})]})},i.id)})})]}),v>1&&e.jsx(ea,{totalItems:g,totalPages:v,currentPage:b,itemsPerPage:B,onPageChange:i=>!f&&L(i),className:"mt-4 pt-4 pb-8 border-t border-slate-100 px-6",children:e.jsxs(ta,{children:[e.jsx(Nt,{children:e.jsx(sa,{disabled:b===1||f,onClick:V})}),e.jsx(aa,{totalPages:v,currentPage:b,onPageChange:i=>!f&&L(i)}),e.jsx(Nt,{children:e.jsx(ra,{disabled:b>=v||f,onClick:A})})]})})]})]})}const ja=[{label:"Draft",dotClass:"bg-purple-400"},{label:"Scheduled",dotClass:"bg-green-400"},{label:"Published",dotClass:"bg-[var(--brand-primary)]"},{label:"Archived",dotClass:"bg-yellow-400"}];function va({upcomingPosts:c,getEventTypeColor:n,onArtifactClick:f}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(pt,{className:"border-0 shadow-lg",children:[e.jsx(xt,{children:e.jsx(gt,{className:"text-base font-semibold text-gray-900",children:"Legend"})}),e.jsx(bt,{className:"p-6",children:e.jsx(qs,{statuses:ja})})]}),e.jsxs(pt,{className:"border-0 shadow-lg",children:[e.jsx(xt,{children:e.jsx(gt,{className:"text-base font-semibold text-gray-900",children:"Upcoming Posts"})}),e.jsx(bt,{className:"p-6 space-y-4",children:e.jsxs("div",{className:"space-y-3",children:[c.map(d=>e.jsxs("div",{className:"p-3 border rounded-lg hover:bg-slate-50 cursor-pointer",onClick:()=>f(d.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(St,{variant:"outline",className:n(d.status),children:d.status.charAt(0).toUpperCase()+d.status.slice(1)})}),e.jsx("span",{className:"text-xs text-slate-500",children:new Date(d.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]}),e.jsx("h4",{className:"text-sm font-medium text-slate-900 mb-1",children:d.title}),d.time&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500",children:[e.jsx(Je,{className:"w-3 h-3"}),d.time]})]},d.uniqueId)),c.length===0&&e.jsx("p",{className:"text-sm text-slate-500 text-center py-4",children:"No upcoming posts"})]})})]})]})}function tr(){const c=Ps(),{selectedProjectId:n,projects:f}=ks(),{isCMSConnected:d}=Ts(),{planInfo:E}=Hs(),{showCreationBanner:M,creationProgress:S,creatingArtifactCount:P,resetCreationBanner:F}=fa(n,E),R=l.useRef(n);l.useEffect(()=>{R.current!==n&&(R.current=n,K({}),b([]),L(1),de(null),je(null),Wt(null),F())},[n,F]);const[U,h]=l.useState(!1),[N,K]=l.useState({}),$=(t,s,a)=>{K(r=>({...r,[t]:{...r[t],[s]:a}}))},y=()=>d,{mutate:k,mutateAsync:ee}=_s(),{mutate:De}=$s(),{mutate:he,mutateAsync:me}=Is(),{mutate:pe}=Es(),{mutate:te}=Fs(),{currentMonth:x,currentYear:j,goToPreviousMonth:se,goToNextMonth:G,goToToday:q}=Vs(),[O,v]=l.useState("draft"),[g,b]=l.useState([]),[B,L]=l.useState(1),V=25,[A,
1i]=l.useState("calendar"),J=l.useMemo(()=>qe(x,j),[x,j]),{data:m,isFetching:u,refetch:ae}=Ie(n,{type:"artifact",view:"list",per_page:100,date_from:J.from,date_to:J.to,enabled:!!n&&A==="calendar"}),Y=l.useMemo(()=>{const t=x===0?11:x-1,s=x===0?j-1:j;return qe(t,s)},[x,j]),We=l.useMemo(()=>{const t=x===11?0:x+1,s=x===11?j+1:j;return qe(t,s)},[x,j]);Ie(n,{type:"artifact",view:"list",per_page:100,date_from:Y.from,date_to:Y.to,enabled:!!n&&A==="calendar",staleTime:6e4}),Ie(n,{type:"artifact",view:"list",per_page:100,date_from:We.from,date_to:We.to,enabled:!!n&&A==="calendar",staleTime:6e4});const{data:W,isFetching:Pt,refetch:Qe}=Ie(n,{type:"artifact",view:"list",page:B,per_page:V,enabled:!!n&&A==="table"}),{data:Xe,refetch:Ze}=Bs(n,{type:"artifact"}),{data:Me}=ua(n),Ke=Me?.features?.artifact?.enabled?Me.features.artifact.per_day||{}:{},kt=Js(Me),H=l.useCallback(async()=>{const t=A==="calendar"?ae:Qe;await Promise.all([t(),Ze()])},[A,ae,Qe,Ze]),z=l.useMemo(()=>!m?.blogs||!Array.isArray(m.blogs)?[]:m.blogs.map((t,s)=>{let a=null;return t.scheduled_date?a=I(t.scheduled_date):t.published_date?a=I(t.published_date):t.created_at&&(a=I(t.created_at)),{id:t.id,title:t.meta_title||`AI Artifact ${s+1}`,status:t.status||"draft",dateCreated:Ve(I(t.created_at)),publishDate:a,scheduledDate:t.scheduled_date?I(t.scheduled_date):null,keywords:t.keyword?[t.keyword]:[],prompt:t.prompt||"",rawData:t}}),[m]),xe=l.useMemo(()=>!W?.blogs||!Array.isArray(W.blogs)?[]:W.blogs.map((t,s)=>{let a=null;t.scheduled_date?a=I(t.scheduled_date):t.published_date?a=I(t.published_date):t.created_at&&(a=I(t.created_at));const r=t.content_length??0;return{id:t.id,title:t.meta_title||`AI Artifact ${s+1}`,status:t.status||"draft",dateCreated:Ve(I(t.created_at)),publishDate:a,publishedDate:t.published_date?Ve(I(t.published_date)):null,scheduledDate:t.scheduled_date?I(t.scheduled_date):null,keywords:t.keyword?[t.keyword]:[],prompt:t.prompt||"",wordCount:r,rawData:t}}),[W]),[Tt,ge]=l.useState(!1),[_t,re]=l.useState(!1),[$t,Pe]=l.useState(!1),[le,et]=l.useState(null),[ke,be]=l.useState(null),[It,fe]=l.useState(!1),[Et,tt]=l.useState(!1),[ie,Ft]=l.useState(!0),[ne,Bt]=l.useState(!0),[Te,_e]=l.useState(!1),[st,Lt]=l.useState("schedule"),{publishError:Rt,clearPublishError:Ot,handlePublishError:$e,handlePublishResult:Ut}=xa(),[Yt,at]=l.useState(!1),[Ht,zt]=l.useState(""),[Gt,ye]=l.useState(!1),[qt,rt]=l.useState(""),[lt,de]=l.useState(null),[Vt,je]=l.useState(null),[Jt,Wt]=l.useState(null),[Qt,Re]=l.useState(!1),Xt=l.useRef({}),[Q,Zt]=l.useState(null),[Oe,it]=l.useState("asc"),Kt=l.useCallback(t=>{Zt(s=>s===t?(it(a=>a==="asc"?"desc":"asc"),t):(it("asc"),t))},[]),ve=l.useMemo(()=>Q?[...xe].sort((t,s)=>{let a,r;if(Q==="title")a=(t.title||"").toLowerCase(),r=(s.title||"").toLowerCase();else if(Q==="status")a=(t.status||"").toLowerCase(),r=(s.status||"").toLowerCase();else if(Q==="date")a=t.publishedDate?new Date(t.publishedDate).getTime():0,r=s.publishedDate?new Date(s.publishedDate).getTime():0;else if(Q==="wordcount")a=t.wordCount||0,r=s.wordCount||0;else return 0;return a<r?Oe==="asc"?-1:1:a>r?Oe==="asc"?1:-1:0}):xe,[xe,Q,Oe]),nt=Math.max(1,W?.pageTotal??1),es=W?.itemsTotal??0;l.useEffect(()=>{L(1)},[O]);const ts=()=>{B>1&&L(B-1)},ss=()=>{B<nt&&L(B+1)},as=()=>{g.length===ve.length?b([]):b(ve.map(t=>t.id))},rs=t=>{g.includes(t)?b(g.filter(s=>s!==t)):b([...g,t])},ls=ve.length>0&&g.length===ve.length,is=(()=>{const t=z.filter(a=>a.status==="scheduled"),s={};return t.forEach((a,r)=>{let o,D="";if(a.scheduledDate){const w=a.scheduledDate,T=w.getFullYear(),_=String(w.getMonth()+1).padStart(2,"0"),ze=String(w.getDate()).padStart(2,"0");o=`${T}-${_}-${ze}`;const p=w.getHours(),ws=String(w.getMinutes()).padStart(2,"0"),Ns=p<12?"AM":"PM";D=`${p>12?p-12:p===0?12:p}:${ws} ${Ns}`}else o=a.dateCreated,D="9:00 AM";s[o]||(s[o]=[]),s[o].push({id:a.id,title:a.title,time:D,status:"scheduled"})}),s})(),dt=(()=>{const t=z.filter(a=>a.status==="draft"),s={};return t.forEach(a=>{const r=a.dateCreated;s[r]||(s[r]=[]),s[r].push({id:a.id,title:a.title,time:"",status:"draft"})}),s})(),ot=(()=>{const t=z.filter(a=>a.status==="published"),s={};return t.forEach(a=>{let r;if(a.publishDate){const o=a.publishDate,D=o.getFullYear(),w=String(o.getMonth()+1).padStart(2,"0"),T=String(o.getDate()).padStart(2,"0");r=`${D}-${w}-${T}`}else r=a.dateCreated;s[r]||(s[r]=[]),s[r].push({id:a.id,title:a.title,time:"",status:"published"})}),s})(),ct=(()=>{const t=z.filter(a=>a.status==="archived"),s={};return t.forEach(a=>{const r=new Date(a.dateCreated),o=new Date(r);o.setDate(r.getDate()+Math.floor(a.id*2));const D=o.getFullYear(),w=String(o.getMonth()+1).padStart(2,"0"),T=String(o.getDate()).padStart(2,"0"),_=`${D}-${w}-${T}`;s[_]||(s[_]=[]),s[_].push({id:a.id,title:a.title,time:"",status:"archived"})}),s})(),Ue=(()=>{const t={...is};return Object.keys(dt).forEach(s=>
1{t[s]||(t[s]=[]),t[s]=[...t[s],...dt[s]]}),Object.keys(ot).forEach(s=>{t[s]||(t[s]=[]),t[s]=[...t[s],...ot[s]]}),Object.keys(ct).forEach(s=>{t[s]||(t[s]=[]),t[s]=[...t[s],...ct[s]]}),t})(),ns=t=>({draft:"bg-purple-50 text-purple-400 border-purple-100",scheduled:"bg-green-50 text-green-400 border-green-100",published:"bg-[rgb(var(--brand-primary-rgb)/0.08)] text-[var(--brand-primary)] border-[var(--brand-primary)]/20",archived:"bg-yellow-50 text-yellow-400 border-yellow-100"})[t]||"bg-gray-50 text-gray-900 border-gray-200",ds=l.useMemo(()=>{const t=new Date;return t.setHours(0,0,0,0),Object.entries(Ue).flatMap(([s,a])=>a.map(r=>({...r,date:s,uniqueId:`upcoming-${r.id}-${s}`}))).filter(s=>new Date(s.date)>=t&&(s.status==="scheduled"||s.status==="draft")).sort((s,a)=>new Date(s.date)-new Date(a.date)).slice(0,5)},[Ue]),os=t=>({published:"bg-[rgb(var(--brand-primary-rgb)/0.08)] text-[var(--brand-primary)]",draft:"bg-purple-50 text-purple-400",scheduled:"bg-green-50 text-green-400",archived:"bg-yellow-50 text-yellow-400",publishing:"bg-[rgb(var(--brand-primary-rgb)/0.08)] text-[var(--brand-primary)] animate-pulse",unpublishing:"bg-[rgb(var(--brand-primary-rgb)/0.08)] text-[var(--brand-primary)] animate-pulse"})[t]||"bg-gray-100 text-gray-700",cs=t=>({published:"Published",draft:"Draft",scheduled:"Scheduled",publishing:"Publishing…",unpublishing:"Moving to draft…"})[t]||t,us=t=>e.jsxs(ce,{onClick:s=>{s.stopPropagation(),Ye(t)},disabled:N[t]?.moveToDraft,children:[N[t]?.moveToDraft?e.jsx(ue,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Move to Draft"]}),hs=async()=>{if(!d){h(!0),ge(!1);return}const t=await Promise.allSettled(g.map(r=>ee({blogs_id:r,status:"scheduled"}))),s=t.filter(r=>r.status==="fulfilled").length,a=t.length-s;if(s>0)try{await H()}catch(r){console.error("Failed to refresh artifacts after scheduling:",r)}if(ge(!1),a>0){be({status:"error",title:s>0?"Schedule Partially Updated":"Schedule Update Failed",description:`${s} artifact${s!==1?"s":""} scheduled, ${a} failed. Please try again for any failed items.`});return}Pe(!0)},ms=()=>{if(!d){h(!0),ge(!1);return}ge(!1),re(!0)},ps=t=>{et(t)},xs=async()=>{if(!d){h(!0),re(!1);return}const t=le?Math.floor(le.getTime()/1e3):null,s=await Promise.allSettled(g.map(o=>me({blogs_id:o,scheduledDate:t}))),a=s.filter(o=>o.status==="fulfilled").length,r=s.length-a;if(a>0)try{await H()}catch(o){console.error("Failed to refresh artifacts after scheduling:",o)}re(!1),et(null),b([]),be({status:r>0?"error":"success",title:r>0?"Schedule Partially Updated":"Schedule Updated",description:r>0?`${a} artifact${a!==1?"s":""} scheduled, ${r} failed. Please try again for any failed items.`:`${a} artifact${a!==1?"s":""} scheduled successfully.`})},gs=()=>{st==="publish"&&(i("table"),v("published")),Pe(!1),b([])},Ye=t=>{if(!y()){h(!0);return}$(t,"moveToDraft",!0),k({blogs_id:t,status:"draft"},{onSuccess:async()=>{const s=z.find(a=>a.id===t)?.title||xe.find(a=>a.id===t)?.title||"AI Artifact";try{await H(),$(t,"moveToDraft",!1),rt(s),ye(!0)}catch{$(t,"moveToDraft",!1),rt(s),ye(!0)}},onError:s=>{$(t,"moveToDraft",!1),Ge(s,{title:"Couldn't move to draft",fallback:"There was an error moving the artifact to draft. Please try again."})}})},bs=t=>{if(!y()){h(!0);return}k({blogs_id:t,status:"archived"},{onSuccess:()=>{H(),b(s=>s.filter(a=>a!==t))},onError:s=>{Ge(s,{title:"Couldn't archive artifact",fallback:"There was an error archiving the artifact. Please try again."})}})},ut=(t,s)=>{if(s?.stopPropagation(),!y()){h(!0);return}$(t,"publish",!0),pe({geo_id:t,website_id:n},{onSuccess:a=>{if($(t,"publish",!1),!Ut(a))return;const r=z.find(o=>o.id===t)?.title||xe.find(o=>o.id===t)?.title||"AI Artifact";zt(r),at(!0),H()},onError:a=>{console.error("Failed to publish artifact:",a),$(t,"publish",!1),$e(a)}})},fs=(t,s)=>{if(!s)return;if(!d){h(!0),de(null),je(null);return}const a=s.toISOString().split("T")[0];he({blogs_id:t,scheduledDate:Math.floor(new Date(a).getTime()/1e3)},{onSuccess:()=>{H(),de(null),je(null),be({status:"success",title:"Schedule Updated",description:"The artifact publishing schedule has been updated successfully."})},onError:r=>{console.error("Failed to schedule artifact:",r),be({status:"error",title:"Schedule Update Failed",description:"There was an error updating the artifact schedule. Please try again."})}})},ht=(t,s)=>{if(s?.stopPropagation(),!y()){h(!0);return}De({blogs_id:t},{onSuccess:()=>{H(),b(a=>
1a.filter(r=>r!==t))},onError:a=>{Ge(a,{title:"Couldn't delete artifact",fallback:"There was an error deleting the artifact. Please try again."})}})},He=t=>{{c(`/aivisibility/generate-artifacts/artifact/${t}`);return}},X=Xe?.draft??0,Z=Xe?.scheduled??0,mt=()=>{const t=[];return ie&&t.push("draft"),ne&&t.push("scheduled"),Ys(n,{type:"artifact",statuses:t})},ys=async()=>{if(Te)return;if(!d){h(!0),fe(!1);return}let t=[];try{_e(!0),t=await mt()}catch(s){console.error("Failed to collect artifacts to schedule:",s),$e(s);return}finally{_e(!1)}t.length!==0&&(b(t),fe(!1),re(!0))},js=async()=>{if(Te)return;if(!d){h(!0),fe(!1);return}let t=[];try{_e(!0),t=await mt()}catch(s){console.error("Failed to collect artifacts to publish:",s),$e(s);return}finally{_e(!1)}t.length!==0&&(b(t),te({ids:t,website_id:n},{onSuccess:()=>{H()},onError:s=>{console.error("Bulk publish failed:",s),$e(s)}}),Lt("publish"),fe(!1),Pe(!0))},vs=({dateKey:t})=>{const s=Ue[t]||[];return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"space-y-2 overflow-y-auto pr-1",children:s.map(a=>{const r=a.status;let o,D,w,T,_;r==="draft"?(o="bg-purple-50",D="border-purple-100",w="hover:bg-purple-50",T="text-purple-400",_="text-purple-400"):r==="scheduled"?(o="bg-green-50",D="border-green-100",w="hover:bg-green-50",T="text-green-400",_="text-green-400"):r==="published"?(o="bg-[rgb(var(--brand-primary-rgb)/0.08)]",D="border-[var(--brand-primary)]/20",w="hover:bg-[rgb(var(--brand-primary-rgb)/0.08)]",T="text-[var(--brand-primary)]",_="text-[var(--brand-primary)]"):r==="archived"?(o="bg-yellow-50",D="border-yellow-100",w="hover:bg-yellow-50",T="text-yellow-400",_="text-yellow-400"):(o="bg-gray-50",D="border-gray-200",w="hover:bg-gray-100",T="text-gray-900",_="text-gray-600");const ze=r==="draft"||r==="scheduled"||r==="published";return e.jsxs("div",{className:`${o} border ${D} rounded overflow-hidden relative ${ze?"pb-2":""}`,"data-testid":`calendar-artifact-${a.id}`,children:[e.jsx("button",{onClick:p=>ht(a.id,p),className:"absolute top-1 right-1 p-0.5 rounded-sm hover:bg-gray-900/10 transition-colors z-10","data-testid":`button-delete-calendar-${a.id}`,title:"Delete artifact",children:e.jsx(vt,{className:"w-3 h-3 text-gray-600 hover:text-gray-900"})}),e.jsxs("div",{onClick:()=>He(a.id),className:`px-2 py-1 cursor-pointer ${w} transition-colors pr-4`,children:[e.jsx("div",{className:`text-xs font-medium ${T} truncate ${r==="archived"?"line-through":""}`,children:a.title}),a.time&&e.jsx("div",{className:`text-xs ${_} ${r==="archived"?"line-through":""}`,children:a.time})]}),(r==="draft"||r==="scheduled")&&e.jsxs("div",{className:"flex items-stretch px-2",children:[e.jsx("button",{onClick:p=>{if(p.stopPropagation(),p.preventDefault(),!y()){h(!0);return}ut(a.id,p)},disabled:N[a.id]?.publish,className:"flex-1 border-r border-[var(--brand-primary)] rounded-l-md bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90 text-white text-xs font-medium py-1 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-1","data-testid":`button-publish-calendar-${a.id}`,children:N[a.id]?.publish?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 animate-spin"}),"Publishing..."]}):"Publish"}),e.jsxs(At,{children:[e.jsx(Dt,{asChild:!0,children:e.jsx("button",{onClick:p=>p.stopPropagation(),className:"bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90 text-white px-1.5 transition-colors rounded-r-md","data-testid":`button-schedule-dropdown-calendar-${a.id}`,children:e.jsx(Us,{className:"w-3 h-3"})})}),e.jsxs(Mt,{align:"end",onClick:p=>p.stopPropagation(),children:[e.jsxs(ce,{onSelect:p=>{if(p.stopPropagation(),!y()){h(!0);return}de(a.id)},"data-testid":`button-schedule-calendar-${a.id}`,children:[e.jsx(Je,{className:"w-4 h-4 mr-2"}),"Schedule"]}),r!=="draft"&&us(a.id)]})]})]}),r==="published"&&e.jsx("div",{className:"flex items-stretch px-2",children:e.jsx("button",{onClick:p=>{p.stopPropagation(),Ye(a.id)},disabled:N[a.id]?.moveToDraft,className:"flex-1 bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90 text-white text-xs font-medium py-1 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-1",children:N[a.id]?.moveToDraft?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"w-3 h-3 animate-spin"}),"Moving..."]}):"Move to Draft"})})]},a.id)})}),s.length===0&&Ke[t]>0&&e.jsx("div",{className:"mt-auto pt-1 flex-shrink-0",children:e.jsx(Zs,{count:Ke[t]})})]})};return e.jsxs("div",{children:[e.jsx(ca,{text:"AI VISIBILITY ON FULL AUTOPILOT"}),e.jsxs(ga,{title:"Step-3: Calendar",description:"Schedule and track y
1our AI visibility artifact publishing calendar.",children:[e.jsx(ha,{redirectPath:"/aivisibility/calendar",testId:"cms-connection-banner-calendar",offerManagedBlogSetup:!0}),e.jsx(Ws,{forecast:Me,feature:"artifact"}),M&&e.jsxs("div",{className:"mt-6 bg-[rgb(var(--brand-primary-rgb)/0.08)] border border-[var(--brand-primary)]/20 rounded-lg p-6 shadow-sm","data-testid":"creation-progress-banner",children:[e.jsxs("div",{className:"mb-3",children:[e.jsxs("h3",{className:"text-lg font-semibold text-[var(--brand-primary)] mb-1",children:["Creating ",P," AI Article",P===1?"":"s"]}),e.jsx("p",{className:"text-sm text-[var(--brand-primary)]",children:"This process may take time. You can navigate to other pages—your artifacts will continue processing in the background."})]}),e.jsx("div",{className:"w-full bg-[rgb(var(--brand-primary-rgb)/0.08)] rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"h-full bg-[var(--brand-primary)] transition-all duration-200 ease-out rounded-full",style:{width:`${S}%`},"data-testid":"creation-progress-bar"})})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-4 gap-6",children:[e.jsxs("div",{className:"xl:col-span-3 space-y-8",children:[e.jsx(ya,{viewMode:A,setViewMode:i,isTableFetching:Pt,tableBlogsData:W,goToPreviousMonth:se,goToNextMonth:G,goToToday:q,currentMonth:x,currentYear:j,isAllSelected:ls,handleSelectAll:as,calSortColumn:Q,handleCalSort:Kt,filteredArtifacts:ve,highlightedArtifactId:Jt,artifactLoadingStates:N,artifactRowRefs:Xt,handleCalendarArtifactClick:He,selectedArtifacts:g,handleSelectArtifact:rs,getStatusBadge:os,getStatusLabel:cs,checkCMSConnection:y,setShowCMSRequiredModal:h,handlePublishFromCalendar:ut,setSchedulingArtifactId:de,handleMoveToDraft:Ye,handleArchive:bs,handleDeleteFromCalendar:ht,totalPages:nt,totalItems:es,currentPage:B,ITEMS_PER_PAGE:V,setCurrentPage:L,handlePreviousPage:ts,handleNextPage:ss}),A==="calendar"&&e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 p-6 mb-6 shadow-sm",children:[e.jsx(Qs,{month:x,year:j,subtitle:`${z.length} ${z.length===1?"artifact":"artifacts"} this month`,onPrev:se,onNext:G,onToday:q,children:e.jsxs(C,{onClick:()=>{A==="calendar"&&v("scheduled"),i(A==="calendar"?"table":"calendar")},variant:"outline",className:"border border-gray-300 text-gray-700 hover:bg-gray-50",size:"sm","data-testid":"button-view-toggle-calendar",children:[e.jsx(ft,{className:"w-4 h-4 mr-2 text-gray-600"}),"Table View"]})}),e.jsx(Xs,{month:x,year:j,ranges:kt,isFetching:u&&!!m,renderDay:vs})]})]}),e.jsx(va,{upcomingPosts:ds,getEventTypeColor:ns,onArtifactClick:He})]}),e.jsx(we,{open:It,onOpenChange:fe,children:e.jsx(Ne,{className:"max-w-lg mx-auto bg-white rounded-lg shadow-xl border-0 p-0 overflow-hidden",children:e.jsxs(e.Fragment,{children:[e.jsxs(Ce,{className:"px-8 pt-8 pb-4",children:[e.jsx(Se,{className:"text-2xl font-bold text-gray-900",children:"Publish AI Artifacts"}),e.jsx(Ee,{className:"text-gray-600 text-base mt-2",children:"Select which artifact groups you'd like to publish."})]}),e.jsxs("div",{className:"px-8 pb-6",children:[e.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-5 mb-6 space-y-4",children:[X>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Be,{id:"publish-draft-group",checked:ie,onCheckedChange:Ft,className:"mt-1","data-testid":"checkbox-publish-draft-group"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"publish-draft-group",className:"text-sm font-semibold text-gray-900 cursor-pointer",children:"Draft Artifacts"}),e.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:[X," ",X===1?"artifact":"artifacts"," ready to schedule for publishing"]})]}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-purple-50 text-purple-400",children:X})]}),Z>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Be,{id:"publish-scheduled-group",checked:ne,onCheckedChange:Bt,className:"mt-1","data-testid":"checkbox-publish-scheduled-group"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"publish-scheduled-group",className:"text-sm font-semibold text-gray-900 cursor-pointer",children:"Scheduled Artifacts"}),e.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:[Z," ",Z===1?"artifact":"artifacts"," already scheduled and ready to publish"]})]}),e.jsx("span",{className:"inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-green-50 text-green-400",children:Z})]})]}),e.jsxs("div",{className:"bg-[rgb(var(--brand-primary-rgb)/0.08)] border border-[var(--brand-primary)]/20 rounded-lg p-4 mb-6",children:[e.jsx("p",{className:"text-sm text-[var(--brand-primary)] font-medium mb-1",children:(()=>{const t=(ie?X:0)+(ne?Z:0);if(t===0)return"Please select at least one group to publish.";const s=[];return ie&&X>0&&s.push(`${X} draft`),ne&&Z>0&&s.push(`${Z} scheduled`),`Publishing ${s.join(" and ")} ${t===1?"artifact":"artifacts"}`})()}),e.jsx("p",{className:"text-xs text-[var(--brand-primary)]",children:"Choose how you'd like to schedule your selected artifacts below."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(C,{onClick:js,disabled:!ie&&!ne||Te,className:"flex-1 bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90 text-white h-auto py-4 flex flex-col items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"button-publish-all-ai-scheduler",children:[e.jsx(yt,{className:"w-6 h-6"}),e.jsx("span",{className:"font-semibold",children:"Publish Now"}),e.jsx("span",{className:"text-xs opacity-90",children:"Instant publishing"})]}),e.jsxs(C,{onClick:ys,disabled:!ie&&!ne||Te,variant:"outline",className:"flex-1 border-2 border-[var(--brand-primary)]/20 text-[var(--brand-primary)] hover:bg-[rgb(var(--brand-primary-rgb)/0.08)] h-auto py-4 flex flex-col items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"button-publish-all-manual-scheduler",children:[e.jsx(Le,{className:"w-6 h-6"}),e.jsx("span",{className:"font-semibold",children:"Schedule"}),e.jsx("span",{className:"text-xs",children:"Pick publish dates"})]})]})]})]})})}),e.jsx(zs,{open:Et,onOpenChange:tt,onCreateClick:()=>{tt(!1),Re(!0)}}),e.jsx(we,{open:Tt,onOpenChange:ge,children:e.jsxs(Ne,{className:"max-w-lg mx-auto bg-white rounded-lg shadow-xl border-0 p-0 overflow-hidden",children:[e.jsxs(Ce,{className:"px-8 pt-8 pb-4",children:[e.jsx(Se,{className:"text-2xl font-bold text-gray-900",children:"Publish AI Artifacts"}),e.jsx(Ee,{className:"text-gray-600 text-base mt-2",children:g.length===1?"1 artifact is ready to be scheduled for publishing.":`${g.length} artifacts are ready to be scheduled for publishing.`})]}),e.jsxs("div",{className:"px-8 pb-6",children:[e.jsx("div",{className:"bg-[rgb(var(--brand-primary-rgb)/0.08)] border border-[var(--brand-primary)]/20 rounded-lg p-4 mb-6",children:e.jsx("p",{className:"text-sm text-[var(--brand-primary)]",children:"Choose how you'd like to schedule your content. AI Sc
1heduler will automatically determine the best publishing times based on AI visibility best practices, or you can manually select a specific date for all selected artifacts."})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(C,{onClick:hs,className:"flex-1 bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90 text-white h-auto py-4 flex flex-col items-center gap-2","data-testid":"button-ai-scheduler",children:[e.jsx(yt,{className:"w-6 h-6"}),e.jsx("span",{className:"font-semibold",children:"AI Scheduler"}),e.jsx("span",{className:"text-xs opacity-90",children:"Optimized scheduling"})]}),e.jsxs(C,{onClick:ms,variant:"outline",className:"flex-1 border-2 border-[var(--brand-primary)]/20 text-[var(--brand-primary)] hover:bg-[rgb(var(--brand-primary-rgb)/0.08)] h-auto py-4 flex flex-col items-center gap-2","data-testid":"button-manual-scheduler",children:[e.jsx(Le,{className:"w-6 h-6"}),e.jsx("span",{className:"font-semibold",children:"Manual"}),e.jsx("span",{className:"text-xs",children:"Pick your own date"})]})]})]})]})}),e.jsx(we,{open:_t,onOpenChange:re,children:e.jsxs(Ne,{className:"max-w-lg mx-auto bg-white rounded-lg shadow-xl border-0 p-0 overflow-hidden",children:[e.jsxs(Ce,{className:"px-8 pt-8 pb-4",children:[e.jsx(Se,{className:"text-2xl font-bold text-gray-900",children:"Select Publishing Date"}),e.jsxs(Ee,{className:"text-gray-600 text-base mt-2",children:["Choose a date to schedule ",g.length===1?"this artifact":`${g.length} artifacts`," for publishing."]})]}),e.jsxs("div",{className:"px-8 pb-6",children:[e.jsx("div",{className:"bg-[rgb(var(--brand-primary-rgb)/0.08)] border border-[var(--brand-primary)]/20 rounded-lg p-4 mb-6",children:e.jsx("p",{className:"text-sm text-[var(--brand-primary)]",children:"All selected artifacts will be scheduled to publish on the date you choose. You can adjust individual publish times later from the calendar view."})}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(wt,{mode:"single",selected:le,onSelect:ps,disabled:t=>t<new Date,className:"rounded-md border border-gray-200","data-testid":"calendar-manual-schedule"})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(C,{onClick:()=>re(!1),variant:"outline",className:"flex-1","data-testid":"button-cancel-manual",children:"Cancel"}),e.jsxs(C,{onClick:xs,disabled:!le,className:"flex-1 bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90 text-white disabled:opacity-50","data-testid":"button-confirm-manual",children:["Schedule for ",le?le.toLocaleDateString("en-US",{month:"short",day:"numeric"}):"Selected Date"]})]})]})]})}),e.jsx(Gs,{open:$t,onOpenChange:Pe,confirmationType:st,artifactCount:g.length,onClose:gs}),e.jsx(we,{open:lt!==null,onOpenChange:t=>{t||(de(null),je(null))},children:e.jsxs(Ne,{className:"max-w-md",children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:"Schedule Artifact"}),e.jsx(Ee,{children:"Select a date to schedule this artifact for publication."})]}),e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(wt,{mode:"single",selected:Vt,onSelect:t=>{je(t),fs(lt,t)},disabled:t=>t<new Date,initialFocus:!0,className:"rounded-md border"})})]})}),e.jsx(pa,{open:!!ke,onClose:()=>
1be(null),status:ke?.status||"success",title:ke?.title||"",description:ke?.description||""}),e.jsx(we,{open:Qt,onOpenChange:Re,children:e.jsxs(Ne,{className:"max-w-2xl",children:[e.jsx(Ce,{children:e.jsx(Se,{className:"text-2xl font-bold text-gray-900",children:"How to Create AI Artifacts"})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("p",{className:"text-gray-700 leading-relaxed",children:"Creating AI artifacts is a simple three-step process that helps you generate high-quality content for AI visibility. Follow these steps to get started:"}),e.jsx("div",{className:"bg-[rgb(var(--brand-primary-rgb)/0.08)] border border-[var(--brand-primary)]/20 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-[var(--brand-primary)] text-white flex items-center justify-center font-bold",children:"1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Add a Topic (Keyword)"}),e.jsx("p",{className:"text-gray-700 leading-relaxed",children:"Start by adding a topic or keyword that represents the subject matter you want to create content about. This could be anything relevant to your business, industry, or target audience."}),e.jsx("div",{className:"mt-3 pl-4 border-l-2 border-[var(--brand-primary)]/20",children:e.jsx("p",{className:"text-sm text-gray-600 italic",children:'Example: "Accessory Dwelling Unit design ideas" or "ADU financing options"'})})]})]})}),e.jsx("div",{className:"bg-green-50 border border-green-100 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-green-400 text-white flex items-center justify-center font-bold",children:"2"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"AI Generates Prompts"}),e.jsx("p",{className:"text-gray-700 leading-relaxed",children:"Once you've added your topics, our AI will automatically generate multiple prompts based on each topic. These prompts are specific questions or search queries that your target customers might use when looking for information."}),e.jsx("div",{className:"mt-3 pl-4 border-l-2 border-green-100",children:e.jsx("p",{className:"text-sm text-gray-600 italic",children:"You can review, edit, or add additional prompts before proceeding to the next step."})})]})]})}),e.jsx("div",{className:"bg-purple-50 border border-purple-100 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-purple-400 text-white flex items-center justify-center font-bold",children:"3"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Create Artifacts & Auto-Schedule"}),e.jsxs("p",{className:"text-gray-700 leading-relaxed mb-3",children:["Click the ",e.jsx("strong",{children:'"Next - Create AI Artifacts"'})," button at the bottom of the Prompts page. The AI will begin creating artifacts based on your topics and prompts."]}),e.jsxs("div",{className:"bg-white rounded-md p-4 border border-purple-100",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(jt,{className:"w-5 h-5 text-purple-400 flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-sm text-gray-700",children:[e.jsx("strong",{children:"Automatic Scheduling:"})," Your artifacts will populate on the calendar with scheduled dates already assigned."]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(jt,{className:"w-5 h-5 text-purple-400 flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-sm text-gray-700",children:[e.jsx("strong",{children:"Publishing Timeline:"})," Artifacts begin publishing today and continue one or more each day after, optimized for maximum visibility."]})]})]})]})]})}),e.jsx("div",{className:"pt-4 border-t border-gray-200",children:e.jsxs(C,{onClick:()=>{Re(!1),c("/aivisibility/context?showAddTopics=true")},className:"w-full bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90 text-white text-base py-6","data-testid":"button-add-new-topic",children:[e.jsx(Ls,{className:"w-5 h-5 mr-2"}),"Add New Topic"]})})]})]})}),e.jsx(Rs,{isOpen:U,onClose:()=>h(!1),description:"Publishing artifacts requires CMS connection"}),e.jsx(Os,{error:Rt,onClose:Ot}),e.jsx(ma,{open:Yt,onClose:()=>at(!1),entityType:"artifact",title:Ht}),Gt&&e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>ye(!1)}),e.jsxs("div",{className:"relative bg-white rounded-lg shadow-lg p-6 mx-4 max-w-md w-full border-0",children:[e.jsx("button",{onClick:()=>ye(!1),className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors",children:e.jsx(vt,{className:"w-5 h-5"})}),e.jsx("div",{className:"flex items-center justify-center mb-4",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-[rgb(var(--brand-primary-rgb)/0.08)] flex items-center justify-center",children:e.jsx(ft,{className:"w-6 h-6 text-[var(--brand-primary)]"})})}),e.jsx("h3",{className:"text-lg font-semibold text-slate-900 text-center mb-2",children:"Artifact Moved to Draft"}),e.jsxs("p",{className:"text-slate-600 text-center text-sm mb-6",children:['"',qt,'" has been moved back to draft.']}),e.jsx("div",{className:"flex justify-center",children:e.jsx(C,{onClick:()=>ye(!1),className:"bg-[var(--brand-primary)] hover:bg-[var(--brand-primary)]/90",children:"OK"})})]})]})]})]})}export{tr 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.