1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/js/Library-Bje-HIPC.js","assets/js/ui-vendor-DeaCpvuz.js","assets/js/react-vendor-BwON9l4R.js","assets/js/index-Kz-5MvZ9.js","assets/js/supabase-vendor-eEOYocAC.js","assets/js/query-vendor-DsJQQYkK.js","assets/index-DCvBSKuj.css","assets/js/badge-Dht8Lt2r.js","assets/js/chevron-right-Dp4t2JdI.js","assets/js/check-CIuB_zKM.js","assets/js/circle-DX1eoveW.js","assets/js/GenerateVideoDialog-C6ZYMIAb.js","assets/js/alert-dialog-Bzgk2_9Q.js","assets/js/trending-up-B__FCMVO.js","assets/js/trash-2-Be1tE6R7.js","assets/js/circle-alert-kCskUU8Q.js","assets/js/sparkles-BdSrl3dE.js","assets/js/calendar-BpG5PemG.js","assets/js/clock-CBETRLQI.js","assets/js/card-B7gy2v7u.js","assets/js/UpgradeModal-ClMfV0NO.js","assets/js/alert-wjtFgdqf.js","assets/js/lightbulb-D41pt8VC.js","assets/js/plus-BFZk4Bhp.js","assets/js/dashboardDataCache-SNkqqi8U.js","assets/js/search-Cy2tqsao.js","assets/js/filter-BdbKwUVE.js","assets/js/play-BRv3YnUl.js","assets/js/eye-Dv41zyqO.js","assets/js/refresh-cw-C0pmwrj9.js","assets/js/CalendarView-hYJPzWvo.js","assets/js/video-BZJbYVPk.js","assets/js/Analytics-CYWt2Uun.js","assets/js/select-BEfq-KiM.js","assets/js/chevron-down-DWhBuuk_.js","assets/js/index-Do3YLtJf.js","assets/js/users-nr0wVtGO.js","assets/js/share-2-NojZO_fH.js","assets/js/SettingsPage-xHl5vA3w.js","assets/js/switch-bX1wSj4i.js","assets/js/style-cartoon-3d-BPyJ4vVt.js","assets/js/timezones-D6aFyEZb.js","assets/js/separator-IaKGCGnr.js","assets/js/mail-Bo0erBmJ.js","assets/js/external-link-CNU32g-o.js","assets/js/BlogManager-DHxvOIB3.js","assets/js/AppSumoAdmin-CyKeZsgK.js","assets/js/gift-DWdsp3zJ.js","assets/js/EmailSequences-BDTV-rur.js","assets/js/EmailSequenceEditor-BKU5Alif.js","assets/js/arrow-left-q65SDx_G.js"])))=>i.map(i=>d[i]); 2import{j as e}from"./ui-vendor-DeaCpvuz.js";import{u as D,r,i as M,O as R}from"./react-vendor-BwON9l4R.js";import{c as I,s,B as O,X as q,M as z,l as U,m as $,u as B}from"./index-Kz-5MvZ9.js";import{B as F}from"./badge-Dht8Lt2r.js";import{u as L,U as H}from"./UpgradeModal-ClMfV0NO.js";import{S as G}from"./sparkles-BdSrl3dE.js";import{C as S}from"./circle-alert-kCskUU8Q.js";import{V as A}from"./video-BZJbYVPk.js";import{T as W}from"./trending-up-B__FCMVO.js";import{C as Z}from"./clock-CBETRLQI.js";import{C as P}from"./calendar-BpG5PemG.js";import{R as J,a as X,b as Y}from"./index-D5cwZfoR.js";import{_ as w}from"./supabase-vendor-eEOYocAC.js";import{g as T,s as E}from"./dashboardDataCache-SNkqqi8U.js";import{G as K}from"./gift-DWdsp3zJ.js";import{M as Q}from"./mail-Bo0erBmJ.js";import{L as ee}from"./log-out-BmXzrMLH.js";import{C as te}from"./chevron-down-DWhBuuk_.js";import"./query-vendor-DsJQQYkK.js";import"./card-B7gy2v7u.js";import"./check-CIuB_zKM.js";/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const se=I("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** 8 * @license lucide-react v0.462.0 - ISC 9 * 10 * This source code is licensed under the ISC license. 11 * See the LICENSE file in the root directory of this source tree. 12 */const ae=I("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** 13 * @license lucide-react v0.462.0 - ISC 14 * 15 * This source code is licensed under the ISC license. 16 * See the LICENSE file in the root directory of this source tree. 17 */const ne=I("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),oe=()=>{const m=D(),{subscription:d}=L(),[p,i]=r.useState(!1),[y,_]=r.useState([]),[x,N]=r.useState(0),[c,l]=r.useState(!0);if(r.useEffect(()=>{const o=async()=>{try{const{data:{user:t}}=await s.auth.getUser();if(!t)return;const{data:u}=await s.from("user_settings").select("autopilot_enabled").eq("user_id",t.id).single();if(i(u?.autopilot_enabled||!1),u?.autopilot_enabled){const{count:C}=await s.from("autopilot_plans").select("*",{count:"exact",head:!0}).eq("user_id",t.id).eq("status","planned");N(C||0);const{data:V}=await s.from("autopilot_plans").select("*").eq("user_id",t.id).eq("status","planned").order("planned_for",{ascending:!0}).limit(1);_(V||[])}else N(0),_([])}catch(t){console.error("Error fetching autopilot status:",t)}finally{l(!1)}};o();let h;s.auth.getUser().then(({data:{user:t}})=>{h=t?.id});const j=t=>{const u=t.detail,C=typeof u=="boolean"?u:u?.enabled;i(!!C),o()};window.addEventListener("autopilot:toggled",j);const a=()=>{o()};window.addEventListener("autopilot:planning-complete",a);const v=s.channel("user_settings_changes").on("postgres_changes",{event:"UPDATE",schema:"public",table:"user_settings"},t=>{t.new.autopilot_enabled!==void 0&&i(t.new.autopilot_enabled),o()}).subscribe(),n=s.channel("autopilot_plans_changes").on("postgres_changes",{event:"*",schema:"public",table:"autopilot_plans"},t=>
17{const u=t.new,C=t.old;(u?.user_id===h||C?.user_id===h)&&(console.log("Autopilot plans updated, refreshing status..."),o())}).subscribe();return()=>{window.removeEventListener("autopilot:toggled",j),window.removeEventListener("autopilot:planning-complete",a),s.removeChannel(v),s.removeChannel(n)}},[]),c)return null;const k=o=>{const h=new Date(o),j=new Date,a=h.getTime()-j.getTime(),v=Math.floor(a/(1e3*60*60)),n=Math.floor(v/24);return n>1?`in ${n} days`:v>1?`in ${v}h`:"soon"},f=o=>{const h=new Date(o);return new Date(h.getTime()-2*60*60*1e3)},g=d&&d.videos_remaining===0,b=y[0];return e.jsx("div",{className:"space-y-3",children:e.jsxs("button",{onClick:()=>m("/dashboard/settings?tab=autopilot"),className:`w-full px-4 py-3 rounded-lg transition-all text-left bg-[#1f1f1f] border border-gray-800 ${!p||g?"hover:bg-[#2a2a2a]":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(G,{className:`h-4 w-4 ${p?g?"text-red-400":"text-cta animate-pulse":"text-gray-500"}`}),p&&!g&&e.jsx("div",{className:"absolute -top-0.5 -right-0.5 h-1.5 w-1.5 bg-cta rounded-full animate-ping"})]}),e.jsx("span",{className:"font-semibold text-sm text-white",children:"Autopilot"}),p?g?e.jsx(S,{className:"ml-auto h-4 w-4 text-red-400"}):e.jsx(F,{variant:"secondary",className:"ml-auto h-5 text-[10px] px-1.5 bg-cta/20 text-cta border-0 hover:bg-cta/20",children:"ACTIVE"}):e.jsx("span",{className:"ml-auto text-xs font-semibold text-gray-500",children:"OFF"})]}),p&&g&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-400 pl-7",children:[e.jsx(S,{className:"h-3 w-3 flex-shrink-0"}),e.jsx("span",{children:"No generation credits left"})]}),p&&!g&&e.jsxs("div",{className:"space-y-2 pl-7",children:[e.jsx("div",{className:"flex items-center gap-3 text-xs",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(A,{className:"h-3 w-3 text-gray-400"}),e.jsxs("span",{className:"text-gray-400",children:[x," planned"]})]})}),b&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(W,{className:"h-3 w-3 text-cta flex-shrink-0"}),e.jsx("span",{className:"font-medium text-gray-200 truncate",children:b.prompt_context?.topic||"Video planning..."})]}),e.jsxs("div",{className:"text-xs text-gray-500 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Z,{className:"h-2.5 w-2.5"}),e.jsxs("span",{children:["Generating ",k(f(b.planned_for).toISOString())]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(P,{className:"h-2.5 w-2.5"}),e.jsxs("span",{children:["Posting ",k(b.planned_for)]})]})]})]}),!b&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400",children:[e.jsx(A,{className:"h-3 w-3 animate-pulse"}),e.jsx("span",{children:"AI is optimizing your schedule..."})]})]})]})})},re=J,ie=X,le=Y,de=()=>{r.useEffect(()=>{const m=setTimeout(()=>{w(()=>import("./Library-Bje-HIPC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])),w(()=>import("./CalendarView-hYJPzWvo.js"),__vite__mapDeps([30,1,2,3,4,5,6,19,7,11,12,8,13,14,15,9,16,17,18,20,21,22,23,31,24])),w(()=>import("./Analytics-CYWt2Uun.js"),__vite__mapDeps([32,1,2,19,3,4,5,6,7,33,34,9,24,35,27,28,36,37,18,17,13])),w(()=>import("./SettingsPage-xHl5vA3w.js"),__vite__mapDeps([38,1,2,19,3,4,5,6,33,34,9,39,7,12,35,40,41,20,42,24,16,13,43,44,15])),w(()=>import("./BlogManager-DHxvOIB3.js"),__vite__mapDeps([45,1,2,3,4,5,6,21,19,39,7,15,23,44,14])),w(()=>import("./AppSumoAdmin-CyKeZsgK.js"),__vite__mapDeps([46,1,2,19,3,4,5,6,33,34,9,7,23,47,25])),w(()=>import("./EmailSequences-BDTV-rur.js"),__vite__mapDeps([48,1,2,5,3,4,6,19,12,33,34,9,23,14])),w(()=>import("./EmailSequenceEditor-BKU5Alif.js"),__vite__mapDeps([49,1,2,5,3,4,6,19,43,12,28,14,50,23]))},100);return()=>clearTimeout(m)},[])},ce=m=>{r.useEffect(()=>{if(!m)return;let d=!1;const p=async()=>{try{const{data:{user:_}}=await s.auth.getUser();if(!_||d)return;const x=[];T("library:videos")===void 0&&x.push((async()=>{const{data:c,error:l}=await s.functions.invoke("get-user-videos");l||d||E("library:videos",c?.videos||[])})());const N="30";T(`analytics:${N}`)===void 0&&x.push((async()=>{const{data:c,error:l}=await s.functions.invoke("get-analytics",{body:{dateRange:N}});l||d||E(`analytics:${N}`,c)})()),T("settings:data")===void 0&&x.push((async()=>{const{data:c,error:l}=await s.functions.invoke("get-user-settings");l||d||E("settings:data",{settings:c?.settings||{},connectedAccounts:c?.connectedAccounts||[]})})()),T("calendar:state")===void 0&&x.push((async()=>{const c=Intl.DateTimeFormat().resolvedOptions().timeZone,[{data:l},k,f]=await Promise.all([s.from("user_settings").select("timezone, autopilot_enabled").eq("user_id",_.id).maybeSingle(),s.functions.invoke("get-scheduled-videos"),s.from("autopilot_plans").select("*").eq("user_id",_.id).order("planned_for",{ascending:!0})]);if(d)return;
17const g=l?.timezone||c||"UTC",b=l?.autopilot_enabled||!1,o=k?.data?.videos||[],h=o.filter(n=>n.scheduled_for&&n.status==="scheduled"||n.status==="published"&&n.published_at),j=o.filter(n=>!n.scheduled_for&&n.status==="draft"),a=f?.data||[],v=b&&a.length===0;E("calendar:state",{userTimezone:g,autopilotEnabled:b,autopilotPlanning:v,scheduledVideos:h,unscheduledVideos:j,autopilotPlans:a})})()),await Promise.allSettled(x)}catch{}},i=window,y=typeof i.requestIdleCallback=="function"?i.requestIdleCallback(p,{timeout:1500}):window.setTimeout(p,300);return()=>{d=!0,typeof i.cancelIdleCallback=="function"?i.cancelIdleCallback(y):clearTimeout(y)}},[m])},Oe=()=>{const m=D(),[d,p]=r.useState(!0),[i,y]=r.useState(!1),[_,x]=r.useState(!1),[N,c]=r.useState(!1),[l,k]=r.useState(!1),{subscription:f}=L();de(),ce(!d),r.useEffect(()=>{let a=!0;(async()=>{const{data:{session:t}}=await s.auth.getSession();if(!t&&a&&m("/auth"),t?.user&&a){const{data:u}=await s.from("user_roles").select("role").eq("user_id",t.user.id).eq("role","admin").single();c(!!u)}a&&p(!1)})();const{data:{subscription:n}}=s.auth.onAuthStateChange((t,u)=>{!u&&a&&m("/auth")});return()=>{a=!1,n.unsubscribe()}},[m]);const g=async()=>{await s.auth.signOut(),B.success("Logged out successfully"),m("/auth")};if(d)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#fafafa]",children:e.jsx("div",{className:"h-12 w-12 border-4 border-primary border-t-transparent rounded-full animate-spin"})});const b=[{to:"/dashboard/library",icon:A,label:"Library"},{to:"/dashboard/calendar",icon:P,label:"Calendar"},{to:"/dashboard/analytics",icon:se,label:"Analytics"}],o=[{to:"/dashboard/blog",icon:ae,label:"Blog",adminOnly:!0},{to:"/dashboard/admin/appsumo",icon:K,label:"AppSumo Codes",adminOnly:!0},{to:"/dashboard/admin/email-sequences",icon:Q,label:"Email Sequences",adminOnly:!0}],h=[{to:"/dashboard/settings",icon:ne,label:"Settings"}],j=[...b,...N?o:[],...h];return e.jsxs(e.Fragment,{children:[e.jsx(H,{open:_,onOpenChange:x,currentPlan:f?.plan}),e.jsxs("div",{className:"h-screen flex w-full bg-[#fafafa] overflow-hidden",children:[e.jsx(O,{variant:"ghost",size:"icon",className:"fixed top-4 right-4 z-50 lg:hidden text-foreground hover:bg-muted",onClick:()=>y(!i),children:i?e.jsx(q,{className:"h-6 w-6"}):e.jsx(z,{className:"h-6 w-6"})}),i&&e.jsx("div",{className:"fixed inset-0 bg-black/80 z-40 lg:hidden",onClick:()=>y(!1)}),e.jsxs("aside",{className:` 18 fixed lg:relative top-0 left-0 z-40 w-full lg:w-64 h-screen flex-shrink-0 19 border-r border-gray-800 bg-[#0a0a0a] flex flex-col 20 transition-transform duration-300 lg:translate-x-0 21 ${i?"translate-x-0":"-translate-x-full"} 22 `,children:[e.jsx("div",{className:"p-6 border-b border-gray-800 flex-shrink-0",children:e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:U,alt:"SnapPilot - AI Autopilot for Viral Videos",className:"h-10 w-auto"})})}),e.jsxs("nav",{className:"flex-1 overflow-y-auto px-4 py-6",children:[e.jsx("div",{className:"space-y-2",children:j.map(a=>{const v=a.icon;return e.jsxs(M,{to:a.to,onClick:()=>y(!1),className:({isActive:n})=>`group flex items-center gap-3 px-4 py-3 rounded-lg transition-all ${n?"bg-cta text-black font-semibold":"text-gray-300 hover:bg-white/5 hover:text-white"}`,children:[e.jsx(v,{className:"h-5 w-5 group-hover:scale-110 transition-transform"}),e.jsx("span",{children:a.label})]},a.to)})}),e.jsx("div",{className:"mt-6",children:e.jsx(oe,{})}),f&&e.jsx("div",{className:"mt-6",children:e.jsxs("div",{className:"rounded-xl bg-[#1f1f1f] p-4 border border-gray-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-semibold text-white",children:"Videos"}),e.jsxs("span",{className:"text-sm text-gray-400",children:[f.videos_remaining," left"]})]}),e.jsx("div",{className:"w-full bg-gray-800 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"h-full bg-cta transition-all duration-300",style:{width:`${f.videos_remaining/f.videos_per_month*100}%`}})}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"remaining this month"}),f.videos_remaining<=0&&e.jsx("div",{className:"mt-3 p-3 rounded-lg bg-red-950/20 border border-red-900/30",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-red-400",children:[e.jsx(S,{className:"h-4 w-4 mt-0.5 shrink-0"}),e.jsx("div",{children:e.jsxs("p",{className:"leading-relaxed",children:["Out of credits."," ",e.jsx("button",{className:"underline font-medium hover:text-red-300",onClick:()=>x(!0),children:"Upgrade plan"})]})})]})})]})})]}),e.jsx("div",{className:"p-4 border-t border-gray-800 flex-shrink-0",children:e.jsxs(O,{variant:"ghost",className:"w-full justify-start gap-3 text-gray-400 hover:bg-red-950/20 hover:text-red-400",onClick:g,children:[e.jsx(ee,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:"Logout"})]})})]}),e.jsx("main",{className:"flex-1 overflow-y-auto bg-[#fafafa] h-screen",children:e.jsxs("div",{className:"max-w-[1600px] mx-auto p-4 sm:p-6 lg:p-12 pt-16 lg:pt-8",children:[e.jsx(re,{open:l,onOpenChange:k,className:"mb-4",children:e.jsxs("div",{className:"rounded-lg border border-border bg-card shadow-sm",children:[e.jsxs(ie,{className:"w-full px-4 py-3 flex items-center justify-between hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("svg",{className:"h-4 w-4 text-muted-foreground",viewBox:"0 0 24 24",fill:"
22currentColor",children:e.jsx("path",{d:"M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 0 1-5.2 1.74 2.89 2.89 0 0 1 2.31-4.64 2.93 2.93 0 0 1 .88.13V9.4a6.84 6.84 0 0 0-1-.05A6.33 6.33 0 0 0 5 20.1a6.34 6.34 0 0 0 10.86-4.43v-7a8.16 8.16 0 0 0 4.77 1.52v-3.4a4.85 4.85 0 0 1-1-.1z"})}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Currently publishing to TikTok Inbox as drafts"})]}),e.jsx(te,{className:`h-4 w-4 text-muted-foreground transition-transform ${l?"rotate-180":""}`})]}),e.jsx(le,{children:e.jsxs("div",{className:"px-4 py-3 border-t border-border bg-muted/30 space-y-2.5",children:[e.jsxs("p",{className:"text-sm text-foreground leading-relaxed",children:[e.jsx("strong",{children:"What's happening:"})," Our TikTok app is pending approval, so videos go to your Creator Tools Inbox as drafts instead of posting directly."]}),e.jsxs("p",{className:"text-sm text-foreground leading-relaxed",children:[e.jsx("strong",{children:"Why analytics show 0:"})," TikTok restricts profile data during app review. Your profile name and analytics will appear automatically once approved."]}),e.jsx("div",{className:"pt-1 flex items-center justify-between text-xs",children:e.jsx("span",{className:"text-muted-foreground",children:"Expected approval: January 24, 2026"})})]})})]})}),e.jsx(r.Suspense,{fallback:e.jsxs("div",{className:"min-h-[60vh] w-full flex flex-col items-center justify-center gap-6",children:[e.jsx("img",{src:$,alt:"Loading",className:"w-20 h-20 animate-spin",style:{animationDuration:"2s"}}),e.jsx("p",{className:"text-lg font-medium text-foreground",children:"Loading..."})]}),children:e.jsx(R,{})})]})})]})]})};export{Oe 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.