@ainyc/canonry 4.112.3 → 4.112.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{j as s}from"./vendor-tanstack-Be8JdV5M.js";import{u as r,bL as t,B as a}from"./index-DB_F_WFv.js";function n({run:e}){const{openRun:i}=r();return s.jsxs("article",{className:"run-row",children:[s.jsxs("div",{className:"run-row-main",children:[s.jsxs("div",{className:"run-row-head",children:[s.jsxs("div",{children:[s.jsx("p",{className:"run-row-title",children:e.summary}),s.jsxs("p",{className:"run-row-subtitle",children:[e.projectName,e.location?` · ${e.location}`:""," · ",e.kindLabel]})]}),s.jsx(t,{status:e.status})]}),s.jsx("p",{className:"run-row-detail",children:e.statusDetail})]}),s.jsxs("dl",{className:"run-row-meta",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Started"}),s.jsx("dd",{children:e.startedAt})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Duration"}),s.jsx("dd",{children:e.duration})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Trigger"}),s.jsx("dd",{children:e.triggerLabel})]})]}),s.jsx(a,{variant:"outline",size:"sm",type:"button",onClick:()=>i(e.id),children:"View run"})]})}export{n as R};
1
+ import{j as s}from"./vendor-tanstack-Be8JdV5M.js";import{u as r,bL as t,B as a}from"./index-BZnlypko.js";function n({run:e}){const{openRun:i}=r();return s.jsxs("article",{className:"run-row",children:[s.jsxs("div",{className:"run-row-main",children:[s.jsxs("div",{className:"run-row-head",children:[s.jsxs("div",{children:[s.jsx("p",{className:"run-row-title",children:e.summary}),s.jsxs("p",{className:"run-row-subtitle",children:[e.projectName,e.location?` · ${e.location}`:""," · ",e.kindLabel]})]}),s.jsx(t,{status:e.status})]}),s.jsx("p",{className:"run-row-detail",children:e.statusDetail})]}),s.jsxs("dl",{className:"run-row-meta",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Started"}),s.jsx("dd",{children:e.startedAt})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Duration"}),s.jsx("dd",{children:e.duration})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Trigger"}),s.jsx("dd",{children:e.triggerLabel})]})]}),s.jsx(a,{variant:"outline",size:"sm",type:"button",onClick:()=>i(e.id),children:"View run"})]})}export{n as R};
@@ -1 +1 @@
1
- import{j as e,r as o}from"./vendor-tanstack-Be8JdV5M.js";import{bJ as u,bK as m,B as h,t as x,g as p}from"./index-DB_F_WFv.js";import{R as j}from"./RunRow-Chc7eyZU.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-recharts-C9EZkgbP.js";import"./vendor-markdown-6dwjPOKK.js";function y(){const{dashboard:l,isLoading:n}=u(),t=m();if(!l||n)return e.jsxs("div",{className:"page-skeleton",children:[e.jsxs("div",{className:"page-skeleton-header",children:[e.jsx("div",{className:"skeleton-text h-6 w-20"}),e.jsx("div",{className:"skeleton-text-sm w-72"})]}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"rounded-xl border border-default bg-surface p-3 flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"skeleton-text w-40"}),e.jsx("div",{className:"skeleton-text-sm w-56"})]}),e.jsx("div",{className:"skeleton h-5 w-16 rounded-full"})]},s))})]});const r=l.runs,[a,c]=o.useState("all"),i=a==="all"?r:r.filter(s=>s.status===a),d=async()=>{try{await t.mutateAsync(void 0)}catch{}};return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Runs"}),e.jsx("p",{className:"page-subtitle",children:"Status, type, project, duration, and the shortest explanation that makes the outcome trustworthy."})]}),e.jsx(h,{type:"button",variant:"outline",size:"sm",disabled:t.isPending,onClick:()=>{d()},children:t.isPending?"Queueing…":"Run all projects"})]}),e.jsxs("section",{children:[e.jsx("div",{className:"filter-row",role:"toolbar","aria-label":"Run filters",children:["all","queued","running","completed","partial","failed","cancelled"].map(s=>e.jsx("button",{className:`filter-chip ${a===s?"filter-chip-active":""}`,type:"button","aria-pressed":a===s,onClick:()=>c(s),children:s==="all"?"All runs":x(s)},s))}),e.jsx("div",{className:"run-list",children:i.length>0?i.map(s=>e.jsx(j,{run:s},s.id)):e.jsxs(p,{className:"surface-card empty-card",children:[e.jsx("h2",{children:"No runs match this filter"}),e.jsx("p",{children:"Try another status filter or queue a new run from a project command center."})]})})]})]})}export{y as RunsPage};
1
+ import{j as e,r as o}from"./vendor-tanstack-Be8JdV5M.js";import{bJ as u,bK as m,B as h,t as x,g as p}from"./index-BZnlypko.js";import{R as j}from"./RunRow-CV2qXxPT.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-recharts-C9EZkgbP.js";import"./vendor-markdown-6dwjPOKK.js";function y(){const{dashboard:l,isLoading:n}=u(),t=m();if(!l||n)return e.jsxs("div",{className:"page-skeleton",children:[e.jsxs("div",{className:"page-skeleton-header",children:[e.jsx("div",{className:"skeleton-text h-6 w-20"}),e.jsx("div",{className:"skeleton-text-sm w-72"})]}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"rounded-xl border border-default bg-surface p-3 flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"skeleton-text w-40"}),e.jsx("div",{className:"skeleton-text-sm w-56"})]}),e.jsx("div",{className:"skeleton h-5 w-16 rounded-full"})]},s))})]});const r=l.runs,[a,c]=o.useState("all"),i=a==="all"?r:r.filter(s=>s.status===a),d=async()=>{try{await t.mutateAsync(void 0)}catch{}};return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Runs"}),e.jsx("p",{className:"page-subtitle",children:"Status, type, project, duration, and the shortest explanation that makes the outcome trustworthy."})]}),e.jsx(h,{type:"button",variant:"outline",size:"sm",disabled:t.isPending,onClick:()=>{d()},children:t.isPending?"Queueing…":"Run all projects"})]}),e.jsxs("section",{children:[e.jsx("div",{className:"filter-row",role:"toolbar","aria-label":"Run filters",children:["all","queued","running","completed","partial","failed","cancelled"].map(s=>e.jsx("button",{className:`filter-chip ${a===s?"filter-chip-active":""}`,type:"button","aria-pressed":a===s,onClick:()=>c(s),children:s==="all"?"All runs":x(s)},s))}),e.jsx("div",{className:"run-list",children:i.length>0?i.map(s=>e.jsx(j,{run:s},s.id)):e.jsxs(p,{className:"surface-card empty-card",children:[e.jsx("h2",{children:"No runs match this filter"}),e.jsx("p",{children:"Try another status filter or queue a new run from a project command center."})]})})]})]})}export{y as RunsPage};
@@ -1 +1 @@
1
- import{r as n,j as e}from"./vendor-tanstack-Be8JdV5M.js";import{B as f,i as A,bM as H,M as B,bN as q,bO as F,g as b,T as y,bP as z,ba as Q,bJ as V,bQ as W,bR as _,bS as T,bT as K}from"./index-DB_F_WFv.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-recharts-C9EZkgbP.js";import"./vendor-markdown-6dwjPOKK.js";function J({providerName:s,keyUrl:m,modelHint:o,onSaved:j}){const u=s.toLowerCase()==="local",[r,d]=n.useState(""),[x,c]=n.useState(""),[g,h]=n.useState(""),[p,a]=n.useState(""),[l,v]=n.useState(""),[N,S]=n.useState(""),[C,k]=n.useState(!1),[w,t]=n.useState(null),[L,M]=n.useState(!1),O=u?x.trim().length>0:r.trim().length>0;async function R(){if(O){k(!0),t(null),M(!1);try{const i=$=>{const I=parseInt($.trim(),10);return Number.isFinite(I)&&I>0?I:void 0},P={},D=i(p);D!==void 0&&(P.maxConcurrency=D);const G=i(l);G!==void 0&&(P.maxRequestsPerMinute=G);const E=i(N);E!==void 0&&(P.maxRequestsPerDay=E),await H(s.toLowerCase(),{...r.trim()?{apiKey:r.trim()}:{},...x.trim()?{baseUrl:x.trim()}:{},...g.trim()?{model:g.trim()}:{},...Object.keys(P).length>0?{quota:P}:{}}),d(""),c(""),h(""),a(""),v(""),S(""),M(!0),B({title:"Provider updated",detail:`${s} configuration saved.`,tone:"positive",dedupeKey:`settings:provider:${s}`,dedupeMode:"replace"}),j()}catch(i){t(i instanceof Error?i.message:"Failed to update provider")}finally{k(!1)}}}const U=o??"Use default model";return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[u&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:`base-url-${s}`,children:"Base URL"}),e.jsx("input",{id:`base-url-${s}`,type:"text",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"http://localhost:11434/v1",value:x,onChange:i=>c(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Any OpenAI-compatible endpoint — Ollama, LM Studio, llama.cpp, vLLM"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-xs text-muted",htmlFor:`api-key-${s}`,children:["API Key",u?" (optional)":""]}),m&&e.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted hover:text-neutral underline underline-offset-2",children:["Get API key ","↗"]})]}),e.jsx("input",{id:`api-key-${s}`,type:"password",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:u?"Optional — most local servers don't need one":`Enter ${s} API key`,value:r,onChange:i=>d(i.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:`model-${s}`,children:"Model (optional)"}),e.jsx("input",{id:`model-${s}`,type:"text",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:U,value:g,onChange:i=>h(i.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",children:"Quota (optional)"}),e.jsxs("div",{className:"mt-0.5 grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Concurrent",value:p,onChange:i=>a(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Max concurrent"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"/min",value:l,onChange:i=>v(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Per minute"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"/day",value:N,onChange:i=>S(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Per day"})]})]})]}),w&&e.jsx("p",{className:"text-xs text-negative-400",children:w}),L&&e.jsx("p",{className:"text-xs text-positive-400",children:"Provider updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!O||C,onClick:A(R),children:C?"Saving...":"Save"})]})}function X({onSaved:s}){const[m,o]=n.useState(""),[j,u]=n.useState(""),[r,d]=n.useState(!1),[x,c]=n.useState(null),[g,h]=n.useState(!1),p=m.trim().length>0&&j.trim().length>0;async function a(){if(p){d(!0),c(null),h(!1);try{await q({clientId:m.trim(),clientSecret:j.trim()}),o(""),u(""),h(!0),B({title:"Google OAuth app updated",detail:"Dashboard Google credentials were saved.",tone:"positive",dedupeKey:"settings:google-oauth",dedupeMode:"replace"}),s()}catch(l){c(l instanceof Error?l.message:"Failed to update Google OAuth credentials")}finally{d(!1)}}}return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:"google-client-id",children:"Client ID"}),e.jsxs("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted hover:text-neutral underline underline-offset-2",children:["Google Cloud ","↗"]})]}),e.jsx("input",{id:"google-client-id",type:"text",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Google OAuth client ID",value:m,onChange:l=>o(l.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:"google-client-secret",children:"Client secret"}),e.jsx("input",{id:"google-client-secret",type:"password",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Google OAuth client secret",value:j,onChange:l=>u(l.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-muted",children:["These credentials are stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"}),". Project-level Search Console connections are created separately per canonical domain."]}),x&&e.jsx("p",{className:"text-xs text-negative-400",children:x}),g&&e.jsx("p",{className:"text-xs text-positive-400",children:"Google OAuth credentials updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!p||r,onClick:A(a),children:r?"Saving...":"Save Google OAuth app"})]})}function Y(){const[s,m]=n.useState(null),[o,j]=n.useState(null),[u,r]=n.useState(!1),[d,x]=n.useState("localhost"),[c,g]=n.useState("9222"),[h,p]=n.useState(!1);return n.useEffect(()=>{F().then(m).catch(a=>{const l=a instanceof Error?a.message:String(a);l.includes("501")||j(l)})},[]),e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Browser provider"}),e.jsx("h2",{children:"ChatGPT (CDP)"})]}),e.jsx(y,{tone:s?.connected?"positive":"caution",children:s?.connected?"Connected":"Not connected"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[s?.endpoint&&e.jsxs("div",{children:[e.jsx("dt",{children:"Endpoint"}),e.jsx("dd",{className:"font-mono text-xs",children:s.endpoint})]}),s?.browserVersion&&e.jsxs("div",{children:[e.jsx("dt",{children:"Browser"}),e.jsx("dd",{className:"text-xs",children:s.browserVersion})]}),s?.targets&&s.targets.length>0&&e.jsxs("div",{children:[e.jsx("dt",{children:"Tabs"}),e.jsx("dd",{children:s.targets.map(a=>e.jsxs("span",{className:"mr-2",children:[a.name,": ",a.alive?"● alive":"○ idle"]},a.name))})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:s?.connected?"Connected to Chrome via CDP. Launch Chrome with --remote-debugging-port to use this provider.":o||"Not configured. Set an endpoint below or run: canonry cdp connect --host localhost --port 9222"}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!u),children:u?"Cancel":s?.connected?"Update endpoint":"Configure"})}),u&&e.jsxs("form",{className:"mt-3 flex flex-col gap-2",onSubmit:A(async a=>{a.preventDefault(),p(!0);try{await z(d,parseInt(c,10)||9222);const l=await F().catch(()=>null);l&&m(l),r(!1),B({title:"CDP endpoint saved",detail:`${d}:${parseInt(c,10)||9222} is now configured.`,tone:"positive",dedupeKey:"settings:cdp",dedupeMode:"replace"})}catch(l){j(l instanceof Error?l.message:String(l))}finally{p(!1)}}),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"localhost",value:d,onChange:a=>x(a.target.value),"aria-label":"CDP host"}),e.jsx("input",{className:"w-24 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"9222",value:c,onChange:a=>g(a.target.value),"aria-label":"CDP port"})]}),e.jsx("div",{children:e.jsx(f,{type:"submit",size:"sm",disabled:h,children:h?"Saving…":"Save endpoint"})})]})]})}const Z={apiStatus:{state:"checking",detail:"Checking service health"},workerStatus:{state:"checking",detail:"Checking service health"}};function le(){const s=Q(),{dashboard:m}=V(),o=m?.settings??s?.dashboard?.settings,r=W(!s,s?.health).data??s?.health??Z,[d,x]=n.useState(null),[c,g]=n.useState(!1),[h,p]=n.useState(!1),[a,l]=n.useState(""),[v,N]=n.useState(!1),[S,C]=n.useState(null),[k,w]=n.useState(!1);return o?e.jsxs("div",{className:"page-container",children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"page-subtitle",children:"Provider state, Google OAuth, Bing WMT setup, and service health."})]})}),e.jsxs("section",{className:"settings-grid",children:[o.providerStatuses.map(t=>e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Provider"}),e.jsx("h2",{children:t.displayName??t.name})]}),e.jsx(y,{tone:t.state==="ready"?"positive":"caution",children:t.state==="ready"?"Ready":"Needs config"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsxs("dd",{className:"font-mono text-xs",children:[t.model??t.defaultModel??"unknown",!t.model&&t.defaultModel&&e.jsx("span",{className:"ml-1 font-sans text-muted",children:"(default)"})]})]}),t.quota&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Concurrency"}),e.jsx("dd",{children:t.quota.maxConcurrency})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Rate limit"}),e.jsxs("dd",{children:[t.quota.maxRequestsPerMinute,"/min · ",t.quota.maxRequestsPerDay,"/day"]})]})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:t.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>x(d===t.name?null:t.name),children:d===t.name?"Cancel":t.state==="ready"?t.name.toLowerCase()==="local"?"Update config":"Update key":"Configure"})}),d===t.name&&e.jsx(J,{providerName:t.name,keyUrl:t.keyUrl,modelHint:t.modelHint,onSaved:()=>{x(null)}})]},t.name)),e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Google"}),e.jsx("h2",{children:"Search Console OAuth"})]}),e.jsx(y,{tone:o.google.state==="ready"?"positive":"caution",children:o.google.state==="ready"?"Ready":"Needs config"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"One app credential set, then one OAuth connection per project domain"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:o.google.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>g(!c),children:c?"Cancel":o.google.state==="ready"?"Update OAuth app":"Configure Google OAuth"})}),c&&e.jsx(X,{onSaved:()=>{g(!1)}})]}),e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Bing"}),e.jsx("h2",{children:"Webmaster Tools"})]}),e.jsx(y,{tone:o.bing.state==="ready"?"positive":"caution",children:o.bing.state==="ready"?"Ready":"Needs config"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"API key authentication — no OAuth needed"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:o.bing.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>p(!h),children:h?"Cancel":o.bing.state==="ready"?"Update API key":"Configure Bing"})}),h&&e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:"bing-api-key",children:"API Key"}),e.jsx("a",{href:"https://www.bing.com/webmasters/",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted hover:text-neutral underline underline-offset-2",children:"Bing Webmaster Tools"})]}),e.jsx("input",{id:"bing-api-key",type:"password",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Bing Webmaster Tools API key",value:a,onChange:t=>l(t.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-muted",children:["This key is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"}),". Project-level Bing connections are created separately per canonical domain."]}),S&&e.jsx("p",{className:"text-xs text-negative-400",children:S}),k&&e.jsx("p",{className:"text-xs text-positive-400",children:"Bing API key updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!a.trim()||v,onClick:A(async()=>{if(a.trim()){N(!0),C(null),w(!1);try{await _(a.trim()),l(""),w(!0),p(!1),B({title:"Bing API key updated",detail:"Dashboard Bing credentials were saved.",tone:"positive",dedupeKey:"settings:bing",dedupeMode:"replace"})}catch(t){C(t instanceof Error?t.message:"Failed to update Bing API key")}finally{N(!1)}}}),children:v?"Saving...":"Save Bing API key"})]})]}),e.jsx(Y,{}),e.jsxs(b,{className:"surface-card",children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Service health"}),e.jsx("h2",{children:"API and worker"})]})}),e.jsxs("div",{className:"compact-stack",children:[e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"API"}),e.jsx("p",{className:"supporting-copy",children:r.apiStatus.detail})]}),e.jsx(y,{tone:K(r.apiStatus),title:T(r.apiStatus),children:r.apiStatus.state==="ok"?"Healthy":"Attention"})]}),e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"Worker"}),e.jsx("p",{className:"supporting-copy",children:r.workerStatus.detail})]}),e.jsx(y,{tone:K(r.workerStatus),title:T(r.workerStatus),children:r.workerStatus.state==="ok"?"Healthy":"Attention"})]})]})]})]}),e.jsx("section",{className:"page-section",children:e.jsxs(b,{className:"surface-card",children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Self-host notes"}),e.jsx("h2",{children:"Operational guidance"})]})}),e.jsx("ul",{className:"detail-list",children:o.selfHostNotes.map(t=>e.jsx("li",{children:t},t))}),e.jsx("p",{className:"supporting-copy",children:o.bootstrapNote})]})})]}):null}export{le as SettingsPage};
1
+ import{r as n,j as e}from"./vendor-tanstack-Be8JdV5M.js";import{B as f,i as A,bM as H,M as B,bN as q,bO as F,g as b,T as y,bP as z,ba as Q,bJ as V,bQ as W,bR as _,bS as T,bT as K}from"./index-BZnlypko.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-recharts-C9EZkgbP.js";import"./vendor-markdown-6dwjPOKK.js";function J({providerName:s,keyUrl:m,modelHint:o,onSaved:j}){const u=s.toLowerCase()==="local",[r,d]=n.useState(""),[x,c]=n.useState(""),[g,h]=n.useState(""),[p,a]=n.useState(""),[l,v]=n.useState(""),[N,S]=n.useState(""),[C,k]=n.useState(!1),[w,t]=n.useState(null),[L,M]=n.useState(!1),O=u?x.trim().length>0:r.trim().length>0;async function R(){if(O){k(!0),t(null),M(!1);try{const i=$=>{const I=parseInt($.trim(),10);return Number.isFinite(I)&&I>0?I:void 0},P={},D=i(p);D!==void 0&&(P.maxConcurrency=D);const G=i(l);G!==void 0&&(P.maxRequestsPerMinute=G);const E=i(N);E!==void 0&&(P.maxRequestsPerDay=E),await H(s.toLowerCase(),{...r.trim()?{apiKey:r.trim()}:{},...x.trim()?{baseUrl:x.trim()}:{},...g.trim()?{model:g.trim()}:{},...Object.keys(P).length>0?{quota:P}:{}}),d(""),c(""),h(""),a(""),v(""),S(""),M(!0),B({title:"Provider updated",detail:`${s} configuration saved.`,tone:"positive",dedupeKey:`settings:provider:${s}`,dedupeMode:"replace"}),j()}catch(i){t(i instanceof Error?i.message:"Failed to update provider")}finally{k(!1)}}}const U=o??"Use default model";return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[u&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:`base-url-${s}`,children:"Base URL"}),e.jsx("input",{id:`base-url-${s}`,type:"text",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"http://localhost:11434/v1",value:x,onChange:i=>c(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Any OpenAI-compatible endpoint — Ollama, LM Studio, llama.cpp, vLLM"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-xs text-muted",htmlFor:`api-key-${s}`,children:["API Key",u?" (optional)":""]}),m&&e.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted hover:text-neutral underline underline-offset-2",children:["Get API key ","↗"]})]}),e.jsx("input",{id:`api-key-${s}`,type:"password",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:u?"Optional — most local servers don't need one":`Enter ${s} API key`,value:r,onChange:i=>d(i.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:`model-${s}`,children:"Model (optional)"}),e.jsx("input",{id:`model-${s}`,type:"text",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:U,value:g,onChange:i=>h(i.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",children:"Quota (optional)"}),e.jsxs("div",{className:"mt-0.5 grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Concurrent",value:p,onChange:i=>a(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Max concurrent"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"/min",value:l,onChange:i=>v(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Per minute"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"/day",value:N,onChange:i=>S(i.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-faint",children:"Per day"})]})]})]}),w&&e.jsx("p",{className:"text-xs text-negative-400",children:w}),L&&e.jsx("p",{className:"text-xs text-positive-400",children:"Provider updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!O||C,onClick:A(R),children:C?"Saving...":"Save"})]})}function X({onSaved:s}){const[m,o]=n.useState(""),[j,u]=n.useState(""),[r,d]=n.useState(!1),[x,c]=n.useState(null),[g,h]=n.useState(!1),p=m.trim().length>0&&j.trim().length>0;async function a(){if(p){d(!0),c(null),h(!1);try{await q({clientId:m.trim(),clientSecret:j.trim()}),o(""),u(""),h(!0),B({title:"Google OAuth app updated",detail:"Dashboard Google credentials were saved.",tone:"positive",dedupeKey:"settings:google-oauth",dedupeMode:"replace"}),s()}catch(l){c(l instanceof Error?l.message:"Failed to update Google OAuth credentials")}finally{d(!1)}}}return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:"google-client-id",children:"Client ID"}),e.jsxs("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted hover:text-neutral underline underline-offset-2",children:["Google Cloud ","↗"]})]}),e.jsx("input",{id:"google-client-id",type:"text",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Google OAuth client ID",value:m,onChange:l=>o(l.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:"google-client-secret",children:"Client secret"}),e.jsx("input",{id:"google-client-secret",type:"password",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Google OAuth client secret",value:j,onChange:l=>u(l.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-muted",children:["These credentials are stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"}),". Project-level Search Console connections are created separately per canonical domain."]}),x&&e.jsx("p",{className:"text-xs text-negative-400",children:x}),g&&e.jsx("p",{className:"text-xs text-positive-400",children:"Google OAuth credentials updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!p||r,onClick:A(a),children:r?"Saving...":"Save Google OAuth app"})]})}function Y(){const[s,m]=n.useState(null),[o,j]=n.useState(null),[u,r]=n.useState(!1),[d,x]=n.useState("localhost"),[c,g]=n.useState("9222"),[h,p]=n.useState(!1);return n.useEffect(()=>{F().then(m).catch(a=>{const l=a instanceof Error?a.message:String(a);l.includes("501")||j(l)})},[]),e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Browser provider"}),e.jsx("h2",{children:"ChatGPT (CDP)"})]}),e.jsx(y,{tone:s?.connected?"positive":"caution",children:s?.connected?"Connected":"Not connected"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[s?.endpoint&&e.jsxs("div",{children:[e.jsx("dt",{children:"Endpoint"}),e.jsx("dd",{className:"font-mono text-xs",children:s.endpoint})]}),s?.browserVersion&&e.jsxs("div",{children:[e.jsx("dt",{children:"Browser"}),e.jsx("dd",{className:"text-xs",children:s.browserVersion})]}),s?.targets&&s.targets.length>0&&e.jsxs("div",{children:[e.jsx("dt",{children:"Tabs"}),e.jsx("dd",{children:s.targets.map(a=>e.jsxs("span",{className:"mr-2",children:[a.name,": ",a.alive?"● alive":"○ idle"]},a.name))})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:s?.connected?"Connected to Chrome via CDP. Launch Chrome with --remote-debugging-port to use this provider.":o||"Not configured. Set an endpoint below or run: canonry cdp connect --host localhost --port 9222"}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!u),children:u?"Cancel":s?.connected?"Update endpoint":"Configure"})}),u&&e.jsxs("form",{className:"mt-3 flex flex-col gap-2",onSubmit:A(async a=>{a.preventDefault(),p(!0);try{await z(d,parseInt(c,10)||9222);const l=await F().catch(()=>null);l&&m(l),r(!1),B({title:"CDP endpoint saved",detail:`${d}:${parseInt(c,10)||9222} is now configured.`,tone:"positive",dedupeKey:"settings:cdp",dedupeMode:"replace"})}catch(l){j(l instanceof Error?l.message:String(l))}finally{p(!1)}}),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"localhost",value:d,onChange:a=>x(a.target.value),"aria-label":"CDP host"}),e.jsx("input",{className:"w-24 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"9222",value:c,onChange:a=>g(a.target.value),"aria-label":"CDP port"})]}),e.jsx("div",{children:e.jsx(f,{type:"submit",size:"sm",disabled:h,children:h?"Saving…":"Save endpoint"})})]})]})}const Z={apiStatus:{state:"checking",detail:"Checking service health"},workerStatus:{state:"checking",detail:"Checking service health"}};function le(){const s=Q(),{dashboard:m}=V(),o=m?.settings??s?.dashboard?.settings,r=W(!s,s?.health).data??s?.health??Z,[d,x]=n.useState(null),[c,g]=n.useState(!1),[h,p]=n.useState(!1),[a,l]=n.useState(""),[v,N]=n.useState(!1),[S,C]=n.useState(null),[k,w]=n.useState(!1);return o?e.jsxs("div",{className:"page-container",children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"page-subtitle",children:"Provider state, Google OAuth, Bing WMT setup, and service health."})]})}),e.jsxs("section",{className:"settings-grid",children:[o.providerStatuses.map(t=>e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Provider"}),e.jsx("h2",{children:t.displayName??t.name})]}),e.jsx(y,{tone:t.state==="ready"?"positive":"caution",children:t.state==="ready"?"Ready":"Needs config"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsxs("dd",{className:"font-mono text-xs",children:[t.model??t.defaultModel??"unknown",!t.model&&t.defaultModel&&e.jsx("span",{className:"ml-1 font-sans text-muted",children:"(default)"})]})]}),t.quota&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Concurrency"}),e.jsx("dd",{children:t.quota.maxConcurrency})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Rate limit"}),e.jsxs("dd",{children:[t.quota.maxRequestsPerMinute,"/min · ",t.quota.maxRequestsPerDay,"/day"]})]})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:t.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>x(d===t.name?null:t.name),children:d===t.name?"Cancel":t.state==="ready"?t.name.toLowerCase()==="local"?"Update config":"Update key":"Configure"})}),d===t.name&&e.jsx(J,{providerName:t.name,keyUrl:t.keyUrl,modelHint:t.modelHint,onSaved:()=>{x(null)}})]},t.name)),e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Google"}),e.jsx("h2",{children:"Search Console OAuth"})]}),e.jsx(y,{tone:o.google.state==="ready"?"positive":"caution",children:o.google.state==="ready"?"Ready":"Needs config"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"One app credential set, then one OAuth connection per project domain"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:o.google.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>g(!c),children:c?"Cancel":o.google.state==="ready"?"Update OAuth app":"Configure Google OAuth"})}),c&&e.jsx(X,{onSaved:()=>{g(!1)}})]}),e.jsxs(b,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Bing"}),e.jsx("h2",{children:"Webmaster Tools"})]}),e.jsx(y,{tone:o.bing.state==="ready"?"positive":"caution",children:o.bing.state==="ready"?"Ready":"Needs config"})]}),e.jsxs("dl",{className:"definition-list mt-3",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"API key authentication — no OAuth needed"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]}),e.jsx("p",{className:"mt-2 text-sm text-muted",children:o.bing.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>p(!h),children:h?"Cancel":o.bing.state==="ready"?"Update API key":"Configure Bing"})}),h&&e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs text-muted",htmlFor:"bing-api-key",children:"API Key"}),e.jsx("a",{href:"https://www.bing.com/webmasters/",target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted hover:text-neutral underline underline-offset-2",children:"Bing Webmaster Tools"})]}),e.jsx("input",{id:"bing-api-key",type:"password",className:"mt-0.5 w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:"Bing Webmaster Tools API key",value:a,onChange:t=>l(t.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-muted",children:["This key is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"}),". Project-level Bing connections are created separately per canonical domain."]}),S&&e.jsx("p",{className:"text-xs text-negative-400",children:S}),k&&e.jsx("p",{className:"text-xs text-positive-400",children:"Bing API key updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!a.trim()||v,onClick:A(async()=>{if(a.trim()){N(!0),C(null),w(!1);try{await _(a.trim()),l(""),w(!0),p(!1),B({title:"Bing API key updated",detail:"Dashboard Bing credentials were saved.",tone:"positive",dedupeKey:"settings:bing",dedupeMode:"replace"})}catch(t){C(t instanceof Error?t.message:"Failed to update Bing API key")}finally{N(!1)}}}),children:v?"Saving...":"Save Bing API key"})]})]}),e.jsx(Y,{}),e.jsxs(b,{className:"surface-card",children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Service health"}),e.jsx("h2",{children:"API and worker"})]})}),e.jsxs("div",{className:"compact-stack",children:[e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"API"}),e.jsx("p",{className:"supporting-copy",children:r.apiStatus.detail})]}),e.jsx(y,{tone:K(r.apiStatus),title:T(r.apiStatus),children:r.apiStatus.state==="ok"?"Healthy":"Attention"})]}),e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"Worker"}),e.jsx("p",{className:"supporting-copy",children:r.workerStatus.detail})]}),e.jsx(y,{tone:K(r.workerStatus),title:T(r.workerStatus),children:r.workerStatus.state==="ok"?"Healthy":"Attention"})]})]})]})]}),e.jsx("section",{className:"page-section",children:e.jsxs(b,{className:"surface-card",children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Self-host notes"}),e.jsx("h2",{children:"Operational guidance"})]})}),e.jsx("ul",{className:"detail-list",children:o.selfHostNotes.map(t=>e.jsx("li",{children:t},t))}),e.jsx("p",{className:"supporting-copy",children:o.bootstrapNote})]})})]}):null}export{le as SettingsPage};
@@ -1 +1 @@
1
- import{r as c,j as e,h as R,u as L,f as U,L as E}from"./vendor-tanstack-Be8JdV5M.js";import{c as I,b$ as $,c0 as B,c1 as q,c2 as A,c3 as F,c4 as O,B as C,i as z,c5 as H,bb as W,l as D,c6 as P,g as w,c7 as _,T as G,c8 as M}from"./index-DB_F_WFv.js";import{a as J,b as Q,c as K,d as T,f as Z,t as Y,R as X}from"./extract-error-message-b-rZowjX.js";import{A as ee}from"./arrow-left-CeWmJYLI.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-recharts-C9EZkgbP.js";import"./vendor-markdown-6dwjPOKK.js";const te=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],re=I("cloud",te);const se=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],ne=I("triangle",se);function oe({open:t,onOpenChange:a,projectName:n}){const[s,r]=c.useState("pick");c.useEffect(()=>{t&&r("pick")},[t]);const o=()=>{a(!1),r("pick")};return e.jsx($,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(B,{children:s==="pick"?e.jsx(ie,{onPick:r}):s==="wordpress"?e.jsx(de,{projectName:n,onBack:()=>r("pick"),onClose:o}):s==="vercel"?e.jsx(pe,{projectName:n,onBack:()=>r("pick"),onClose:o}):e.jsx(ue,{projectName:n,onBack:()=>r("pick"),onClose:o})})})}const ae=[{type:"wordpress",name:"WordPress site",tagline:"Easiest if you run WordPress",description:"Install the Canonry Traffic Logger plugin and connect with an Application Password. No cloud account needed.",icon:O},{type:"cloud-run",name:"Google Cloud Run",tagline:"For apps hosted on Cloud Run",description:"Connect a Google Cloud service account so Canonry can read your Cloud Run request logs.",icon:re},{type:"vercel",name:"Vercel project",tagline:"For sites hosted on Vercel",description:"Connect a Vercel personal access token so Canonry can pull request logs straight from Vercel, no in-app instrumentation needed.",icon:ne}];function ie({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(q,{children:[e.jsx(A,{children:"Connect a traffic source"}),e.jsx(F,{children:"Canonry reads your server logs to see when AI crawlers and AI-referred visitors hit your site. Pick where your site is hosted to get started."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:ae.map(({type:a,name:n,tagline:s,description:r,icon:o})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-start gap-4 rounded-lg border border-base bg-bg-elevated/30 p-4 text-left transition-colors hover:border-mono-600 hover:bg-bg-elevated/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-base bg-bg text-neutral group-hover:text-heading",children:e.jsx(o,{className:"size-4"})}),e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-heading",children:n}),e.jsx("span",{className:"text-[11px] text-muted",children:s})]}),e.jsx("span",{className:"text-xs leading-5 text-muted",children:r})]})]},a))})]})}function le({title:t,description:a,onBack:n}){return e.jsxs(q,{children:[e.jsxs("button",{type:"button",onClick:n,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-xs text-muted transition-colors hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(A,{children:t}),e.jsx(F,{children:a})]})}function ce(t,a){const n=R();return async(s,r)=>{await H(t,s),r?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:s}})}}function S(t,a){const[n,s]=c.useState(null),r=ce(t,a);return{error:n,runConnect:async i=>{s(null);const d=i.validate();if(d){s(d);return}let u;try{u=await i.mutate()}catch(l){s(T(l));return}try{await r(u.id,i.onConnected)}catch(l){s(`Source connected, but starting the initial backfill failed: ${T(l)}`)}}}}function k({title:t,description:a,projectName:n,onBack:s,onClose:r,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(le,{title:t,description:a,onBack:s}),e.jsxs("form",{onSubmit:z(async l=>{l.preventDefault(),await o()}),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[e.jsx(p,{label:"Project",description:"Canonry project this source attaches to.",children:e.jsx("input",{type:"text",value:n,disabled:!0,className:"w-full rounded border border-strong bg-bg-elevated/50 px-2 py-1.5 text-sm text-neutral"})}),u,d?e.jsx("p",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-default pt-4",children:[e.jsx(C,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Close"}),e.jsx(C,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function de({projectName:t,onBack:a,onClose:n}){const[s,r]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),f=J(t||null),{error:g,runConnect:b}=S(t,n),y=()=>b({validate:()=>s.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:s.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:l.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(k,{title:"Connect a WordPress site",description:e.jsxs(e.Fragment,{children:["Pulls request events from the Canonry Traffic Logger plugin. The Application Password is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:y,isPending:f.isPending,error:g,children:[e.jsx(p,{label:"WordPress site URL",description:"Base URL of the site running the Canonry Traffic Logger plugin.",required:!0,children:e.jsx("input",{type:"url",value:s,onChange:x=>r(x.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Username",description:"WordPress user that owns the Application Password.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Application Password",description:"Create one in wp-admin under Users -> Profile -> Application Passwords.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:x=>u(x.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the WordPress host.",children:e.jsx("input",{type:"text",value:l,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function ue({projectName:t,onBack:a,onClose:n}){const[s,r]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),[f,g]=c.useState(""),b=K(t||null),{error:y,runConnect:x}=S(t,n),N=()=>x({validate:()=>s.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:s.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:l.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async m=>{if(!m)return;const V=await m.text();g(V)};return e.jsxs(k,{title:"Connect a Cloud Run service",description:e.jsxs(e.Fragment,{children:["v1 supports service-account JSON only. The private key is stored in"," ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:N,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"GCP project ID",description:"The Google Cloud project hosting the Cloud Run service (e.g. my-prod-foo).",required:!0,children:e.jsx("input",{type:"text",value:s,onChange:m=>r(m.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Service name (optional)",description:"Restrict log pulls to a specific Cloud Run service. Omit to pull all services in the project.",children:e.jsx("input",{type:"text",value:o,onChange:m=>i(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Location (optional)",description:"Region of the Cloud Run service (e.g. us-central1). Helpful when multiple regions emit logs.",children:e.jsx("input",{type:"text",value:d,onChange:m=>u(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the project + service combo.",children:e.jsx("input",{type:"text",value:l,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsxs(p,{label:"Service-account JSON",description:"Paste the contents of the SA key (JSON). The SA needs roles/logging.viewer (or any role granting logging.logEntries.list).",required:!0,children:[e.jsx("textarea",{value:f,onChange:m=>g(m.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 font-mono text-[11px] text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:'{"type":"service_account","project_id":"…","private_key":"…"}',required:!0}),e.jsxs("label",{className:"mt-2 inline-flex cursor-pointer items-center gap-2 text-xs text-secondary hover:text-strong",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:m=>{h(m.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-base px-2 py-1",children:"Or upload a key file"})]})]})]})}function pe({projectName:t,onBack:a,onClose:n}){const[s,r]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState("production"),[f,g]=c.useState(""),b=Q(t||null),{error:y,runConnect:x}=S(t,n),N=()=>x({validate:()=>s.trim()?o.trim()?d.trim()?null:"Vercel personal access token is required.":"Vercel team / account ID is required.":"Vercel project ID is required.",mutate:()=>b.mutateAsync({projectId:s.trim(),teamId:o.trim(),token:d.trim(),environment:l,displayName:f.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(k,{title:"Connect a Vercel project",description:e.jsxs(e.Fragment,{children:["Pulls request logs straight from Vercel, no in-app instrumentation needed. The personal access token is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:N,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"Vercel project ID",description:"The prj_… id from the Vercel dashboard or .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:s,onChange:h=>r(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Vercel team / account ID",description:"The Vercel team or personal account that owns the project. Find it as orgId in your .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Personal access token",description:"Create a Vercel personal access token under Account Settings → Tokens. Tokens can expire, so use a long-lived one.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:h=>u(h.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:l,onChange:h=>j(h.target.value),className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong focus:border-mono-500 focus:outline-none",children:[e.jsx("option",{value:"production",children:"production"}),e.jsx("option",{value:"preview",children:"preview"})]})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the Vercel project ID.",children:e.jsx("input",{type:"text",value:f,onChange:h=>g(h.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function p({label:t,description:a,required:n,children:s}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-xs font-medium text-strong",children:[t,n?e.jsx("span",{className:"ml-1 text-negative-400",children:"*"}):null]}),s,e.jsx("span",{className:"text-[11px] text-muted",children:a})]})}function me(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function Ce(){const[t,a]=c.useState(""),[n,s]=c.useState(!1),o=L(W({client:D})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=Z(i||null),u=d.data?.sources??[];return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Server traffic"}),e.jsx("p",{className:"page-subtitle",children:"Bulk crawler hits, AI user fetches (ChatGPT-User, Perplexity-User), and AI referral sessions pulled directly from your server logs. Independent of GA — useful when you need server-side evidence that an AI engine actually hit a page."})]}),e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>s(!0),disabled:!i,children:[e.jsx(P,{className:"size-3.5"}),"Connect a source"]})})]}),e.jsxs("section",{children:[e.jsx("div",{className:"filter-row",role:"toolbar","aria-label":"Project picker",children:o.map(l=>e.jsx("button",{type:"button",className:`filter-chip ${i===l.name?"filter-chip-active":""}`,"aria-pressed":i===l.name,onClick:()=>a(l.name),children:l.displayName??l.name},l.id))}),i?d.isLoading?e.jsx(w,{className:"p-6 text-center text-sm text-muted",children:"Loading sources…"}):u.length===0?e.jsxs(w,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-neutral",children:["No traffic sources connected for ",i,"."]}),e.jsx("p",{className:"mt-1 text-xs text-muted",children:"Connect a traffic source to start ingesting crawler hits and AI-referral sessions from your server logs."}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>s(!0),children:[e.jsx(P,{className:"size-3.5"}),"Connect a source"]})})]}):e.jsx(xe,{projectName:i,sources:u}):e.jsx(w,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),e.jsx(oe,{open:n,onOpenChange:s,projectName:i})]})}function xe({projectName:t,sources:a}){const n=U({queries:a.map(r=>({..._({client:D,path:{name:t,id:r.id}}),staleTime:3e4}))}),s=a.map((r,o)=>({source:r,detail:n[o]?.data,isLoading:n[o]?.isLoading??!1}));return e.jsxs("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Source"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Last sync"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h content"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h infra"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h AI hits"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h AI sessions"}),e.jsx("th",{className:"px-4 py-2 text-right"})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:s.map(({source:r,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-heading",children:r.displayName}),e.jsxs("div",{className:"text-[11px] text-muted font-mono",children:[r.sourceType," · ",r.id.slice(0,8)]})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(G,{tone:Y(r.status),children:r.status}),r.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-[11px] text-negative-400/80",title:r.lastError,children:r.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-neutral",children:me(r.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",title:o?`${o.totals24h.crawlerHits.toLocaleString("en-US")} total crawler hits`:void 0,children:i?"—":v(o?.totals24h.crawlerContentHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-muted",children:i?"—":v(o?.totals24h.crawlerInfraHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiReferralHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(E,{to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r.id},className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-heading",children:[e.jsx(X,{className:"size-3"}),"View"]})})]},r.id))})]}),e.jsxs("p",{className:"border-t border-default px-4 py-2 text-[11px] text-faint",children:["Showing ",a.filter(r=>r.status!==M.archived).length," active source",a.length===1?"":"s"," for ",t,". Same shape as ",e.jsxs("code",{className:"text-secondary",children:["canonry traffic status ",t," --format json"]}),"."]})]})}export{Ce as TrafficPage};
1
+ import{r as c,j as e,h as R,u as L,f as U,L as E}from"./vendor-tanstack-Be8JdV5M.js";import{c as I,b$ as $,c0 as B,c1 as q,c2 as A,c3 as F,c4 as O,B as C,i as z,c5 as H,bb as W,l as D,c6 as P,g as w,c7 as _,T as G,c8 as M}from"./index-BZnlypko.js";import{a as J,b as Q,c as K,d as T,f as Z,t as Y,R as X}from"./extract-error-message-ClFtdJwM.js";import{A as ee}from"./arrow-left-CAIQypB3.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-recharts-C9EZkgbP.js";import"./vendor-markdown-6dwjPOKK.js";const te=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],re=I("cloud",te);const se=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],ne=I("triangle",se);function oe({open:t,onOpenChange:a,projectName:n}){const[s,r]=c.useState("pick");c.useEffect(()=>{t&&r("pick")},[t]);const o=()=>{a(!1),r("pick")};return e.jsx($,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(B,{children:s==="pick"?e.jsx(ie,{onPick:r}):s==="wordpress"?e.jsx(de,{projectName:n,onBack:()=>r("pick"),onClose:o}):s==="vercel"?e.jsx(pe,{projectName:n,onBack:()=>r("pick"),onClose:o}):e.jsx(ue,{projectName:n,onBack:()=>r("pick"),onClose:o})})})}const ae=[{type:"wordpress",name:"WordPress site",tagline:"Easiest if you run WordPress",description:"Install the Canonry Traffic Logger plugin and connect with an Application Password. No cloud account needed.",icon:O},{type:"cloud-run",name:"Google Cloud Run",tagline:"For apps hosted on Cloud Run",description:"Connect a Google Cloud service account so Canonry can read your Cloud Run request logs.",icon:re},{type:"vercel",name:"Vercel project",tagline:"For sites hosted on Vercel",description:"Connect a Vercel personal access token so Canonry can pull request logs straight from Vercel, no in-app instrumentation needed.",icon:ne}];function ie({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(q,{children:[e.jsx(A,{children:"Connect a traffic source"}),e.jsx(F,{children:"Canonry reads your server logs to see when AI crawlers and AI-referred visitors hit your site. Pick where your site is hosted to get started."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:ae.map(({type:a,name:n,tagline:s,description:r,icon:o})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-start gap-4 rounded-lg border border-base bg-bg-elevated/30 p-4 text-left transition-colors hover:border-mono-600 hover:bg-bg-elevated/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-base bg-bg text-neutral group-hover:text-heading",children:e.jsx(o,{className:"size-4"})}),e.jsxs("span",{className:"flex flex-col gap-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2",children:[e.jsx("span",{className:"text-sm font-medium text-heading",children:n}),e.jsx("span",{className:"text-[11px] text-muted",children:s})]}),e.jsx("span",{className:"text-xs leading-5 text-muted",children:r})]})]},a))})]})}function le({title:t,description:a,onBack:n}){return e.jsxs(q,{children:[e.jsxs("button",{type:"button",onClick:n,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-xs text-muted transition-colors hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(A,{children:t}),e.jsx(F,{children:a})]})}function ce(t,a){const n=R();return async(s,r)=>{await H(t,s),r?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:s}})}}function S(t,a){const[n,s]=c.useState(null),r=ce(t,a);return{error:n,runConnect:async i=>{s(null);const d=i.validate();if(d){s(d);return}let u;try{u=await i.mutate()}catch(l){s(T(l));return}try{await r(u.id,i.onConnected)}catch(l){s(`Source connected, but starting the initial backfill failed: ${T(l)}`)}}}}function k({title:t,description:a,projectName:n,onBack:s,onClose:r,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(le,{title:t,description:a,onBack:s}),e.jsxs("form",{onSubmit:z(async l=>{l.preventDefault(),await o()}),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[e.jsx(p,{label:"Project",description:"Canonry project this source attaches to.",children:e.jsx("input",{type:"text",value:n,disabled:!0,className:"w-full rounded border border-strong bg-bg-elevated/50 px-2 py-1.5 text-sm text-neutral"})}),u,d?e.jsx("p",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-default pt-4",children:[e.jsx(C,{type:"button",variant:"ghost",size:"sm",onClick:r,children:"Close"}),e.jsx(C,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function de({projectName:t,onBack:a,onClose:n}){const[s,r]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),f=J(t||null),{error:g,runConnect:b}=S(t,n),y=()=>b({validate:()=>s.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:s.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:l.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(k,{title:"Connect a WordPress site",description:e.jsxs(e.Fragment,{children:["Pulls request events from the Canonry Traffic Logger plugin. The Application Password is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:y,isPending:f.isPending,error:g,children:[e.jsx(p,{label:"WordPress site URL",description:"Base URL of the site running the Canonry Traffic Logger plugin.",required:!0,children:e.jsx("input",{type:"url",value:s,onChange:x=>r(x.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Username",description:"WordPress user that owns the Application Password.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Application Password",description:"Create one in wp-admin under Users -> Profile -> Application Passwords.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:x=>u(x.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the WordPress host.",children:e.jsx("input",{type:"text",value:l,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function ue({projectName:t,onBack:a,onClose:n}){const[s,r]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),[f,g]=c.useState(""),b=K(t||null),{error:y,runConnect:x}=S(t,n),N=()=>x({validate:()=>s.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:s.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:l.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async m=>{if(!m)return;const V=await m.text();g(V)};return e.jsxs(k,{title:"Connect a Cloud Run service",description:e.jsxs(e.Fragment,{children:["v1 supports service-account JSON only. The private key is stored in"," ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:N,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"GCP project ID",description:"The Google Cloud project hosting the Cloud Run service (e.g. my-prod-foo).",required:!0,children:e.jsx("input",{type:"text",value:s,onChange:m=>r(m.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Service name (optional)",description:"Restrict log pulls to a specific Cloud Run service. Omit to pull all services in the project.",children:e.jsx("input",{type:"text",value:o,onChange:m=>i(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Location (optional)",description:"Region of the Cloud Run service (e.g. us-central1). Helpful when multiple regions emit logs.",children:e.jsx("input",{type:"text",value:d,onChange:m=>u(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the project + service combo.",children:e.jsx("input",{type:"text",value:l,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsxs(p,{label:"Service-account JSON",description:"Paste the contents of the SA key (JSON). The SA needs roles/logging.viewer (or any role granting logging.logEntries.list).",required:!0,children:[e.jsx("textarea",{value:f,onChange:m=>g(m.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 font-mono text-[11px] text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:'{"type":"service_account","project_id":"…","private_key":"…"}',required:!0}),e.jsxs("label",{className:"mt-2 inline-flex cursor-pointer items-center gap-2 text-xs text-secondary hover:text-strong",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:m=>{h(m.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-base px-2 py-1",children:"Or upload a key file"})]})]})]})}function pe({projectName:t,onBack:a,onClose:n}){const[s,r]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState("production"),[f,g]=c.useState(""),b=Q(t||null),{error:y,runConnect:x}=S(t,n),N=()=>x({validate:()=>s.trim()?o.trim()?d.trim()?null:"Vercel personal access token is required.":"Vercel team / account ID is required.":"Vercel project ID is required.",mutate:()=>b.mutateAsync({projectId:s.trim(),teamId:o.trim(),token:d.trim(),environment:l,displayName:f.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(k,{title:"Connect a Vercel project",description:e.jsxs(e.Fragment,{children:["Pulls request logs straight from Vercel, no in-app instrumentation needed. The personal access token is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:N,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"Vercel project ID",description:"The prj_… id from the Vercel dashboard or .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:s,onChange:h=>r(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Vercel team / account ID",description:"The Vercel team or personal account that owns the project. Find it as orgId in your .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Personal access token",description:"Create a Vercel personal access token under Account Settings → Tokens. Tokens can expire, so use a long-lived one.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:h=>u(h.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:l,onChange:h=>j(h.target.value),className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong focus:border-mono-500 focus:outline-none",children:[e.jsx("option",{value:"production",children:"production"}),e.jsx("option",{value:"preview",children:"preview"})]})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the Vercel project ID.",children:e.jsx("input",{type:"text",value:f,onChange:h=>g(h.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function p({label:t,description:a,required:n,children:s}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-xs font-medium text-strong",children:[t,n?e.jsx("span",{className:"ml-1 text-negative-400",children:"*"}):null]}),s,e.jsx("span",{className:"text-[11px] text-muted",children:a})]})}function me(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function Ce(){const[t,a]=c.useState(""),[n,s]=c.useState(!1),o=L(W({client:D})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=Z(i||null),u=d.data?.sources??[];return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Server traffic"}),e.jsx("p",{className:"page-subtitle",children:"Bulk crawler hits, AI user fetches (ChatGPT-User, Perplexity-User), and AI referral sessions pulled directly from your server logs. Independent of GA — useful when you need server-side evidence that an AI engine actually hit a page."})]}),e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>s(!0),disabled:!i,children:[e.jsx(P,{className:"size-3.5"}),"Connect a source"]})})]}),e.jsxs("section",{children:[e.jsx("div",{className:"filter-row",role:"toolbar","aria-label":"Project picker",children:o.map(l=>e.jsx("button",{type:"button",className:`filter-chip ${i===l.name?"filter-chip-active":""}`,"aria-pressed":i===l.name,onClick:()=>a(l.name),children:l.displayName??l.name},l.id))}),i?d.isLoading?e.jsx(w,{className:"p-6 text-center text-sm text-muted",children:"Loading sources…"}):u.length===0?e.jsxs(w,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-neutral",children:["No traffic sources connected for ",i,"."]}),e.jsx("p",{className:"mt-1 text-xs text-muted",children:"Connect a traffic source to start ingesting crawler hits and AI-referral sessions from your server logs."}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>s(!0),children:[e.jsx(P,{className:"size-3.5"}),"Connect a source"]})})]}):e.jsx(xe,{projectName:i,sources:u}):e.jsx(w,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),e.jsx(oe,{open:n,onOpenChange:s,projectName:i})]})}function xe({projectName:t,sources:a}){const n=U({queries:a.map(r=>({..._({client:D,path:{name:t,id:r.id}}),staleTime:3e4}))}),s=a.map((r,o)=>({source:r,detail:n[o]?.data,isLoading:n[o]?.isLoading??!1}));return e.jsxs("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Source"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Last sync"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h content"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h infra"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h AI hits"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"24h AI sessions"}),e.jsx("th",{className:"px-4 py-2 text-right"})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:s.map(({source:r,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-heading",children:r.displayName}),e.jsxs("div",{className:"text-[11px] text-muted font-mono",children:[r.sourceType," · ",r.id.slice(0,8)]})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(G,{tone:Y(r.status),children:r.status}),r.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-[11px] text-negative-400/80",title:r.lastError,children:r.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-neutral",children:me(r.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",title:o?`${o.totals24h.crawlerHits.toLocaleString("en-US")} total crawler hits`:void 0,children:i?"—":v(o?.totals24h.crawlerContentHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-muted",children:i?"—":v(o?.totals24h.crawlerInfraHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiReferralHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(E,{to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r.id},className:"inline-flex items-center gap-1 text-xs text-neutral hover:text-heading",children:[e.jsx(X,{className:"size-3"}),"View"]})})]},r.id))})]}),e.jsxs("p",{className:"border-t border-default px-4 py-2 text-[11px] text-faint",children:["Showing ",a.filter(r=>r.status!==M.archived).length," active source",a.length===1?"":"s"," for ",t,". Same shape as ",e.jsxs("code",{className:"text-secondary",children:["canonry traffic status ",t," --format json"]}),"."]})]})}export{Ce as TrafficPage};
@@ -1 +1 @@
1
- import{j as e,B as Re,C as $e,r as h,L as Ue}from"./vendor-tanstack-Be8JdV5M.js";import{I as D,c9 as Y,ca as u,T as Ee,B as Fe,g as P,b as Me,cb as He,cc as Pe}from"./index-DB_F_WFv.js";import{g as Oe,h as De,i as _e,t as Be,R as ze,d as Ge}from"./extract-error-message-b-rZowjX.js";import{e as ee,i as Ke,C as le,a as ie,c as We,h as Ve}from"./ChartPrimitives-BjcDtBSv.js";import{R as Ye,B as Xe,a as Qe,X as qe,Y as Ze,T as Je,e as X,f as Q}from"./vendor-recharts-C9EZkgbP.js";import{A as ce}from"./arrow-left-CeWmJYLI.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-markdown-6dwjPOKK.js";function q({value:s,label:a,delta:l,tone:n,description:x,tooltip:i,isNumeric:c=!0,progress:o,providerCoverage:d}){const v=2*Math.PI*48,m=Number.parseInt(s,10),L=typeof o=="number"&&Number.isFinite(o)?Math.min(Math.max(o,0),100)/100:c&&!Number.isNaN(m)?Math.min(m/100,1):.5,j=v*(1-L);return e.jsxs("div",{className:"score-gauge",children:[e.jsxs("div",{className:"gauge-ring-wrapper",children:[e.jsxs("svg",{className:"gauge-ring",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("circle",{className:"gauge-bg",cx:"60",cy:"60",r:48,strokeWidth:6}),e.jsx("circle",{className:`gauge-fill gauge-fill-${n}`,cx:"60",cy:"60",r:48,strokeWidth:6,strokeDasharray:v,strokeDashoffset:j,transform:"rotate(-90 60 60)"})]}),e.jsx("div",{className:"gauge-center",children:e.jsx("span",{className:c?"gauge-value":"gauge-value-text",children:s.split(" / ")[0]})})]}),e.jsxs("p",{className:"gauge-label",children:[a,i&&e.jsx(D,{text:i})]}),e.jsx("p",{className:"gauge-delta",children:l}),d&&e.jsx("p",{className:"gauge-provider-coverage",children:d}),e.jsx("p",{className:"gauge-description",children:x})]})}const et=[{value:"all",label:"All status"},{value:"2xx",label:"2xx success"},{value:"3xx",label:"3xx redirect"},{value:"4xx",label:"4xx client error"},{value:"5xx",label:"5xx server error"}],fe=[{value:"all",label:"All claims"},{value:Y.verified,label:"Verified"},{value:Y.claimed_unverified,label:"Claimed unverified"},{value:Y.unknown_ai_like,label:"Unknown AI-like"}];function tt(s){return s==="all"?null:Number.parseInt(s[0],10)}function pe(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.botId;case u["ai-referral"]:return s.product}}function ge(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.pathNormalized;case u["ai-referral"]:return s.landingPathNormalized}}function st(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.verificationStatus;case u["ai-referral"]:return null}}function be(s,a){if(a==="hour")return s;const l=new Date(s),n=l.getFullYear(),x=String(l.getMonth()+1).padStart(2,"0"),i=String(l.getDate()).padStart(2,"0");return`${n}-${x}-${i}`}function at(s,a,l){const n=a.pathQuery.trim().toLowerCase(),x=tt(a.statusClass);return s.filter(i=>!(a.selectedBucket&&be(i.tsHour,l)!==a.selectedBucket||a.identity&&pe(i)!==a.identity||a.operator&&i.operator!==a.operator||n&&!ge(i).toLowerCase().includes(n)||x!==null&&Math.floor(i.status/100)!==x||a.verification!=="all"&&st(i)!==a.verification))}function rt(s,a){if(!s||typeof s!="object")return null;const l=s.activeTooltipIndex;let n;if(typeof l=="number")n=l;else if(typeof l=="string"&&l!=="")n=Number(l);else return null;return!Number.isInteger(n)||n<0||n>=a.length?null:a[n]?.bucket??null}const _=[{value:60,label:"1h",granularity:"hour",fetchLimit:500},{value:360,label:"6h",granularity:"hour",fetchLimit:500},{value:1440,label:"24h",granularity:"hour",fetchLimit:500},{value:10080,label:"7d",granularity:"hour",fetchLimit:1e3},{value:720*60,label:"30d",granularity:"day",fetchLimit:2e3},{value:2160*60,label:"90d",granularity:"day",fetchLimit:5e3}],oe=_.find(s=>s.label==="24h")??_[2],$=50,ue=ee[0],de=ee[2],xe=ee[1],he=He();function ye(s){const a=new Date(s);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:00`}function nt(s){const a=new Date(`${s}T00:00:00`);return`${a.getMonth()+1}/${a.getDate()}`}function U(s){if(!s)return"never";const a=Date.now()-new Date(s).getTime(),l=Math.floor(a/6e4);if(l<1)return"just now";if(l<60)return`${l}m ago`;const n=Math.floor(l/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function me({canGoBack:s,className:a}){const l="inline-flex items-center gap-1";if(s){const n=()=>{window.history.back()};return e.jsxs("button",{type:"button",onClick:n,className:`${l} ${a??""}`,children:[e.jsx(ce,{className:"size-3"})," Back"]})}return e.jsxs(Ue,{to:"/traffic",className:`${l} ${a??""}`,children:[e.jsx(ce,{className:"size-3"})," All sources"]})}function jt(){const s=Re({strict:!1}),a=s.projectName??"",l=$e(),n=s.sourceId??"",[x,i]=h.useState(oe.value),[c,o]=h.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[d,C]=h.useState(null),[f,v]=h.useState(""),[m,L]=h.useState(""),[j,B]=h.useState(""),[k,z]=h.useState("all"),[T,G]=h.useState("all"),[je,K]=h.useState(1),[te,se]=h.useState(null),[ae,re]=h.useState(null),b=h.useMemo(()=>_.find(t=>t.value===x)??oe,[x]),W=Oe(a||null,n||null),y=De(a||null,{kind:"all",sourceId:n||void 0,sinceMinutes:x,limit:b.fetchLimit}),E=_e(a||null,n||null),r=W.data,N=y.data?.events??[],S=y.data?.totals,F=h.useMemo(()=>N.filter(t=>{switch(t.kind){case u.crawler:return c.has("crawler");case u["ai-user-fetch"]:return c.has("ai-user-fetch");case u["ai-referral"]:return c.has("ai-referral")}}),[N,c]),ve=h.useMemo(()=>{const t=new Set;for(const p of N)t.add(pe(p));return f&&t.add(f),[...t].sort((p,g)=>p.localeCompare(g))},[N,f]),Ne=h.useMemo(()=>{const t=new Set;for(const p of N)t.add(p.operator);return m&&t.add(m),[...t].sort((p,g)=>p.localeCompare(g))},[N,m]),w=h.useMemo(()=>at(F,{selectedBucket:d,identity:f,operator:m,pathQuery:j,statusClass:k,verification:T},b.granularity),[F,d,f,m,j,k,T,b.granularity]);h.useEffect(()=>{K(1)},[F,d,f,m,j,k,T]);const M=Math.max(1,Math.ceil(w.length/$)),H=Math.min(Math.max(1,je),M),R=(H-1)*$,Se=h.useMemo(()=>w.slice(R,R+$),[w,R]),we=w.length>$,Ce=w.length===0?0:R+1,ke=Math.min(R+$,w.length),ne=h.useMemo(()=>d?O(d,b.granularity):null,[d,b.granularity]),I=h.useMemo(()=>lt(N,b.granularity,y.data?.windowStart,y.data?.windowEnd),[N,b.granularity,y.data?.windowStart,y.data?.windowEnd]),V=t=>{o(p=>{const g=new Set(p);return g.has(t)?g.size>1&&g.delete(t):g.add(t),g})},Te=t=>{const p=rt(t,I);p&&C(g=>g===p?null:p)},Ie=()=>{C(null),v(""),L(""),B(""),z("all"),G("all")},Ae=!!(d||f||m||j.trim()||k!=="all"||T!=="all"),Le=async()=>{se(null),re(null);try{const t=await E.mutateAsync({sinceMinutes:60});re(`Pulled ${t.pulledEvents} entries · ${t.crawlerHits} crawler · ${t.aiUserFetchHits} AI user fetch · ${t.aiReferralHits} AI referral · ${t.unknownHits} unknown`)}catch(t){se(Ge(t))}};return!a||!n?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Missing project name or source id in URL."})}):W.isLoading?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Loading source…"})}):W.isError||!r?e.jsxs("div",{className:"page-container",children:[e.jsx("p",{className:"text-sm text-negative",children:"Could not load this source."}),e.jsx(me,{canGoBack:l,className:"mt-2 text-xs text-secondary hover:text-strong"})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx(me,{canGoBack:l,className:"text-xs text-muted hover:text-strong"}),e.jsx("h1",{className:"page-title mt-2",children:r.displayName}),e.jsxs("p",{className:"page-subtitle",children:[r.sourceType," · project ",e.jsx("span",{className:"text-neutral",children:a})," ·",e.jsx("span",{className:"ml-1 font-mono text-secondary",children:r.id})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{tone:Be(r.status),children:r.status}),e.jsxs(Fe,{type:"button",variant:"outline",size:"sm",disabled:E.isPending,onClick:()=>{Le()},children:[e.jsx(ze,{className:`size-3.5 ${E.isPending?"animate-spin":""}`}),E.isPending?"Syncing…":"Sync now"]})]})]}),te?e.jsx("div",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:te}):null,ae?e.jsx("div",{className:"rounded-md border border-positive-800/50 bg-positive-950/30 px-3 py-2 text-xs text-positive-200",children:ae}):null,e.jsxs("section",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(q,{label:"24h content crawls",value:String(r.totals24h.crawlerContentHits),delta:r.lastSyncedAt?`last sync ${U(r.lastSyncedAt)}`:"never synced",tone:r.totals24h.crawlerContentHits>0?"positive":"neutral",description:`Pages crawled — ${r.totals24h.crawlerInfraHits.toLocaleString("en-US")} sitemap/robots/asset fetches excluded.`,tooltip:`Content-page crawls by GPTBot, OAI-SearchBot, PerplexityBot, Googlebot, etc. Infrastructure fetches (sitemap ${r.totals24h.crawlerSegments.sitemap.toLocaleString("en-US")}, robots ${r.totals24h.crawlerSegments.robots.toLocaleString("en-US")}, assets ${r.totals24h.crawlerSegments.asset.toLocaleString("en-US")}) are tracked separately so polling doesn't inflate this number. Total crawler hits: ${r.totals24h.crawlerHits.toLocaleString("en-US")}.`,isNumeric:!0,progress:Math.min(100,Math.round(r.totals24h.crawlerContentHits/1e3*100))}),e.jsx(q,{label:"24h AI user fetches",value:String(r.totals24h.aiUserFetchHits),delta:r.lastSyncedAt?`last sync ${U(r.lastSyncedAt)}`:"never synced",tone:r.totals24h.aiUserFetchHits>0?"positive":"neutral",description:"ChatGPT-User, Perplexity-User — fetches initiated by a real user inside an AI surface (citation click, URL read).",isNumeric:!0,progress:Math.min(100,Math.round(r.totals24h.aiUserFetchHits/1e3*100))}),e.jsx(q,{label:"24h AI referral sessions",value:String(r.totals24h.aiReferralHits),delta:r.lastSyncedAt?`last sync ${U(r.lastSyncedAt)}`:"never synced",tone:r.totals24h.aiReferralHits>0?"positive":"neutral",description:"Browser click-throughs from chatgpt.com, perplexity.ai, etc. (Referer / UTM evidence).",isNumeric:!0,progress:Math.min(100,Math.round(r.totals24h.aiReferralHits/1e3*100))})]}),e.jsxs("section",{children:[e.jsx("p",{className:"mb-4 text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Latest sync run"}),r.latestRun?e.jsxs(P,{className:"p-4 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1.5",children:[e.jsxs("span",{className:"text-heading",children:["Status: ",e.jsx("span",{className:"font-medium",children:r.latestRun.status})]}),e.jsxs("span",{className:"text-muted",children:["Started: ",U(r.latestRun.startedAt)]}),r.latestRun.finishedAt?e.jsxs("span",{className:"text-muted",children:["Finished: ",U(r.latestRun.finishedAt)]}):null,e.jsx("span",{className:"font-mono text-[11px] text-faint",children:r.latestRun.runId})]}),r.latestRun.error?e.jsx("p",{className:"mt-2 rounded border border-negative-900/40 bg-negative-950/30 px-3 py-2 text-xs text-negative",children:r.latestRun.error}):null]}):e.jsx(P,{className:"px-4 py-3 text-sm text-muted",children:'No traffic-sync runs recorded yet. Hit "Sync now" above to create one.'})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Events"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-primary",children:b.granularity==="day"?"Daily rollups":"Hourly rollups"}),S?e.jsxs("p",{className:"mt-1.5 text-xs text-muted",children:[S.crawlerContentHits.toLocaleString("en-US")," content crawls ·"," ",S.crawlerInfraHits.toLocaleString("en-US")," infra (sitemap/robots/assets) ·"," ",S.aiUserFetchHits.toLocaleString("en-US")," AI user fetches ·"," ",S.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",b.label," · ",he]}):null]}),e.jsx("div",{className:"filter-row mb-0",role:"toolbar","aria-label":"Window",children:_.map(t=>e.jsx("button",{type:"button",className:`filter-chip ${x===t.value?"filter-chip-active":""}`,"aria-pressed":x===t.value,onClick:()=>{i(t.value),C(null)},children:t.label},t.value))})]}),e.jsxs(P,{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",role:"toolbar","aria-label":"Series",children:[e.jsx(J,{label:"Crawler",color:ue,count:S?.crawlerHits??0,active:c.has("crawler"),onToggle:()=>V("crawler")}),e.jsx(J,{label:"AI user fetches",color:de,count:S?.aiUserFetchHits??0,active:c.has("ai-user-fetch"),onToggle:()=>V("ai-user-fetch")}),e.jsx(J,{label:"AI referral sessions",color:xe,count:S?.aiReferralHits??0,active:c.has("ai-referral"),onToggle:()=>V("ai-referral")})]}),y.isError?e.jsxs("p",{className:"py-12 text-center text-xs text-negative-400",children:["Failed to load events: ",y.error instanceof Error?y.error.message:"Unknown error"]}):y.isLoading?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"Loading events…"}):I.length===0?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"No events in this window."}):e.jsx("div",{className:"h-72",children:e.jsx(Ye,{children:e.jsxs(Xe,{data:I,margin:{top:4,right:4,bottom:0,left:0},onClick:Te,style:{cursor:"pointer"},children:[e.jsx(Qe,{stroke:Ke,strokeDasharray:"3 3"}),e.jsx(qe,{dataKey:"label",tick:ie,stroke:le,interval:"preserveStartEnd",minTickGap:b.granularity==="day"?24:32}),e.jsx(Ze,{tick:ie,stroke:le,allowDecimals:!1}),e.jsx(Je,{...We}),c.has("crawler")?e.jsx(X,{dataKey:"crawler",name:"Crawler",fill:ue,stackId:"a",children:I.map(t=>e.jsx(Q,{fillOpacity:d&&d!==t.bucket?.25:1},t.bucket))}):null,c.has("ai-user-fetch")?e.jsx(X,{dataKey:"aiUserFetch",name:"AI user fetch",fill:de,stackId:"a",children:I.map(t=>e.jsx(Q,{fillOpacity:d&&d!==t.bucket?.25:1},t.bucket))}):null,c.has("ai-referral")?e.jsx(X,{dataKey:"aiReferral",name:"AI referral",fill:xe,stackId:"a",children:I.map(t=>e.jsx(Q,{fillOpacity:d&&d!==t.bucket?.25:1},t.bucket))}):null]})})})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Event rows"}),e.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Showing ",e.jsx("span",{className:"tabular-nums text-neutral",children:w.length.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:F.length.toLocaleString("en-US")})," events · ",he]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by identity",value:f,onChange:t=>v(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All identities"}),ve.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(D,{text:"The specific bot or AI product making the request (e.g., GPTBot, ChatGPT-User, Perplexity). One operator usually runs several identities."})]}),e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by operator",value:m,onChange:t=>L(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All operators"}),Ne.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(D,{text:"The company that runs the bot or product (e.g., OpenAI, Anthropic, Perplexity). Filtering by operator includes every identity under that company."})]}),e.jsx("select",{"aria-label":"Filter by HTTP status class",value:k,onChange:t=>z(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:et.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("select",{"aria-label":"Filter by verification claim",value:T,onChange:t=>G(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:fe.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:j,onChange:t=>B(t.target.value),className:"w-44 rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong placeholder:text-faint focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600"})]})]}),Ae?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[ne?e.jsx(A,{label:`Bucket: ${ne}`,onClear:()=>C(null)}):null,f?e.jsx(A,{label:`Identity: ${f}`,onClear:()=>v("")}):null,m?e.jsx(A,{label:`Operator: ${m}`,onClear:()=>L("")}):null,j.trim()?e.jsx(A,{label:`Path: ${j.trim()}`,onClear:()=>B("")}):null,k!=="all"?e.jsx(A,{label:`Status: ${k}`,onClear:()=>z("all")}):null,T!=="all"?e.jsx(A,{label:`Claim: ${it(T)}`,onClear:()=>G("all")}):null,e.jsx("button",{type:"button",onClick:Ie,className:"text-xs text-muted underline-offset-4 hover:text-strong hover:underline",children:"Clear all"})]}):null,e.jsx(dt,{events:Se}),we?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-secondary",children:[e.jsxs("p",{className:"tabular-nums",children:["Showing ",e.jsx("span",{className:"text-neutral",children:Ce.toLocaleString("en-US")}),"–",e.jsx("span",{className:"text-neutral",children:ke.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"text-neutral",children:w.length.toLocaleString("en-US")})," events"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.max(1,t-1)),disabled:H<=1,"aria-label":"Previous page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:[e.jsx(Ve,{className:"size-3.5"}),"Prev"]}),e.jsxs("span",{className:"tabular-nums",children:["Page ",e.jsx("span",{className:"text-strong",children:H})," of"," ",e.jsx("span",{className:"text-strong",children:M})]}),e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.min(M,t+1)),disabled:H>=M,"aria-label":"Next page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:["Next",e.jsx(Me,{className:"size-3.5"})]})]})]}):null]})]})}function Z(s,a){return{bucket:s,label:a,crawler:0,aiUserFetch:0,aiReferral:0}}function O(s,a){return a==="day"?nt(s):ye(s)}function lt(s,a,l,n){const x=new Map;for(const i of s){const c=be(i.tsHour,a);let o=x.get(c);switch(o||(o=Z(c,O(c,a)),x.set(c,o)),i.kind){case u.crawler:o.crawler+=i.hits;break;case u["ai-user-fetch"]:o.aiUserFetch+=i.hits;break;case u["ai-referral"]:o.aiReferral+=i.hits;break}}if(l&&n){const i=new Date(l),c=new Date(n);if(a==="day"){const o=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate())),d=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()));for(;o<=d;){const C=o.getUTCFullYear(),f=String(o.getUTCMonth()+1).padStart(2,"0"),v=String(o.getUTCDate()).padStart(2,"0"),m=`${C}-${f}-${v}`;x.has(m)||x.set(m,Z(m,O(m,a))),o.setUTCDate(o.getUTCDate()+1)}}else{const o=new Date(i);for(o.setUTCMinutes(0,0,0);o<=c;){const d=o.toISOString();x.has(d)||x.set(d,Z(d,O(d,a))),o.setUTCHours(o.getUTCHours()+1)}}}return[...x.values()].sort((i,c)=>i.bucket<c.bucket?-1:i.bucket>c.bucket?1:0)}function it(s){return fe.find(a=>a.value===s)?.label??s}function A({label:s,onClear:a}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-strong bg-surface-inset px-2.5 py-1 text-[11px] text-strong",children:[s,e.jsx("button",{type:"button",onClick:a,"aria-label":`Clear ${s}`,className:"rounded-full p-0.5 text-secondary hover:bg-mono-700/60 hover:text-heading",children:e.jsx(Pe,{className:"size-3"})})]})}function J({label:s,color:a,count:l,active:n,onToggle:x}){return e.jsxs("button",{type:"button",onClick:x,"aria-pressed":n,className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium transition ${n?"border-strong bg-surface-inset text-heading":"border-base bg-transparent text-muted hover:text-neutral"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`size-2 rounded-full transition-opacity ${n?"opacity-100":"opacity-30"}`,style:{backgroundColor:a}}),e.jsx("span",{children:s}),e.jsx("span",{className:`tabular-nums ${n?"text-secondary":"text-faint"}`,children:l.toLocaleString("en-US")})]})}function ct(s){switch(s){case u.crawler:return"Crawler";case u["ai-user-fetch"]:return"AI hit";case u["ai-referral"]:return"AI referral"}}function ot(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.botId;case u["ai-referral"]:return s.product}}function ut(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return`${s.verificationStatus} · HTTP ${s.status}`;case u["ai-referral"]:return`${s.evidenceType} · ${s.sourceDomain}`}}function dt({events:s}){return s.length===0?e.jsx(P,{className:"p-6 text-center text-sm text-muted",children:"No event rows match the current filters."}):e.jsx("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Hour"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Kind"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Identity"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Evidence / status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Path"}),e.jsx("th",{className:"px-4 py-2 text-right",children:e.jsxs("span",{className:"inline-flex items-center",children:["Hits",e.jsx(D,{text:"Each row is one hour-bucket, not one request. Hits is the number of requests in that hour that shared the same identity, path, HTTP status, and verification claim."})]})})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:s.map((a,l)=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-neutral",children:ye(a.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ct(a.kind)}),e.jsxs("td",{className:"px-4 py-2 text-heading",children:[ot(a),e.jsx("span",{className:"ml-2 text-[11px] text-muted",children:a.operator})]}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ut(a)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-neutral",children:ge(a)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-heading",children:a.hits})]},`${a.kind}:${a.tsHour}:${l}`))})]})})}export{jt as TrafficSourceDetailPage};
1
+ import{j as e,B as Re,C as $e,r as h,L as Ue}from"./vendor-tanstack-Be8JdV5M.js";import{I as D,c9 as Y,ca as u,T as Ee,B as Fe,g as P,b as Me,cb as He,cc as Pe}from"./index-BZnlypko.js";import{g as Oe,h as De,i as _e,t as Be,R as ze,d as Ge}from"./extract-error-message-ClFtdJwM.js";import{e as ee,i as Ke,C as le,a as ie,c as We,h as Ve}from"./ChartPrimitives-CeHtwsJJ.js";import{R as Ye,B as Xe,a as Qe,X as qe,Y as Ze,T as Je,e as X,f as Q}from"./vendor-recharts-C9EZkgbP.js";import{A as ce}from"./arrow-left-CAIQypB3.js";import"./vendor-radix-CQ77EO2y.js";import"./vendor-markdown-6dwjPOKK.js";function q({value:s,label:a,delta:l,tone:n,description:x,tooltip:i,isNumeric:c=!0,progress:o,providerCoverage:d}){const v=2*Math.PI*48,m=Number.parseInt(s,10),L=typeof o=="number"&&Number.isFinite(o)?Math.min(Math.max(o,0),100)/100:c&&!Number.isNaN(m)?Math.min(m/100,1):.5,j=v*(1-L);return e.jsxs("div",{className:"score-gauge",children:[e.jsxs("div",{className:"gauge-ring-wrapper",children:[e.jsxs("svg",{className:"gauge-ring",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("circle",{className:"gauge-bg",cx:"60",cy:"60",r:48,strokeWidth:6}),e.jsx("circle",{className:`gauge-fill gauge-fill-${n}`,cx:"60",cy:"60",r:48,strokeWidth:6,strokeDasharray:v,strokeDashoffset:j,transform:"rotate(-90 60 60)"})]}),e.jsx("div",{className:"gauge-center",children:e.jsx("span",{className:c?"gauge-value":"gauge-value-text",children:s.split(" / ")[0]})})]}),e.jsxs("p",{className:"gauge-label",children:[a,i&&e.jsx(D,{text:i})]}),e.jsx("p",{className:"gauge-delta",children:l}),d&&e.jsx("p",{className:"gauge-provider-coverage",children:d}),e.jsx("p",{className:"gauge-description",children:x})]})}const et=[{value:"all",label:"All status"},{value:"2xx",label:"2xx success"},{value:"3xx",label:"3xx redirect"},{value:"4xx",label:"4xx client error"},{value:"5xx",label:"5xx server error"}],fe=[{value:"all",label:"All claims"},{value:Y.verified,label:"Verified"},{value:Y.claimed_unverified,label:"Claimed unverified"},{value:Y.unknown_ai_like,label:"Unknown AI-like"}];function tt(s){return s==="all"?null:Number.parseInt(s[0],10)}function pe(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.botId;case u["ai-referral"]:return s.product}}function ge(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.pathNormalized;case u["ai-referral"]:return s.landingPathNormalized}}function st(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.verificationStatus;case u["ai-referral"]:return null}}function be(s,a){if(a==="hour")return s;const l=new Date(s),n=l.getFullYear(),x=String(l.getMonth()+1).padStart(2,"0"),i=String(l.getDate()).padStart(2,"0");return`${n}-${x}-${i}`}function at(s,a,l){const n=a.pathQuery.trim().toLowerCase(),x=tt(a.statusClass);return s.filter(i=>!(a.selectedBucket&&be(i.tsHour,l)!==a.selectedBucket||a.identity&&pe(i)!==a.identity||a.operator&&i.operator!==a.operator||n&&!ge(i).toLowerCase().includes(n)||x!==null&&Math.floor(i.status/100)!==x||a.verification!=="all"&&st(i)!==a.verification))}function rt(s,a){if(!s||typeof s!="object")return null;const l=s.activeTooltipIndex;let n;if(typeof l=="number")n=l;else if(typeof l=="string"&&l!=="")n=Number(l);else return null;return!Number.isInteger(n)||n<0||n>=a.length?null:a[n]?.bucket??null}const _=[{value:60,label:"1h",granularity:"hour",fetchLimit:500},{value:360,label:"6h",granularity:"hour",fetchLimit:500},{value:1440,label:"24h",granularity:"hour",fetchLimit:500},{value:10080,label:"7d",granularity:"hour",fetchLimit:1e3},{value:720*60,label:"30d",granularity:"day",fetchLimit:2e3},{value:2160*60,label:"90d",granularity:"day",fetchLimit:5e3}],oe=_.find(s=>s.label==="24h")??_[2],$=50,ue=ee[0],de=ee[2],xe=ee[1],he=He();function ye(s){const a=new Date(s);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:00`}function nt(s){const a=new Date(`${s}T00:00:00`);return`${a.getMonth()+1}/${a.getDate()}`}function U(s){if(!s)return"never";const a=Date.now()-new Date(s).getTime(),l=Math.floor(a/6e4);if(l<1)return"just now";if(l<60)return`${l}m ago`;const n=Math.floor(l/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function me({canGoBack:s,className:a}){const l="inline-flex items-center gap-1";if(s){const n=()=>{window.history.back()};return e.jsxs("button",{type:"button",onClick:n,className:`${l} ${a??""}`,children:[e.jsx(ce,{className:"size-3"})," Back"]})}return e.jsxs(Ue,{to:"/traffic",className:`${l} ${a??""}`,children:[e.jsx(ce,{className:"size-3"})," All sources"]})}function jt(){const s=Re({strict:!1}),a=s.projectName??"",l=$e(),n=s.sourceId??"",[x,i]=h.useState(oe.value),[c,o]=h.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[d,C]=h.useState(null),[f,v]=h.useState(""),[m,L]=h.useState(""),[j,B]=h.useState(""),[k,z]=h.useState("all"),[T,G]=h.useState("all"),[je,K]=h.useState(1),[te,se]=h.useState(null),[ae,re]=h.useState(null),b=h.useMemo(()=>_.find(t=>t.value===x)??oe,[x]),W=Oe(a||null,n||null),y=De(a||null,{kind:"all",sourceId:n||void 0,sinceMinutes:x,limit:b.fetchLimit}),E=_e(a||null,n||null),r=W.data,N=y.data?.events??[],S=y.data?.totals,F=h.useMemo(()=>N.filter(t=>{switch(t.kind){case u.crawler:return c.has("crawler");case u["ai-user-fetch"]:return c.has("ai-user-fetch");case u["ai-referral"]:return c.has("ai-referral")}}),[N,c]),ve=h.useMemo(()=>{const t=new Set;for(const p of N)t.add(pe(p));return f&&t.add(f),[...t].sort((p,g)=>p.localeCompare(g))},[N,f]),Ne=h.useMemo(()=>{const t=new Set;for(const p of N)t.add(p.operator);return m&&t.add(m),[...t].sort((p,g)=>p.localeCompare(g))},[N,m]),w=h.useMemo(()=>at(F,{selectedBucket:d,identity:f,operator:m,pathQuery:j,statusClass:k,verification:T},b.granularity),[F,d,f,m,j,k,T,b.granularity]);h.useEffect(()=>{K(1)},[F,d,f,m,j,k,T]);const M=Math.max(1,Math.ceil(w.length/$)),H=Math.min(Math.max(1,je),M),R=(H-1)*$,Se=h.useMemo(()=>w.slice(R,R+$),[w,R]),we=w.length>$,Ce=w.length===0?0:R+1,ke=Math.min(R+$,w.length),ne=h.useMemo(()=>d?O(d,b.granularity):null,[d,b.granularity]),I=h.useMemo(()=>lt(N,b.granularity,y.data?.windowStart,y.data?.windowEnd),[N,b.granularity,y.data?.windowStart,y.data?.windowEnd]),V=t=>{o(p=>{const g=new Set(p);return g.has(t)?g.size>1&&g.delete(t):g.add(t),g})},Te=t=>{const p=rt(t,I);p&&C(g=>g===p?null:p)},Ie=()=>{C(null),v(""),L(""),B(""),z("all"),G("all")},Ae=!!(d||f||m||j.trim()||k!=="all"||T!=="all"),Le=async()=>{se(null),re(null);try{const t=await E.mutateAsync({sinceMinutes:60});re(`Pulled ${t.pulledEvents} entries · ${t.crawlerHits} crawler · ${t.aiUserFetchHits} AI user fetch · ${t.aiReferralHits} AI referral · ${t.unknownHits} unknown`)}catch(t){se(Ge(t))}};return!a||!n?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Missing project name or source id in URL."})}):W.isLoading?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Loading source…"})}):W.isError||!r?e.jsxs("div",{className:"page-container",children:[e.jsx("p",{className:"text-sm text-negative",children:"Could not load this source."}),e.jsx(me,{canGoBack:l,className:"mt-2 text-xs text-secondary hover:text-strong"})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx(me,{canGoBack:l,className:"text-xs text-muted hover:text-strong"}),e.jsx("h1",{className:"page-title mt-2",children:r.displayName}),e.jsxs("p",{className:"page-subtitle",children:[r.sourceType," · project ",e.jsx("span",{className:"text-neutral",children:a})," ·",e.jsx("span",{className:"ml-1 font-mono text-secondary",children:r.id})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{tone:Be(r.status),children:r.status}),e.jsxs(Fe,{type:"button",variant:"outline",size:"sm",disabled:E.isPending,onClick:()=>{Le()},children:[e.jsx(ze,{className:`size-3.5 ${E.isPending?"animate-spin":""}`}),E.isPending?"Syncing…":"Sync now"]})]})]}),te?e.jsx("div",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:te}):null,ae?e.jsx("div",{className:"rounded-md border border-positive-800/50 bg-positive-950/30 px-3 py-2 text-xs text-positive-200",children:ae}):null,e.jsxs("section",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(q,{label:"24h content crawls",value:String(r.totals24h.crawlerContentHits),delta:r.lastSyncedAt?`last sync ${U(r.lastSyncedAt)}`:"never synced",tone:r.totals24h.crawlerContentHits>0?"positive":"neutral",description:`Pages crawled — ${r.totals24h.crawlerInfraHits.toLocaleString("en-US")} sitemap/robots/asset fetches excluded.`,tooltip:`Content-page crawls by GPTBot, OAI-SearchBot, PerplexityBot, Googlebot, etc. Infrastructure fetches (sitemap ${r.totals24h.crawlerSegments.sitemap.toLocaleString("en-US")}, robots ${r.totals24h.crawlerSegments.robots.toLocaleString("en-US")}, assets ${r.totals24h.crawlerSegments.asset.toLocaleString("en-US")}) are tracked separately so polling doesn't inflate this number. Total crawler hits: ${r.totals24h.crawlerHits.toLocaleString("en-US")}.`,isNumeric:!0,progress:Math.min(100,Math.round(r.totals24h.crawlerContentHits/1e3*100))}),e.jsx(q,{label:"24h AI user fetches",value:String(r.totals24h.aiUserFetchHits),delta:r.lastSyncedAt?`last sync ${U(r.lastSyncedAt)}`:"never synced",tone:r.totals24h.aiUserFetchHits>0?"positive":"neutral",description:"ChatGPT-User, Perplexity-User — fetches initiated by a real user inside an AI surface (citation click, URL read).",isNumeric:!0,progress:Math.min(100,Math.round(r.totals24h.aiUserFetchHits/1e3*100))}),e.jsx(q,{label:"24h AI referral sessions",value:String(r.totals24h.aiReferralHits),delta:r.lastSyncedAt?`last sync ${U(r.lastSyncedAt)}`:"never synced",tone:r.totals24h.aiReferralHits>0?"positive":"neutral",description:"Browser click-throughs from chatgpt.com, perplexity.ai, etc. (Referer / UTM evidence).",isNumeric:!0,progress:Math.min(100,Math.round(r.totals24h.aiReferralHits/1e3*100))})]}),e.jsxs("section",{children:[e.jsx("p",{className:"mb-4 text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Latest sync run"}),r.latestRun?e.jsxs(P,{className:"p-4 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1.5",children:[e.jsxs("span",{className:"text-heading",children:["Status: ",e.jsx("span",{className:"font-medium",children:r.latestRun.status})]}),e.jsxs("span",{className:"text-muted",children:["Started: ",U(r.latestRun.startedAt)]}),r.latestRun.finishedAt?e.jsxs("span",{className:"text-muted",children:["Finished: ",U(r.latestRun.finishedAt)]}):null,e.jsx("span",{className:"font-mono text-[11px] text-faint",children:r.latestRun.runId})]}),r.latestRun.error?e.jsx("p",{className:"mt-2 rounded border border-negative-900/40 bg-negative-950/30 px-3 py-2 text-xs text-negative",children:r.latestRun.error}):null]}):e.jsx(P,{className:"px-4 py-3 text-sm text-muted",children:'No traffic-sync runs recorded yet. Hit "Sync now" above to create one.'})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Events"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-primary",children:b.granularity==="day"?"Daily rollups":"Hourly rollups"}),S?e.jsxs("p",{className:"mt-1.5 text-xs text-muted",children:[S.crawlerContentHits.toLocaleString("en-US")," content crawls ·"," ",S.crawlerInfraHits.toLocaleString("en-US")," infra (sitemap/robots/assets) ·"," ",S.aiUserFetchHits.toLocaleString("en-US")," AI user fetches ·"," ",S.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",b.label," · ",he]}):null]}),e.jsx("div",{className:"filter-row mb-0",role:"toolbar","aria-label":"Window",children:_.map(t=>e.jsx("button",{type:"button",className:`filter-chip ${x===t.value?"filter-chip-active":""}`,"aria-pressed":x===t.value,onClick:()=>{i(t.value),C(null)},children:t.label},t.value))})]}),e.jsxs(P,{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",role:"toolbar","aria-label":"Series",children:[e.jsx(J,{label:"Crawler",color:ue,count:S?.crawlerHits??0,active:c.has("crawler"),onToggle:()=>V("crawler")}),e.jsx(J,{label:"AI user fetches",color:de,count:S?.aiUserFetchHits??0,active:c.has("ai-user-fetch"),onToggle:()=>V("ai-user-fetch")}),e.jsx(J,{label:"AI referral sessions",color:xe,count:S?.aiReferralHits??0,active:c.has("ai-referral"),onToggle:()=>V("ai-referral")})]}),y.isError?e.jsxs("p",{className:"py-12 text-center text-xs text-negative-400",children:["Failed to load events: ",y.error instanceof Error?y.error.message:"Unknown error"]}):y.isLoading?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"Loading events…"}):I.length===0?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"No events in this window."}):e.jsx("div",{className:"h-72",children:e.jsx(Ye,{children:e.jsxs(Xe,{data:I,margin:{top:4,right:4,bottom:0,left:0},onClick:Te,style:{cursor:"pointer"},children:[e.jsx(Qe,{stroke:Ke,strokeDasharray:"3 3"}),e.jsx(qe,{dataKey:"label",tick:ie,stroke:le,interval:"preserveStartEnd",minTickGap:b.granularity==="day"?24:32}),e.jsx(Ze,{tick:ie,stroke:le,allowDecimals:!1}),e.jsx(Je,{...We}),c.has("crawler")?e.jsx(X,{dataKey:"crawler",name:"Crawler",fill:ue,stackId:"a",children:I.map(t=>e.jsx(Q,{fillOpacity:d&&d!==t.bucket?.25:1},t.bucket))}):null,c.has("ai-user-fetch")?e.jsx(X,{dataKey:"aiUserFetch",name:"AI user fetch",fill:de,stackId:"a",children:I.map(t=>e.jsx(Q,{fillOpacity:d&&d!==t.bucket?.25:1},t.bucket))}):null,c.has("ai-referral")?e.jsx(X,{dataKey:"aiReferral",name:"AI referral",fill:xe,stackId:"a",children:I.map(t=>e.jsx(Q,{fillOpacity:d&&d!==t.bucket?.25:1},t.bucket))}):null]})})})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Event rows"}),e.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Showing ",e.jsx("span",{className:"tabular-nums text-neutral",children:w.length.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:F.length.toLocaleString("en-US")})," events · ",he]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by identity",value:f,onChange:t=>v(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All identities"}),ve.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(D,{text:"The specific bot or AI product making the request (e.g., GPTBot, ChatGPT-User, Perplexity). One operator usually runs several identities."})]}),e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by operator",value:m,onChange:t=>L(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All operators"}),Ne.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(D,{text:"The company that runs the bot or product (e.g., OpenAI, Anthropic, Perplexity). Filtering by operator includes every identity under that company."})]}),e.jsx("select",{"aria-label":"Filter by HTTP status class",value:k,onChange:t=>z(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:et.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("select",{"aria-label":"Filter by verification claim",value:T,onChange:t=>G(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:fe.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:j,onChange:t=>B(t.target.value),className:"w-44 rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong placeholder:text-faint focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600"})]})]}),Ae?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[ne?e.jsx(A,{label:`Bucket: ${ne}`,onClear:()=>C(null)}):null,f?e.jsx(A,{label:`Identity: ${f}`,onClear:()=>v("")}):null,m?e.jsx(A,{label:`Operator: ${m}`,onClear:()=>L("")}):null,j.trim()?e.jsx(A,{label:`Path: ${j.trim()}`,onClear:()=>B("")}):null,k!=="all"?e.jsx(A,{label:`Status: ${k}`,onClear:()=>z("all")}):null,T!=="all"?e.jsx(A,{label:`Claim: ${it(T)}`,onClear:()=>G("all")}):null,e.jsx("button",{type:"button",onClick:Ie,className:"text-xs text-muted underline-offset-4 hover:text-strong hover:underline",children:"Clear all"})]}):null,e.jsx(dt,{events:Se}),we?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-secondary",children:[e.jsxs("p",{className:"tabular-nums",children:["Showing ",e.jsx("span",{className:"text-neutral",children:Ce.toLocaleString("en-US")}),"–",e.jsx("span",{className:"text-neutral",children:ke.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"text-neutral",children:w.length.toLocaleString("en-US")})," events"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.max(1,t-1)),disabled:H<=1,"aria-label":"Previous page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:[e.jsx(Ve,{className:"size-3.5"}),"Prev"]}),e.jsxs("span",{className:"tabular-nums",children:["Page ",e.jsx("span",{className:"text-strong",children:H})," of"," ",e.jsx("span",{className:"text-strong",children:M})]}),e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.min(M,t+1)),disabled:H>=M,"aria-label":"Next page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:["Next",e.jsx(Me,{className:"size-3.5"})]})]})]}):null]})]})}function Z(s,a){return{bucket:s,label:a,crawler:0,aiUserFetch:0,aiReferral:0}}function O(s,a){return a==="day"?nt(s):ye(s)}function lt(s,a,l,n){const x=new Map;for(const i of s){const c=be(i.tsHour,a);let o=x.get(c);switch(o||(o=Z(c,O(c,a)),x.set(c,o)),i.kind){case u.crawler:o.crawler+=i.hits;break;case u["ai-user-fetch"]:o.aiUserFetch+=i.hits;break;case u["ai-referral"]:o.aiReferral+=i.hits;break}}if(l&&n){const i=new Date(l),c=new Date(n);if(a==="day"){const o=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate())),d=new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()));for(;o<=d;){const C=o.getUTCFullYear(),f=String(o.getUTCMonth()+1).padStart(2,"0"),v=String(o.getUTCDate()).padStart(2,"0"),m=`${C}-${f}-${v}`;x.has(m)||x.set(m,Z(m,O(m,a))),o.setUTCDate(o.getUTCDate()+1)}}else{const o=new Date(i);for(o.setUTCMinutes(0,0,0);o<=c;){const d=o.toISOString();x.has(d)||x.set(d,Z(d,O(d,a))),o.setUTCHours(o.getUTCHours()+1)}}}return[...x.values()].sort((i,c)=>i.bucket<c.bucket?-1:i.bucket>c.bucket?1:0)}function it(s){return fe.find(a=>a.value===s)?.label??s}function A({label:s,onClear:a}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-strong bg-surface-inset px-2.5 py-1 text-[11px] text-strong",children:[s,e.jsx("button",{type:"button",onClick:a,"aria-label":`Clear ${s}`,className:"rounded-full p-0.5 text-secondary hover:bg-mono-700/60 hover:text-heading",children:e.jsx(Pe,{className:"size-3"})})]})}function J({label:s,color:a,count:l,active:n,onToggle:x}){return e.jsxs("button",{type:"button",onClick:x,"aria-pressed":n,className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium transition ${n?"border-strong bg-surface-inset text-heading":"border-base bg-transparent text-muted hover:text-neutral"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`size-2 rounded-full transition-opacity ${n?"opacity-100":"opacity-30"}`,style:{backgroundColor:a}}),e.jsx("span",{children:s}),e.jsx("span",{className:`tabular-nums ${n?"text-secondary":"text-faint"}`,children:l.toLocaleString("en-US")})]})}function ct(s){switch(s){case u.crawler:return"Crawler";case u["ai-user-fetch"]:return"AI hit";case u["ai-referral"]:return"AI referral"}}function ot(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return s.botId;case u["ai-referral"]:return s.product}}function ut(s){switch(s.kind){case u.crawler:case u["ai-user-fetch"]:return`${s.verificationStatus} · HTTP ${s.status}`;case u["ai-referral"]:return`${s.evidenceType} · ${s.sourceDomain}`}}function dt({events:s}){return s.length===0?e.jsx(P,{className:"p-6 text-center text-sm text-muted",children:"No event rows match the current filters."}):e.jsx("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Hour"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Kind"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Identity"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Evidence / status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Path"}),e.jsx("th",{className:"px-4 py-2 text-right",children:e.jsxs("span",{className:"inline-flex items-center",children:["Hits",e.jsx(D,{text:"Each row is one hour-bucket, not one request. Hits is the number of requests in that hour that shared the same identity, path, HTTP status, and verification claim."})]})})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:s.map((a,l)=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-neutral",children:ye(a.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ct(a.kind)}),e.jsxs("td",{className:"px-4 py-2 text-heading",children:[ot(a),e.jsx("span",{className:"ml-2 text-[11px] text-muted",children:a.operator})]}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ut(a)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-neutral",children:ge(a)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-heading",children:a.hits})]},`${a.kind}:${a.tsHour}:${l}`))})]})})}export{jt as TrafficSourceDetailPage};
@@ -1 +1 @@
1
- import{c as o}from"./index-DB_F_WFv.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A};
1
+ import{c as o}from"./index-BZnlypko.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A};
@@ -1 +1 @@
1
- import{c as l,j as a,cd as m,c7 as y,ce as S,aD as g,l as t,cf as v,c8 as s,cg as p,ch as T,ci as h,cj as C}from"./index-DB_F_WFv.js";import{u as c,r as q,n as o,o as u}from"./vendor-tanstack-Be8JdV5M.js";const w=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],k=l("refresh-cw",w);function A(e){switch(e){case s.connected:return"positive";case s.paused:return"caution";case s.error:return"negative";case s.archived:return"neutral"}}function M(e){const n={};return e.kind&&e.kind!=="all"&&(n.kind=e.kind),e.sourceId&&(n.sourceId=e.sourceId),e.sinceMinutes!==void 0&&(n.since=new Date(Date.now()-e.sinceMinutes*6e4).toISOString()),e.limit!==void 0&&(n.limit=String(e.limit)),n}function f(e){e.invalidateQueries({predicate:n=>{const r=n.queryKey[0];return typeof r?._id=="string"&&r._id.startsWith("getApiV1ProjectsByNameTraffic")}})}function F(e){return c({...m({client:t,path:{name:e??""}}),enabled:!!e,staleTime:a})}function R(e){return c({...C({client:t,path:{name:e??""}}),enabled:!!e,staleTime:a})}function V(e,n){return c({...y({client:t,path:{name:e??"",id:n??""}}),enabled:!!(e&&n),staleTime:a})}function I(e,n){const r=q.useMemo(()=>M(n),[n.kind,n.sourceId,n.sinceMinutes,n.limit]);return c({...S({client:t,path:{name:e??""},query:r}),enabled:!!e,staleTime:a})}function b(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Cloud Run source");return h(e,r)},onSuccess:()=>{e&&f(n)}})}function Q(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a WordPress source");return p(e,r)},onSuccess:()=>{e&&f(n)}})}function N(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Vercel source");return T(e,r)},onSuccess:()=>{e&&f(n)}})}function _(e,n){const r=o();return u({mutationFn:d=>{if(!e||!n)throw new Error("Project and sourceId are required to sync");return v(e,n,d??void 0)},onSuccess:()=>{e&&(f(r),r.invalidateQueries({queryKey:g({client:t})}))}})}function i(e){return typeof e=="object"&&e!==null}function E(e){if(e instanceof Error){const n=e;return{message:e.message,code:typeof n.code=="string"?n.code:void 0,details:i(n.details)?n.details:void 0}}if(i(e)){const n=e.error;if(i(n))return{message:typeof n.message=="string"?n.message:"Request failed",code:typeof n.code=="string"?n.code:void 0,details:i(n.details)?n.details:void 0};if(typeof n=="string")return{message:n};const r=e.message;if(typeof r=="string")return{message:r}}return typeof e=="string"?{message:e}:{message:String(e)}}function O(e){return E(e).message}export{k as R,Q as a,N as b,b as c,O as d,E as e,F as f,V as g,I as h,_ as i,A as t,R as u};
1
+ import{c as l,j as a,cd as m,c7 as y,ce as S,aD as g,l as t,cf as v,c8 as s,cg as p,ch as T,ci as h,cj as C}from"./index-BZnlypko.js";import{u as c,r as q,n as o,o as u}from"./vendor-tanstack-Be8JdV5M.js";const w=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],k=l("refresh-cw",w);function A(e){switch(e){case s.connected:return"positive";case s.paused:return"caution";case s.error:return"negative";case s.archived:return"neutral"}}function M(e){const n={};return e.kind&&e.kind!=="all"&&(n.kind=e.kind),e.sourceId&&(n.sourceId=e.sourceId),e.sinceMinutes!==void 0&&(n.since=new Date(Date.now()-e.sinceMinutes*6e4).toISOString()),e.limit!==void 0&&(n.limit=String(e.limit)),n}function f(e){e.invalidateQueries({predicate:n=>{const r=n.queryKey[0];return typeof r?._id=="string"&&r._id.startsWith("getApiV1ProjectsByNameTraffic")}})}function F(e){return c({...m({client:t,path:{name:e??""}}),enabled:!!e,staleTime:a})}function R(e){return c({...C({client:t,path:{name:e??""}}),enabled:!!e,staleTime:a})}function V(e,n){return c({...y({client:t,path:{name:e??"",id:n??""}}),enabled:!!(e&&n),staleTime:a})}function I(e,n){const r=q.useMemo(()=>M(n),[n.kind,n.sourceId,n.sinceMinutes,n.limit]);return c({...S({client:t,path:{name:e??""},query:r}),enabled:!!e,staleTime:a})}function b(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Cloud Run source");return h(e,r)},onSuccess:()=>{e&&f(n)}})}function Q(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a WordPress source");return p(e,r)},onSuccess:()=>{e&&f(n)}})}function N(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Vercel source");return T(e,r)},onSuccess:()=>{e&&f(n)}})}function _(e,n){const r=o();return u({mutationFn:d=>{if(!e||!n)throw new Error("Project and sourceId are required to sync");return v(e,n,d??void 0)},onSuccess:()=>{e&&(f(r),r.invalidateQueries({queryKey:g({client:t})}))}})}function i(e){return typeof e=="object"&&e!==null}function E(e){if(e instanceof Error){const n=e;return{message:e.message,code:typeof n.code=="string"?n.code:void 0,details:i(n.details)?n.details:void 0}}if(i(e)){const n=e.error;if(i(n))return{message:typeof n.message=="string"?n.message:"Request failed",code:typeof n.code=="string"?n.code:void 0,details:i(n.details)?n.details:void 0};if(typeof n=="string")return{message:n};const r=e.message;if(typeof r=="string")return{message:r}}return typeof e=="string"?{message:e}:{message:String(e)}}function O(e){return E(e).message}export{k as R,Q as a,N as b,b as c,O as d,E as e,F as f,V as g,I as h,_ as i,A as t,R as u};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProjectPage-DVED6lF7.js","./vendor-tanstack-Be8JdV5M.js","./RunRow-Chc7eyZU.js","./ChartPrimitives-BjcDtBSv.js","./extract-error-message-b-rZowjX.js","./vendor-recharts-C9EZkgbP.js","./trash-2-6CLXNfZm.js","./vendor-radix-CQ77EO2y.js","./vendor-markdown-6dwjPOKK.js","./RunsPage-DQ8ip0Tf.js","./SettingsPage-CZokCKF4.js","./BacklinksPage-D00sAx6q.js","./TrafficPage-C0nEB9tv.js","./arrow-left-CeWmJYLI.js","./TrafficSourceDetailPage-CKsWe8kA.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProjectPage-DcR0lYs1.js","./vendor-tanstack-Be8JdV5M.js","./RunRow-CV2qXxPT.js","./ChartPrimitives-CeHtwsJJ.js","./extract-error-message-ClFtdJwM.js","./vendor-recharts-C9EZkgbP.js","./trash-2-bCb6xhDV.js","./vendor-radix-CQ77EO2y.js","./vendor-markdown-6dwjPOKK.js","./RunsPage-DWW5QQ20.js","./SettingsPage-CdpsDKrQ.js","./BacklinksPage-CvriSR5g.js","./TrafficPage-BOe2UKFg.js","./arrow-left-CAIQypB3.js","./TrafficSourceDetailPage-VmvIxQBH.js"])))=>i.map(i=>d[i]);
2
2
  import{c as Nw,d as kw,Q as Aw,M as _w,r as q,q as Te,j as f,L as st,a as Cw,e as ks,u as fn,f as Tw,h as fc,k as Ew,l as Ow,m as dv,O as xf,n as Wa,o as Ti,p as zw,s as Et,t as Hf,v as Ps,x as Dw,y as Rw,z as Mw}from"./vendor-tanstack-Be8JdV5M.js";import{S as Bw,O as Qf,P as fv,C as Kf,a as pv,T as Zf,D as mv,R as hv}from"./vendor-radix-CQ77EO2y.js";import{c as gv}from"./vendor-recharts-C9EZkgbP.js";import{M as Lw}from"./vendor-markdown-6dwjPOKK.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const c of l)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&r(d)}).observe(document,{childList:!0,subtree:!0});function i(l){const c={};return l.integrity&&(c.integrity=l.integrity),l.referrerPolicy&&(c.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?c.credentials="include":l.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function r(l){if(l.ep)return;l.ep=!0;const c=i(l);fetch(l.href,c)}})();var tf={exports:{}},Kr={},nf={exports:{}},af={};var Uy;function qw(){return Uy||(Uy=1,(function(e){function n($,W){var fe=$.length;$.push(W);e:for(;0<fe;){var je=fe-1>>>1,se=$[je];if(0<l(se,W))$[je]=W,$[fe]=se,fe=je;else break e}}function i($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var W=$[0],fe=$.pop();if(fe!==W){$[0]=fe;e:for(var je=0,se=$.length,Ye=se>>>1;je<Ye;){var J=2*(je+1)-1,ue=$[J],ee=J+1,de=$[ee];if(0>l(ue,fe))ee<se&&0>l(de,ue)?($[je]=de,$[ee]=fe,je=ee):($[je]=ue,$[J]=fe,je=J);else if(ee<se&&0>l(de,fe))$[je]=de,$[ee]=fe,je=ee;else break e}}return W}function l($,W){var fe=$.sortIndex-W.sortIndex;return fe!==0?fe:$.id-W.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,h=d.now();e.unstable_now=function(){return d.now()-h}}var g=[],v=[],S=1,x=null,N=3,_=!1,T=!1,k=!1,O=!1,R=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;function Z($){for(var W=i(v);W!==null;){if(W.callback===null)r(v);else if(W.startTime<=$)r(v),W.sortIndex=W.expirationTime,n(g,W);else break;W=i(v)}}function X($){if(k=!1,Z($),!T)if(i(g)!==null)T=!0,F||(F=!0,Se());else{var W=i(v);W!==null&&pe(X,W.startTime-$)}}var F=!1,z=-1,M=5,oe=-1;function ke(){return O?!0:!(e.unstable_now()-oe<M)}function ze(){if(O=!1,F){var $=e.unstable_now();oe=$;var W=!0;try{e:{T=!1,k&&(k=!1,I(z),z=-1),_=!0;var fe=N;try{t:{for(Z($),x=i(g);x!==null&&!(x.expirationTime>$&&ke());){var je=x.callback;if(typeof je=="function"){x.callback=null,N=x.priorityLevel;var se=je(x.expirationTime<=$);if($=e.unstable_now(),typeof se=="function"){x.callback=se,Z($),W=!0;break t}x===i(g)&&r(g),Z($)}else r(g);x=i(g)}if(x!==null)W=!0;else{var Ye=i(v);Ye!==null&&pe(X,Ye.startTime-$),W=!1}}break e}finally{x=null,N=fe,_=!1}W=void 0}}finally{W?Se():F=!1}}}var Se;if(typeof P=="function")Se=function(){P(ze)};else if(typeof MessageChannel<"u"){var He=new MessageChannel,le=He.port2;He.port1.onmessage=ze,Se=function(){le.postMessage(null)}}else Se=function(){R(ze,0)};function pe($,W){z=R(function(){$(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return N},e.unstable_next=function($){switch(N){case 1:case 2:case 3:var W=3;break;default:W=N}var fe=N;N=W;try{return $()}finally{N=fe}},e.unstable_requestPaint=function(){O=!0},e.unstable_runWithPriority=function($,W){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var fe=N;N=$;try{return W()}finally{N=fe}},e.unstable_scheduleCallback=function($,W,fe){var je=e.unstable_now();switch(typeof fe=="object"&&fe!==null?(fe=fe.delay,fe=typeof fe=="number"&&0<fe?je+fe:je):fe=je,$){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=fe+se,$={id:S++,callback:W,priorityLevel:$,startTime:fe,expirationTime:se,sortIndex:-1},fe>je?($.sortIndex=fe,n(v,$),i(g)===null&&$===i(v)&&(k?(I(z),z=-1):k=!0,pe(X,fe-je))):($.sortIndex=se,n(g,$),T||_||(T=!0,F||(F=!0,Se()))),$},e.unstable_shouldYield=ke,e.unstable_wrapCallback=function($){var W=N;return function(){var fe=N;N=W;try{return $.apply(this,arguments)}finally{N=fe}}}})(af)),af}var $y;function Uw(){return $y||($y=1,nf.exports=qw()),nf.exports}var Vy;function $w(){if(Vy)return Kr;Vy=1;var e=Uw(),n=Nw(),i=kw();function r(t){var a="https://react.dev/errors/"+t;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)a+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function c(t){var a=t,s=t;if(t.alternate)for(;a.return;)a=a.return;else{t=a;do a=t,(a.flags&4098)!==0&&(s=a.return),t=a.return;while(t)}return a.tag===3?s:null}function d(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function h(t){if(t.tag===31){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function g(t){if(c(t)!==t)throw Error(r(188))}function v(t){var a=t.alternate;if(!a){if(a=c(t),a===null)throw Error(r(188));return a!==t?null:t}for(var s=t,o=a;;){var u=s.return;if(u===null)break;var m=u.alternate;if(m===null){if(o=u.return,o!==null){s=o;continue}break}if(u.child===m.child){for(m=u.child;m;){if(m===s)return g(u),t;if(m===o)return g(u),a;m=m.sibling}throw Error(r(188))}if(s.return!==o.return)s=u,o=m;else{for(var b=!1,j=u.child;j;){if(j===s){b=!0,s=u,o=m;break}if(j===o){b=!0,o=u,s=m;break}j=j.sibling}if(!b){for(j=m.child;j;){if(j===s){b=!0,s=m,o=u;break}if(j===o){b=!0,o=m,s=u;break}j=j.sibling}if(!b)throw Error(r(189))}}if(s.alternate!==o)throw Error(r(190))}if(s.tag!==3)throw Error(r(188));return s.stateNode.current===s?t:a}function S(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=S(t),a!==null)return a;t=t.sibling}return null}var x=Object.assign,N=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),P=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),oe=Symbol.for("react.activity"),ke=Symbol.for("react.memo_cache_sentinel"),ze=Symbol.iterator;function Se(t){return t===null||typeof t!="object"?null:(t=ze&&t[ze]||t["@@iterator"],typeof t=="function"?t:null)}var He=Symbol.for("react.client.reference");function le(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===He?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case R:return"Profiler";case O:return"StrictMode";case X:return"Suspense";case F:return"SuspenseList";case oe:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case T:return"Portal";case P:return t.displayName||"Context";case I:return(t._context.displayName||"Context")+".Consumer";case Z:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case z:return a=t.displayName||null,a!==null?a:le(t.type)||"Memo";case M:a=t._payload,t=t._init;try{return le(t(a))}catch{}}return null}var pe=Array.isArray,$=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},je=[],se=-1;function Ye(t){return{current:t}}function J(t){0>se||(t.current=je[se],je[se]=null,se--)}function ue(t,a){se++,je[se]=t.current,t.current=a}var ee=Ye(null),de=Ye(null),ae=Ye(null),Ne=Ye(null);function tt(t,a){switch(ue(ae,a),ue(de,t),ue(ee,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?ly(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=ly(a),t=cy(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}J(ee),ue(ee,t)}function xe(){J(ee),J(de),J(ae)}function $e(t){t.memoizedState!==null&&ue(Ne,t);var a=ee.current,s=cy(a,t.type);a!==s&&(ue(de,t),ue(ee,s))}function Qe(t){de.current===t&&(J(ee),J(de)),Ne.current===t&&(J(Ne),Pr._currentValue=fe)}var Dt,Un;function Rt(t){if(Dt===void 0)try{throw Error()}catch(s){var a=s.stack.trim().match(/\n( *(at )?)/);Dt=a&&a[1]||"",Un=-1<s.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Dt+t+Un}var er=!1;function Ri(t,a){if(!t||er)return"";er=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(a){var Y=function(){throw Error()};if(Object.defineProperty(Y.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Y,[])}catch(V){var U=V}Reflect.construct(t,[],Y)}else{try{Y.call()}catch(V){U=V}t.call(Y.prototype)}}else{try{throw Error()}catch(V){U=V}(Y=t())&&typeof Y.catch=="function"&&Y.catch(function(){})}}catch(V){if(V&&U&&typeof V.stack=="string")return[V.stack,U.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=o.DetermineComponentFrameRoot(),b=m[0],j=m[1];if(b&&j){var C=b.split(`
@@ -207,4 +207,4 @@ spec:
207
207
  `);$(ot)}}catch(ie){Qe(ie instanceof Error?ie.message:"Failed to generate queries")}finally{xe(!1)}}},Ui=async()=>{if(!oe)return;const ie=_t;if(ie.length!==0){Mi(!0),go(null);try{await Ak(oe,ie),er(!0),await r(),N(4)}catch(ot){go(ot instanceof Error?ot.message:"Failed to save competitors")}finally{Mi(!1)}}},$i=async()=>{const ie=va.trim();if(ie){wo(!0),Sa(null);try{await Ek("gemini",{apiKey:ie}),tn({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),xo(""),await r()}catch(ot){Sa(ot instanceof Error?ot.message:"Failed to save Gemini key")}finally{wo(!1)}}},Zn=async()=>{if(oe){bo(!0);try{const ie=await vo.mutateAsync({projectName:oe,projectLabel:k||_||oe,sourceAction:"setup-launch"});Uc(ie.id),nr(!0),await r()}catch{}finally{bo(!1)}}},pn=()=>N(ie=>Math.max(0,ie-1)),ai=(()=>{switch(x){case 0:return f.jsxs(kn,{className:"surface-card step-card",children:[f.jsx("div",{className:"section-head",children:f.jsxs("div",{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 1 of 5"}),f.jsx("h2",{children:"System ready"})]})}),f.jsx("p",{className:"supporting-copy",children:"Checking that your Canonry instance is configured and reachable."}),f.jsx("div",{className:"compact-stack",children:v.healthChecks.map(ie=>f.jsxs("div",{className:"health-check-row",children:[f.jsxs("div",{children:[f.jsx("p",{className:"run-row-title",children:ie.label}),f.jsx("p",{className:"supporting-copy",children:ie.detail}),ie.id==="provider"&&ie.state!=="ready"&&f.jsxs("div",{className:"mt-3 rounded-md border border-default bg-bg-elevated/40 p-3 space-y-2",children:[f.jsxs("p",{className:"text-xs text-secondary",children:["Paste a Gemini key to enable visibility checks (free at"," ",f.jsx("a",{href:"https://aistudio.google.com/apikey",target:"_blank",rel:"noreferrer",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"aistudio.google.com"}),")."]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"password",value:va,onChange:ot=>xo(ot.target.value),placeholder:"AI... (paste here)",className:"flex-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-sm text-heading placeholder:text-faint focus:border-mono-600 focus:outline-none font-mono",disabled:Li}),f.jsx(Ue,{type:"button",size:"sm",disabled:Li||!va.trim(),onClick:Nn($i),children:Li?"Saving...":"Save"})]}),jo&&f.jsx("p",{className:"text-xs text-negative-400",children:jo}),f.jsxs("p",{className:"text-[11px] text-faint",children:["Other providers (OpenAI, Claude, Perplexity) configurable later via"," ",f.jsx(st,{to:"/settings",className:"text-muted hover:text-neutral underline underline-offset-2",children:"/settings"}),"."]})]})]}),f.jsx(Bn,{tone:ie.state==="ready"?"positive":"caution",title:ie.id==="api"?$s(g.apiStatus):ie.id==="worker"?$s(g.workerStatus):ie.detail,children:ie.state==="ready"?"Ready":"Attention"})]},ie.id))}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Ue,{type:"button",disabled:!$c,onClick:()=>N(1),children:"Continue"})]})]});case 1:return f.jsxs(kn,{className:"surface-card step-card",children:[f.jsxs("div",{className:"section-head",children:[f.jsxs("div",{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 2 of 5"}),f.jsx("h2",{children:"Create project"})]}),oe?f.jsx(Bn,{tone:"positive",children:"Created"}):null]}),oe?f.jsxs("div",{className:"compact-stack",children:[f.jsxs("p",{className:"text-neutral",children:["Project ",f.jsx("span",{className:"text-heading font-medium",children:oe})," created successfully."]}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsx(Ue,{type:"button",onClick:()=>N(2),children:"Continue"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"project-name",children:"Project name"}),f.jsx("input",{id:"project-name",className:"setup-input",type:"text",placeholder:"my-website",value:_,onChange:ie=>T(ie.target.value)}),ht&&ht!==_?f.jsxs("p",{className:"supporting-copy",children:["Slug: ",ht]}):null]}),f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"display-name",children:"Display name (optional)"}),f.jsx("input",{id:"display-name",className:"setup-input",type:"text",placeholder:"My Website",value:k,onChange:ie=>O(ie.target.value)})]}),f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"domain",children:"Canonical domain"}),f.jsx("input",{id:"domain",className:"setup-input",type:"text",placeholder:"example.com",value:R,onChange:ie=>I(ie.target.value)})]}),f.jsxs("div",{className:"setup-field-row",children:[f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"country",children:"Country"}),f.jsx("input",{id:"country",className:"setup-input",type:"text",placeholder:"US",maxLength:2,value:P,onChange:ie=>Z(ie.target.value.toUpperCase())})]}),f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"language",children:"Language"}),f.jsx("input",{id:"language",className:"setup-input",type:"text",placeholder:"en",maxLength:5,value:X,onChange:ie=>F(ie.target.value.toLowerCase())})]})]}),f.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-default bg-surface p-3 cursor-pointer hover:border-strong",children:[f.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-strong bg-bg",checked:z,onChange:ie=>M(ie.target.checked)}),f.jsxs("span",{className:"flex-1",children:[f.jsx("span",{className:"block text-sm text-heading",children:"Auto-extract backlinks"}),f.jsxs("span",{className:"block text-xs text-muted mt-0.5",children:["When a new Common Crawl release syncs, automatically extract backlinks for this project."," ",f.jsx(st,{to:"/backlinks",className:"text-positive-400 hover:text-positive underline underline-offset-2",children:"Manage backlinks"})]})]})]}),ze?f.jsx("p",{className:"text-negative-400 text-sm",children:ze}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsx(Ue,{type:"button",disabled:!ht||!R||He,onClick:Nn(Vc),children:He?"Creating...":"Create project"})]})]})]});case 2:return f.jsxs(kn,{className:"surface-card step-card",children:[f.jsxs("div",{className:"section-head",children:[f.jsxs("div",{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 3 of 5"}),f.jsx("h2",{children:"Add queries"})]}),W?f.jsxs(Bn,{tone:"positive",children:[Mt.length," saved"]}):f.jsxs(Bn,{tone:"neutral",children:[Mt.length," quer",Mt.length!==1?"ies":"y"]})]}),f.jsx("p",{className:"supporting-copy",children:"Enter the search queries you want to track. One per line."}),W?f.jsxs("div",{className:"compact-stack",children:[f.jsx("ul",{className:"detail-list",children:Mt.map(ie=>f.jsx("li",{children:ie},ie))}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsx(Ue,{type:"button",onClick:()=>N(3),children:"Continue"})]})]}):f.jsxs("div",{className:"compact-stack",children:[ue.length>0?f.jsxs("div",{className:"compact-stack",children:[f.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[f.jsx("span",{className:"flex-1 border-t border-base"}),"auto-generate",f.jsx("span",{className:"flex-1 border-t border-base"})]}),f.jsxs("div",{className:"flex items-end gap-2",children:[f.jsxs("div",{className:"setup-field flex-1",children:[f.jsx("label",{className:"setup-label",htmlFor:"gen-provider",children:"Provider"}),f.jsx("select",{id:"gen-provider",className:"setup-input",value:ee,onChange:ie=>de(ie.target.value),children:ue.map(ie=>f.jsxs("option",{value:ie.name,children:[ie.displayName??ie.name,ie.model?` (${ie.model})`:""]},ie.name))})]}),f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"gen-count",children:"Count"}),f.jsx("select",{id:"gen-count",className:"setup-input",value:ae,onChange:ie=>Ne(Number(ie.target.value)),children:[3,5,10,15,20].map(ie=>f.jsx("option",{value:ie,children:ie},ie))})]}),f.jsx(Ue,{type:"button",variant:"outline",disabled:tt||!ee,onClick:Nn(qi),children:tt?"Analyzing site...":"Generate"})]}),$e?f.jsx("p",{className:"text-negative-400 text-sm",children:$e}):null]}):null,f.jsxs("div",{className:"flex items-center gap-2 text-muted text-xs uppercase tracking-wide",children:[f.jsx("span",{className:"flex-1 border-t border-base"}),"or type manually",f.jsx("span",{className:"flex-1 border-t border-base"})]}),f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"queries",children:"Queries (one per line)"}),f.jsx("textarea",{id:"queries",className:"setup-textarea",rows:6,placeholder:`emergency dentist brooklyn
208
208
  best invisalign downtown brooklyn
209
209
  pediatric dentist brooklyn heights`,value:pe,onChange:ie=>$(ie.target.value)})]}),je?f.jsx("p",{className:"text-negative-400 text-sm",children:je}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsx(Ue,{type:"button",disabled:Mt.length===0||Ye,onClick:Nn(Ic),children:Ye?"Saving...":`Save ${Mt.length} quer${Mt.length!==1?"ies":"y"}`})]})]})]});case 3:return f.jsxs(kn,{className:"surface-card step-card",children:[f.jsxs("div",{className:"section-head",children:[f.jsxs("div",{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 4 of 5"}),f.jsx("h2",{children:"Add competitors"})]}),Rt?f.jsx(Bn,{tone:"positive",children:"Saved"}):null]}),f.jsx("p",{className:"supporting-copy",children:"Domains that compete for the same queries. One per line."}),Rt?f.jsxs("div",{className:"compact-stack",children:[f.jsx("ul",{className:"detail-list",children:_t.map(ie=>f.jsx("li",{children:ie},ie))}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsx(Ue,{type:"button",onClick:()=>N(4),children:"Continue"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("div",{className:"setup-field",children:[f.jsx("label",{className:"setup-label",htmlFor:"competitors",children:"Competitor domains (one per line)"}),f.jsx("textarea",{id:"competitors",className:"setup-textarea",rows:4,placeholder:`competitor1.com
210
- competitor2.com`,value:Dt,onChange:ie=>Un(ie.target.value)})]}),Ri?f.jsx("p",{className:"text-negative-400 text-sm",children:Ri}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:()=>N(4),children:"Skip"}),f.jsx(Ue,{type:"button",disabled:_t.length===0||tr,onClick:Nn(Ui),children:tr?"Saving...":`Save ${_t.length} competitor${_t.length!==1?"s":""}`})]})]})]})]});case 4:{const ie=So.data,ot=ie?.status==="completed"||ie?.status==="partial"||ie?.status==="failed"||ie?.status==="cancelled",Yn=ie?.snapshots??[],ii=Yn.filter($n=>$n.citationState==="cited").length,Pc=Yn.filter($n=>$n.answerMentioned===!0).length,ar=new Set(Yn.map($n=>$n.query).filter($n=>!!$n)).size,No=Bi?ot&&(ie?.status==="completed"||ie?.status==="partial")?f.jsx(Bn,{tone:"positive",children:"Complete"}):ot?f.jsx(Bn,{tone:"negative",children:"Failed"}):f.jsx(Bn,{tone:"caution",children:"Running"}):null;return f.jsxs(kn,{className:"surface-card step-card",children:[f.jsxs("div",{className:"section-head",children:[f.jsxs("div",{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 5 of 5"}),f.jsx("h2",{children:"Launch first run"})]}),No]}),Bi?ot?ie?.status==="failed"?f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-negative-400",children:"Sweep failed. Inspect the run on the project page for the provider error and retry from there."}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Ue,{type:"button",onClick:()=>{S({to:oe?`/projects/${encodeURIComponent(oe)}`:"/"})},children:"Open project"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",f.jsx("span",{className:"text-heading font-medium",children:oe}),":"]}),f.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[f.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted",children:"Mentioned"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Pc,f.jsxs("span",{className:"text-faint text-lg",children:[" / ",ar]})]}),f.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:"queries with brand in answer"})]}),f.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted",children:"Cited"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[ii,f.jsxs("span",{className:"text-faint text-lg",children:[" / ",ar]})]}),f.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:"queries with domain in sources"})]}),f.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted",children:"Snapshots"}),f.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Yn.length}),f.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:"total (query × provider)"})]})]}),f.jsx("p",{className:"text-[11px] text-muted mt-1",children:"Full evidence, per-provider breakdown, and suggested next queries on the project dashboard."}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Ue,{type:"button",onClick:()=>{S({to:oe?`/projects/${encodeURIComponent(oe)}`:"/"})},children:"Open project dashboard →"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-neutral",children:"Sweep running — typically 30-60s. Polling every 2s…"}),f.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:f.jsxs("p",{children:["Status: ",f.jsx("span",{className:"text-neutral",children:ie?.status??"queued"})]})}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Ue,{type:"button",variant:"outline",onClick:()=>{S({to:oe?`/projects/${encodeURIComponent(oe)}`:"/"})},children:"Watch on project page"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("p",{className:"supporting-copy",children:["Everything is configured. Launch an answer-visibility sweep to start tracking citations for ",f.jsx("span",{className:"text-heading font-medium",children:oe}),"."]}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsx(Ue,{type:"button",disabled:yo,onClick:Nn(Zn),children:yo?"Launching...":"Launch visibility sweep"})]})]})]})}default:return null}})();return f.jsxs("div",{className:"page-container",children:[f.jsx("div",{className:"page-header",children:f.jsxs("div",{className:"page-header-left",children:[f.jsx("h1",{className:"page-title",children:"Setup"}),f.jsx("p",{className:"page-subtitle",children:"Create a project, add queries, add competitors, and launch the first run."})]})}),f.jsx($B,{current:x,labels:UB}),f.jsx("section",{className:"setup-wizard",children:ai})]})}function IB(){return f.jsx("div",{className:"page-container",children:f.jsx("section",{className:"page-section",children:f.jsxs(kn,{className:"surface-card empty-card",children:[f.jsx("h1",{children:"Route not found"}),f.jsx("p",{children:"The current path does not map to a dashboard view."}),f.jsx(Ue,{asChild:!0,children:f.jsx(st,{to:"/",children:"Return to overview"})})]})})})}const ba=Ps(()=>Gs(()=>import("./ProjectPage-DVED6lF7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url),"ProjectPage"),PB=Ps(()=>Gs(()=>import("./RunsPage-DQ8ip0Tf.js"),__vite__mapDeps([9,1,2,7,5,8]),import.meta.url),"RunsPage"),GB=Ps(()=>Gs(()=>import("./SettingsPage-CZokCKF4.js"),__vite__mapDeps([10,1,7,5,8]),import.meta.url),"SettingsPage"),HB=Ps(()=>Gs(()=>import("./BacklinksPage-D00sAx6q.js"),__vite__mapDeps([11,1,6,7,5,8]),import.meta.url),"BacklinksPage"),QB=Ps(()=>Gs(()=>import("./TrafficPage-C0nEB9tv.js"),__vite__mapDeps([12,1,4,13,7,5,8]),import.meta.url),"TrafficPage"),KB=Ps(()=>Gs(()=>import("./TrafficSourceDetailPage-CKsWe8kA.js"),__vite__mapDeps([14,1,4,3,5,13,7,8]),import.meta.url),"TrafficSourceDetailPage");function ZB(){return f.jsx(vM,{children:f.jsx(bM,{})})}const nn=zw()({component:ZB,validateSearch:e=>({runId:typeof e.runId=="string"?e.runId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0})}),YB=Et({getParentRoute:()=>nn,path:"/",component:wM,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Oi({client:te}));if(n&&n.length===0)throw Hf({to:"/setup"})}}),XB=Et({getParentRoute:()=>nn,path:"/projects",component:RB}),JB=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Kn=Et({getParentRoute:()=>nn,path:"/projects/$projectName",component:()=>f.jsx(xf,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!JB.test(r))return;let l=e.queryClient.getQueryData(Oi({client:te}));if(!l)try{l=await e.queryClient.ensureQueryData(wc({client:te}))}catch{return}const c=l.find(d=>d.id===r);if(c)throw Hf({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(c.name)}`),replace:!0})}}),FB=Et({getParentRoute:()=>Kn,path:"/",component:()=>f.jsx(ba,{tab:"overview"})}),WB=Et({getParentRoute:()=>Kn,path:"/search-console",component:()=>f.jsx(ba,{tab:"search-console"})}),eL=Et({getParentRoute:()=>Kn,path:"/local",component:()=>f.jsx(ba,{tab:"local"})}),tL=Et({getParentRoute:()=>Kn,path:"/discovery",component:()=>f.jsx(ba,{tab:"discovery"})}),nL=Et({getParentRoute:()=>Kn,path:"/report",component:()=>f.jsx(ba,{tab:"report"})}),aL=Et({getParentRoute:()=>Kn,path:"/activity",component:()=>f.jsx(ba,{tab:"activity"})}),iL=Et({getParentRoute:()=>Kn,path:"/backlinks",component:()=>f.jsx(ba,{tab:"backlinks"})}),sL=Et({getParentRoute:()=>Kn,path:"/technical-aeo",component:()=>f.jsx(ba,{tab:"technical-aeo"})}),rL=Et({getParentRoute:()=>Kn,path:"/settings",component:()=>f.jsx(ba,{tab:"settings"})}),oL=Et({getParentRoute:()=>nn,path:"/runs",component:PB}),lL=Et({getParentRoute:()=>nn,path:"/settings",component:GB,beforeLoad:({context:e})=>{}}),cL=Et({getParentRoute:()=>nn,path:"/setup",component:VB,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Oi({client:te}));if(n&&n.length>0)throw Hf({to:"/"})}}),uL=Et({getParentRoute:()=>nn,path:"/backlinks",component:HB}),dL=Et({getParentRoute:()=>nn,path:"/traffic",component:QB}),fL=Et({getParentRoute:()=>nn,path:"/traffic/$projectName/$sourceId",component:KB}),pL=Et({getParentRoute:()=>nn,path:"*",component:IB}),mL=nn.addChildren([YB,XB,Kn.addChildren([FB,WB,eL,tL,nL,aL,iL,sL,rL]),oL,lL,cL,uL,dL,fL,pL]);function hL(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const uv=hL(),gL=uv==="/"?"":uv.replace(/\/$/,"");function yL(e,n){return Dw({routeTree:mL,basepath:gL||"/",context:{queryClient:e},...n?.initialEntries})}const bL=6e4;function vL(){const[e,n]=q.useState(rf()?"ready":"checking"),[i,r]=q.useState(""),[l,c]=q.useState(""),[d,h]=q.useState(null),[g,v]=q.useState(!1),[S,x]=q.useState(!1),N=q.useRef(null),_=q.useRef(null),T=()=>{if(!N.current){const R=Fk();_.current=R,N.current=yL(R)}return{queryClient:_.current,router:N.current}};q.useEffect(()=>{if(rf())return;let R=!1;return Qy().then(I=>{R||(I.authenticated?n("ready"):n(I.setupRequired?"setup":"login"))}).catch(I=>{R||(h(I instanceof Error?I.message:"Failed to reach the Canonry API"),n("login"))}),()=>{R=!0}},[]),q.useEffect(()=>{if(e!=="ready"||rf())return;const R=setInterval(()=>{Qy().then(I=>{I.authenticated||(x(!0),n(I.setupRequired?"setup":"login"))}).catch(()=>{})},bL);return Hy(()=>{x(!0),n("login")}),()=>{clearInterval(R),Hy(null)}},[e]);const k=async R=>{if(R.preventDefault(),!i.trim()||i.trim().length<8){h("Password must be at least 8 characters");return}if(i!==l){h("Passwords do not match");return}v(!0),h(null);try{if(!(await Ck(i.trim())).authenticated){h("Setup failed");return}r(""),c(""),x(!1),n("ready")}catch(I){h(I instanceof Hn||I instanceof Error?I.message:"Setup failed")}finally{v(!1)}},O=async R=>{if(R.preventDefault(),!!i.trim()){v(!0),h(null);try{if(!(await Tk(i.trim())).authenticated){h("Incorrect password");return}r(""),x(!1),n("ready")}catch(I){h(I instanceof Hn||I instanceof Error?I.message:"Authentication failed")}finally{v(!1)}}};if(e==="ready"){const{queryClient:R,router:I}=T();return f.jsx(Rw,{client:R,children:f.jsx(Mw,{router:I})})}return f.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:f.jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md items-center justify-center",children:f.jsx(kn,{className:"surface-card w-full",children:e==="checking"?f.jsx(Yl,{className:"py-8",children:f.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):e==="setup"?f.jsxs(f.Fragment,{children:[f.jsxs(Bf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),f.jsx(Lf,{children:"Create a dashboard password"}),f.jsx(qf,{children:"Choose a password to protect the Canonry dashboard. You will use this to sign in on future visits."})]}),f.jsx(Yl,{children:f.jsxs("form",{className:"space-y-4",onSubmit:Nn(k),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:i,onChange:R=>r(R.target.value),placeholder:"At least 8 characters"})]}),f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-secondary",children:"Confirm password"}),f.jsx("input",{className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:l,onChange:R=>c(R.target.value),placeholder:"Re-enter password"})]}),d?f.jsx("p",{className:"text-sm text-negative-400",children:d}):null,f.jsx(Ue,{type:"submit",disabled:g||!i.trim()||!l.trim(),children:g?"Setting up…":"Create password & open dashboard"})]})})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Bf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),f.jsx(Lf,{children:"Sign in to Canonry"}),f.jsx(qf,{children:"Enter your dashboard password to continue."})]}),f.jsxs(Yl,{children:[S?f.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,f.jsxs("form",{className:"space-y-4",onSubmit:Nn(O),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:i,onChange:R=>r(R.target.value),placeholder:"Dashboard password"})]}),d?f.jsx("p",{className:"text-sm text-negative-400",children:d}):null,f.jsx(Ue,{type:"submit",disabled:g||!i.trim(),children:g?"Signing in…":"Open dashboard"})]})]})]})})})})}const f1=document.getElementById("root");if(!f1)throw new Error("Expected #root element for web app bootstrap.");Iw.createRoot(f1).render(f.jsx(q.StrictMode,{children:f.jsx(vL,{})}));export{v6 as $,J5 as A,Ue as B,sc as C,ML as D,a6 as E,s6 as F,R5 as G,r6 as H,Xr as I,HL as J,GL as K,KL as L,tn as M,n5 as N,c6 as O,XR as P,u6 as Q,YL as R,PD as S,Bn as T,o6 as U,l6 as V,i6 as W,QL as X,XL as Y,d6 as Z,f6 as _,I6 as a,LL as a$,h6 as a0,y6 as a1,g6 as a2,b6 as a3,$k as a4,F0 as a5,Ae as a6,m6 as a7,J4 as a8,_i as a9,FL as aA,Oi as aB,WL as aC,wp as aD,U6 as aE,V6 as aF,$6 as aG,JL as aH,mA as aI,Bv as aJ,q4 as aK,$4 as aL,U4 as aM,U5 as aN,E6 as aO,q5 as aP,u5 as aQ,X6 as aR,I5 as aS,$5 as aT,P5 as aU,G5 as aV,L5 as aW,V5 as aX,zL as aY,OL as aZ,EL as a_,p6 as aa,fO as ab,pO as ac,B5 as ad,M5 as ae,E5 as af,x5 as ag,_5 as ah,C5 as ai,Hn as aj,T5 as ak,NL as al,TA as am,Y5 as an,_A as ao,LA as ap,eR as aq,Wl as ar,z5 as as,O5 as at,Af as au,O6 as av,ZL as aw,B6 as ax,L6 as ay,q6 as az,Wf as b,JR as b$,e6 as b0,Tb as b1,W5 as b2,qL as b3,UL as b4,F5 as b5,$L as b6,VL as b7,PL as b8,IL as b9,o5 as bA,r5 as bB,N6 as bC,x6 as bD,Z5 as bE,a5 as bF,i5 as bG,s5 as bH,l5 as bI,Ac as bJ,H6 as bK,kp as bL,Ek as bM,BL as bN,e5 as bO,t5 as bP,_p as bQ,c5 as bR,$s as bS,Eb as bT,v5 as bU,w5 as bV,N5 as bW,k5 as bX,S5 as bY,j5 as bZ,A5 as b_,uo as ba,wc as bb,$3 as bc,pk as bd,n6 as be,qB as bf,Qt as bg,wk as bh,ZD as bi,DL as bj,_L as bk,CL as bl,RL as bm,G6 as bn,xk as bo,Ak as bp,AL as bq,kL as br,Nk as bs,TL as bt,Y6 as bu,i4 as bv,S6 as bw,w6 as bx,Rk as by,j6 as bz,et as c,gS as c0,n3 as c1,yS as c2,bS as c3,jA as c4,b5 as c5,Jy as c6,R6 as c7,H5 as c8,Q5 as c9,xp as ca,t6 as cb,Hs as cc,z6 as cd,M6 as ce,y5 as cf,h5 as cg,g5 as ch,m5 as ci,D6 as cj,$E as d,P6 as e,X5 as f,kn as g,Vb as h,Nn as i,D5 as j,k6 as k,te as l,A6 as m,_6 as n,T6 as o,C6 as p,d5 as q,p5 as r,f5 as s,HD as t,Cp as u,Q6 as v,K6 as w,Z6 as x,Mf as y,K5 as z};
210
+ competitor2.com`,value:Dt,onChange:ie=>Un(ie.target.value)})]}),Ri?f.jsx("p",{className:"text-negative-400 text-sm",children:Ri}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:()=>N(4),children:"Skip"}),f.jsx(Ue,{type:"button",disabled:_t.length===0||tr,onClick:Nn(Ui),children:tr?"Saving...":`Save ${_t.length} competitor${_t.length!==1?"s":""}`})]})]})]})]});case 4:{const ie=So.data,ot=ie?.status==="completed"||ie?.status==="partial"||ie?.status==="failed"||ie?.status==="cancelled",Yn=ie?.snapshots??[],ii=Yn.filter($n=>$n.citationState==="cited").length,Pc=Yn.filter($n=>$n.answerMentioned===!0).length,ar=new Set(Yn.map($n=>$n.query).filter($n=>!!$n)).size,No=Bi?ot&&(ie?.status==="completed"||ie?.status==="partial")?f.jsx(Bn,{tone:"positive",children:"Complete"}):ot?f.jsx(Bn,{tone:"negative",children:"Failed"}):f.jsx(Bn,{tone:"caution",children:"Running"}):null;return f.jsxs(kn,{className:"surface-card step-card",children:[f.jsxs("div",{className:"section-head",children:[f.jsxs("div",{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Step 5 of 5"}),f.jsx("h2",{children:"Launch first run"})]}),No]}),Bi?ot?ie?.status==="failed"?f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-negative-400",children:"Sweep failed. Inspect the run on the project page for the provider error and retry from there."}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Ue,{type:"button",onClick:()=>{S({to:oe?`/projects/${encodeURIComponent(oe)}`:"/"})},children:"Open project"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("p",{className:"text-neutral",children:["Sweep complete. Your first answer-visibility snapshot for"," ",f.jsx("span",{className:"text-heading font-medium",children:oe}),":"]}),f.jsxs("div",{className:"grid grid-cols-3 gap-2 mt-1",children:[f.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted",children:"Mentioned"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[Pc,f.jsxs("span",{className:"text-faint text-lg",children:[" / ",ar]})]}),f.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:"queries with brand in answer"})]}),f.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted",children:"Cited"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:[ii,f.jsxs("span",{className:"text-faint text-lg",children:[" / ",ar]})]}),f.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:"queries with domain in sources"})]}),f.jsxs("div",{className:"rounded-md border border-default bg-surface p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted",children:"Snapshots"}),f.jsx("p",{className:"text-2xl font-bold tabular-nums text-primary mt-1",children:Yn.length}),f.jsx("p",{className:"text-[11px] text-muted mt-0.5",children:"total (query × provider)"})]})]}),f.jsx("p",{className:"text-[11px] text-muted mt-1",children:"Full evidence, per-provider breakdown, and suggested next queries on the project dashboard."}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Ue,{type:"button",onClick:()=>{S({to:oe?`/projects/${encodeURIComponent(oe)}`:"/"})},children:"Open project dashboard →"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-neutral",children:"Sweep running — typically 30-60s. Polling every 2s…"}),f.jsx("div",{className:"rounded-md border border-default bg-surface p-3 text-xs text-muted",children:f.jsxs("p",{children:["Status: ",f.jsx("span",{className:"text-neutral",children:ie?.status??"queued"})]})}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Ue,{type:"button",variant:"outline",onClick:()=>{S({to:oe?`/projects/${encodeURIComponent(oe)}`:"/"})},children:"Watch on project page"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("p",{className:"supporting-copy",children:["Everything is configured. Launch an answer-visibility sweep to start tracking citations for ",f.jsx("span",{className:"text-heading font-medium",children:oe}),"."]}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Ue,{type:"button",variant:"outline",onClick:pn,children:"Back"}),f.jsx(Ue,{type:"button",disabled:yo,onClick:Nn(Zn),children:yo?"Launching...":"Launch visibility sweep"})]})]})]})}default:return null}})();return f.jsxs("div",{className:"page-container",children:[f.jsx("div",{className:"page-header",children:f.jsxs("div",{className:"page-header-left",children:[f.jsx("h1",{className:"page-title",children:"Setup"}),f.jsx("p",{className:"page-subtitle",children:"Create a project, add queries, add competitors, and launch the first run."})]})}),f.jsx($B,{current:x,labels:UB}),f.jsx("section",{className:"setup-wizard",children:ai})]})}function IB(){return f.jsx("div",{className:"page-container",children:f.jsx("section",{className:"page-section",children:f.jsxs(kn,{className:"surface-card empty-card",children:[f.jsx("h1",{children:"Route not found"}),f.jsx("p",{children:"The current path does not map to a dashboard view."}),f.jsx(Ue,{asChild:!0,children:f.jsx(st,{to:"/",children:"Return to overview"})})]})})})}const ba=Ps(()=>Gs(()=>import("./ProjectPage-DcR0lYs1.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url),"ProjectPage"),PB=Ps(()=>Gs(()=>import("./RunsPage-DWW5QQ20.js"),__vite__mapDeps([9,1,2,7,5,8]),import.meta.url),"RunsPage"),GB=Ps(()=>Gs(()=>import("./SettingsPage-CdpsDKrQ.js"),__vite__mapDeps([10,1,7,5,8]),import.meta.url),"SettingsPage"),HB=Ps(()=>Gs(()=>import("./BacklinksPage-CvriSR5g.js"),__vite__mapDeps([11,1,6,7,5,8]),import.meta.url),"BacklinksPage"),QB=Ps(()=>Gs(()=>import("./TrafficPage-BOe2UKFg.js"),__vite__mapDeps([12,1,4,13,7,5,8]),import.meta.url),"TrafficPage"),KB=Ps(()=>Gs(()=>import("./TrafficSourceDetailPage-VmvIxQBH.js"),__vite__mapDeps([14,1,4,3,5,13,7,8]),import.meta.url),"TrafficSourceDetailPage");function ZB(){return f.jsx(vM,{children:f.jsx(bM,{})})}const nn=zw()({component:ZB,validateSearch:e=>({runId:typeof e.runId=="string"?e.runId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0})}),YB=Et({getParentRoute:()=>nn,path:"/",component:wM,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Oi({client:te}));if(n&&n.length===0)throw Hf({to:"/setup"})}}),XB=Et({getParentRoute:()=>nn,path:"/projects",component:RB}),JB=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Kn=Et({getParentRoute:()=>nn,path:"/projects/$projectName",component:()=>f.jsx(xf,{}),beforeLoad:async({context:e,params:n,location:i})=>{const r=n.projectName;if(!JB.test(r))return;let l=e.queryClient.getQueryData(Oi({client:te}));if(!l)try{l=await e.queryClient.ensureQueryData(wc({client:te}))}catch{return}const c=l.find(d=>d.id===r);if(c)throw Hf({to:i.pathname.replace(`/projects/${r}`,`/projects/${encodeURIComponent(c.name)}`),replace:!0})}}),FB=Et({getParentRoute:()=>Kn,path:"/",component:()=>f.jsx(ba,{tab:"overview"})}),WB=Et({getParentRoute:()=>Kn,path:"/search-console",component:()=>f.jsx(ba,{tab:"search-console"})}),eL=Et({getParentRoute:()=>Kn,path:"/local",component:()=>f.jsx(ba,{tab:"local"})}),tL=Et({getParentRoute:()=>Kn,path:"/discovery",component:()=>f.jsx(ba,{tab:"discovery"})}),nL=Et({getParentRoute:()=>Kn,path:"/report",component:()=>f.jsx(ba,{tab:"report"})}),aL=Et({getParentRoute:()=>Kn,path:"/activity",component:()=>f.jsx(ba,{tab:"activity"})}),iL=Et({getParentRoute:()=>Kn,path:"/backlinks",component:()=>f.jsx(ba,{tab:"backlinks"})}),sL=Et({getParentRoute:()=>Kn,path:"/technical-aeo",component:()=>f.jsx(ba,{tab:"technical-aeo"})}),rL=Et({getParentRoute:()=>Kn,path:"/settings",component:()=>f.jsx(ba,{tab:"settings"})}),oL=Et({getParentRoute:()=>nn,path:"/runs",component:PB}),lL=Et({getParentRoute:()=>nn,path:"/settings",component:GB,beforeLoad:({context:e})=>{}}),cL=Et({getParentRoute:()=>nn,path:"/setup",component:VB,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Oi({client:te}));if(n&&n.length>0)throw Hf({to:"/"})}}),uL=Et({getParentRoute:()=>nn,path:"/backlinks",component:HB}),dL=Et({getParentRoute:()=>nn,path:"/traffic",component:QB}),fL=Et({getParentRoute:()=>nn,path:"/traffic/$projectName/$sourceId",component:KB}),pL=Et({getParentRoute:()=>nn,path:"*",component:IB}),mL=nn.addChildren([YB,XB,Kn.addChildren([FB,WB,eL,tL,nL,aL,iL,sL,rL]),oL,lL,cL,uL,dL,fL,pL]);function hL(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const uv=hL(),gL=uv==="/"?"":uv.replace(/\/$/,"");function yL(e,n){return Dw({routeTree:mL,basepath:gL||"/",context:{queryClient:e},...n?.initialEntries})}const bL=6e4;function vL(){const[e,n]=q.useState(rf()?"ready":"checking"),[i,r]=q.useState(""),[l,c]=q.useState(""),[d,h]=q.useState(null),[g,v]=q.useState(!1),[S,x]=q.useState(!1),N=q.useRef(null),_=q.useRef(null),T=()=>{if(!N.current){const R=Fk();_.current=R,N.current=yL(R)}return{queryClient:_.current,router:N.current}};q.useEffect(()=>{if(rf())return;let R=!1;return Qy().then(I=>{R||(I.authenticated?n("ready"):n(I.setupRequired?"setup":"login"))}).catch(I=>{R||(h(I instanceof Error?I.message:"Failed to reach the Canonry API"),n("login"))}),()=>{R=!0}},[]),q.useEffect(()=>{if(e!=="ready"||rf())return;const R=setInterval(()=>{Qy().then(I=>{I.authenticated||(x(!0),n(I.setupRequired?"setup":"login"))}).catch(()=>{})},bL);return Hy(()=>{x(!0),n("login")}),()=>{clearInterval(R),Hy(null)}},[e]);const k=async R=>{if(R.preventDefault(),!i.trim()||i.trim().length<8){h("Password must be at least 8 characters");return}if(i!==l){h("Passwords do not match");return}v(!0),h(null);try{if(!(await Ck(i.trim())).authenticated){h("Setup failed");return}r(""),c(""),x(!1),n("ready")}catch(I){h(I instanceof Hn||I instanceof Error?I.message:"Setup failed")}finally{v(!1)}},O=async R=>{if(R.preventDefault(),!!i.trim()){v(!0),h(null);try{if(!(await Tk(i.trim())).authenticated){h("Incorrect password");return}r(""),x(!1),n("ready")}catch(I){h(I instanceof Hn||I instanceof Error?I.message:"Authentication failed")}finally{v(!1)}}};if(e==="ready"){const{queryClient:R,router:I}=T();return f.jsx(Rw,{client:R,children:f.jsx(Mw,{router:I})})}return f.jsx("div",{className:"min-h-screen bg-bg px-4 py-8",children:f.jsx("div",{className:"mx-auto flex min-h-[calc(100vh-4rem)] max-w-md items-center justify-center",children:f.jsx(kn,{className:"surface-card w-full",children:e==="checking"?f.jsx(Yl,{className:"py-8",children:f.jsx("p",{className:"supporting-copy text-center",children:"Connecting to Canonry…"})}):e==="setup"?f.jsxs(f.Fragment,{children:[f.jsxs(Bf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),f.jsx(Lf,{children:"Create a dashboard password"}),f.jsx(qf,{children:"Choose a password to protect the Canonry dashboard. You will use this to sign in on future visits."})]}),f.jsx(Yl,{children:f.jsxs("form",{className:"space-y-4",onSubmit:Nn(k),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:i,onChange:R=>r(R.target.value),placeholder:"At least 8 characters"})]}),f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-secondary",children:"Confirm password"}),f.jsx("input",{className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:l,onChange:R=>c(R.target.value),placeholder:"Re-enter password"})]}),d?f.jsx("p",{className:"text-sm text-negative-400",children:d}):null,f.jsx(Ue,{type:"submit",disabled:g||!i.trim()||!l.trim(),children:g?"Setting up…":"Create password & open dashboard"})]})})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Bf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),f.jsx(Lf,{children:"Sign in to Canonry"}),f.jsx(qf,{children:"Enter your dashboard password to continue."})]}),f.jsxs(Yl,{children:[S?f.jsx("p",{className:"mb-4 rounded-md border border-caution bg-caution-soft px-3 py-2 text-sm text-caution",children:"Your session expired — please sign in again."}):null,f.jsxs("form",{className:"space-y-4",onSubmit:Nn(O),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-secondary",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-base bg-bg px-3 py-2 text-sm text-heading outline-none transition focus:border-mono-600",type:"password",value:i,onChange:R=>r(R.target.value),placeholder:"Dashboard password"})]}),d?f.jsx("p",{className:"text-sm text-negative-400",children:d}):null,f.jsx(Ue,{type:"submit",disabled:g||!i.trim(),children:g?"Signing in…":"Open dashboard"})]})]})]})})})})}const f1=document.getElementById("root");if(!f1)throw new Error("Expected #root element for web app bootstrap.");Iw.createRoot(f1).render(f.jsx(q.StrictMode,{children:f.jsx(vL,{})}));export{v6 as $,J5 as A,Ue as B,sc as C,ML as D,a6 as E,s6 as F,R5 as G,r6 as H,Xr as I,HL as J,GL as K,KL as L,tn as M,n5 as N,c6 as O,XR as P,u6 as Q,YL as R,PD as S,Bn as T,o6 as U,l6 as V,i6 as W,QL as X,XL as Y,d6 as Z,f6 as _,I6 as a,LL as a$,h6 as a0,y6 as a1,g6 as a2,b6 as a3,$k as a4,F0 as a5,Ae as a6,m6 as a7,J4 as a8,_i as a9,FL as aA,Oi as aB,WL as aC,wp as aD,U6 as aE,V6 as aF,$6 as aG,JL as aH,mA as aI,Bv as aJ,q4 as aK,$4 as aL,U4 as aM,U5 as aN,E6 as aO,q5 as aP,u5 as aQ,X6 as aR,I5 as aS,$5 as aT,P5 as aU,G5 as aV,L5 as aW,V5 as aX,zL as aY,OL as aZ,EL as a_,p6 as aa,fO as ab,pO as ac,B5 as ad,M5 as ae,E5 as af,x5 as ag,_5 as ah,C5 as ai,Hn as aj,T5 as ak,NL as al,TA as am,Y5 as an,_A as ao,LA as ap,eR as aq,Wl as ar,z5 as as,O5 as at,Af as au,O6 as av,ZL as aw,B6 as ax,L6 as ay,q6 as az,Wf as b,JR as b$,e6 as b0,Tb as b1,W5 as b2,qL as b3,UL as b4,F5 as b5,$L as b6,VL as b7,PL as b8,IL as b9,o5 as bA,r5 as bB,N6 as bC,x6 as bD,Z5 as bE,a5 as bF,i5 as bG,s5 as bH,l5 as bI,Ac as bJ,H6 as bK,kp as bL,Ek as bM,BL as bN,e5 as bO,t5 as bP,_p as bQ,c5 as bR,$s as bS,Eb as bT,v5 as bU,w5 as bV,N5 as bW,k5 as bX,S5 as bY,j5 as bZ,A5 as b_,uo as ba,wc as bb,$3 as bc,pk as bd,n6 as be,qB as bf,Qt as bg,wk as bh,ZD as bi,DL as bj,_L as bk,CL as bl,RL as bm,G6 as bn,xk as bo,Ak as bp,AL as bq,kL as br,Nk as bs,TL as bt,Y6 as bu,i4 as bv,S6 as bw,w6 as bx,Rk as by,j6 as bz,et as c,gS as c0,n3 as c1,yS as c2,bS as c3,jA as c4,b5 as c5,Jy as c6,R6 as c7,H5 as c8,Q5 as c9,xp as ca,t6 as cb,Hs as cc,z6 as cd,M6 as ce,y5 as cf,h5 as cg,g5 as ch,m5 as ci,D6 as cj,$E as d,P6 as e,X5 as f,kn as g,Vb as h,Nn as i,D5 as j,k6 as k,te as l,A6 as m,_6 as n,T6 as o,C6 as p,d5 as q,p5 as r,f5 as s,HD as t,Cp as u,Q6 as v,K6 as w,Z6 as x,Mf as y,K5 as z};