1import{D as ke,j as e,C as E,l as D,a2 as R,A as de,a as O,b as A,u as L,G as M,r as p,c as S,T as Ce,W as k,aW as he,a6 as Ge,am as We,aF as Xe,al as me,aM as Je,R as Qe,aB as Ze,cd as es,cB as ss,X as xe,o as X,af as Ie,H as Ae,a1 as ue,L as fe,U as ts,S as as,Z as rs,ao as J,aq as Q,ar as K,as as V,aN as ie,E as Ee,at as le,m as ns,B as F,aj as os}from"./main-DX7XzkoU.js";import{u as is}from"./useWeeklyIdeasSeen-DvWtJot1.js";import{S as y}from"./skeleton-DN2cjZOe.js";import{u as ls}from"./useBioPage-BL4QjuKg.js";import{u as cs}from"./useBioAnalytics-COqfK5D_.js";import{f as ce}from"./format-number-CwMs0Eao.js";import{L as Pe}from"./link-2-CASnJw5r.js";import{C as ee}from"./chevron-right-D27HfhtL.js";import{E as ds}from"./eye-DTdVPMB0.js";import{M as ms}from"./mouse-pointer-click-DA8rXXNz.js";import{E as us}from"./external-link-Bhm5X9sQ.js";import{B as Re}from"./badge-BOGaWzi1.js";import{I as Te}from"./image-off-BUfV3N24.js";import{P as De,G as Le}from"./panels-top-left-DM7gdoeV.js";import{I as Me}from"./image-play-FzvV3P2U.js";import{V as qe}from"./video-BvJDFQSG.js";import{S as $}from"./smartphone-WGY3uvd5.js";import{L as Oe}from"./layers-UGj9VXD5.js";import{I as Z}from"./instagramPublishingService-BVQSHM0o.js";import{c as ps,p as hs,e as xs}from"./pt-BR-g-tPW2Ip.js";import{P as He}from"./plus-C6FQ2-b-.js";import{C as fs}from"./clock-DZY59rpR.js";import{c as Fe}from"./constructNow-CO-G4Rcw.js";import{i as Be}from"./isSameDay-BKzx1q_S.js";import{f as re}from"./format-kQpqiptj.js";import{a as gs}from"./addDays-CTmn1H6a.js";import{u as bs}from"./useBannerConfig-Cjnayi6d.js";import{C as _s,a as js,b as Ns}from"./collapsible-BquexElO.js";import{a as ws}from"./automationService-C3IdZDrE.js";import{C as vs}from"./circle-check-DRpR_UoF.js";import{C as ys}from"./circle-BXmX70XD.js";import{b as Ss}from"./index-Bf_8NQ-v.js";import{u as ks,M as Cs,V as Is,f as As,A as Es,a as ne,b as Ps}from"./availability-GoWcazUC.js";import{N as Rs}from"./NicheRulesHint-B_AnsSXo.js";import{G as Ts}from"./gem-DGeoeC5P.js";import{M as Ds}from"./mic-Cdt-o0ua.js";import{a as Ls}from"./rollout-yo8TKvhk.js";import{T as W}from"./Trans-CUvlxym0.js";import{d as Ms}from"./diagnosticService-DCDJsjWt.js";import{S as ge}from"./ScoreGauge-BSKfidvX.js";import{A as qs}from"./routes-C6M2Yg1X.js";import{b as Os}from"./instagram-connection-error-C5t4-2DQ.js";import{T as Hs}from"./trending-down-D6wPF7rt.js";import{F as Fs,L as Bs,a as Us,R as $s,u as zs,b as Ks}from"./CreateContentModal-eREkTihJ.js";import{u as Vs,s as Ys,a as Gs,d as Ws,b as Xs,C as Js}from"./useNow-CLIUYe8K.js";import{I as Qs}from"./image-BBUOngQh.js";import{P as Zs}from"./palette-OTKsHiwO.js";import{W as et}from"./wand-sparkles-CwRAYUwy.js";import{M as st}from"./megaphone-B0K-HV7w.js";import{C as tt}from"./clapperboard-BoJYuZop.js";import{C as at}from"./chart-column-Dsbf4ZZ1.js";import{L as rt}from"./lightbulb-UJa6zn96.js";import{U as nt}from"./user-check-BR60HPjZ.js";import{D as ot}from"./DashboardLoading-DZLzzgDQ.js";import{A as it}from"./AppHeader-CzkMBh75.js";import{M as lt}from"./MobileBottomNav-B6c1hPKj.js";import{u as ct}from"./useProfileRedirect-DxHBy1EC.js";import{u as dt}from"./useSubscriptionErrors-Cz5UkWh8.js";import{C as mt}from"./chevron-left-B_lb0x5L.js";import{P as ut}from"./play-EybWeSlT.js";import{A as pt}from"./apple-DWW9bkLi.js";import{I as ht}from"./instagram-uOX4SJX4.js";import"./dropdown-menu-D6liHcXh.js";import"./index-D6Z5KIMn.js";import"./MediaLibraryModal-BCoaB8Tw.js";import"./scroll-area-D4uBgFjC.js";import"./tabs-BuRg9jtd.js";import"./imageCompression-CmCw4g5L.js";import"./image-file-BbkB38iy.js";import"./search-Du1BtiHK.js";import"./upload-CRdrqrw1.js";import"./trash-2-pjGqSJFK.js";import"./useImageUpload-DxkTg4K9.js";import"./image-plus-B8KpqAee.js";import"./images-RMU8x23j.js";import"./types-Cddy06IB.js";import"./NicheRulesDialog-9bYTgvZA.js";import"./referral-code-CAIXjQN4.js";import"./sheet-D4yLKOxB.js";import"./useSalesCrm-BbMwVkcj.js";import"./AppInstallBanner-CAnCi_kO.js";import"./ThemeToggle-C5kzRcph.js";import"./monitor-MvsPdGOU.js";import"./routes-Dh-CjbFu.js";import"./history-BQ1iBcZd.js";import"./chart-no-axes-column-CL-SWzid.js";import"./link-D6mXMmG7.js";import"./settings-N25lzdMz.js";import"./circle-help-CV3y08qY.js";import"./user-x-BOA8xi05.js";import"./globe-BBWCCznd.js";import"./download-DFu9GkQ8.js";import"./useInstagramProfiles-D_KQvT_K.js";import"./arrow-left-Cf41rOjY.js";import"./menu-B6sRxHFL.js";import"./house-C4ToeB93.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const xt=ke("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ft=ke("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",ke
11y:"1blaws"}]]);function gt(s,t){return Be(ps(s,s),Fe(s))}function bt(s,t){return Be(s,gs(Fe(s),1),t)}const Ue=s=>({role:"button",tabIndex:0,onClick:s,onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),s())}}),B=({icon:s,title:t,subtitle:a,onActivate:r,badge:n,className:c,iconClassName:o})=>e.jsx(E,{className:R("cursor-pointer group border-border/50 bg-card hover:bg-card/80 transition-colors duration-200 active:scale-[0.99] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",c),...Ue(r),children:e.jsxs(D,{className:"flex h-full items-center gap-3 p-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(s,{className:R("h-4 w-4 text-primary",o)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-semibold leading-tight truncate",children:[t,n&&e.jsx("span",{className:"ml-1.5 inline-flex items-center rounded-full bg-primary/15 text-primary font-semibold px-2 py-0.5 text-[10px] leading-none align-middle",children:n})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight mt-0.5 line-clamp-1",children:a})]}),e.jsx(de,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/40 transition-transform group-hover:translate-x-0.5"})]})}),_t=()=>{const s=O(),{t,i18n:a}=A(),{user:r}=L(),{selectedProfile:n}=M(),{fetchPageByInstagramProfileId:c,currentPage:o}=ls(),{currentMonthStats:h,fetchAnalytics:i}=cs(),u=a.language.startsWith("pt")?"pt-BR":"en-US",[x,b]=p.useState(!0),[f,g]=p.useState(!1);p.useEffect(()=>{r!=null&&r.id&&(n!=null&&n.id)?m():(b(!1),g(!1))},[r==null?void 0:r.id,n==null?void 0:n.id]);const m=async()=>{if(!(!(r!=null&&r.id)||!(n!=null&&n.id))){b(!0);try{const l=await c(n.id);l?(g(!0),await i(l.id,1)):g(!1)}catch(l){console.error("Erro ao carregar dados da bio:",l),g(!1)}finally{b(!1)}}},_=h.views>0?(h.total_clicks/h.views*100).toFixed(1):"0",v=o!=null&&o.slug?`${window.location.origin}/bio/${o.slug}`:null;return x?e.jsxs("div",{className:"space-y-3 mt-6 px-4 md:px-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{className:"h-5 w-32"}),e.jsx(y,{className:"h-4 w-24"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(y,{className:"h-20 rounded-xl"}),e.jsx(y,{className:"h-20 rounded-xl"}),e.jsx(y,{className:"h-20 rounded-xl"})]})]}):n?f?e.jsxs("div",{className:"space-y-4 md:mt-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base md:text-lg font-semibold text-foreground tracking-tight",children:t("bioLinks.title")}),e.jsxs(S,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground hover:text-primary hover:bg-transparent px-0",onClick:()=>s(`/bio-links/${o==null?void 0:o.id}?tab=analytics`),children:[t("dashboard.see_all","Ver detalhes"),e.jsx(ee,{className:"w-4 h-4 ml-1"})]})]}),e.jsxs("div",{className:"flex overflow-x-auto pb-2 -mx-4 px-4 sm:grid sm:grid-cols-3 sm:overflow-visible sm:pb-0 sm:px-0 gap-3 md:gap-4 snap-x snap-mandatory hide-scrollbar",children:[e.jsx(E,{className:"min-w-[140px] flex-1 sm:min-w-0 snap-start bg-card/50 border-border/50 hover:bg-card transition-colors",children:e.jsxs(D,{className:"p-3 md:p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"p-1.5 bg-blue-500/10 rounded-md",children:e.jsx(ds,{className:"w-3.5 h-3.5 md:w-4 md:h-4 text-blue-500"})}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-muted-foreground uppercase tracking-wide truncate",children:t("bioLinks.analytics.views")})]}),e.jsx("p",{className:"text-xl md:text-2xl font-bold text-foreground",children:ce(h.views,u)})]})}),e.jsx(E,{className:"min-w-[140px] flex-1 sm:min-w-0 snap-start bg-card/50 border-border/50 hover:bg-card transition-colors",children:e.jsxs(D,{className:"p-3 md:p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"p-1.5 bg-green-500/10 rounded-md",children:e.jsx(ms,{className:"w-3.5 h-3.5 md:w-4 md:h-4 text-green-500"})}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-muted-foreground uppercase tracking-wide truncate",children:t("bioLinks.analytics.clicks")})]}),e.jsx("p",{className:"text-xl md:text-2xl font-bold text-foreground",children:ce(h.total_clicks,u)})]})}),e.jsx(E,{className:"min-w-[140px] flex-1 sm:min-w-0 snap-start bg-card/50 border-border/50 hover:bg-card transition-colors",children:e.jsxs(D,{className:"p-3 md:p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 rounded-md",children:e.jsx(Ce,{className:"w-3.5 h-3.5 md:w-4 md:h-4 text-orange-500"})}),e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-muted-foreground uppercase tracking-wide truncate",children:t("bioLinks.analytics.clickRate")})]}),e.jsxs("p",{className:R("text-xl md:text-2xl font-bold",parseFloat(_)>=1?"text-green-600 dark:text-green-400":"text-foreground"),children:[_,"%"]})]})})]}
11),v&&e.jsx(E,{className:"bg-muted/20 border-border/30 cursor-pointer hover:bg-muted/40 transition-colors",onClick:()=>window.open(v,"_blank"),children:e.jsxs(D,{className:"flex items-center justify-between p-3",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:v.replace("https://","").replace("http://","")})}),e.jsx(us,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0 ml-2"})]})})]}):e.jsx(B,{icon:Pe,title:t("bioLinks.title"),subtitle:t("dashboard.bioMetrics.createYourPage"),onActivate:()=>s("/bio-links")}):null},jt=({maxPosts:s=4})=>{const t=O(),{t:a}=A(),{user:r}=L(),{selectedProfile:n}=M(),[c,o]=p.useState([]),[h,i]=p.useState(!0);p.useEffect(()=>{r!=null&&r.id&&(n!=null&&n.id)?u():i(!1)},[r==null?void 0:r.id,n==null?void 0:n.id]);const u=async()=>{if(!(!(r!=null&&r.id)||!(n!=null&&n.id))){i(!0);try{const{data:m,error:_}=await k.from("posts").select("id, title, thumbnail_url, slide_images, content_type, slides_count, status, created_at").eq("user_id",r.id).eq("instagram_profile_id",n.id).eq("status","completed").is("archived_at",null).order("created_at",{ascending:!1}).limit(s);if(_)throw _;if(!m||m.length===0){o([]),i(!1);return}const v=m.map(l=>({id:l.id,title:l.title,thumbnail_url:l.thumbnail_url,slide_images:l.slide_images,content_type:l.content_type,slides_count:l.slides_count||1,status:l.status,created_at:l.created_at}));o(v)}catch(m){console.error("Erro ao carregar posts recentes:",m),o([])}finally{i(!1)}}},x=m=>{switch(m){case"carousel":return e.jsx(Le,{className:"w-3 h-3"});case"story_sequence":return e.jsx(Oe,{className:"w-3 h-3"});case"story":return e.jsx($,{className:"w-3 h-3"});case"reel":return e.jsx(qe,{className:"w-3 h-3"});case"reel_cover":return e.jsx(Me,{className:"w-3 h-3"});case"post":default:return e.jsx(De,{className:"w-3 h-3"})}},b=m=>{switch(m){case"carousel":return a("postSuggestions.carousel");case"story_sequence":return a("postSuggestions.storySequence");case"story":return a("postSuggestions.story");case"reel":return a("postSuggestions.reel");case"reel_cover":return a("create.reel_cover");case"post":default:return a("postSuggestions.post")}},f=m=>m.thumbnail_url?m.thumbnail_url:m.slide_images&&m.slide_images.length>0?m.slide_images[0]:null,g=m=>{t(`/dashboard/post/${m}`)};return n?h?e.jsxs("div",{className:"space-y-3 mt-6 px-4 md:px-0",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:a("dashboard.recent_posts")})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 md:gap-3",children:[...Array(4)].map((m,_)=>e.jsx(y,{className:"aspect-square rounded-lg"},_))})]}):c.length===0?null:e.jsxs("div",{className:"space-y-4 md:mt-8 pb-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base md:text-lg font-semibold text-foreground tracking-tight",children:a("dashboard.recent_posts")}),e.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>t("/dashboard/posts"),className:"text-xs text-muted-foreground hover:text-primary hover:bg-transparent px-0",children:[a("dashboard.see_all"),e.jsx(ee,{className:"w-4 h-4 ml-1"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 md:gap-3",children:c.map(m=>{const _=f(m);return e.jsx(E,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:scale-[1.02] active:scale-[0.98] touch-manipulation border border-border/50",onClick:()=>g(m.id),children:e.jsxs("div",{className:"relative aspect-square bg-muted",children:[_?e.jsx("img",{src:_,alt:m.title||"Post",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-muted to-muted/50",children:e.jsx(Te,{className:"w-8 h-8 text-muted-foreground/50"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:e.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-2",children:e.jsx("p",{className:"text-white text-xs font-medium truncate",children:m.title||a("chat.untitled")})})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(Re,{variant:"secondary",className:"text-[10px] h-5 px-1.5 gap-1 bg-black/50 text-white border-0 backdrop-blur-sm",children:[x(m.content_type),e.jsx("span",{className:"hidden xs:inline",children:b(m.content_type)})]})})]})},m.id)})})]}):null},Nt=({maxPosts:s=4})=>{const t=O(),{t:a,i18n:r}=A(),{user:n}=L(),{selectedProfile:c}=M(),o=r.language==="pt"?hs:xs,[h,i]=p.useState([]),[u,x]=p.useState(!0);p.useEffect(()=>{n!=null&&n.id&&(c!=null&&c.id)?b():x(!1)},[n==null?void 0:n.id,c==null?void 0:c.id]);const b=async()=>
11{if(!(!(n!=null&&n.id)||!(c!=null&&c.id))){x(!0);try{const l=await Z.listScheduledPosts({instagramProfileId:c.id,status:["pending","scheduled"],limit:s});i(l)}catch(l){console.error("Erro ao carregar posts agendados:",l),i([])}finally{x(!1)}}},f=l=>{switch(l){case"carousel":return e.jsx(Le,{className:"w-3 h-3"});case"story":return e.jsx($,{className:"w-3 h-3"});case"reel":return e.jsx($,{className:"w-3 h-3"});case"post":default:return e.jsx(De,{className:"w-3 h-3"})}},g=l=>{switch(l){case"carousel":return a("postSuggestions.carousel");case"story":return a("postSuggestions.story");case"story_sequence":return a("postSuggestions.storySequence");case"reel":return"Reel";case"post":default:return a("postSuggestions.post")}},m=l=>l?gt(l)?`${a("publishing.today","Hoje")}, ${re(l,"HH:mm",{locale:o})}`:bt(l)?`${a("publishing.tomorrow","Amanhã")}, ${re(l,"HH:mm",{locale:o})}`:re(l,"d MMM, HH:mm",{locale:o}):a("publishing.no_date","Sem data"),_=l=>{var N;return!l||l.length===0?null:((N=l[0])==null?void 0:N.image_url)||null},v=l=>{l.postId?t(`/dashboard/post/${l.postId}`):t("/dashboard/scheduled")};return c?u?e.jsxs("div",{className:"space-y-3 mt-6 px-4 md:px-0",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4"}),a("dashboard.upcoming_posts","Próximos Agendamentos")]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 md:gap-3",children:[...Array(2)].map((l,N)=>e.jsx(y,{className:"aspect-square rounded-lg"},N))})]}):e.jsxs("div",{className:"space-y-4 md:mt-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-base md:text-lg font-semibold text-foreground tracking-tight",children:a("dashboard.upcoming_posts")}),h.length>0&&e.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>t("/dashboard/scheduled"),className:"text-xs text-muted-foreground hover:text-primary hover:bg-transparent px-0",children:[a("dashboard.see_all","Ver todos"),e.jsx(ee,{className:"w-4 h-4 ml-1"})]})]}),h.length===0?e.jsx(E,{className:"border-border/50 bg-card",children:e.jsxs("div",{className:"flex flex-col gap-3 p-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted",children:e.jsx(he,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium leading-tight",children:a("publishing.no_scheduled")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:a("dashboard.schedule_hint")})]})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>t("/dashboard/scheduled/create"),className:"w-full sm:w-auto shrink-0 gap-1.5",children:[e.jsx(He,{className:"w-3.5 h-3.5"}),a("publishing.schedule_post","Agendar post")]})]})}):e.jsx("div",{className:"flex overflow-x-auto pb-4 -mx-4 px-4 sm:grid sm:grid-cols-2 md:grid-cols-4 sm:overflow-visible sm:pb-0 sm:px-0 gap-3 md:gap-3 snap-x snap-mandatory hide-scrollbar",children:h.map(l=>{var C;const N=l.imageUrl||_(l.carouselSlides),d=m(l.scheduledAt),j=l.scheduledAt&&l.scheduledAt<new Date;return e.jsx(E,{className:"group min-w-[160px] sm:min-w-0 snap-start cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:scale-[1.02] active:scale-[0.98] touch-manipulation border border-border/50",onClick:()=>v(l),children:e.jsxs("div",{className:"relative aspect-square bg-muted",children:[N?e.jsx("img",{src:N,alt:((C=l.caption)==null?void 0:C.slice(0,30))||"Post agendado",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-muted to-muted/50",children:e.jsx(Te,{className:"w-8 h-8 text-muted-foreground/50"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent",children:e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-2 space-y-1",children:[e.jsxs("div",{className:`flex items-center gap-1 text-[10px] ${j?"text-orange-300":"text-white/90"}`,children:[j?e.jsx(Ge,{className:"w-3 h-3"}):e.jsx(fs,{className:"w-3 h-3"}),e.jsx("span",{className:"font-medium truncate",children:d})]}),l.caption&&e.jsxs("p",{className:"text-white text-xs truncate opacity-80",children:[l.caption.slice(0,40),"..."]})]})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(Re,{variant:"secondary",className:"text-[10px] h-5 px-1.5 gap-1 bg-black/50 text-white border-0 backdrop-blur-sm",children:[f(l.contentType),e.jsx("span",{className:"hidden xs:inline",children:g(l.contentType)})]})}),e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${l.status==="scheduled"?"bg-green-400":"bg-yellow-400"} animate-pulse`})})]})},l.id)})})]}):null};function wt(s){return!s||!(!s.isActive||!!s.connectionError||s.isExpired)?null:s.isPending?"pending":s.connectionErrorCode==="wrong_account"?"wrong_account":"disconnected"}const vt={pending:"dashboard.connection_alert.pending_message",wrong_account:"dashboard.connection_alert.wrong_account_message",disconnected:"dashboard.connection_alert.message"},yt=()=>{const{t:s}=A(),t=O(),{selectedProfile:a}=M(),[r,n]=p.useState(null);p.useEffect(()=>{if(n(null),!(a!=null&&a.id))return;let i=!0;return Z.getConnection(a.id).then(u=>{i&&n(u)}),()=>{i=!1}},[a==null?void 0:a.id]);const c=wt(r);if(!c)return null;const o=r==null?void 0:r.connectionErrorUsername,h=c==="wrong_account"&&o?s("dashboard.connection_alert.wrong_account_message_with_username",{username:o}):s(vt[c]);return e.jsxs("div",{role:"status",className:"flex flex-col gap-3 overflow-hidden rounded-xl border border-border/60 border-l-[3px] border-l-warning bg-card p-3 pl-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex flex-1 items-start gap-3 min-w-0",children:[e.jsx(We,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning","aria-hidden":!0}),e.jsx("p",{className:"text-sm leading-snug text-foreground",children:h})]}),e.jsx(S,{size:"sm",onClick:()=>t(`/connect-instagram?profileId=${a==null?void 0:a.id}`),className:"min-h-11 w-full shrink-0 sm:w-auto",children:s(c==="pending"?"dashboard.connection_alert.complete":"dashboard.connection_alert.reconnect_short")})]})},St=()=>{const{data:s}=bs();if(!(s!=null&&s.title)||!s.link)return null;const t=s.link;return e.jsx(B,{icon:Xe,iconClassName:"text-[#25D366]",title:s.title,subtitle:s.description??"",onActivate:()=>window.open(t,"_blank","noopener,noreferrer")})},kt=["brand_profile","first_post","connect_instagram","install_app","publish_or_schedule","bio_link","view_insights","automation"],be={brand_profile:!1,first_post:!1,
11connect_instagram:!1,publish_or_schedule:!1,bio_link:!1,view_insights:!1,automation:!1,install_app:!1};async function H(s){try{return await s()}catch{return!1}}function Ct(){const{user:s}=L(),{selectedProfile:t}=M(),[a,r]=p.useState(!0),[n,c]=p.useState(be),o=p.useRef(0),h=s==null?void 0:s.id,i=t==null?void 0:t.id,u=t==null?void 0:t.business_category_slug,x=p.useCallback(async()=>{const m=++o.current,_=()=>o.current!==m;if(!h||!i){c(be),r(!1);return}r(!0);const v=!!(u&&u.trim()),[l,N,d,j,C,P,U]=await Promise.all([H(async()=>{const{data:w}=await k.from("posts").select("id").eq("user_id",h).eq("instagram_profile_id",i).eq("status","completed").is("form_data->contentPlan",null).limit(1);return!!(w&&w.length>0)}),H(async()=>{const w=await Z.getConnection(i);return!!(w&&w.isActive&&!w.isExpired)}),H(async()=>{const w=await Z.listScheduledPosts({instagramProfileId:i,status:["pending","scheduled","processing","publishing","published"],limit:1});return!!(w&&w.length>0)}),H(async()=>{const{data:w}=await k.from("bio_pages").select("id").eq("instagram_profile_id",i).limit(1);return!!(w&&w.length>0)}),H(async()=>{const{data:w}=await k.from("instagram_ai_summaries").select("id").eq("instagram_profile_id",i).limit(1);return!!(w&&w.length>0)}),H(()=>ws.hasAutomations(i)),H(async()=>{const{data:w}=await k.from("devices").select("id").eq("user_id",h).limit(1);return!!(w&&w.length>0)})]);_()||(c({brand_profile:v,first_post:l,connect_instagram:N,publish_or_schedule:d,bio_link:j,view_insights:C,automation:P,install_app:U}),r(!1))},[h,i,u]);p.useEffect(()=>{x()},[x]);const b=m=>{switch(m){case"brand_profile":return i?`/profile-onboarding?profileId=${i}`:"/profile-onboarding";case"first_post":return"/dashboard/create/carousel";case"connect_instagram":return"/connect-instagram";case"publish_or_schedule":return"/dashboard/scheduled";case"bio_link":return"/bio-links";case"view_insights":return"/dashboard/insights";case"automation":return"/dashboard/automations";
11case"install_app":return"/baixar-app"}},f=kt.map(m=>({id:m,done:n[m],path:b(m)})),g=f.filter(m=>m.done).length;return{loading:a,profileId:i,steps:f,completedCount:g,total:f.length,allDone:g===f.length,refresh:x}}const $e=({children:s})=>e.jsx(E,{className:"overflow-hidden border-border/50 bg-card",children:s}),ze="instagem:onboarding-checklist-done:",_e=s=>{if(!s)return!1;try{return localStorage.getItem(ze+s)==="1"}catch{return!1}},It=s=>{try{localStorage.setItem(ze+s,"1")}catch{}},At=()=>e.jsx($e,{children:e.jsxs(D,{className:"space-y-3 p-3.5 sm:p-4 md:space-y-4 md:p-5",children:[e.jsxs("div",{className:"flex w-full items-center gap-2.5 sm:gap-3",children:[e.jsx(y,{className:"h-9 w-9 rounded-lg sm:h-10 sm:w-10"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx(y,{className:"h-3.5 w-44 max-w-[55%]"}),e.jsx(y,{className:"h-2.5 w-24"})]}),e.jsx(y,{className:"h-5 w-9 rounded-full"}),e.jsx(y,{className:"h-4 w-4 rounded"})]}),e.jsx(y,{className:"h-1.5 w-full rounded-full"})]})}),Et=()=>{const{t:s}=A(),t=O(),{loading:a,profileId:r,steps:n,completedCount:c,total:o,allDone:h}=Ct(),{isSubscribed:i,loading:u}=me(),{openPricingModal:x}=Je(),b=(l,N,d)=>{if(!N){if(l==="install_app"){if(u)return;i?t(d):x();return}t(d)}},[f,g]=p.useState(!1),[m,_]=p.useState(()=>_e(r));if(p.useEffect(()=>{_(_e(r))},[r]),p.useEffect(()=>{!a&&h&&r&&!m&&(It(r),_(!0))},[a,h,r,m]),m||h)return null;if(a)return e.jsx(At,{});const v=o>0?Math.round(c/o*100):0;return e.jsx($e,{children:e.jsx(_s,{open:f,onOpenChange:g,children:e.jsxs(D,{className:"space-y-3 p-3.5 sm:p-4 md:space-y-4 md:p-5",children:[e.jsx(js,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center gap-2.5 rounded-lg text-left transition-colors hover:bg-muted/40 active:bg-muted/60 sm:gap-3","aria-label":s("onboardingChecklist.toggle"),children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 sm:h-10 sm:w-10",children:e.jsx(Qe,{className:"h-4 w-4 text-primary sm:h-5 sm:w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold leading-snug",children:s("onboardingChecklist.title")}),e.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:s("onboardingChecklist.progress",{completed:c,total:o})})]}),e.jsxs("span",{className:"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold tabular-nums text-primary",children:[c,"/",o]}),e.jsx(Ze,{className:R("h-4 w-4 shrink-0 text-muted-foreground transition-transform",f&&"rotate-180")})]})}),e.jsx(es,{value:v,className:"h-1.5"}),e.jsx(Ns,{className:"space-y-0.5 pt-0.5 sm:space-y-1",children:n.map(l=>e.jsxs("button",{type:"button",onClick:()=>b(l.id,l.done,l.path),disabled:l.done,className:R("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-3 text-left transition-colors sm:gap-3 sm:py-2.5",l.done?"cursor-default":"cursor-pointer hover:bg-muted/60 active:bg-muted"),children:[l.done?e.jsx(vs,{className:"h-[18px] w-[18px] shrink-0 text-emerald-500"}):e.jsx(ys,{className:"h-[18px] w-[18px] shrink-0 text-muted-foreground/40"}),e.jsx("span",{className:R("flex-1 text-sm leading-snug",l.done?"line-through text-muted-foreground":"text-foreground"),children:s(`onboardingChecklist.steps.${l.id}`)})]},l.id))})]})})})},Pt=s=>s<12?"assistant.hero.greeting_morning":s<18?"assistant.hero.greeting_afternoon":"assistant.hero.greeting_evening",je=["assistant.hero.question_1","assistant.hero.question_2","assistant.hero.question_3","assistant.hero.question_4"],Rt=je[Math.floor(Math.random()*je.length)],Tt=()=>{const{t:s,i18n:t}=A(),{user:a}=L(),{selectedProfile:r}=M(),{launch:n}=ss(),[c,o]=p.useState(!1),{isRecording:h,isTranscribing:i,error:u,seconds:x,startRecording:b,stopRecording:f,cancelRecording:g,resetError:m}=ks(t.language),[_,v]=p.useState(""),[l,N]=p.useState([]),d=p.useRef(null),j=a==null?void 0:a.user_metadata,C=(j==null?void 0:j.full_name)||(j==null?void 0:j.name)||(j==null?void 0:j.first_name),P=C?String(C).split(" ")[0]:r==null?void 0:r.username,U=s(Pt(new Date().getHours())),w=!!_.trim()&&!c,se=Ss(r==null?void 0:r.business_category_slug,r==null?void 0:r.business_context),Y=I=>{I&&(v(T=>T.trim()?`${T.trim()} ${I}`:I),setTimeout(()=>{var T;
11return(T=d.current)==null?void 0:T.focus()},0))},te=async()=>{m(),await b()},z=async()=>{Y(await f())};p.useEffect(()=>{h&&x>=Cs&&f().then(Y)},[h,x]);const q=()=>{w&&(n(_.trim(),l.length>0?l:void 0),v(""),N([]))},G=I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),q())};return e.jsxs("section",{className:"group relative py-4 md:py-10",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-1/2 top-1/4 h-56 w-[min(40rem,90%)] -translate-x-1/2 rounded-full bg-primary/10 opacity-50 blur-[80px] transition-opacity duration-500 group-focus-within:opacity-100 motion-reduce:transition-none"}),e.jsxs("div",{className:"relative mx-auto max-w-3xl",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center md:flex-row md:justify-center md:gap-4 md:text-left",children:[e.jsx(Ts,{className:"h-7 w-7 shrink-0 text-primary md:h-8 md:w-8"}),e.jsxs("h1",{className:"text-2xl font-bold leading-snug tracking-tight md:text-[2rem]",children:[P?s("assistant.hero.greeting",{greeting:U,name:P}):`${U}.`," ",e.jsx("span",{className:"block md:inline",children:s(Rt)})]})]}),e.jsxs("div",{className:R("mt-5 rounded-[1.75rem] border border-border bg-card p-3 md:mt-7 md:p-4 dark:bg-[hsl(var(--surface-elevated))]","shadow-[var(--shadow-card)] transition-[box-shadow,border-color] duration-300","focus-within:border-primary/40 focus-within:shadow-[var(--shadow-glow)] motion-reduce:transition-none"),children:[(l.length>0||c)&&e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 pl-1",children:[l.map((I,T)=>e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:I.previewUrl,alt:"",className:"h-14 w-14 rounded-lg border border-border object-cover"}),e.jsx("button",{type:"button",onClick:()=>N(ae=>ae.filter((pe,Ye)=>Ye!==T)),className:"absolute -right-1.5 -top-1.5 rounded-full border border-border bg-background p-0.5 text-muted-foreground shadow hover:text-destructive",title:s("assistant.attach.remove"),"aria-label":s("assistant.attach.remove"),children:e.jsx(xe,{className:"h-3 w-3"})}),e.jsx("span",{className:"absolute -bottom-1.5 -left-1.5 rounded-full border border-border bg-background px-1.5 text-[10px] font-medium text-muted-foreground",children:T+1})]},I.path)),c&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(X,{className:"h-3.5 w-3.5 animate-spin"}),s("assistant.attach.uploading")]})]}),e.jsx(Ie,{ref:d,value:_,onChange:I=>v(I.target.value),onKeyDown:G,placeholder:s("assistant.hero.placeholder"),rows:2,"aria-label":s("assistant.hero.placeholder"),className:"max-h-40 min-h-[56px] resize-none border-0 bg-transparent px-1.5 text-[15px] leading-relaxed shadow-none placeholder:text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0 md:min-h-[64px]",style:{fieldSizing:"content"}}),u&&e.jsx("p",{className:"mt-2 px-1.5 text-xs text-destructive",children:s(Is[u]||"assistant.voice.error")}),e.jsx("div",{className:"mt-2 flex items-center gap-1.5",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"relative ml-2 flex h-2.5 w-2.5 shrink-0",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-red-500 opacity-75 motion-reduce:animate-none"}),e.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-red-500"})]}),e.jsxs("span",{className:"text-sm tabular-nums text-foreground",children:[s("assistant.voice.recording")," · ",As(x)]}),e.jsx("div",{className:"flex-1"}),e.jsx(S,{size:"icon",variant:"ghost",className:"h-9 w-9 shrink-0 rounded-full text-muted-foreground hover:text-destructive",onClick:g,title:s("assistant.voice.cancel"),"aria-label":s("assistant.voice.cancel"),children:e.jsx(xe,{className:"h-[18px] w-[18px]"})}),e.jsx(S,{size:"icon",className:"h-10 w-10 shrink-0 rounded-full text-white",style:{background:"var(--gradient-primary)"},onClick:z,title:s("assistant.voice.stop"),"aria-label":s("assistant.voice.stop"),children:e.jsx(Ae,{className:"h-[18px] w-[18px]"})})]}):i?e.jsxs("div",{className:"flex items-center gap-2 pl-1.5 text-sm text-muted-foreground",children:[e.jsx(X,{className:"h-4 w-4 animate-spin"}),s("assistant.voice.transcribing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Es,{profileId:r==null?void 0:r.id,disabled:c||l.length>=ne,maxFiles:ne-l.length,variant:"outline",className:"h-9 w-9 shrink-0 rounded-full border-border/70 bg-transparent text-muted-foreground hover:text-foreground",onAttach:I=>N(T=>[...T,...I.filter(ae=>!T.some(pe=>pe.path===ae.path))].slice(0,ne)),onUploadingChange:o}),e.jsx("div",{className:"flex-1"}),e.jsx(S,{size:"icon",variant:"ghost",className:"h-9 w-9 shrink-0 rounded-full text-muted-foreground hover:text-foreground",onClick:te,disabled:c,title:s("assistant.voice.start"),"aria-label":s("assistant.voice.start"),children:e.jsx(Ds,{className:"h-[18px] w-[18px]"})}),e.jsx(S,{size:"icon",className:"h-10 w-10 shrink-0 rounded-full text-white transition-opacity disabled:opacity-40",style:{background:"var(--gradient-primary)"},onClick:q,disabled:!w,title:s("assistant.hero.send"),"aria-label":s("assistant.hero.send"),children:e.jsx(de,{className:"h-[18px] w-[18px]"})})]})})]}),e.jsx(Rs,{pack:se,className:"mt-2 px-1.5"})]})]})},Ke="instagem_rollout_new_home",Dt=()=>{try{return localStorage.getItem(Ke)}catch{return null}};function Lt(s){const[t,a]=p.useState(Dt);return p.useEffect(()=>
11{const r=new URLSearchParams(window.location.search).get("new_home");if(!(r!=="on"&&r!=="off")){try{localStorage.setItem(Ke,r)}catch{}a(r)}},[]),t==="on"?!0:t==="off"||!s?!1:Ls(s)}const Mt=100;function qt(s){return s.publishedCount>0&&s.reach>=Mt}function Ot(s,t,a,r){if(s<=0)return null;const n=new Set(a.map(i=>i.scheduled_post_id).filter(i=>!!i)),c=new Set,o=new Set;for(const i of t)!i.post_id||!(i.instagram_profile_id===r||n.has(i.id))||(o.add(i.id),c.add(i.post_id));let h=0;for(const i of a)i.scheduled_post_id&&o.has(i.scheduled_post_id)&&(h+=i.reach??0);return{creations:s,reach:h,publishedCount:c.size}}const Ht=1e3,Ft=1e3,Bt="instagem-creation-results",Ut=s=>{const t=s;return typeof(t==null?void 0:t.creations)=="number"&&typeof(t==null?void 0:t.reach)=="number"&&typeof(t==null?void 0:t.publishedCount)=="number"},$t=s=>{try{const t=localStorage.getItem(s);if(!t)return;const a=JSON.parse(t);return!a||!("value"in a)||!Ut(a.value)?void 0:{value:a.value}}catch{return}},zt=(s,t)=>{try{localStorage.setItem(s,JSON.stringify({value:t}))}catch{}};function Kt(s,t){const a=`${Bt}:${s}:${t}`,r=s&&t?$t(a):void 0;return ue({queryKey:["creation-results",s,t],enabled:!!s&&!!t,staleTime:1e3*60*30,...r?{initialData:r.value,initialDataUpdatedAt:0}:{},queryFn:async()=>{const[{count:n,error:c},{data:o,error:h},{data:i,error:u}]=await Promise.all([k.from("posts").select("id",{count:"exact",head:!0}).eq("user_id",s).eq("status","completed"),k.from("scheduled_posts").select("id, post_id, instagram_profile_id").eq("user_id",s).eq("status","published").not("post_id","is",null).order("created_at",{ascending:!1}).limit(Ht),k.from("instagram_media_insights").select("scheduled_post_id, reach").eq("instagram_profile_id",t).not("scheduled_post_id","is",null).order("created_at",{ascending:!1}).limit(Ft)]);if(c)throw c;if(h)throw h;if(u)throw u;const x=Ot(n??0,o??[],i??[],t);return x?(zt(a,x),x):null}})}const Vt=({fallback:s})=>{const{i18n:t}=A(),{user:a}=L(),{selectedProfile:r,profiles:n}=M(),c=t.language.startsWith("pt")?"pt-BR":"en-US",{data:o,isPending:h}=Kt(a==null?void 0:a.id,r==null?void 0:r.id);if(h)return e.jsx("div",{className:"text-sm",children:e.jsx("div",{className:"flex h-[21px] items-center",children:e.jsx(y,{className:"h-3.5 w-56 max-w-full"})})});if(o===void 0)return null;if(o===null)return e.jsx(e.Fragment,{children:s});const i={1:e.jsx("span",{className:"font-semibold text-foreground"})};return e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{children:e.jsx(W,{i18nKey:n.length>1?"dashboard.creation_results.summary_multi":"dashboard.creation_results.summary",count:o.creations,values:{creations:o.creations.toLocaleString(c),profiles:n.length},components:i})}),qt(o)&&e.jsxs("p",{children:[e.jsx(W,{i18nKey:n.length>1?"dashboard.creation_results.reach_multi":"dashboard.creation_results.reach",count:o.publishedCount,values:{posts:o.publishedCount.toLocaleString(c)},components:i})," ",e.jsx(W,{i18nKey:"dashboard.creation_results.reach_accounts",count:o.reach,values:{reach:ce(o.reach,c)},components:i})]})]})};function Yt(s){return ue({queryKey:["score-summary",s],queryFn:()=>Ms.summary(s),enabled:!!s,staleTime:30*60*1e3,refetchOnMount:t=>{var a;return((a=t.state.data)==null?void 0:a.score)==null?"always":!0}})}function Gt(s){var t;return s?s.score!==null&&s.diagnostic_id?{kind:"score",value:s.score,reportId:s.diagnostic_id,measuredAt:s.created_at,delta:Wt(s)?s.delta:null,topMove:(t=s.top_move)!=null&&t.title?s.top_move:null}:s.measurable?{kind:"invite"}:s.connected===!1?{kind:"connect"}:{kind:"hidden"}:{kind:"hidden"}}function Wt(s){return s.delta!==null&&s.delta!==0&&s.noise===!1}const Xt=()=>{const{t:s,i18n:t}=A(),{selectedProfile:a}=M(),{data:r,isPending:n}=Yt(a==null?void 0:a.id),c=Gt(r),o=t.language.startsWith("pt")?"pt-BR":"en-US";if(n&&(a!=null&&a.id))return e.jsx(y,{className:"h-[149px] sm:h-[119px] w-full rounded-xl"});if(c.kind==="hidden")return null;if(c.kind==="invite"||c.kind==="connect"){const g=c.kind==="connect";return e.jsx(E,{className:"border-primary/20 bg-primary/5",children:e.jsxs(D,{className:"p-4 flex flex-col items-start gap-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 w-full sm:w-auto
11sm:contents",children:[e.jsx(ge,{value:null,locale:o}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold leading-tight",children:s("dashboard.score.title")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s(g?"dashboard.score.connect_subtitle":"dashboard.score.invite_subtitle")})]})]}),e.jsx(S,{asChild:!0,size:"sm",className:"w-full sm:w-auto shrink-0",children:e.jsx(fe,{to:g?Os(a==null?void 0:a.id):qs,children:s(g?"dashboard.score.connect_action":"dashboard.score.invite_action")})})]})})}const{value:h,delta:i,topMove:u,measuredAt:x,reportId:b}=c,f=i!==null&&i>0;return e.jsx(E,{className:"group border-border/50 bg-card cursor-pointer transition-colors hover:bg-card/80 hover:border-primary/30",children:e.jsx(fe,{to:`/diagnostico/${b}`,className:"block rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:e.jsxs(D,{className:"p-4 flex items-center gap-3 sm:gap-4",children:[e.jsx(ge,{value:h,locale:o}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-sm font-semibold leading-tight",children:s("dashboard.score.title")}),i!==null&&e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] font-medium leading-none ${f?"bg-emerald-500/15 text-emerald-500":"bg-amber-500/15 text-amber-500"}`,children:[f?e.jsx(Ce,{className:"h-3 w-3"}):e.jsx(Hs,{className:"h-3 w-3"}),e.jsxs("span",{"aria-hidden":"true",children:[f?"+":"-",Math.abs(i)]}),e.jsx("span",{className:"sr-only",children:s(f?"dashboard.score.delta_up":"dashboard.score.delta_down",{points:Math.abs(i)})})]})]}),u&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:u.points_gain?s("dashboard.score.next_move_points",{move:u.title,points:u.points_gain}):s("dashboard.score.next_move",{move:u.title})}),x&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s("dashboard.score.measured_at",{date:new Date(x).toLocaleDateString(o,{day:"2-digit",month:"short"})})})]}),e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-primary shrink-0",children:[e.jsx("span",{className:"sr-only sm:not-sr-only",children:s("dashboard.score.open_report")}),e.jsx(ee,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})})})};async function Jt(){const{data:s,error:t}=await k.rpc("get_public_feed",{p_limit:3,p_offset:0});if(t)throw t;return s??[]}function Qt(){const{t:s}=A(),t=O(),{data:a=[]}=ue({queryKey:["feed-preview-dashboard"],queryFn:Jt,staleTime:5*60*1e3});return a.length===0?null:e.jsx(E,{className:"cursor-pointer group overflow-hidden border-border/50 bg-card hover:bg-card/80 transition-all duration-300 hover:shadow-md active:scale-[0.99]",onClick:()=>t("/feed"),children:e.jsxs(D,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(ts,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold leading-tight",children:s("dashboard.feed_card_title")}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:s("dashboard.feed_card_subtitle")})]}),e.jsx("div",{className:"flex items-center gap-1 shrink-0",children:a.map(r=>e.jsx("div",{className:"w-10 h-10 rounded-lg overflow-hidden bg-muted ring-1 ring-border/50",children:e.jsx("img",{src:r.image_url,alt:`@${r.instagram_username}`,className:"w-full h-full object-cover",loading:"lazy"})},r.id))}),e.jsx(de,{className:"h-4 w-4 text-muted-foreground/50 group-hover:text-purple-500 group-hover:translate-x-0.5 transition-all shrink-0"})]})})}function Zt({posts:s,now:t,onOpen:a,onOpenPost:r}){const{t:n}=A(),c=Vs(),o=Ys(s,t),h=f=>({day:c.weekday(new Date(f.publishAt)),time:c.time(new Date(f.publishAt))}),{headline:i}=o,[u,x]=i.kind==="to_approve"?[n("contentPlan.home_ready_title"),n("contentPlan.home_to_approve",{count:i.count})]:i.kind==="missed"?[n("contentPlan.home_missed_title"),n("contentPlan.home_missed",{count:i.count})]:i.kind==="scheduled"?[n("contentPlan.home_scheduled_title"),n("contentPlan.home_next",h(i.next))]:i.kind==="failed"?[n("contentPlan.home_failed_title",{count:i.count}),n("contentPlan.home_failed",{count:i.count})]:i.kind==="publishing"?[n("contentPlan.home_scheduled_title"),n("contentPlan.home_publishing")]:[n("contentPlan.home_settled_title"),n("contentPlan.home_settled")],b=i.kind==="to_approve"||i.kind==="missed"||i.kind==="failed";return e.jsxs("section",{className:"rounded-2xl border border-border/50 bg-card p-4","aria-labelledby":"
11content-plan-home-title",children:[e.jsx("h2",{id:"content-plan-home-title",className:"text-base font-semibold leading-tight",children:u}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:x}),e.jsx("ul",{className:"mt-4 grid grid-cols-3 gap-2",children:o.sorted.map(f=>{const g=Gs(f,t),m=new Date(f.publishAt),_=g==="approved"||g==="publishing"||g==="published";return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>r(f.postId),className:"block w-full rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsxs("span",{className:"relative block",children:[e.jsx("img",{src:f.slideUrls[0],alt:"",className:R("aspect-[4/5] w-full rounded-lg object-cover",(g==="missed"||g==="failed"||g==="rejected")&&"opacity-40 grayscale"),loading:"lazy"}),_&&e.jsx("span",{className:"absolute bottom-1.5 right-1.5 flex h-5 w-5 items-center justify-center rounded-full bg-background/90",children:e.jsx(Ae,{className:"h-3 w-3 text-foreground",strokeWidth:3,"aria-hidden":"true"})})]}),e.jsxs("span",{className:"mt-1.5 block text-xs tabular-nums text-muted-foreground",children:[e.jsxs("span",{className:"sr-only",children:[f.title," · ",n(`contentPlan.status_${g}`),":"," "]}),c.weekdayShort(m)," · ",c.time(m)]})]})},f.postId)})}),e.jsx(S,{variant:b?"default":"secondary",className:"mt-4 h-11 w-full",onClick:a,children:n(b?"contentPlan.home_review":"contentPlan.home_open")})]})}function ea(){return e.jsxs("section",{className:"rounded-2xl border border-border/50 bg-card p-4","aria-hidden":"true",children:[e.jsx(y,{className:"h-5 w-40"}),e.jsx(y,{className:"mt-1.5 h-4 w-28"}),e.jsx("div",{className:"mt-4 grid grid-cols-3 gap-2",children:[0,1,2].map(s=>e.jsxs("div",{children:[e.jsx(y,{className:"aspect-[4/5] w-full rounded-lg"}),e.jsx(y,{className:"mt-1.5 h-3 w-16"})]},s))}),e.jsx(y,{className:"mt-4 h-11 w-full rounded-xl"})]})}function sa(){const s=O(),{selectedProfile:t}=M(),{query:a}=Ws(t==null?void 0:t.id),r=Xs(),n=a.data;return a.isLoading?e.jsx(ea,{}):!n||n.posts.length===0?e.jsx(Js,{}):e.jsx(Zt,{posts:n.posts,now:r,onOpen:()=>s("/dashboard/plan"),onOpenPost:c=>s("/dashboard/plan",{state:{openPostId:c}})})}const Ne="__story_chooser__",ta=()=>{const s=O(),{t}=A(),{user:a}=L(),{selectedProfile:r}=M(),n=is(r==null?void 0:r.id),{isAgency:c}=me(),o=Ps(),h=Lt(a==null?void 0:a.id),[i,u]=p.useState(!1),[x,b]=p.useState(!1),[f,g]=p.useState(!1),_=(()=>{const d=a==null?void 0:a.user_metadata,j=(d==null?void 0:d.full_name)||(d==null?void 0:d.name)||(d==null?void 0:d.first_name);return j?j.split(" ")[0]:r==null?void 0:r.username})(),v=[{icon:Fs,label:t("create.carousel","Carrossel"),description:t("create.carousel_description","Conteúdo educativo e tutoriais"),path:"/dashboard/create/carousel"},{icon:Qs,label:t("create.post","Post"),description:t("create.post_description","Imagem única para o feed"),path:"/dashboard/create/post"},{icon:Bs,label:t("create.template_post"),description:t("create.template_post_short"),path:"/dashboard/criar-modelo",isNew:!0},{icon:$,label:t("create.story_group"),description:t("create.story_group_short"),path:Ne},{icon:qe,label:t("create.video_reels"),description:t("create.video_reels_short"),path:"/dashboard/video-editor"},{icon:Me,label:t("create.reel_cover"),description:t("create.reel_cover_short"),path:"/dashboard/reels-cover"},{icon:Zs,label:t("create.freeform","Criação Livre"),description:t("create.freeform_short","Descreva sua imagem"),path:"/dashboard/freeform"},{icon:et,label:t("create.photo_transform","Foto Pro"),description:t("create.photo_transform_short","Transforme suas fotos"),path:"/dashboard/photo-transform"},{icon:st,label:t("create.ad_creator"),description:t("create.ad_creator_short"),path:"/dashboard/ad-creator"}],l=[{icon:tt,label:t("create.script_reels","Roteiro Reels"),description:t("create.script_reels_short","Roteiros para vÃdeos"),path:"/dashboard/script-generator/reel"},{icon:Us,label:t("create.script_stories","Roteiro Stories"),description:t("create.script_stories_short","Frames para Stories"),path:"/dashboard/script-generator/story"},{icon:as,label:t("create.bio_generator","Bio & Nome"),description:t("create.bio_generator_short","Otimize seu perfil"),path:"/dashboard/bio-generator"},{icon:Pe,label:t("dashboard.bio_page_card_title"),description:t("dashboard.bio_page_card_desc"),path:"/bio-links"},{icon:at,label:t("dashboard.insights_card_title"),description:t("dashboard.insights_card_desc"),path:"/dashboard/insights"},{icon:rs,label:t("dashboard.automations_card_title"),description:t("dashboard.automations_card_desc"),path:"/dashboard/automations"}],N=d=>
11{if(d===Ne){g(!0);return}s(d)};return r?e.jsx("div",{className:"flex-1 overflow-auto bg-background/50",children:e.jsxs("div",{className:"max-w-6xl mx-auto p-4 md:p-8 space-y-6 md:space-y-10",children:[e.jsx(yt,{}),e.jsx(Et,{}),o&&h?e.jsx(Tt,{}):e.jsxs("div",{className:"flex flex-col space-y-2 mb-2",children:[e.jsxs("h1",{className:"text-2xl font-bold tracking-tight",children:[t("dashboard.welcome","Olá"),", ",e.jsx("span",{className:"text-primary",children:_})]}),e.jsx(Vt,{fallback:e.jsx("p",{className:"text-muted-foreground",children:e.jsx(W,{i18nKey:"dashboard.publish_subtitle",values:{username:r.username},components:{1:e.jsx("span",{className:"font-medium text-foreground"})}})})})]}),e.jsx(sa,{}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(Xt,{}),e.jsx(B,{icon:rt,title:t("weeklyIdeas.badge"),subtitle:t("weeklyIdeas.shortcutSubtitle"),onActivate:()=>s("/ideias/semana"),badge:n===!1?t("weeklyIdeas.newBadge"):void 0,className:"h-full"}),c&&e.jsx(B,{icon:nt,title:t("dashboard.approvals_shortcut_title"),subtitle:t("dashboard.approvals_shortcut_subtitle"),onActivate:()=>s("/dashboard/approvals"),className:"h-full"})]}),e.jsxs("section",{className:"space-y-3 md:space-y-4",children:[e.jsx("h2",{className:"text-base md:text-lg font-semibold text-foreground tracking-tight",children:t("dashboard.create_new")}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-4 lg:flex lg:gap-3",children:v.map(d=>{const j=d.icon;return e.jsxs(E,{"aria-label":d.isNew?`${d.label}, ${t("create.badge_new")}`:d.label,className:R("relative cursor-pointer group border-border/50 bg-card transition-all duration-200 lg:flex-1","hover:border-primary/40 hover:shadow-sm active:scale-[0.98]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),...Ue(()=>N(d.path)),children:[d.isNew&&e.jsx("span",{className:"absolute right-1 top-1 rounded-full bg-primary px-1.5 py-0.5 text-[9px] font-semibold leading-none text-primary-foreground md:text-[10px] lg:-top-2",children:t("create.badge_new")}),e.jsxs(D,{className:"flex flex-col items-center gap-1.5 px-3 pb-3 pt-3 text-center md:gap-2 md:p-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 transition-colors group-hover:bg-primary/15 md:h-12 md:w-12",children:e.jsx(j,{className:"h-5 w-5 text-primary md:h-6 md:w-6"})}),e.jsx("h3",{className:"flex min-h-[2.4em] items-center justify-center break-words text-[11px] font-semibold leading-tight text-foreground md:text-sm",children:d.label}),e.jsx("span",{className:"inline-flex items-center whitespace-nowrap rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium leading-none text-muted-foreground",children:t("create.badge_uses_post")})]})]},d.path)})}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:flex sm:flex-wrap sm:gap-2 sm:pt-1",children:l.map(d=>{const j=d.icon;return e.jsxs("button",{type:"button",onClick:()=>N(d.path),title:d.description,className:R("flex flex-col items-center gap-1.5 rounded-xl border border-border/60 bg-card px-2 py-3 text-center text-[11px] font-semibold text-foreground transition-colors","sm:min-h-11 sm:flex-row sm:gap-2 sm:rounded-full sm:px-3.5 sm:py-0 sm:text-sm sm:font-medium","hover:border-primary/40 hover:text-primary active:bg-card/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:[e.jsx(j,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"flex min-h-[2.4em] items-center justify-center break-words leading-tight sm:min-h-0",children:d.label}),e.jsx("span",{className:"whitespace-nowrap rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium leading-none text-muted-foreground",children:t("create.badge_unlimited")})]},d.path)})})]}),e.jsx(Nt,{maxPosts:3}),e.jsx(jt,{maxPosts:4}),e.jsx(_t,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Qt,{}),e.jsx($s,{dismissible:!1}),e.jsx(St,{}),e.jsx(B,{icon:xt,title:t("dashboard.tutorial_card_title"),subtitle:t("dashboard.tutorial_card_subtitle"),onActivate:()=>u(!0)})]}),e.jsx(J,{open:i,onOpenChange:d=>{u(d),d||b(!1)},children:e.jsxs(Q,{className:"max-w-3xl p-0 overflow-hidden",children:[e.jsx(K,{className:"p-4 pb-2",children:e.jsx(V,{children:t("dashboard.tutorial_dialog_title")})}),e.jsx("div",{className:"relative aspect-video w-full bg-black",children:i&&e.jsxs(e.Fragment,{children:[!x&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(X,{className:"h-8 w-8 animate-spin text-white/70"})}),e.jsx("iframe",{className:R("w-full h-full transition-opacity duration-300",x?"opacity-100":"opacity-0"),src:"https://www.youtube.com/embed/yWKm6HBNUCc?start=5224",title:t("dashboard.tutorial_dialog_title"),allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,onLoad:()=>b(!0)})]})})]})}),e.jsx(J,{open:f,onOpenChange:g,children:e.jsxs(Q,{className:"max-w-md",children:[e.jsx(K,{children:e.jsx(V,{children:t("create.story_choose_title")})}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(B,{icon:$,title:t("create.story"),subtitle:t("create.story_description"),onActivate:()=>{g(!1),s("/dashboard/create/story")}}),e.jsx(B,{icon:Oe,title:t("create.story_sequence"),subtitle:t("create.story_sequence_description"),onActivate:()=>{g(!1),s("/dashboard/create/story_sequence")}})]})]})}),e.jsx("div",{className:"h-14"})]})}):null},we=3,oe="ptp_dismissed_";function aa(){const{user:s}=L(),[t,a]=p.useState(!1),[r,n]=p.useState(!0),[c,o]=p.useState(!1);return p.useEffect(()=>{let u=!1;return a(!1),o(!1),s?(n(!0),(async()=>{try{try{if(localStorage.getItem(`${oe}${s.id}`)){u||(a(!1),n(!1));return}}catch{}const x=await k.rpc("get_user_flags");if(x.error){u||(a(!1),n(!1));return}const b=x.data??[];if(b.includes("testimonial_submitted")||b.includes("testimonial_prompt_dism
11issed")){u||(a(!1),n(!1));return}const f=await k.from("platform_testimonials").select("id").eq("user_id",s.id).maybeSingle();if(f.error){u||(a(!1),n(!1));return}if(f.data){u||(a(!1),n(!1));return}const{data:g,error:m}=await k.from("posts").select("id").eq("user_id",s.id).eq("status","completed").limit(we);if(m){u||(a(!1),n(!1));return}u||(a(((g==null?void 0:g.length)??0)>=we),n(!1))}catch(x){console.error("usePlatformTestimonialPrompt failed:",x),u||(a(!1),n(!1))}})(),()=>{u=!0}):(n(!1),()=>{u=!0})},[s]),{shouldShow:t&&!c,loading:r,markSubmitted:()=>{if(o(!0),s)try{localStorage.setItem(`${oe}${s.id}`,"1")}catch{}},markDismissed:()=>{if(o(!0),s){try{localStorage.setItem(`${oe}${s.id}`,"1")}catch{}k.rpc("mark_testimonial_prompt_dismissed").then(u=>{u.error&&console.warn("mark_testimonial_prompt_dismissed RPC failed:",u.error)})}}}}const ra=14,na=90,ve=864e5;function oa(s,t=new Date){if(!s.subscribed||!s.subscribed_at||s.published_posts_count<1)return!1;const a=new Date(s.subscribed_at).getTime();if(Number.isNaN(a)||t.getTime()-a<ra*ve)return!1;if(s.last_response_at){const r=new Date(s.last_response_at).getTime();if(Number.isNaN(r)||t.getTime()-r<na*ve)return!1}return!0}function Ve(s){return s>=9?"promoter":s>=7?"passive":"detractor"}function ia(s,t,a){return Ve(s)!=="promoter"?"none":t==="recurring"&&!a?"testimonial":"referral"}function la(){const{user:s}=L(),[t,a]=p.useState(null),[r,n]=p.useState(!1),[c,o]=p.useState(!0),[h,i]=p.useState(!1);return p.useEffect(()=>{let u=!1;return n(!1),i(!1),a(null),s?(o(!0),(async()=>{const{data:x,error:b}=await k.rpc("get_nps_prompt_context");if(u)return;if(b||!x){b&&ie.warn("get_nps_prompt_context failed",b),o(!1);return}const f=x;a(f),n(oa(f)),o(!1)})(),()=>{u=!0}):(o(!1),()=>{u=!0})},[s]),{shouldShow:r&&!h,loading:c,context:t,hide:()=>i(!0)}}const ca=[0,1,2,3,4,5,6,7,8,9,10],da=180;function ma({open:s,onClose:t}){const{t:a}=A(),{toast:r}=Ee(),[n,c]=p.useState("score"),[o,h]=p.useState(null),[i,u]=p.useState(""),[x,b]=p.useState(!1),f=p.useRef(!1),g=p.useRef(null),m=p.useId();p.useEffect(()=>(s&&(f.current=!1,c("score"),h(null),u("")),()=>{g.current&&clearTimeout(g.current)}),[s]);const _=d=>{h(d),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>c("comment"),da)},v=()=>{f.current||(f.current=!0,k.rpc("record_nps_response",{p_score:o}).then(({error:d})=>{d&&ie.warn("record_nps_response (dismiss) failed",d)}),t(null))},l=async d=>{if(o==null||x||f.current)return;b(!0);const j=d?i.trim():"",{data:C,error:P}=await k.rpc("record_nps_response",{p_score:o,p_comment:j||null});if(b(!1),(P==null?void 0:P.code)==="23505"){f.current=!0,t(null);return}if(P||C!=="first"&&C!=="recurring"){ie.error("record_nps_response failed",{error:P,data:C}),r({title:a("nps.error_title"),description:a("nps.error_desc"),variant:"destructive"});return}f.current=!0,t({score:o,trigger:C})},N=o!=null&&Ve(o)==="promoter";return e.jsx(J,{open:s,onOpenChange:d=>!d&&!x&&v(),children:e.jsx(Q,{className:"w-[95vw] max-w-md rounded-2xl p-5 sm:p-6 gap-4",children:n==="score"?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"space-y-2",children:[e.jsx("div",{className:"mx-auto w-11 h-11 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ft,{className:"w-5 h-5 text-primary","aria-hidden":"true"})}),e.jsx(V,{className:"text-center text-base sm:text-lg",children:a("nps.title")}),e.jsx(le,{className:"text-center text-xs sm:text-sm",children:a("nps.subtitle")})]}),e.jsx("div",{role:"group","aria-label":a("nps.title"),className:"grid grid-cols-11 overflow-hidden rounded-xl border-2 border-border bg-background divide-x divide-border",children:ca.map(d=>{const j=o===d;return e.jsx("button",{type:"button","aria-label":a("nps.score_aria",{score:d}),"aria-pressed":j,disabled:o!=null&&!j,onClick:()=>_(d),className:R("h-12 text-base sm:text-lg font-semibold tabular-nums transition-colors duration-150","focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40",j?"bg-gradient-primary text-white":"text-foreground hover:bg-primary/10 active:bg-primary/15 disabled:opacity-50"),children:d},d)})}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:a("nps.scale_low")}),e.jsx("span",{children:a("nps.scale_high")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"space-y-2 px-6",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-xl bg-gradient-primary text-white text-xl font-bold tabular-nums flex items-center justify-center shadow-glow","aria-label":a("nps.chosen_score_aria",{score:o}),role:"img",children:o}),e.jsx(V,{className:"text-center text-base sm:text-lg",children:a(N?"nps.comment_title_promoter":"nps.comment_title_other")}),e.jsx(le,{className:"text-center text-xs sm:text-sm",children:a("nps.comment_subtitle")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:m,className:"sr-only",children:a(N?"nps.comment_title_promoter":"nps.comment_title_other")}),e.jsx(Ie,{id:m,value:i,onChange:d=>u(d.target.value),placeholder:a("nps.comment_placeholder"),maxLength:1e3,disabled:x,autoFocus:!0,className:"min-h-[96px] text-base md:text-sm rounded-xl border-2 focus:border-primary/50"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{variant:"outline",className:"flex-1",disabled:x,onClick:()=>l(!1),children:a("nps.skip")}),e.jsx(S,{className:"flex-1",disabled:x,onClick:()=>l(!0),children:x?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"w-4 h-4 mr-2 animate-spin","aria-hidden":"true"}),a("nps.sending")]}):a("nps.send")})]}),e.jsxs(S,{variant:"ghost",size:"sm",className:"mx-auto text-muted-foreground",disabled:x,onClick:()=>{h(null),c("score")},children:[e.jsx(mt,{className:"w-4 h-4 mr-1","aria-hidden":"true"}),a("nps.change_score")]})]})})})}const ye="app_install_prompt_seen_";function ua(){const{user:s}=L(),[t,a]=p.useState(!1);p.useEffect(()=>{let c=!1;return a(!1),!s||ns()||!F.playStoreUrl&&!F.appStoreUrl?()=>{c=!0}:((async()=>{try{try{if(localStorage.getItem(`${ye}${s.id}`))return}catch{}const{data:o,error:h}=await k.from("devices").select("id").eq("user_id",s.id).limit(1).maybeSingle();if(h||c||o)return;a(!0)}catch(o){console.error("useAppInstallPrompt failed:",o)}})(),()=>{c=!0})},[s]);const r=p.useCallback(()=>
11{if(s)try{localStorage.setItem(`${ye}${s.id}`,"1")}catch{}},[s]),n=p.useCallback(()=>a(!1),[]);return{shouldShow:t,markSeen:r,dismiss:n}}const Se="w-full h-11 text-sm font-semibold gap-2 border-0 text-white shadow-sm bg-gradient-to-r from-purple-500 via-pink-500 to-orange-400 hover:opacity-90";function pa({open:s,onOpenChange:t}){const{t:a}=A(),r=p.useMemo(()=>os(),[]),n=!!F.playStoreUrl&&r!=="ios",c=!!F.appStoreUrl&&r!=="android";return e.jsx(J,{open:s,onOpenChange:t,children:e.jsxs(Q,{className:"w-[95vw] max-w-md rounded-2xl p-5 sm:p-6 gap-4",children:[e.jsxs(K,{className:"space-y-2",children:[e.jsx("div",{"aria-hidden":"true",className:"mx-auto w-11 h-11 rounded-full bg-gradient-to-br from-purple-500 via-pink-500 to-orange-400 flex items-center justify-center",children:e.jsx($,{className:"w-5 h-5 text-white"})}),e.jsx(V,{className:"text-center text-base sm:text-lg",children:a("app_install_modal.title",{brand:F.name})}),e.jsx(le,{className:"text-center text-xs sm:text-sm",children:a("app_install_modal.subtitle")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[n&&e.jsx(S,{asChild:!0,size:"lg",className:Se,children:e.jsxs("a",{href:F.playStoreUrl,target:"_blank",rel:"noopener noreferrer",onClick:()=>t(!1),children:[e.jsx(ut,{className:"w-4 h-4"}),a("app_install_modal.google_play")]})}),c&&e.jsx(S,{asChild:!0,size:"lg",className:Se,children:e.jsxs("a",{href:F.appStoreUrl,target:"_blank",rel:"noopener noreferrer",onClick:()=>t(!1),children:[e.jsx(pt,{className:"w-4 h-4"}),a("app_install_modal.app_store")]})}),e.jsx("button",{type:"button",onClick:()=>t(!1),className:"w-full text-xs text-muted-foreground hover:text-foreground transition-colors py-1",children:a("app_install_modal.later")})]})]})})}const tn=()=>{const s=O(),{t}=A(),{selectedProfile:a,profilesLoading:r,hasInitialized:n}=M(),{loading:c,error:o,isSubscribed:h,subscription:i}=me(),{toast:u}=Ee(),{user:x}=L(),{shouldShow:b,markSubmitted:f,markDismissed:g}=aa(),m=i!=null&&!h&&b,{openTestimonialModal:_,testimonialModal:v}=zs(),{shouldShow:l,loading:N,context:d,hide:j}=la(),[C,P]=p.useState(null),U=C!=null&&C===(x==null?void 0:x.id),{shouldShow:w,markSeen:se,dismiss:Y}=ua(),te=h&&w&&!N&&!l&&!U,z=p.useRef(!1);return ct(),dt(o),c||r||!n?e.jsx(ot,{}):e.jsxs("div",{className:"min-h-screen bg-gradient-background",children:[e.jsx("div",{className:"fixed top-0 left-0 right-0 z-50",children:e.jsx(it,{})}),e.jsx("main",{className:"fixed left-0 right-0 md:bottom-0 flex flex-col overflow-hidden top-[calc(var(--app-banner-h,0px)_+_var(--app-header-h)_+_var(--sai-top))] bottom-[calc(4rem_+_var(--sai-bottom))]",children:a?e.jsx(ta,{}):e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center max-w-md space-y-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-gradient-to-br from-purple-500 via-pink-500 to-orange-400 mx-auto flex items-center justify-center",children:e.jsx(ht,{className:"w-10 h-10 text-white"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:t("dashboard.no_profile_title")}),e.jsx("p",{className:"text-muted-foreground",children:t("dashboard.no_profile_description")})]}),e.jsxs(S,{onClick:()=>s("/add-instagram"),className:"bg-gradient-to-r from-purple-500 via-pink-500 to-orange-400 hover:opacity-90 text-white",children:[e.jsx(He,{className:"w-4 h-4 mr-2"}),t("dashboard.add_profile")]})]})})}),e.jsx(lt,{}),e.jsx(ma,{open:l,onClose:q=>{if(j(),P((x==null?void 0:x.id)??null),!q)return;const G=ia(q.score,q.trigger,(d==null?void 0:d.has_testimonial)??!0);if(G==="referral"){u({title:t("nps.thanks_title"),description:t("nps.thanks_desc_referral")}),s("/afiliado");return}if(G==="testimonial"){_();return}u({title:t("nps.thanks_title"),description:t("nps.thanks_desc")})}}),v,e.jsx(Ks,{open:m,onOpenChange:q=>{q||(z.current?z.current=!1:g())},autoPrompt:!0,onSubmitted:()=>{z.current=!0,f()}}),e.jsx(pa,{open:te,onOpenChange:q=>{q||(se(),Y())}})]})};export{tn 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.