PageSourceSearch

https://www.sociallift.ai/assets/Automations-Q0ykhuJM.js

js sociallift.ai collected 2026-10-05 15:08:13 UTC 27,373 bytes, 4 lines download raw bytes

1import{r as h,aY as pe,j as e,Y as u,N as $e,aZ as Be,a_ as ze,a$ as Oe,u as Ue,b0 as We,f as Ye,b1 as B,k as he,a2 as Qe,L as z,l as O,b2 as He,b3 as Ze,s as w,m as Ge,B as N,P as Ve,T as ge,b4 as Je,b5 as Xe,w as et,d as je,ad as tt,R as st,b6 as xe,W as at,I as nt,z as fe}from"./index-DL0d_lAK.js";import{u as q}from"./useMutation-D_ZYaUMO.js";import{c as rt}from"./compose-DOjjQ7ye.js";import{C as ot,S as it,K as lt,B as ct,T as be}from"./BrandContextNote-DnPmclCj.js";import{w as Y,P as dt}from"./PostDialog-DdRtyTJW.js";import{a as ut,c as mt,e as pt,f as ht,b as gt,u as xt}from"./useBrandAssets-BgjUMr2B.js";import{u as ft}from"./useImageModels-D1B3HlzB.js";import{C as bt,B as jt,d as yt}from"./BestTimeChips-DKGbKGbB.js";import{r as vt,M as _t,T as wt}from"./ModelPicker-CtRKTCqa.js";import{C as ye}from"./card-DnGeKDac.js";import{I as k}from"./input-BZVgYfh9.js";import{S}from"./select-DCy2S0v2.js";import{B as I}from"./badge-DVlcMS-_.js";import{C as Nt}from"./chip-BlU4hIu0.js";import{L as kt,C as Ct,a as St}from"./CaptionExtras-Bz5Mr8jg.js";import{P as It}from"./PageHeader-C6rx3uss.js";import{F as Pt,a as Tt}from"./file-upload-BLNZQkWD.js";import{L as Ft}from"./lightbulb-C5M0oYT_.js";import{P as At}from"./pencil-C2hosQyU.js";import{C as Rt}from"./copy-Cw_kODYa.js";import{P as qt}from"./play-DYt6T6WR.js";import{T as Lt}from"./trash-2-DHhGh4SX.js";import{C as Et}from"./clock-NU_a80La.js";import"./textTags-BjQI4wYd.js";import"./knowledgeSources-yhVD2IZH.js";import"./checkbox-CfDdTcFe.js";import"./chevron-down-CIYFcfTQ.js";import"./layout-grid-Bk1IDLDF.js";import"./clapperboard-Ba-1BRCA.js";import"./upload-DGmusEJv.js";import"./useCreditPrice-BF5NDqiX.js";import"./tooltip-DE3ztT2v.js";import"./InstagramPreview-DnJAVGZO.js";import"./refresh-cw-D6LjrvwT.js";import"./chevron-left-D7Y-UJRg.js";import"./chevron-right-Bnb0q334.js";import"./renderImage-BWv-M-n1.js";import"./MediaLibraryDialog-Di896w4t.js";import"./sparkle-C-SzCLEl.js";import"./image-plus-C46YF3W0.js";import"./EmptyState-BWePa1hl.js";import"./list-filter-CGqFwn1t.js";import"./upload-CRc1gxYv.js";import"./star-wjux-bxy.js";import"./external-link-Dcz4p2aP.js";import"./download-fXEMRr1g.js";import"./type-BewEBZ4p.js";import"./settings-2-DdEblyGZ.js";import"./carousel-BSHhh02V.js";import"./pen-line-C2Hn2z6G.js";import"./font-picker-gaR7P3mg.js";import"./scroll-row-4D5ytrZp.js";function Mt({value:a=[],onChange:r,carousel:o=!1}){const[c,d]=h.useState(""),p=pe(a).filter(m=>m.slide===0),s=m=>{const b=m.map(i=>ze(i)),f=m.find((i,v)=>!b[v]);d(f?`"${f}" is not an Instagram username.`:"");const j=b.filter(Boolean);let y=0;r(pe(j.map(i=>p.find(P=>P.username===i)??{username:i,...Oe(p.length+y++),slide:0})))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Tag people ",e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(optional — tagged on every run's ",o?"first slide":"picture",")"]})]}),e.jsx($e,{value:p.map(m=>"@"+m.username),onChange:s,placeholder:p.length>=Be?"":"@username, then Enter"}),c&&e.jsx("p",{className:"text-xs text-red-600",children:c}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Public accounts only. To choose where each tag sits, place them on the example picture when you create the series."})]})}function ve(a,r=Date.now()){const o=new Date(a).getTime();if(a==null||Number.isNaN(o))return"";const c=Math.max(0,Math.floor((r-o)/1e3));return c<60?`${c}s ago`:`${Math.floor(c/60)}m ago`}function Dt(a,r){const o=ve(a,r);return o?`Running · started ${o}`:"Running…"}function Kt(a,r){const o=ve(a,r);return o?`A run started ${o} and may still be generating`:"A run started in the last 10 minutes and may still be generating"}const $t=a=>(a==null?void 0:a.output_mode)==="publish",U={title:"This automation publishes to Instagram.",body:"Running again now will publish a second post.",action:"Run anyway"},_e=[{value:"draft",label:"Draft",hint:"saves as a draft for you to publish"},{value:"schedule",label:"Schedule for review",hint:"lands on the calendar one cycle ahead — edit or cancel, or it publishes"},{value:"publish",label:"Auto-publish",hint:"publishes to Instagram immediately"}],we=a=>a.output_mode==="publish";function Bt({a}){var r;return we(a)?e.jsxs(I,{className:"gap-1 bg-brand text-white",children:[e.jsx(at,{size:11})," Auto-publish · goes live on its own"]}):e.jsx(I,{variant:"muted",children:((r=_e.find(o=>o.value===a.output_mode))==null?void 0:r.label)??a.output_mode})}const zt={draft:"ring-slate-300",scheduled:"ring-blue-400",publishing:"ring-amber-400",published:"ring-green-500",failed:"ring-red-500",ready:"ring-violet-400"},Ot=a=>{var r;return a.image_url??(Array.isArray(a.slides)?(r=a.slides.find(o=>o==null?void 0:o.image_url))==null?void 0:r.image_url:null)};function Ut({posts:a,onOpen:r}){if(a.length===0)return null;const o=a.slice(0,8);return e.jsxs("div",{className:"mt-3 pt-3 border-t border-border",children:[e.jsx("div",{className:"mb-2 text-xs text-muted-foreground",children:"Recent creations"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(c=>{const d=Ot(c);return e.jsx("button",{type:"button",onClick:()=>r(c),title:`${c.status} · ${Y(c.created_at)}
1${c.caption?` — ${c.caption.slice(0,80)}`:""}`,className:je("h-14 w-14 shrink-0 overflow-hidden rounded-lg bg-background ring-2 ring-offset-2 ring-offset-card transition hover:opacity-80 focus-visible:outline-none focus-visible:ring-brand",zt[c.status]??"ring-slate-300"),children:d?e.jsx(nt,{src:d,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"grid h-full w-full place-items-center text-[10px] text-muted-foreground",children:"no image"})},c.id)})})]})}const Ne=[{key:"complete",label:"Complete",narrowKey:null,desc:"A different source each run — your products, Sources and competitors take turns. Add topics below to put them in the rotation too."},{key:"topics",label:"My topics",narrowKey:"topics",desc:"Your own topic list — each run takes the next line."},{key:"product",label:"Product",narrowKey:"product_ids",desc:"Each run features the next product. Narrow with chips, or leave empty for the whole catalog."},{key:"bible",label:"Sources",narrowKey:"knowledge_ids",desc:"Each run draws on the next Source. Narrow with chips, or leave empty for all of them."},{key:"competitor",label:"Competitor",narrowKey:"competitor_ids",desc:"Each run remixes the next competitor’s latest unseen Instagram post in your voice."},{key:"url",label:"URL",narrowKey:null,desc:"Each run re-reads a page you pin (blog, launch post, category page) and posts a fresh idea from it."},{key:"hook",label:"Brand hooks",narrowKey:null,desc:"Each run opens with a fresh scroll-stopping hook grounded in your brand voice."}];function L({title:a,hint:r,children:o}){return e.jsxs(ye,{className:"p-4 sm:p-6 mb-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs uppercase tracking-[0.12em] font-bold text-muted-foreground",children:a}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r})]}),o]})}const ke=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Wt=Array.from({length:24},(a,r)=>({value:r,label:`${String(r).padStart(2,"0")}:00`})),Yt=a=>a.run_hour==null?a.frequency:`${a.frequency} · ${a.frequency==="weekly"?`${ke[a.run_dow??1]} `:""}${String(a.run_hour).padStart(2,"0")}:00`,Qt=(a={})=>{var c;if(a.source==="complete"||!a.source)return"Complete · all sources";const r=Ne.find(d=>d.key===a.source);if(!r)return a.source;if(!r.narrowKey)return r.label;const o=(c=a[r.narrowKey])==null?void 0:c.length;return`${r.label}${o?` (${o})`:" (all)"}`};function W({options:a,selected:r,onToggle:o,render:c=d=>d.label??d}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:a.map(d=>{const p=d.value??d,s=r.includes(p);return e.jsx(Nt,{active:s,onClick:()=>o(p),children:c(d)},p)})})}function Ys(){var de,ue;const{activeBrand:a,activeBrandId:r,readOnly:o}=Ue(),{tone:c}=We(),d=Ye(),p=["automations",r],[s,m]=h.useState(B),[b,f]=h.useState(!1),[j,y]=h.useState(null),i=(t,n)=>m(l=>({...l,[t]:n})),v=(t,n)=>m(l=>({...l,[t]:l[t].includes(n)?l[t].filter(g=>g!==n):[...l[t],n]})),[P,Q]=h.useState(!1),Ce=async()=>{Q(!0);try{const n=(await rt(r,{language:s.language})).map(l=>l.topic).filter(Boolean);m(l=>({...l,topics:[l.topics.trim(),...n].filter(Boolean).join(`
2`)}))}catch{}finally{Q(!1)}},Se=()=>{var n,l;y(null);const t=(l=(n=a==null?void 0:a.best_post_times)==null?void 0:n.times)==null?void 0:l[0];m({...B,language:st(a==null?void 0:a.language),...t?{run_hour:t.hour,run_dow:t.dow}:{}}),f(!0)},H=t=>{y(t.id),m(xe(t)),f(!0)},Ie=t=>{y(null),m({...xe(t),name:`${t.name} (copy)`}),f(!0)},Z=()=>{f(!1),y(null),m(B)},{data:_=[]}=he({queryKey:p,enabled:!!r,queryFn:async()=>fe(await w.from("automations").select("*").eq("brand_id",r).order("created_at"))}),{data:G=[]}=he({queryKey:["automation-posts",r],enabled:!!r,queryFn:async()=>fe(await w.from("posts").select("id,type,status,caption,image_url,slides,created_at,scheduled_at,published_at,ig_permalink,hashtags,first_comment,image_prompt,last_error,generation_input").eq("brand_id",r).not("generation_input->>automation_id","is",null).order("created_at",{ascending:!1}).limit(200))}),Pe=h.useMemo(()=>{var n,l;const t={};for(const g of G)(t[l=(n=g.generation_input)==null?void 0:n.automation_id]??(t[l]=[])).push(g);return t},[G]),[V,J]=h.useState(null),{data:T=[]}=ut(),{data:X=[]}=mt(),{data:F=[]}=pt(),{data:ee=[]}=ht(),{data:te=[]}=ft(),{data:se=[]}=gt(),Te=xt(r),E=((de=Qe().state)==null?void 0:de.automationId)??null,ae=h.useRef(!1);h.useEffect(()=>{if(!E||ae.current||o)return;const t=_.find(n=>n.id===E);t&&(ae.current=!0,H(t))},[E,o,_]);
2const M=vt(te,s.image_model),ne=s.product_image==="upload"&&!!s.upload_url&&s.upload_mode==="ai",A=se.filter(t=>t.instagram_url),Fe=s.source==="topics"&&!s.topics.trim()?"add at least one topic":s.source==="product"&&T.length===0?e.jsxs(e.Fragment,{children:["add a product first — ",e.jsx(z,{to:"/products",className:"underline",children:"Products"})]}):s.source==="bible"&&F.length===0?e.jsxs(e.Fragment,{children:["add a Source first — ",e.jsx(z,{to:"/knowledge",className:"underline",children:"Brand Book"})]}):s.source==="competitor"&&A.length===0?e.jsxs(e.Fragment,{children:["no competitor has an Instagram URL yet — ",e.jsx(z,{to:"/competitors",className:"underline",children:"Competitors"})]}):s.source==="feeds"&&F.length===0&&se.length===0?"no fresh signals yet — add Sources or competitors":s.source==="complete"&&!s.topics.trim()&&T.length===0&&F.length===0&&A.length===0?"no usable sources — add topics, products, Sources or competitors":s.source==="url"&&!/^https?:\/\/\S+\.\S+/.test(s.url.trim())?"enter a full page URL (https://…)":s.type==="post"&&s.product_image==="upload"&&!s.upload_url?"upload an image, or pick another image source":null,Ae=!!s.name.trim()&&_.some(t=>t.id!==j&&t.name.trim().toLowerCase()===s.name.trim().toLowerCase()),Re=((ue=Te.data)==null?void 0:ue.status)==="connected",qe=s.output_mode==="publish"&&!Re?"Auto-publish needs Instagram connected — connect it in Brand Book → Brand, or choose Draft / Schedule.":null,D=o?"read-only — this brand belongs to another account":s.name.trim()?Ae?"an automation with that name already exists — pick a different name":Fe||qe:"give the automation a name",K=q({mutationFn:async()=>{const t={name:s.name,frequency:s.frequency,output_mode:s.output_mode,brief:Ze(s),run_hour:Number(s.run_hour),run_dow:s.frequency==="weekly"?Number(s.run_dow):null,tz:Intl.DateTimeFormat().resolvedOptions().timeZone,next_run_at:He(s.frequency,Number(s.run_hour),Number(s.run_dow))},{error:n}=j?await w.from("automations").update(t).eq("id",j):await w.from("automations").insert({...t,brand_id:r});if(n)throw n},onSuccess:()=>{Z(),d.invalidateQueries({queryKey:p})},onError:t=>O(t)}),Le=q({mutationFn:async t=>{const{error:n}=await w.from("automations").update({active:!t.active,last_error:null}).eq("id",t.id);if(n)throw n},onSuccess:()=>d.invalidateQueries({queryKey:p})}),Ee=q({mutationFn:async t=>{const{error:n}=await w.from("automations").delete().eq("id",t);if(n)throw n},onSuccess:()=>d.invalidateQueries({queryKey:p}),onError:t=>O(t)}),[C,re]=h.useState(null),[Me,De]=h.useState(null),[oe,R]=h.useState(null),x=q({mutationFn:({id:t,force:n=!1})=>Ge("run-automations",{automation_id:t,force:n}),onMutate:()=>{re(null),De(Date.now())},onSuccess:(t,{id:n})=>{var me;const l=(me=t==null?void 0:t.results)==null?void 0:me.find($=>!$.ok);l&&!l.skipped&&O(l.error);const g=_.find($=>$.id===n);re(l!=null&&l.skipped?{id:n,startedAt:l.started_at??(g==null?void 0:g.last_run_at)??null}:null),d.invalidateQueries({queryKey:["posts",r]}),d.invalidateQueries({queryKey:p})}}),Ke=t=>$t(t)?R(t):x.mutate({id:t.id,force:!0}),[ie,le]=h.useState(()=>Date.now()),ce=x.isPending||!!C;return h.useEffect(()=>{if(!ce)return;le(Date.now());const t=setInterval(()=>le(Date.now()),1e3);return()=>clearInterval(t)},[ce]),r?e.jsxs("div",{className:"max-w-2xl",children:[e.jsx(It,{title:"Automations",subtitle:"Auto-generate posts on a schedule, each run drawing on a live source — your products, Sources or a competitor's latest posts — so the series never repeats itself.",actions:!b&&!o&&e.jsxs(N,{variant:"brand",onClick:Se,className:"shrink-0",children:[e.jsx(Ve,{size:16})," New automation"]})}),c==="out"&&e.jsxs("div",{className:"mb-4 flex items-start gap-2.5 rounded-xl border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-500/10 dark:text-amber-200",children:[e.jsx("span",{"aria-hidden":!0,children:"🪙"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold",children:"You're out of credits."})," Scheduled runs are paused until your balance is topped up — re-enable any automation that was turned off afterwards."]})]}),b&&e.jsxs(e.Fragment,{children:[e.jsx(ot,{active:s.type,onSelect:t=>i("type",t)}),e.jsxs(L,{title:"Concept",hint:"What each run is about.",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Name"}),e.jsx(k,{value:s.name,onChange:t=>i("name",t.target.value)})]}),s.type==="carousel"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Slides (",s.slide_count,")"]}),e.jsx(k,{type:"range",min:2,max:10,value:s.slide_count,onChange:t=>i("slide_count",Number(t.target.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(it,{options:Ne,value:s.source,onCh
2ange:t=>i("source",t)}),(s.source==="complete"||s.source==="topics")&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(u,{children:s.source==="complete"?e.jsxs(e.Fragment,{children:["My topics ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional — joins the rotation when filled)"})]}):e.jsxs(e.Fragment,{children:["Topics ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(one per line — each run takes the next)"})]})}),e.jsxs(N,{type:"button",variant:"ghost",size:"sm",disabled:P,onClick:Ce,children:[e.jsx(Ft,{size:14})," ",P?"Thinking…":"Suggest ideas"]})]}),e.jsx(ge,{rows:3,value:s.topics,onChange:t=>i("topics",t.target.value),placeholder:`share a practical tip
3myth-bust a common misconception
4behind the scenes of how we work`})]}),s.source==="product"&&T.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Products ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(rotated; none selected = all, including new ones)"})]}),e.jsx(W,{options:T.map(t=>({value:t.id,label:t.name})),selected:s.product_ids,onToggle:t=>v("product_ids",t)})]}),s.source==="bible"&&e.jsx(lt,{items:F,selected:s.knowledge_ids,onToggle:t=>v("knowledge_ids",t),placeholder:"All Sources (rotated) — narrow here"}),s.source==="competitor"&&A.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Competitors ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(rotated; none selected = all with an Instagram URL)"})]}),e.jsx(W,{options:A.map(t=>({value:t.id,label:t.name})),selected:s.competitor_ids,onToggle:t=>v("competitor_ids",t)})]}),s.source==="url"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Page URL"}),e.jsx(k,{value:s.url,onChange:t=>i("url",t.target.value),placeholder:"https://yourblog.com/latest"})]})]})]}),e.jsxs(L,{title:"Texts",hint:"How the words come out — caption, voice, and the comment under every post.",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Voice (optional)"}),e.jsxs(S,{value:s.voice_id,onChange:t=>{const n=X.find(l=>l.id===t.target.value);i("voice_id",t.target.value),n!=null&&n.language&&i("language",n.language)},children:[e.jsx("option",{value:"",children:"— brand default —"}),X.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsx(kt,{value:s.language,onChange:t=>i("language",t)}),e.jsxs("div",{className:"sm:col-span-2 space-y-3",children:[e.jsx(Ct,{include:s.include_cta,value:s.cta,id:"automation-cta",onChange:({include:t,value:n})=>m(l=>({...l,include_cta:t,cta:n}))}),e.jsx(St,{value:s.caption_instructions,onChange:t=>i("caption_instructions",t)})]})]}),e.jsx(ct,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["First comment ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional — posted as-is under every post; links are clickable here, unlike captions)"})]}),e.jsx(k,{value:s.first_comment,onChange:t=>i("first_comment",t.target.value),placeholder:"Join our free deals channel → t.me/…"}),e.jsx(be,{hasProduct:s.source==="product"||s.source==="complete",onInsert:t=>i("first_comment",(s.first_comment+" "+t).trimStart())})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Mt,{value:s.user_tags,onChange:t=>i("user_tags",t),carousel:s.type==="carousel"}),e.jsx(bt,{value:s.collaborators,onChange:t=>i("collaborators",t)})]})]}),e.jsxs(L,{title:"Images",hint:"How every image from this automation is made.",children:[s.type==="post"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Image source"}),e.jsx(S,{value:s.product_image,onChange:t=>i("product_image",t.target.value),children:Je(s.source==="product"||s.source==="complete").map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),s.product_image==="upload"?e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx(Pt,{value:s.upload_url||null,onChange:t=>i("upload_url",t??""),bucket:"post-images",brandId:r,accept:"image/*",image:!0}),s.upload_url&&e.jsxs(e.Fragment,{children:[e.jsx(W,{options:Xe,selected:[s.upload_mode],onToggle:t=>i("upload_mode",t)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every run uses this image — posted untouched, or as the basis the model builds a new image from."})]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"The product options apply to product runs. Photo-based AI uses a model that accepts image input (auto-upgraded when needed)."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Image instructions ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional — standing direction added to every image prompt)"})]}),e.jsx(ge,{rows:2,value:s.style,onChange:t=>i("style",t.target.value),placeholder:"e.g. photorealistic, natural light, no people, bright colors"})]}),e.jsx(_t,{label:"Image model",models:te,model:s.image_model,onModel:t=>i("image_model",t),inputs:s.inputs,onInput:(t,n)=>i("inputs",{...s.inputs,[t]:n}),language:s.language,hasReference:s.template_ids.length>0||!!(a!=null&&a.logo_url)||ne||s.source==="product"&&s.product_image==="ref",disabledReason:t=>(s.template_ids.length>0||ne)&&t.referenceCapable===!1?"no image input":null,children:s.type==="carousel"&&(M==null?void 0:M.referenceCapable)===!1&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Ideogram or Nano Banana Pro keep carousel slides visually consistent (style reference support)."})}),ee.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Templates ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional — attached as an image reference; pick several to rotate one per run)"})]}),e.jsx(wt,{templates:ee,selectedIds:s.template_ids,onSelect:t=>
4i("template_ids",t),hint:"Images will be generated with a reference-capable model using the selected template — multiple templates take turns, one per run."})]}),s.type!=="carousel"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Text on image ",e.jsx("span",{className:"text-muted-foreground font-normal",children:'(optional — exact words rendered on the image; empty = AI wording, or an automatic "deal · price" line on product runs)'})]}),e.jsx(k,{value:s.image_text,onChange:t=>i("image_text",t.target.value),placeholder:"e.g. {name} — only {price}!"}),e.jsx(be,{hasProduct:s.source==="product"||s.source==="complete",onInsert:t=>i("image_text",(s.image_text+" "+t).trimStart())})]}),(a==null?void 0:a.logo_url)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(u,{children:["Logo instruction ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional — how the brand logo should appear; empty = placed wherever it naturally fits. Ignored on models that can't take reference images)"})]}),e.jsx(k,{value:s.logo_note,onChange:t=>i("logo_note",t.target.value),placeholder:"e.g. small, bottom-right corner, white version"})]})]}),e.jsxs(L,{title:"Publishing",hint:"When it runs, and what happens to each post it makes.",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Frequency"}),e.jsx(S,{options:[{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"}],placeholder:null,value:s.frequency,onChange:t=>i("frequency",t.target.value)})]}),s.frequency==="weekly"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Day"}),e.jsx(S,{value:s.run_dow,onChange:t=>i("run_dow",Number(t.target.value)),children:ke.map((t,n)=>e.jsx("option",{value:n,children:t},n))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Hour"}),e.jsx(S,{value:s.run_hour,onChange:t=>i("run_hour",Number(t.target.value)),children:Wt.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground -mt-2",children:["Times are in your local timezone (",Intl.DateTimeFormat().resolvedOptions().timeZone,")."]}),e.jsx(jt,{label:"Your audience is most active:",onPick:t=>m(n=>({...n,run_hour:t.hour,...n.frequency==="weekly"?{run_dow:t.dow}:{}}))}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"When a post is generated"}),e.jsx("div",{className:"space-y-1",children:_e.map(t=>e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{type:"radio",name:"output_mode",className:"mt-1",checked:s.output_mode===t.value,onChange:()=>i("output_mode",t.value)}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:t.label})," ",e.jsxs("span",{className:"text-muted-foreground",children:["— ",t.hint]})]})]},t.value))})]}),D&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:D}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(N,{variant:"brand",disabled:K.isPending||!!D,onClick:()=>K.mutate(),children:K.isPending?"Saving…":j?"Update":"Create"}),e.jsx(N,{variant:"outline",onClick:Z,children:"Cancel"})]})]})]}),!b&&_.length>0&&e.jsx("ul",{className:"space-y-3",children:_.map(t=>{var n,l,g;return e.jsx("li",{children:e.jsxs(ye,{className:je("p-4 sm:p-5 transition-colors hover:border-brand/40",we(t)&&"border-brand",!t.active&&"opacity-75"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-semibold truncate",children:t.name}),e.jsx(I,{variant:t.active?"success":"muted",className:"shrink-0",children:t.active?"active":"paused"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(I,{variant:"brand",className:"gap-1",children:((n=t.brief)==null?void 0:n.type)==="carousel"?e.jsxs(e.Fragment,{children:[e.jsx(et,{size:11})," carousel"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tt,{size:11})," post"]})}),e.jsx(I,{variant:"muted",children:Yt(t)}),e.jsx(Bt,{a:t})]}),e.jsx("div",{className:"text-sm text-muted-foreground truncate",children:Qt(t.brief)})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0 text-muted-foreground",children:[!
4o&&e.jsx("button",{title:"Edit",onClick:()=>H(t),className:"p-2 rounded-lg hover:bg-accent hover:text-foreground focus-visible:ring-2 ring-brand/40",children:e.jsx(At,{size:16})}),!o&&e.jsx("button",{title:"Duplicate",onClick:()=>Ie(t),className:"p-2 rounded-lg hover:bg-accent hover:text-foreground focus-visible:ring-2 ring-brand/40",children:e.jsx(Rt,{size:16})}),!o&&e.jsx("button",{title:"Run now",onClick:()=>x.mutate({id:t.id}),disabled:x.isPending&&((l=x.variables)==null?void 0:l.id)===t.id,className:"p-2 rounded-lg hover:bg-accent hover:text-foreground focus-visible:ring-2 ring-brand/40 disabled:opacity-40",children:e.jsx(qt,{size:16})}),!o&&e.jsx("button",{title:"Delete",onClick:()=>Ee.mutate(t.id),className:"p-2 rounded-lg hover:bg-red-50 hover:text-red-600 focus-visible:ring-2 ring-red-400/40",children:e.jsx(Lt,{size:16})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 mt-4 pt-3 border-t border-border text-xs text-muted-foreground",children:[!o&&e.jsx("button",{className:"font-medium text-brand hover:underline",onClick:()=>Le.mutate(t),children:t.active?"Pause":"Resume"}),t.last_run_at&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Et,{size:12})," Last run ",Y(t.last_run_at)]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(yt,{size:12})," Next ",Y(t.next_run_at)]}),x.isPending&&((g=x.variables)==null?void 0:g.id)===t.id&&e.jsx("span",{className:"text-brand",children:Dt(Me,ie)}),!x.isPending&&(C==null?void 0:C.id)===t.id&&e.jsxs("span",{children:[Kt(C.startedAt,ie)," ·"," ",e.jsx("button",{className:"underline text-brand",onClick:()=>Ke(t),children:"Run anyway"})]})]}),e.jsx(Ut,{posts:Pe[t.id]??[],onOpen:J}),t.last_error&&e.jsx("p",{className:"text-xs text-red-600 mt-2",children:t.last_error})]})},t.id)})}),V&&e.jsx(dt,{post:V,onClose:()=>J(null)}),oe&&e.jsxs(tt,{onClose:()=>R(null),hideClose:!0,className:"w-[26rem] rounded-2xl bg-card p-5",children:[e.jsx("p",{className:"font-semibold",children:U.title}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:U.body}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>R(null),children:"Cancel"}),e.jsx(N,{variant:"brand",onClick:()=>{const t=oe;R(null),x.mutate({id:t.id,force:!0})},children:U.action})]})]})]}):e.jsx("p",{className:"text-muted-foreground",children:"Create a brand first."})}export{Ys 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.