PageSourceSearch

https://portal.heyfilo.ai/assets/IdeasPage-B_lKmLjM.js

js heyfilo.ai collected 2026-10-05 14:28:35 UTC 10,788 bytes, 1 lines download raw bytes

1import{A as Q,e as B,O,r,d as U,W,g as G,k as v,j as s,P as H,B as g,S as P,J as f,ay as J,F as V,X as F,ak as X,z as y,y as q,ax as h}from"./index-BIdkve2-.js";import{i as Y}from"./integrations-Ce3RP6k9.js";import{L as R}from"./loader-circle-E1TIqegY.js";function se(){const b=Q(),p=B(),{start:N}=O(),[M,o]=r.useState(!1),[L,_]=r.useState(null),[k,C]=r.useState(""),[w,I]=r.useState(null),{isReadOnlyTenant:A}=U(),i=r.useRef(null),u=r.useRef(null);r.useEffect(()=>{W.listBrandGuidelines().then(e=>{var n;const a=Array.isArray(e.data)?e.data:((n=e.data)==null?void 0:n.results)||[];_(a.length>0)}).catch(()=>_(!1))},[]);const[d,z]=r.useState("active"),{data:m,isLoading:T}=G({queryKey:["content-ideas",d],queryFn:async()=>(await h.listIdeas(d==="used"?{saved:"true"}:{unused:"true"})).data}),c=v({mutationFn:e=>(i.current=new AbortController,h.generateIdeas({topic:e||void 0},i.current.signal)),onMutate:()=>({pg:N({title:"Idea generation",stepLabel:"Finding angles and drafting suggestions…",indeterminate:!0,onCancel:()=>{var a;return(a=i.current)==null?void 0:a.abort()}})}),onSuccess:(e,a,n)=>{b.invalidateQueries({queryKey:["content-ideas"]}),n==null||n.pg.complete({toast:"Ideas generated successfully"}),o(!1),C("");const t=e==null?void 0:e.data;(t!=null&&t.token_debug||t!=null&&t.ai_meta)&&console.info("[AI token debug] ideas.generate",{ai_meta:t.ai_meta,token_debug:t.token_debug,token_limit_adjusted:t.token_limit_adjusted,requested_count:t.requested_count,allowed_count:t.allowed_count}),t!=null&&t.verification&&console.info("[guardrails] ideas verification",t.verification),t!=null&&t.token_limit_adjusted&&y(`Weekly AI limit: generated ${t.allowed_count} ideas (requested ${t.requested_count}). Generate fewer ideas to stay within the limit.`)},onError:(e,a,n)=>{var l,x;if((e==null?void 0:e.code)==="ERR_CANCELED"||(e==null?void 0:e.name)==="CanceledError"){n==null||n.pg.remove();return}const t=(l=e==null?void 0:e.response)==null?void 0:l.data;(t!=null&&t.ai_meta||(t==null?void 0:t.weekly_limit)!=null)&&console.info("[AI token debug] ideas.generate error",{status:(x=e==null?void 0:e.response)==null?void 0:x.status,ai_meta:t==null?void 0:t.ai_meta,weekly_limit:t==null?void 0:t.weekly_limit,remaining_tokens:t==null?void 0:t.remaining_tokens,week_start:t==null?void 0:t.week_start,detail:t==null?void 0:t.detail}),y.error(q(e)),n==null||n.pg.remove()}}),j=v({mutationFn:e=>(u.current=new AbortController,h.convertIdea(e,u.current.signal)),onMutate:e=>(I(e),{pg:N({title:"Content generation",stepLabel:"Turning your idea into a draft…",indeterminate:!0,onCancel:()=>{var n;return(n=u.current)==null?void 0:n.abort()}})}),onSuccess:(e,a,n)=>{var t,l;b.invalidateQueries({queryKey:["content-ideas"]}),(t=e.data)!=null&&t.verification&&console.info("[guardrails] convert verification",e.data.verification),n==null||n.pg.complete({toast:"Content generation complete ✓"}),(l=e.data)!=null&&l.content_id?p(`/content/${e.data.content_id}`):p("/content")},onError:(e,a,n)=>{var l,x;if((e==null?void 0:e.code)==="ERR_CANCELED"||(e==null?void 0:e.name)==="CanceledError"){n==null||n.pg.remove();return}const t=(l=e==null?void 0:e.response)==null?void 0:l.data;(t!=null&&t.ai_meta||(t==null?void 0:t.weekly_limit)!=null)&&console.info("[AI token debug] ideas.convert error",{status:(x=e==null?void 0:e.response)==null?void 0:x.status,ai_meta:t==null?void 0:t.ai_meta,weekly_limit:t==null?void 0:t.weekly_limit,remaining_tokens:t==null?void 0:t.remaining_tokens,week_start:t==null?void 0:t.week_start,detail:t==null?void 0:t.detail}),y.error(q(e)),n==null||n.pg.remove()},onSettled:()=>{I(null),u.current=null}}),K=v({mutationFn:e=>h.updateIdea(e,{is_dismissed:!0}),onSuccess:()=>b.invalidateQueries({queryKey:["content-ideas"]})}),$=e=>{var a;w===e&&((a=u.current)==null||a.abort()),K.mutate(e)},{data:D}=G({queryKey:["keyword-insights"],queryFn:async()=>{const a=(await Y.listKeywordInsights()).data;return Array.isArray(a)?a:a.results??[]}}),S=D??[];if(T)return s.jsx(H,{});const E=Array.isArray(m)?m:(m==null?void 0:m.results)||[];return s.jsxs("div",{children:[s.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between mb-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"text-2xl font-semibold text-claude-text tracking-tight",children:"Content Ideas"}),s.jsx("p",{className:"text-sm text-claude-text-tertiary mt-1",children:"AI-generated content suggestions"})]}),!A&&s.jsxs(g,{onClick:()=>o(!0),className:"w-full sm:w-auto",children:[s.jsx(P,{className:"h-4 w-4 mr-1.5"})," Generate Ideas"]})]}),s.jsx("div",{className:"inline-flex rounded-xl border border-claude-border bg-claude-bg-alt p-0.5 mb-6",children:["active","used"].map(e=>s.jsx("button",{onClick:()=>z(e),className:`px-4 py-1.5 text-sm font-medium rounded-lg transition-colors ${d===e?"bg-claude-surface text-claude-text shadow-soft":"text-claude-text-tertiary hover:text-claude-text"}`,children:e==="active"?"Active":"Used"},e))}),S.length>0&&s.jsxs("section",{className:"mb-6 rounded-2xl border border-claude-border bg-claude-surface p-5 shadow-soft",children:[s.jsx("h2",{className:"text-sm font-semibold text-claude-text mb-1",children:"Suggested keywords (SEMrush)"}),s.jsx("p",{className:"text-xs text-claude-text-tertiary mb-3",children:"Stored from Integrations keyword research — use as angles for new ideas or drafts."}),s.jsx("div",{className:"flex flex-wrap gap-2",children:S.slice(0,24).map(e=>s.jsx("span",{title:`Volume ~${e.search_volume} · difficulty ~${Number(e.difficulty).toFixed(1)}`,children:s.jsx(f,{className:"bg-claude-bg-alt text-claude-text-secondary text-[11px] font-normal",children:e.keyword})},e.id))})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:E.length===0?s.jsxs("div",{className:"col-span-full flex flex-col items-center py-16",children:[s.jsx("div",{className:"h-12 w-12 rounded-2xl bg-claude-warning-light flex items-center justify-center mb-3",children:s.jsx(J,{className:"h-5 w-5 text-claude-warning"})}),s.jsx("p",{className:"text-sm text-claude-text-secondary font-medium",children:d==="used"?"No used ideas yet":"No ideas yet"}),s.jsx("p",{className:"text-xs text-claude-text-tertiary mt-1",children:d==="used"?"Ideas you generate content from will appear here.":'Click "Generate Ideas" to get AI-powered content suggestions.'})]}):E.map(e=>{var a;return s.jsxs("div",{className:"bg-claude-surface rounded-2xl border border-claude-border shadow-soft p-5 hover:shadow-card transition-shadow",children:[s.jsx("h3",{className:"font-medium text-claude-text text-sm mb-2 leading-snug",children:e.title}),s.jsx("p",{className:"text-xs text-claude-text-secondary mb-3 line-clamp-3",children:e.description}),e.trending_topic_name&&s.jsxs(f,{className:"bg-claude-info-light text-claude-info mb-3 text-[10px]",children:["Trend: ",e.trending_topic_name]}),s.jsx("div",{className:"flex flex-wrap gap-1 mb-4",children:(a=e.suggested_platforms)==null?void 0:a.map(n=>s.jsx(f,{className:"bg-claude-bg-alt text-claude-text-tertiary text-[10px]",children:n},n))}),d==="used"?s.jsx(f,{className:"bg-claude-success-light text-claude-success text-[10px]",children:"✓ Used"}):!A&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx(g,{size:"sm",onClick:()=>j.mutate(e.id),disabled:j.isPending&&w===e.id,children:j.isPending&&w===e.id?s.jsxs(s.Fragment,{children:[s.jsx(R,{className:"h-3 w-3 mr-1 animate-spin"})," Generating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(V,{className:"h-3 w-3 mr-1"})," Generate Content"]})}),s.jsxs(g,{size:"sm",variant:"ghost",onClick:()=>$(e.id),children:[s.jsx(F,{className:"h-3 w-3"})," Dismiss"]})]})]},e.id)})}),M&&X.createPortal(s.jsx("div",{className:"fixed inset-0 z-[100] bg-black/40 overflow-y-auto",role:"presentation",onClick:()=>{var e;c.isPending&&((e=i.current)==null||e.abort(),i.current=null),o(!1)},children:s.jsx("div",{className:"min-h-full flex items-start sm:items-center justify-center p-0 sm:p-4",onClick:e=>e.stopPropagation(),children:s.jsxs("div",{className:"bg-white w-full max-h-[100dvh] sm:max-h-[calc(100vh-2rem)] sm:max-w-md overflow-hidden flex flex-col rounded-none sm:rounded-2xl border-0 sm:border sm:border-claude-border shadow-none sm:shadow-dropdown p-4 sm:p-6 animate-in fade-in scale-in duration-150",children:[s.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between mb-4 bg-white/85 backdrop-blur-md py-2",children:[s.jsxs("h3",{className:"font-semibold text-claude-text flex items-center gap-2",children:[s.jsx(P,{className:"h-4 w-4 text-claude-accent"}),"Generate Ideas"]}),s.jsx("button",{onClick:()=>{var e;c.isPending&&((e=i.current)==null||e.abort(),i.current=null),o(!1)},className:"p-2 rounded-lg text-claude-text-tertiary hover:text-claude-text hover:bg-claude-bg-alt","aria-label":"Close",children:s.jsx(F,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"space-y-4 flex-1 min-h-0 overflow-y-auto",children:L===!1?s.jsxs("div",{className:"py-2 text-center space-y-3",children:[s.jsx("h4",{className:"font-semibold text-claude-text",children:"Setup Required"}),s.jsx("p",{className:"text-sm text-claude-text-tertiary leading-relaxed",children:"Please set your brand guidelines before generating any content."}),s.jsx(g,{size:"sm",onClick:()=>{o(!1),p("/guidelines")},className:"w-full",children:"Configure Guidelines"})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-claude-text-secondary",children:"Enter a specific topic to generate content ideas about, or leave blank to automatically generate based on your workspace keywords and current trends."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-claude-text mb-1.5",children:"Topic (Optional)"}),s.jsx("input",{type:"text",value:k,onChange:e=>C(e.target.value),placeholder:"e.g. AI in marketing, Summer sale, etc.",className:"w-full rounded-xl border border-claude-border bg-claude-surface px-3 py-2 text-sm text-claude-text focus:outline-none focus:ring-2 focus:ring-claude-accent/20"})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsx("button",{disabled:c.isPending,onClick:()=>c.mutate(k),className:"flex-1 bg-claude-accent hover:bg-claude-accent-hover text-white rounded-xl px-3 py-2 text-sm font-medium transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:c.isPending?s.jsxs(s.Fragment,{children:[s.jsx(R,{className:"h-4 w-4 animate-spin"})," Generating..."]}):"Generate"}),s.jsx("button",{onClick:()=>{var e;c.isPending&&((e=i.current)==null||e.abort(),i.current=null),o(!1)},className:"flex-1 border border-claude-border hover:bg-claude-bg-alt text-claude-text rounded-xl px-3 py-2 text-sm font-medium transition-colors",children:"Cancel"})]})]})})]})})}),document.body)]})}
1export{se as IdeasPage};

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.