1import{r as b,j as e}from"./react-BVqF6wkN.js";import{c as re,B as f,S as ie,r as y,l as S,v as le,H as Ae,x as oe,af as Z,a as L,ag as Te,ah as Q,ai as Ee,aj as ee,X as ce,a2 as F,ak as de,al as me,am as ze,an as Ie,G as Le}from"./index-DBhDrNME.js";import{f as Pe,g as Re,h as De,e as Me,i as _e,j as Oe,k as $e,l as We,m as Fe,n as Be}from"./useWebsites-B3RvPniZ.js";import{C as M}from"./card-CXt9VTDW.js";import{I as B}from"./input-CF6oAZBA.js";import{S as U,a as V,b as H,c as X,d as Y,e as $,C as Ue}from"./select-CQrWyJAD.js";import{T as G}from"./textarea-DvApP050.js";import{b as Ve,d as He,e as Xe,f as Ye,g as Ge,h as qe}from"./dialog-D67JDdFp.js";import{G as Je}from"./globe-Df5_qH6X.js";import{R as Ke}from"./refresh-cw-BOFhcJxe.js";import{T as Ze}from"./triangle-alert-mRfokR17.js";import{P as q}from"./plus-CkFTUlbv.js";import{L as Qe}from"./lock-DogbLdat.js";import{T as xe}from"./trash-2-CWT7eiOt.js";import"./assets--OE6x10G.js";import"./check-BK_3A3pj.js";import"./index-BdQq_4o_.js";import"./index-CowZngIO.js";import"./index-oEU1U2mS.js";import"./index-Bj21RNpY.js";/** 2 * @license lucide-react v0.453.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 ue=re("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** 7 * @license lucide-react v0.453.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 es=re("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]),ss=({websiteId:s,open:n,onOpenChange:i})=>{const[a,l]=b.useState(null),h=Pe(),d=async()=>{if(s){l(null);try{const p=await h.mutateAsync(s);y.success(p.removed>0?`Regenerating your calendar. ${p.removed} upcoming item${p.removed===1?"":"s"} replaced.`:"Regenerating your calendar."),i(!1)}catch(p){l(p instanceof S?p.message:"Could not regenerate your calendar. Please try again.")}}};return e.jsx(Ve,{open:n,onOpenChange:i,children:e.jsxs(He,{className:"sm:max-w-md",children:[e.jsxs(Xe,{children:[e.jsx(Ye,{children:"Regenerate your remaining calendar?"}),e.jsxs(Ge,{className:"space-y-3 text-left",children:[e.jsx("span",{className:"block",children:"This will replace every article that hasn't been published yet with a new plan based on your updated settings."}),e.jsx("span",{className:"block font-medium text-gray-900",children:"Any keywords you've added or changes you've made to those upcoming articles will be lost."}),e.jsx("span",{className:"block",children:"Articles already published on your site are not affected."})]})]}),a&&e.jsx("p",{className:"text-sm text-red-600",children:a}),e.jsxs(qe,{className:"mt-2",children:[e.jsx(f,{variant:"outline",onClick:()=>i(!1),disabled:h.isPending,children:"No, keep it"}),e.jsx(f,{onClick:d,disabled:h.isPending,className:"bg-red-600 hover:bg-red-700",children:h.isPending?e.jsx(ie,{className:"size-4"}):"Yes, regenerate"})]})]})})},ts=[{id:"website",label:"Website",icon:Je},{id:"sections",label:"Sections",icon:es}],as=[{id:"residential",label:"Residential",sub:"Homeowners"}
11,{id:"commercial",label:"Commercial",sub:"Businesses"},{id:"both",label:"Both",sub:"Everyone"}],O="auto",se={all:"Every article",selected:"Only articles I tick"},te=s=>{if(!s)return"";const n=Math.max(1,Math.ceil((new Date(s).getTime()-Date.now())/(60*60*1e3)));return`in about ${n} hour${n===1?"":"s"}`},W=s=>s.timezoneSource==="user"?s.timezone:O,ae=s=>({services:s.services||[],serviceAreas:s.serviceAreas||[],audienceType:s.audienceType,targetAudience:s.targetAudience||[],competitors:s.competitors||[],excludedTopics:s.excludedTopics||[],excludedLocations:s.excludedLocations||[],timezoneSelection:W(s)}),R=(s,n)=>JSON.stringify([...s].sort())===JSON.stringify([...n].sort()),he=()=>e.jsx(M,{className:"border-gray-200 p-6",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Qe,{className:"mt-0.5 size-4 shrink-0 text-gray-400"}),e.jsx("p",{className:"text-base text-gray-700",children:"Only the account owner can edit this page. Team members can view it."})]})}),ge=()=>e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(ie,{className:"size-8"})}),Es=()=>{const{activeWebsite:s}=le(),[n,i]=b.useState("website");return e.jsxs("div",{className:"max-w-5xl space-y-6",children:[e.jsx(Ae,{children:e.jsx("title",{children:"Brand settings | Rankpilot"})}),e.jsx("p",{className:"text-base text-gray-700",children:"Tell us about your business so every article fits it. All optional - the more you add, the better the results."}),e.jsx("div",{role:"tablist",className:"flex gap-2 border-b border-gray-200 pb-4",children:ts.map(a=>{const l=a.icon;return e.jsxs("button",{role:"tab","aria-selected":n===a.id,onClick:()=>i(a.id),className:`flex items-center gap-2 rounded-lg px-4 py-2 transition-colors ${n===a.id?"bg-blue text-white":"text-gray-600 hover:bg-gray-100"}`,children:[e.jsx(l,{className:"size-4"}),e.jsx("span",{className:"text-sm font-medium",children:a.label})]},a.id)})}),s?n==="website"?e.jsx(rs,{website:s}):e.jsx(is,{}):e.jsx(ge,{})]})},D=({items:s,onChange:n,placeholder:i,label:a,tone:l="default",disabled:h})=>{const[d,p]=b.useState(""),T=()=>{const x=d.trim();x&&!s.some(g=>g.toLowerCase()===x.toLowerCase())&&n([...s,x]),p("")};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.map(x=>e.jsxs("span",{className:L("inline-flex items-center gap-1 rounded-full py-1 pr-1.5 pl-3 text-sm",l==="warning"?"bg-rose-50 text-rose-700":"bg-gray-100 text-gray-800"),children:[x,!h&&e.jsx("button",{type:"button","aria-label":`Remove ${x}`,onClick:()=>n(s.filter(g=>g!==x)),className:L("flex size-5 items-center justify-center rounded-full transition-colors",l==="warning"?"hover:bg-rose-200":"hover:bg-gray-200"),children:e.jsx(ce,{className:"size-3"})})]},x)),s.length===0&&e.jsx("span",{className:"text-sm text-gray-400 italic",children:"None yet"})]}),!h&&e.jsxs("div",{className:"relative mt-2.5 max-w-xs",children:[e.jsx(B,{value:d,onChange:x=>p(x.target.value),onKeyDown:x=>{(x.key==="Enter"||x.key===",")&&(x.preventDefault(),T())},placeholder:i,"aria-label":a,className:"h-10 rounded-lg pr-9 pl-3 text-sm"}),e.jsx("button",{type:"button",onClick:T,disabled:!d.trim(),"aria-label":a,className:"absolute top-1/2 right-1.5 flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 disabled:opacity-40",children:e.jsx(q,{className:"size-4"})})]})]})},ne=({children:s,onAddAll:n,onIgnoreAll:i,addAllLabel:a="Add all"})=>e.jsxs("div",{className:"mt-3 max-w-2xl rounded-xl border border-blue/20 bg-blue-50/40 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-xs font-semibold text-blue",children:"Found on your site"}),e.jsxs("div",{className:"flex shrink-0 gap-3 text-xs font-medium",children:[e.jsx("button",{type:"button",onClick:n,className:"text-blue hover:underline",children:a}),e.jsx("button",{type:"button",onClick:i,className:"text-gray-500 hover:text-gray-800",children:"Ignore"})]})]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:s})]}),ns=(s,n)=>{const a=["services","serviceAreas","competitors","targetAudience"].flatMap(l=>(s.proposed[l]||[]).filter(h=>!n[l].some(d=>d.toLowerCase()===h.toLowerCase())).map(h=>({field:l,value:h})));
11return s.proposed.timezone&&a.push({field:"timezone",value:s.proposed.timezone}),a},rs=({website:s})=>{const{isTeamContext:n}=oe(),i=Re(),a=De(),[l,h]=b.useState(()=>ae(s)),[d,p]=b.useState([]),[T,x]=b.useState(!1);b.useEffect(()=>{h(ae(s)),p([])},[s.id]);const g=(r,u)=>h(c=>({...c,[r]:u})),C=!!s.rescanAvailableAt,N=!!s.regenerateAvailableAt,z=!R(l.services,s.services||[])||!R(l.serviceAreas,s.serviceAreas||[])||l.audienceType!==s.audienceType||!R(l.targetAudience,s.targetAudience||[])||!R(l.competitors,s.competitors||[])||!R(l.excludedTopics,s.excludedTopics||[])||!R(l.excludedLocations,s.excludedLocations||[])||l.timezoneSelection!==W(s),k=()=>{if(n)return;const{timezoneSelection:r,...u}=l,c=r!==W(s);i.mutate({websiteId:s.id,payload:c?{...u,timezone:r}:u},{onSuccess:()=>y.success("Saved.",{description:"Applies automatically the next time your content calendar generates. Want it sooner? Use Regenerate remaining calendar instead."}),onError:E=>y.error(E instanceof S?E.message:"Failed to save brand settings")})},j=()=>{a.mutate(s.id,{onSuccess:r=>{const u=ns(r,l);p(u),u.length===0?y.success("Rescanned - nothing new found on your site."):y.success("Rescanned - suggestions are shown under each section below.")},onError:r=>y.error(r instanceof S?r.message:"Could not rescan your website")})},P=r=>{if(r.field==="timezone")g("timezoneSelection",r.value);else{const u=r.field;h(c=>c[u].some(E=>E.toLowerCase()===r.value.toLowerCase())?c:{...c,[u]:[...c[u],r.value]})}p(u=>u.filter(c=>c!==r))},_=r=>p(u=>u.filter(c=>c!==r)),w=r=>{const u=d.filter(c=>c.field===r);if(!u.length||n)return null;if(r==="timezone"){const c=u[0];return e.jsx(ne,{onAddAll:()=>P(c),onIgnoreAll:()=>_(c),addAllLabel:"Switch",children:e.jsxs("span",{className:"text-sm text-gray-800",children:["We think this site is in ",Z(c.value),". Switch?"]})})}return e.jsx(ne,{onAddAll:()=>u.forEach(P),onIgnoreAll:()=>p(c=>c.filter(E=>E.field!==r)),children:u.map(c=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-dashed border-blue/40 bg-white py-1 pr-1.5 pl-3 text-sm text-gray-800",children:[c.value,e.jsx("button",{type:"button","aria-label":`Add ${c.value}`,onClick:()=>P(c),className:"flex size-5 items-center justify-center rounded-full text-blue transition-colors hover:bg-blue-100",children:e.jsx(q,{className:"size-3"})}),e.jsx("button",{type:"button","aria-label":`Ignore ${c.value}`,onClick:()=>_(c),className:"flex size-5 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-200",children:e.jsx(ce,{className:"size-3"})})]},c.value))})},A=l.timezoneSelection!==O?null:s.timezoneSource==="inferred"?`Detected: ${Z(s.timezone)} - change if wrong.`:"Timezone not set - pick one or rescan your website to auto-detect.";return e.jsxs("div",{className:"space-y-6",children:[n&&e.jsx(he,{}),e.jsx(M,{className:"border-gray-200 p-6",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-bold text-gray-900",children:"Rescan your website"}),e.jsx("p",{className:"mt-2 max-w-xl text-base text-gray-700",children:"Made changes to your site? Rescan it and we'll suggest updates here - nothing changes automatically."})]}),e.jsxs(f,{variant:"outline",onClick:j,disabled:a.isPending||n||C,title:C?`You can rescan once per day. Available again ${te(s.rescanAvailableAt)}.`:void 0,className:"shrink-0",children:[e.jsx(Ke,{className:L("mr-2 size-4",a.isPending&&"animate-spin")}),a.isPending?"Rescanningâ¦":"Rescan my website"]})]})}),e.jsxs(M,{className:"space-y-5 border-gray-200 p-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold text-gray-900",children:"Services you offer"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-600",children:"Content and keywords are built around this list."}),e.jsxs("div",{className:"mt-3",children:[e.jsx(D,{items:l.services,onChange:r=>g("services",r),placeholder:"Add a service",label:"Add a service",disabled:n}),w("services")]})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-5",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900",children:"Target audience"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-600",children:"Who you're writing for. Helps the AI match tone and examples to the right reader."}),e.jsxs("div",{className:"mt-3",children:[e.jsx(D,{items:l.targetAudience,onChange:r=>g("targetAudience",r),placeholder:"e.g. Homeowners in Austin",label:"Add a target audience",disabled:n}),w("targetAudience")]})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-5",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900",children:"Cities you want to target"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-600",children:"Articles will focus on these areas, not just anywhere you're mentioned online."}),e.jsxs("div",{className:"mt-3",children:[e.jsx(D,{items:l.serviceAreas,onChange:r=>g("serviceAreas",r),placeholder:"Add a city",label:"Add a service area",disabled:n}),w("serviceAreas")]})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-5",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900",children:"Competitors"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-600",children:"Who you're up against. We use this to find topics and keywords you can still win."}),e.jsxs("div",{className:"mt-3",children:[e.jsx(D,{items:l.competitors,onChange:r=>g("competitors",r),placeholder:"e.g. competitor.com",label:"Add a competitor",disabled:n}),w("competitors")]})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-5",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900",children:"Who you serve"}),e.jsx("div",{className:"mt-3 grid max-w-lg grid-cols-3 gap-3",children:as.map(r=>e.jsxs("button",{type:"button",onClick:()=>g("audienceType",r.id),"aria-pressed":l.audienceType===r.id,disabled:n,className:L("min-w-0 rounded-xl border px-3.5 py-3 text-left transition",l.audie
11nceType===r.id?"border-blue bg-blue-50/60 ring-1 ring-blue":"border-gray-200 hover:border-gray-300"),children:[e.jsx("div",{className:"truncate text-base font-semibold text-gray-900",children:r.label}),e.jsx("div",{className:"truncate text-sm text-gray-600",children:r.sub})]},r.id))})]}),e.jsxs("div",{className:"border-t border-gray-100 pt-5",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900",children:"Timezone"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-600",children:"This website's own timezone - controls when its articles publish."}),e.jsx("div",{className:"mt-3 max-w-xs",children:e.jsxs(U,{value:l.timezoneSelection,onValueChange:r=>g("timezoneSelection",r),disabled:n,children:[e.jsx(V,{className:"h-11 w-full text-sm","aria-label":"Timezone",children:e.jsx(H,{})}),e.jsx(X,{children:e.jsxs(Y,{children:[e.jsx($,{value:O,children:"Auto-detect from website (recommended)"}),Te(l.timezoneSelection===O?null:l.timezoneSelection).map(r=>e.jsx($,{value:r.id,children:r.label},r.id))]})})]})}),A&&e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:A}),w("timezone")]})]}),e.jsxs(M,{className:"space-y-5 border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ze,{className:"mt-0.5 size-4 shrink-0 text-rose-500"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-bold text-gray-900",children:"What to never write about"}),e.jsx("p",{className:"mt-2 text-base text-gray-700",children:"We check every article against this list before it's scheduled, not just when it's written."})]})]}),e.jsx(D,{items:l.excludedTopics,onChange:r=>g("excludedTopics",r),placeholder:"e.g. high-rise window cleaning",label:"Add an excluded topic",tone:"warning",disabled:n}),e.jsxs("div",{className:"border-t border-gray-100 pt-5",children:[e.jsx("div",{className:"text-base font-semibold text-gray-900",children:"Locations to never target"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-600",children:"Useful if your site mentions areas you no longer serve."}),e.jsx("div",{className:"mt-3",children:e.jsx(D,{items:l.excludedLocations,onChange:r=>g("excludedLocations",r),placeholder:"e.g. Dallas",label:"Add an excluded location",tone:"warning",disabled:n})})]})]}),!n&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("p",{className:"text-sm text-gray-500",children:z||s.settingsDirty?"Unsaved changes apply to your next scheduled calendar automatically.":"Everything here matches your current calendar."}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx(f,{variant:"ghost",onClick:()=>x(!0),disabled:!s.settingsDirty||N,title:N?`You can regenerate once per day. Available again ${te(s.regenerateAvailableAt)}.`:void 0,className:"text-gray-500 hover:bg-gray-100 hover:text-gray-700",children:"Regenerate remaining calendar"}),e.jsx(f,{onClick:k,disabled:i.isPending||!z,children:"Save changes"})]})]}),e.jsx(ss,{websiteId:s.id,open:T,onOpenChange:x})]})},pe=({on:s,onChange:n,label:i,disabled:a})=>e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":i,disabled:a,onClick:()=>n(!s),className:L("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full p-0 transition-colors disabled:cursor-not-allowed",s?"bg-blue":"bg-gray-200"),children:e.jsx("span",{className:L("absolute left-0.5 size-5 rounded-full bg-white shadow transition-transform",s?"translate-x-5":"translate-x-0")})}),is=()=>{const{activeWebsite:s}=le(),{isTeamContext:n}=oe(),i=(s==null?void 0:s.id)??null,{data:a,isLoading:l}=Me(i),h=_e(i),d=Oe(i),p=$e(i),T=We(i),x=Fe(i),g=Be(i),[C,N]=b.useState([]),[z,k]=b.useState(!1),[j,P]=b.useState(""),[_,w]=b.useState([]);if(b.useEffect(()=>{N([]),k(!1),w([])},[i]),b.useEffect(()=>{a&&P(a.customInstructions||"")},[a==null?void 0:a.customInstructions,i]),l||!a)return e.jsx(ge,{});const A=[...a.sections].sort((t,m)=>t.order-m.order),r=[...A.map(t=>({kind:"saved",key:t.id,section:t})),...C.map(t=>({kind:"draft",key:t.key,draft:t}))],u=r.length>=Q,c=t=>{if(k(!1),u)return;const m=t===F;N(o=>[...o,{key:`draft-${Date.now()}-${o.length}`,preset:t,name:t==="Custom section"?"":t,content:"",placement:"end",applyTo:m?"selected":"all",enabled:!0}])},E=(t,m)=>N(o=>o.map(v=>v.key===t?{...v,...m}:v)),J=t=>N(m=>m.filter(o=>o.key!==t)),K=t=>{t.status==="ok"?y.success(t.polished?"Section saved. Lightly polished by AI.":"Section saved."):y.error("This section can't be used as written. See the note under it.")},Se=t=>{if(!t.name.trim()||!t.content.trim()){y.error("Add a name and the wording before saving.");return}
11h.mutate({preset:t.preset,name:t.name.trim(),content:t.content.trim(),placement:t.placement,applyTo:t.applyTo},{onSuccess:async m=>{t.enabled||await p.mutateAsync({sectionId:m.id,payload:{enabled:!1}}),J(t.key),K(m)},onError:m=>y.error(m instanceof S?m.message:"Couldn't check this section, try again.")})},Ce=(t,m)=>{const o=t+m;if(o<0||o>=A.length)return;const v=[...A];[v[t],v[o]]=[v[o],v[t]],T.mutate(v.map(I=>I.id),{onError:I=>y.error(I instanceof S?I.message:"Couldn't reorder sections.")})},ke=(t,m)=>p.mutate({sectionId:t,payload:m},{onError:o=>y.error(o instanceof S?o.message:"Couldn't update this section.")}),we=()=>{w([]),g.mutate(j.trim(),{onSuccess:()=>y.success("Custom instructions saved. New articles will follow them."),onError:t=>{var o;const m=t instanceof S?(o=t.data)==null?void 0:o.reasons:void 0;t instanceof S&&t.status===422?w(m!=null&&m.length?m:[t.message]):y.error(t instanceof S?t.message:"Couldn't save these instructions, try again.")}})};return e.jsxs("div",{className:"space-y-6",children:[n&&e.jsx(he,{}),e.jsxs(M,{className:"border-gray-200 p-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-bold text-gray-900",children:"Required sections"}),e.jsx("p",{className:"mt-2 text-base text-gray-700",children:"Added to every new article, worked into a natural spot - not just tacked on. Lightly polished to read naturally. Facts, names and links are kept exactly."})]}),e.jsx("div",{className:"mt-5 space-y-3",children:r.map(t=>{var m;return t.kind==="saved"?e.jsx(ls,{section:t.section,index:A.findIndex(o=>o.id===t.section.id),total:A.length,disabled:n,saving:d.isPending&&((m=d.variables)==null?void 0:m.sectionId)===t.section.id,onMove:o=>Ce(A.findIndex(v=>v.id===t.section.id),o),onPatch:o=>ke(t.section.id,o),onDelete:()=>x.mutate(t.section.id,{onError:o=>y.error(o instanceof S?o.message:"Couldn't delete this section.")}),onSave:(o,v)=>d.mutate({sectionId:t.section.id,payload:{name:o,content:v}},{onSuccess:K,onError:I=>y.error(I instanceof S?I.message:"Couldn't check this section, try again.")})},t.key):e.jsx(os,{draft:t.draft,saving:h.isPending,onChange:o=>E(t.draft.key,o),onCancel:()=>J(t.draft.key),onSave:()=>Se(t.draft)},t.key)})}),!n&&(z?e.jsxs("div",{className:"mt-4 rounded-2xl border border-gray-200 bg-gray-50/60 p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium text-gray-700",children:"Pick a section to add"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ee.map(t=>e.jsx("button",{type:"button",onClick:()=>c(t),className:"rounded-full border border-gray-200 bg-white px-3 py-1.5 text-sm font-medium text-gray-700 hover:border-blue/40 hover:text-blue",children:t},t))}),e.jsx("button",{type:"button",onClick:()=>k(!1),className:"mt-3 text-sm font-medium text-gray-500 hover:text-gray-800",children:"Cancel"})]}):e.jsxs("button",{type:"button",onClick:()=>k(!0),disabled:u,title:u?`You can add up to ${Q} sections.`:void 0,className:"mt-4 flex w-full items-center justify-center gap-2 rounded-2xl border border-dashed border-gray-300 bg-white px-5 py-3.5 text-sm font-medium text-gray-600 transition hover:border-blue/40 hover:bg-blue-50/30 hover:text-blue disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(q,{className:"size-4"})," Add a section"]}))]}),e.jsxs(M,{className:"border-gray-200 p-6",children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-bold text-gray-900",children:"Custom instructions"}),e.jsx("p",{className:"mt-2 max-w-xl text-base text-gray-700",children:"Standing rules the AI follows in every article - not tone or style, that's still in Voice."})]})}),e.jsxs("div",{className:"mt-3 flex items-start gap-1.5 rounded-lg bg-blue-50/60 px-3 py-2 text-sm text-gray-600",children:[e.jsx(ue,{className:"mt-0.5 size-3.5 shrink-0 text-blue"}),"Moved from your Voice tab - your existing writer's notes carried over automatically. Voice now covers tone and style only."]}),e.jsx(G,{value:j,onChange:t=>P(t.target.value),rows:3,maxLength:ee,disabled:n,placeholder:'e.g. "Cite sources for health claims"',className:"mt-3 text-sm"}),e.jsxs("div",{className:"mt-1 text-right text-xs text-gray-400",children:[j.length,"/",ee]}),_.length>0&&e.jsx("ul",{className:"mt-1 space-y-1 text-sm text-rose-600",children:_.map(t=>e.jsx("li",{children:t},t))}),!n&&e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(f,{className:"h-12 px-6 text-sm",onClick:we,disabled:g.isPending,children:g.isPending?"Saving...":"Save instructions"})})]})]})},ye=({value:s,onChange:n,disabled:i})=>e.jsxs(U,{value:s,onValueChange:a=>n(a),disabled:i,children:[e.jsx(V,{className:"h-8 w-auto gap-1.5 border-none bg-gray-50 px-2.5 text-xs font-medium text-gray-700 shadow-none hover:bg-gray-100","aria-label":"Placement preference",children:e.jsx(H,{})}),e.jsx(X,{children:e.jsx(Y,{children:ze.map(a=>e.jsx($,{value:a,children:Ie[a]},a))})})]}),be=({value:s,onChange:n,disabled:i})=>e.jsxs(U,{value:s,onValueChange:a=>n(a),disabled:i,children:[e.jsx(V,{className:"h-8 w-auto gap-1.5 border-none bg-gray-50 px-2.5 text-xs font-medium text-gray-700 shadow-none hover:bg-gray-100","aria-label":"Apply to",children:e.jsx(H,{})}),e.jsx(X,{children:e.jsx(Y,{children:Object.keys(se).map(a=>e.jsx($,{value:a,children:se[a]},a))})})]}),je=()=>e.jsxs("p",{className:"mt-2.5 flex items-start gap-1.5 text-sm text-gray-600",children:[e.jsx(ue,{className:"mt-0.5 size-3.5 shrink-0"}),"Only appears on articles you tick, or on every article if you switch this to Every article. The AI never adds or implies a reviewer on its own."]}),ve=({enabled:s,header:n,children:i})=>
11e.jsxs("div",{className:L("rounded-2xl border bg-white p-4 transition-opacity",s?"border-gray-200":"border-gray-100 opacity-60"),children:[e.jsx("div",{className:"flex items-center gap-2.5",children:n}),i]}),fe=({index:s,total:n,disabled:i,onMove:a})=>e.jsxs("div",{className:"flex shrink-0 flex-col rounded-md bg-gray-50",children:[e.jsx("button",{type:"button",onClick:()=>a(-1),disabled:i||s<=0,"aria-label":"Move up",className:"px-1 pt-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30",children:e.jsx(Ue,{className:"size-3.5"})}),e.jsx("button",{type:"button",onClick:()=>a(1),disabled:i||s<0||s>=n-1,"aria-label":"Move down",className:"px-1 pb-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30",children:e.jsx(Le,{className:"size-3.5"})})]}),Ne="h-9 min-w-0 flex-1 border-transparent bg-transparent px-2 text-base font-semibold text-gray-900 shadow-none hover:border-gray-200 focus-visible:border-gray-200 focus-visible:ring-0",ls=({section:s,index:n,total:i,disabled:a,saving:l,onMove:h,onPatch:d,onDelete:p,onSave:T})=>{const[x,g]=b.useState(s.name),[C,N]=b.useState(s.content);b.useEffect(()=>{g(s.name),N(s.content)},[s.id,s.name,s.content]);const z=x!==s.name||C!==s.content,k=s.preset===F;return e.jsxs(ve,{enabled:s.enabled,header:e.jsxs(e.Fragment,{children:[!a&&e.jsx(fe,{index:n,total:i,onMove:h}),e.jsx(B,{value:x,onChange:j=>g(j.target.value),maxLength:me,disabled:a,placeholder:"Section name","aria-label":"Section name",className:Ne}),e.jsx(pe,{on:s.enabled,onChange:j=>d({enabled:j}),label:`${s.name||"Section"} enabled`,disabled:a}),!a&&e.jsx(f,{variant:"ghost",size:"icon-sm",onClick:p,"aria-label":`Delete ${s.name||"section"}`,children:e.jsx(xe,{className:"size-4 text-gray-400 hover:text-rose-500"})})]}),children:[e.jsx(G,{value:C,onChange:j=>N(j.target.value),maxLength:de,disabled:a,placeholder:"Exact wording to include - names, links, phone numbers, etc.",rows:2,className:"mt-2.5 text-sm"}),s.status==="rejected"&&s.reason&&e.jsx("p",{className:"mt-1.5 text-sm text-rose-600",children:s.reason}),s.status==="ok"&&s.polished&&!z&&e.jsx("p",{className:"mt-1.5 text-xs text-gray-400",children:"Polished by AI"}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Appears"}),e.jsx(ye,{value:s.placement,onChange:j=>d({placement:j}),disabled:a}),k&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"ml-2 text-xs font-medium text-gray-400",children:"Apply to"}),e.jsx(be,{value:s.applyTo,onChange:j=>d({applyTo:j}),disabled:a})]}),z&&!a&&e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{g(s.name),N(s.content)},disabled:l,children:"Cancel"}),e.jsx(f,{size:"sm",onClick:()=>T(x.trim(),C.trim()),disabled:l||!x.trim()||!C.trim(),children:l?"Saving...":"Save"})]})]}),k&&e.jsx(je,{})]})},os=({draft:s,saving:n,onChange:i,onCancel:a,onSave:l})=>{const h=s.preset===F;return e.jsxs(ve,{enabled:s.enabled,header:e.jsxs(e.Fragment,{children:[e.jsx(fe,{index:-1,total:0,disabled:!0,onMove:()=>{}}),e.jsx(B,{value:s.name,onChange:d=>i({name:d.target.value}),maxLength:me,placeholder:"Section name","aria-label":"Section name",className:Ne}),e.jsx(pe,{on:s.enabled,onChange:d=>i({enabled:d}),label:`${s.name||"Section"} enabled`}),e.jsx(f,{variant:"ghost",size:"icon-sm",onClick:a,"aria-label":`Delete ${s.name||"section"}`,children:e.jsx(xe,{className:"size-4 text-gray-400 hover:text-rose-500"})})]}),children:[e.jsx(G,{value:s.content,onChange:d=>i({content:d.target.value}),maxLength:de,placeholder:"Exact wording to include - names, links, phone numbers, etc.",rows:2,className:"mt-2.5 text-sm"}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Appears"}),e.jsx(ye,{value:s.placement,onChange:d=>i({placement:d})}),h&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"ml-2 text-xs font-medium text-gray-400",children:"Apply to"}),e.jsx(be,{value:s.applyTo,onChange:d=>i({applyTo:d})})]}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:a,disabled:n,children:"Cancel"}),e.jsx(f,{size:"sm",onClick:l,disabled:n||!s.name.trim()||!s.content.trim(),children:n?"Saving...":"Save"})]})]}),h&&e.jsx(je,{})]})};export{Es as Brand};
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.