1import{ai as H,o as a,A as B,al as w,a4 as m,U as d,a5 as q,j as e,aM as V,C as E,G as p,$ as X,T as l,X as A,a0 as $,br as _,D as M,E as U,F as O,ao as J,L as Q,I as W}from"./index-dE8a1mPK.js";import{I as Z}from"./IconPlus-B47PY1MC.js";import{C as ee}from"./Collapse-BaYf95bQ.js";import{T as n}from"./Table-5ftamFSf.js";import{S as N}from"./Switch-Bm85N10X.js";import{I as se}from"./IconTrash-DIXYcrq7.js";import{I as te}from"./IconInfoCircle-CQg5L7ni.js";import{S as G}from"./Select-DebRlW67.js";import{I as ne}from"./IconEye-Clupefz6.js";import{N as K}from"./NumberInput-EbCp_odp.js";import"./InputsGroupFieldset-C0syow2C.js";import"./OptionsDropdown-wonErrz5.js";import"./CheckIcon-DkMc45y2.js";const oe=[{value:"rss",label:"RSS / Atom feed â blog, Substack, Medium, podcast"},{value:"youtube",label:"YouTube channel"},{value:"googlenews",label:"Google News search"},{value:"hackernews",label:"Hacker News search"}],re={rss:{key:"url",label:"Feed URL",placeholder:"https://yourblog.com/rss.xml"},youtube:{key:"channelId",label:"Channel ID or channel URL",placeholder:"https://www.youtube.com/channel/UCâ¦"},googlenews:{key:"query",label:"Search query",placeholder:"shopify seo site:techcrunch.com"},hackernews:{key:"query",label:"Search query (blank = front page)",placeholder:"llm agents"}};function ye(){const C=H(),[S,c]=a.useState(!1),{data:x,isLoading:g}=B({queryKey:["content-sources"],queryFn:()=>d.listContentSources()}),{data:u}=B({queryKey:["accounts"],queryFn:()=>d.listAccounts()}),i=()=>C.invalidateQueries({queryKey:["content-sources"]}),I=w({mutationFn:({id:s,enabled:r})=>d.updateContentSource(s,{enabled:r}),onSuccess:i,onError:m}),j=w({mutationFn:s=>d.deleteContentSource(s),onSuccess:()=>{q("Source removed"),i()},onError:m}),f=w({mutationFn:s=>d.pollContentSource(s),onSuccess:s=>{q(s.firstPoll?`Bookmarked ${s.seen} items â posts start with the next new one`:s.queued?`Queued ${s.queued} post${s.queued>1?"s":""}`:"Nothing new in this feed"),i()},onError:m}),b=(x==null?void 0:x.sources)||[],k=((u==null?void 0:u.accounts)||[]).filter(s=>s.status==="active"),y=s=>{var r;return(r=k.find(h=>h.id===s))==null?void 0:r.handle};return g?e.jsx(V,{}):e.jsxs(E,{gap:"md",children:[e.jsxs(p,{justify:"space-between",children:[e.jsxs("div",{children:[e.jsx(X,{order:2,children:"Content sources"}),e.jsx(l,{c:"dimmed",size:"sm",children:"Feeds that keep your queue full. New items get rewritten in your brand voice and scheduled like any other post."})]}),e.jsx(A,{leftSection:e.jsx(Z,{size:16}),onClick:()=>c(s=>!s),children:S?"Cancel":"Add source"})]}),e.jsx(ee,{in:S,children:e.jsx(ae,{accounts:k,onDone:()=>{c(!1),i()}})}),b.length?e.jsx(M,{withBorder:!0,p:0,children:e.jsxs(n,{verticalSpacing:"sm",horizontalSpacing:"md",children:[e.jsx(n.Thead,{children:e.jsxs(n.Tr,{children:[e.jsx(n.Th,{children:"Source"}),e.jsx(n.Th,{children:"Posts as"}),e.jsx(n.Th,{children:"Every"}),e.jsx(n.Th,{children:"Last poll"}),e.jsx(n.Th,{children:"On"}),e.jsx(n.Th,{})]})}),e.jsx(n.Tbody,{children:b.map(s=>{var r,h,v;return e.jsxs(n.Tr,{children:[e.jsxs(n.Td,{children:[e.jsxs(p,{gap:6,children:[e.jsx(l,{fw:600,size:"sm",children:s.name}),e.jsx(U,{size:"sm",variant:"light",children:s.type}),s.approvalMode!==!1&&e.jsx(U,{size:"sm",variant:"light",color:"orange",children:"needs approval"})]}),e.jsx(l,{size:"xs",c:"dimmed",children:((r=s.config)==null?void 0:r.url)||((h=s.config)==null?void 0:h.query)||((v=s.config)==null?void 0:v.channelId)}),s.lastError&&e.jsx(l,{size:"xs",c:"red",children:s.lastError})]}),e.jsx(n.Td,{children:e.jsx(l,{size:"sm",children:y(s.accountId)?`@${y(s.accountId)}`:"â"})}),e.jsx(n.Td,{children:e.jsxs(l,{size:"sm",children:[s.pollMin," min"]})}),e.jsx(n.Td,{children:e.jsx(l,{size:"sm",c:"dimmed",children:s.lastPolledAtMs?new Date(s.lastPolledAtMs).toLocaleString():"never"})}),e.jsx(n.Td,{children:e.jsx(N,{checked:s.enabled!==!1,onChange:P=>I.mutate({id:s.id,enabled:P.currentTarget.checked})})}),e.jsx(n.Td,{children:e.jsxs(p,{gap:4,justify:"flex-end",wrap:"nowrap",children:[e.jsx(O,{variant:"subtle",title:"Poll now",loading:f.isPending&&f.variables===s.id,onClick:()=>f.mutate(s.id),children:e.jsx(J,{size:16})}),e.jsx(O,{variant:"subtle",color:"red",title:"Delete",onClick:()=>j.mutate(s.id),children:e.jsx(se,{size:16})})]})})]},s.id)})})]})}):e.jsx($,{color:"gray",icon:e.jsx(_,{size:16}),variant:"light",children:"No sources yet. Your own blog is the best first one â every post you publish becomes a tweet without you writing it twice."}),e.jsx($,{color:"blue",icon:e.jsx(te,{size:16}),variant:"light",children:"The first poll of a feed only bookmarks what's already in it â otherwise adding a blog would queue its whole archive at once. Posts start with the next item published."})]})}function ae({accounts:C,onDone:S}
1){const[c,x]=a.useState("rss"),[g,u]=a.useState(""),[i,I]=a.useState(""),[j,f]=a.useState(""),[b,k]=a.useState(60),[y,s]=a.useState(3),[r,h]=a.useState(!0),[v,P]=a.useState(!0),[o,T]=a.useState(null),z=re[c],F={[z.key]:g},Y=c==="hackernews"||g.trim(),L=w({mutationFn:()=>d.previewContentSource({type:c,config:F}),onSuccess:t=>{var D;T(t.items||[]),(D=t.items)!=null&&D.length||m(new Error("That feed read fine but has no items in it"))},onError:t=>{T(null),m(t)}}),R=w({mutationFn:()=>d.createContentSource({type:c,config:F,accountId:j,name:i.trim()||void 0,pollMin:b,maxPerPoll:y,approvalMode:r,includeLink:v}),onSuccess:()=>{q("Source added"),S()},onError:m});return e.jsx(M,{withBorder:!0,p:"lg",children:e.jsxs(E,{gap:"md",children:[e.jsx(G,{label:"Type",data:oe,value:c,onChange:t=>{x(t),u(""),T(null)},allowDeselect:!1}),e.jsx(Q,{label:z.label,placeholder:z.placeholder,value:g,onChange:t=>{u(t.currentTarget.value),T(null)}}),e.jsxs(p,{children:[e.jsx(A,{variant:"light",leftSection:e.jsx(ne,{size:16}),onClick:()=>L.mutate(),loading:L.isPending,disabled:!Y,children:"Preview feed"}),(o==null?void 0:o.length)>0&&e.jsxs(l,{size:"sm",c:"green",children:[o.length," items read"]})]}),(o==null?void 0:o.length)>0&&e.jsx(M,{withBorder:!0,p:"sm",bg:"var(--mantine-color-default-hover)",children:e.jsx(E,{gap:4,children:o.slice(0,5).map(t=>e.jsx(W,{href:t.link,target:"_blank",size:"sm",lineClamp:1,children:t.title},t.id))})}),e.jsx(Q,{label:"Name (optional)",placeholder:"My blog",value:i,onChange:t=>I(t.currentTarget.value)}),e.jsx(G,{label:"Post as",placeholder:"Pick an account",data:C.map(t=>({value:t.id,label:`@${t.handle}`})),value:j,onChange:f}),e.jsxs(p,{grow:!0,children:[e.jsx(K,{label:"Check every (minutes)",value:b,onChange:t=>k(Number(t)||60),min:15}),e.jsx(K,{label:"Max posts per check",value:y,onChange:t=>s(Number(t)||3),min:1,max:10})]}),e.jsx(N,{label:"Hold for approval",description:"Outside content rewritten by AI is the one place a bad draft is publicly wrong about facts. Recommended on.",checked:r,onChange:t=>h(t.currentTarget.checked)}),e.jsx(N,{label:"Append the link",checked:v,onChange:t=>P(t.currentTarget.checked)}),e.jsx(p,{justify:"flex-end",children:e.jsx(A,{onClick:()=>R.mutate(),loading:R.isPending,disabled:!j||!(o!=null&&o.length),children:"Add source"})}),!(o!=null&&o.length)&&e.jsx(l,{size:"xs",c:"dimmed",ta:"right",children:"Preview the feed first â a URL that doesn't read is a source that never posts."})]})})}export{ye 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.