@ainyc/canonry 4.55.1 → 4.55.3
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.
- package/assets/agent-workspace/skills/canonry/references/server-side-traffic.md +9 -4
- package/assets/assets/{BacklinksPage-DVmaM864.js → BacklinksPage-buvZ4ZOd.js} +1 -1
- package/assets/assets/{ProjectPage-DtL3LFne.js → ProjectPage-D0UqSqe7.js} +1 -1
- package/assets/assets/{RunRow-BRqiLxj2.js → RunRow-D-DTu1PA.js} +1 -1
- package/assets/assets/{RunsPage-UxZ93-cg.js → RunsPage-CrBpgwkO.js} +1 -1
- package/assets/assets/{SettingsPage-Cr5_EGbk.js → SettingsPage-Bgsi9tZ2.js} +1 -1
- package/assets/assets/{TrafficPage-CUC_lfTe.js → TrafficPage-DAHXrzqz.js} +1 -1
- package/assets/assets/TrafficSourceDetailPage-DCcDN3VD.js +1 -0
- package/assets/assets/{extract-error-message-DD5MibWI.js → extract-error-message-BGhWiJPr.js} +1 -1
- package/assets/assets/{index-nnF1LnyK.js → index-CbDkoDBH.js} +2 -2
- package/assets/assets/{index-Bm3JQsW0.css → index-dxdJhCQO.css} +1 -1
- package/assets/assets/{server-traffic-DjRISEZ-.js → server-traffic-3xxyOEIX.js} +1 -1
- package/assets/assets/{trash-2-CJ5M--Le.js → trash-2-dppRdHYI.js} +1 -1
- package/assets/index.html +2 -2
- package/dist/{chunk-2OI7HFAB.js → chunk-5EAGNVCJ.js} +131 -188
- package/dist/{chunk-ZY3EDW3S.js → chunk-UOQ62KDD.js} +8 -3
- package/dist/{chunk-UTM3FPAJ.js → chunk-XB6Y63NI.js} +181 -3
- package/dist/{chunk-OFY3Z2F7.js → chunk-XHU35P3S.js} +359 -361
- package/dist/cli.js +12 -10
- package/dist/index.js +4 -4
- package/dist/{intelligence-service-NKAEHHJ5.js → intelligence-service-4PT22FED.js} +2 -2
- package/dist/mcp.js +2 -2
- package/package.json +6 -6
- package/assets/assets/TrafficSourceDetailPage-DARPL2TU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-tanstack-Dq7p98wZ.js";import{u as r,ba as t,B as a}from"./index-
|
|
1
|
+
import{j as s}from"./vendor-tanstack-Dq7p98wZ.js";import{u as r,ba as t,B as a}from"./index-CbDkoDBH.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-Dq7p98wZ.js";import{b8 as m,b9 as u,B as h,t as x,g as p}from"./index-
|
|
1
|
+
import{j as e,r as o}from"./vendor-tanstack-Dq7p98wZ.js";import{b8 as m,b9 as u,B as h,t as x,g as p}from"./index-CbDkoDBH.js";import{R as j}from"./RunRow-D-DTu1PA.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-recharts-DWvKDyBF.js";import"./vendor-markdown-DK7fbRNb.js";function y(){const{dashboard:l,isLoading:n}=m(),t=u();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-zinc-800/60 bg-zinc-900/30 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-Dq7p98wZ.js";import{B as f,i as k,bb as $,L as A,bc as R,bd as E,g as b,T as y,be as q,aH as V,b8 as W,bf as Q,bg as _,bh as F,bi as K}from"./index-nnF1LnyK.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-recharts-DWvKDyBF.js";import"./vendor-markdown-DK7fbRNb.js";function J({providerName:s,keyUrl:m,modelHint:l,onSaved:j}){const u=s.toLowerCase()==="local",[r,o]=n.useState(""),[x,d]=n.useState(""),[g,h]=n.useState(""),[p,a]=n.useState(""),[i,v]=n.useState(""),[N,S]=n.useState(""),[z,P]=n.useState(!1),[C,t]=n.useState(null),[L,I]=n.useState(!1),O=u?x.trim().length>0:r.trim().length>0;async function T(){if(O){P(!0),t(null),I(!1);try{const c=U=>{const B=parseInt(U.trim(),10);return Number.isFinite(B)&&B>0?B:void 0},w={},M=c(p);M!==void 0&&(w.maxConcurrency=M);const D=c(i);D!==void 0&&(w.maxRequestsPerMinute=D);const G=c(N);G!==void 0&&(w.maxRequestsPerDay=G),await $(s.toLowerCase(),{...r.trim()?{apiKey:r.trim()}:{},...x.trim()?{baseUrl:x.trim()}:{},...g.trim()?{model:g.trim()}:{},...Object.keys(w).length>0?{quota:w}:{}}),o(""),d(""),h(""),a(""),v(""),S(""),I(!0),A({title:"Provider updated",detail:`${s} configuration saved.`,tone:"positive",dedupeKey:`settings:provider:${s}`,dedupeMode:"replace"}),j()}catch(c){t(c instanceof Error?c.message:"Failed to update provider")}finally{P(!1)}}}const H=l??"Use default model";return e.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3 space-y-2",children:[u&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"http://localhost:11434/v1",value:x,onChange:c=>d(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",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-zinc-500",htmlFor:`api-key-${s}`,children:["API Key",u?" (optional)":""]}),m&&e.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-zinc-500 hover:text-zinc-300 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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:u?"Optional — most local servers don't need one":`Enter ${s} API key`,value:r,onChange:c=>o(c.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",htmlFor:`model-${s}`,children:"Model (optional)"}),e.jsx("input",{id:`model-${s}`,type:"text",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:H,value:g,onChange:c=>h(c.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Concurrent",value:p,onChange:c=>a(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Max concurrent"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"/min",value:i,onChange:c=>v(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Per minute"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"/day",value:N,onChange:c=>S(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Per day"})]})]})]}),C&&e.jsx("p",{className:"text-xs text-rose-400",children:C}),L&&e.jsx("p",{className:"text-xs text-emerald-400",children:"Provider updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!O||z,onClick:k(T),children:z?"Saving...":"Save"})]})}function X({onSaved:s}){const[m,l]=n.useState(""),[j,u]=n.useState(""),[r,o]=n.useState(!1),[x,d]=n.useState(null),[g,h]=n.useState(!1),p=m.trim().length>0&&j.trim().length>0;async function a(){if(p){o(!0),d(null),h(!1);try{await R({clientId:m.trim(),clientSecret:j.trim()}),l(""),u(""),h(!0),A({title:"Google OAuth app updated",detail:"Dashboard Google credentials were saved.",tone:"positive",dedupeKey:"settings:google-oauth",dedupeMode:"replace"}),s()}catch(i){d(i instanceof Error?i.message:"Failed to update Google OAuth credentials")}finally{o(!1)}}}return e.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/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-zinc-500",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-zinc-500 hover:text-zinc-300 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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Google OAuth client ID",value:m,onChange:i=>l(i.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Google OAuth client secret",value:j,onChange:i=>u(i.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-zinc-500",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-rose-400",children:x}),g&&e.jsx("p",{className:"text-xs text-emerald-400",children:"Google OAuth credentials updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!p||r,onClick:k(a),children:r?"Saving...":"Save Google OAuth app"})]})}function Y(){const[s,m]=n.useState(null),[l,j]=n.useState(null),[u,r]=n.useState(!1),[o,x]=n.useState("localhost"),[d,g]=n.useState("9222"),[h,p]=n.useState(!1);return n.useEffect(()=>{E().then(m).catch(a=>{const i=a instanceof Error?a.message:String(a);i.includes("501")||j(i)})},[]),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-zinc-500",children:s?.connected?"Connected to Chrome via CDP. Launch Chrome with --remote-debugging-port to use this provider.":l||"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:k(async a=>{a.preventDefault(),p(!0);try{await q(o,parseInt(d,10)||9222);const i=await E().catch(()=>null);i&&m(i),r(!1),A({title:"CDP endpoint saved",detail:`${o}:${parseInt(d,10)||9222} is now configured.`,tone:"positive",dedupeKey:"settings:cdp",dedupeMode:"replace"})}catch(i){j(i instanceof Error?i.message:String(i))}finally{p(!1)}}),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-500",placeholder:"localhost",value:o,onChange:a=>x(a.target.value),"aria-label":"CDP host"}),e.jsx("input",{className:"w-24 rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-500",placeholder:"9222",value:d,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 ie(){const s=V(),{dashboard:m}=W(),l=m?.settings??s?.dashboard?.settings,r=Q(!s,s?.health).data??s?.health??Z,[o,x]=n.useState(null),[d,g]=n.useState(!1),[h,p]=n.useState(!1),[a,i]=n.useState(""),[v,N]=n.useState(!1),[S,z]=n.useState(null),[P,C]=n.useState(!1);return l?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:[l.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.jsx("dd",{className:"font-mono text-xs",children:t.model})]}),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-zinc-500",children:t.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>x(o===t.name?null:t.name),children:o===t.name?"Cancel":t.state==="ready"?t.name.toLowerCase()==="local"?"Update config":"Update key":"Configure"})}),o===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:l.google.state==="ready"?"positive":"caution",children:l.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-zinc-500",children:l.google.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>g(!d),children:d?"Cancel":l.google.state==="ready"?"Update OAuth app":"Configure Google OAuth"})}),d&&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:l.bing.state==="ready"?"positive":"caution",children:l.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-zinc-500",children:l.bing.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>p(!h),children:h?"Cancel":l.bing.state==="ready"?"Update API key":"Configure Bing"})}),h&&e.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/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-zinc-500",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-zinc-500 hover:text-zinc-300 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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Bing Webmaster Tools API key",value:a,onChange:t=>i(t.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-zinc-500",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-rose-400",children:S}),P&&e.jsx("p",{className:"text-xs text-emerald-400",children:"Bing API key updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!a.trim()||v,onClick:k(async()=>{if(a.trim()){N(!0),z(null),C(!1);try{await _(a.trim()),i(""),C(!0),p(!1),A({title:"Bing API key updated",detail:"Dashboard Bing credentials were saved.",tone:"positive",dedupeKey:"settings:bing",dedupeMode:"replace"})}catch(t){z(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:F(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:F(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:l.selfHostNotes.map(t=>e.jsx("li",{children:t},t))}),e.jsx("p",{className:"supporting-copy",children:l.bootstrapNote})]})})]}):null}export{ie as SettingsPage};
|
|
1
|
+
import{r as n,j as e}from"./vendor-tanstack-Dq7p98wZ.js";import{B as f,i as k,bb as $,L as A,bc as R,bd as E,g as b,T as y,be as q,aH as V,b8 as W,bf as Q,bg as _,bh as F,bi as K}from"./index-CbDkoDBH.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-recharts-DWvKDyBF.js";import"./vendor-markdown-DK7fbRNb.js";function J({providerName:s,keyUrl:m,modelHint:l,onSaved:j}){const u=s.toLowerCase()==="local",[r,o]=n.useState(""),[x,d]=n.useState(""),[g,h]=n.useState(""),[p,a]=n.useState(""),[i,v]=n.useState(""),[N,S]=n.useState(""),[z,P]=n.useState(!1),[C,t]=n.useState(null),[L,I]=n.useState(!1),O=u?x.trim().length>0:r.trim().length>0;async function T(){if(O){P(!0),t(null),I(!1);try{const c=U=>{const B=parseInt(U.trim(),10);return Number.isFinite(B)&&B>0?B:void 0},w={},M=c(p);M!==void 0&&(w.maxConcurrency=M);const D=c(i);D!==void 0&&(w.maxRequestsPerMinute=D);const G=c(N);G!==void 0&&(w.maxRequestsPerDay=G),await $(s.toLowerCase(),{...r.trim()?{apiKey:r.trim()}:{},...x.trim()?{baseUrl:x.trim()}:{},...g.trim()?{model:g.trim()}:{},...Object.keys(w).length>0?{quota:w}:{}}),o(""),d(""),h(""),a(""),v(""),S(""),I(!0),A({title:"Provider updated",detail:`${s} configuration saved.`,tone:"positive",dedupeKey:`settings:provider:${s}`,dedupeMode:"replace"}),j()}catch(c){t(c instanceof Error?c.message:"Failed to update provider")}finally{P(!1)}}}const H=l??"Use default model";return e.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3 space-y-2",children:[u&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"http://localhost:11434/v1",value:x,onChange:c=>d(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",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-zinc-500",htmlFor:`api-key-${s}`,children:["API Key",u?" (optional)":""]}),m&&e.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-zinc-500 hover:text-zinc-300 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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:u?"Optional — most local servers don't need one":`Enter ${s} API key`,value:r,onChange:c=>o(c.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",htmlFor:`model-${s}`,children:"Model (optional)"}),e.jsx("input",{id:`model-${s}`,type:"text",className:"mt-0.5 w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:H,value:g,onChange:c=>h(c.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Concurrent",value:p,onChange:c=>a(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Max concurrent"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"/min",value:i,onChange:c=>v(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Per minute"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"/day",value:N,onChange:c=>S(c.target.value)}),e.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:"Per day"})]})]})]}),C&&e.jsx("p",{className:"text-xs text-rose-400",children:C}),L&&e.jsx("p",{className:"text-xs text-emerald-400",children:"Provider updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!O||z,onClick:k(T),children:z?"Saving...":"Save"})]})}function X({onSaved:s}){const[m,l]=n.useState(""),[j,u]=n.useState(""),[r,o]=n.useState(!1),[x,d]=n.useState(null),[g,h]=n.useState(!1),p=m.trim().length>0&&j.trim().length>0;async function a(){if(p){o(!0),d(null),h(!1);try{await R({clientId:m.trim(),clientSecret:j.trim()}),l(""),u(""),h(!0),A({title:"Google OAuth app updated",detail:"Dashboard Google credentials were saved.",tone:"positive",dedupeKey:"settings:google-oauth",dedupeMode:"replace"}),s()}catch(i){d(i instanceof Error?i.message:"Failed to update Google OAuth credentials")}finally{o(!1)}}}return e.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/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-zinc-500",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-zinc-500 hover:text-zinc-300 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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Google OAuth client ID",value:m,onChange:i=>l(i.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-zinc-500",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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Google OAuth client secret",value:j,onChange:i=>u(i.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-zinc-500",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-rose-400",children:x}),g&&e.jsx("p",{className:"text-xs text-emerald-400",children:"Google OAuth credentials updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!p||r,onClick:k(a),children:r?"Saving...":"Save Google OAuth app"})]})}function Y(){const[s,m]=n.useState(null),[l,j]=n.useState(null),[u,r]=n.useState(!1),[o,x]=n.useState("localhost"),[d,g]=n.useState("9222"),[h,p]=n.useState(!1);return n.useEffect(()=>{E().then(m).catch(a=>{const i=a instanceof Error?a.message:String(a);i.includes("501")||j(i)})},[]),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-zinc-500",children:s?.connected?"Connected to Chrome via CDP. Launch Chrome with --remote-debugging-port to use this provider.":l||"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:k(async a=>{a.preventDefault(),p(!0);try{await q(o,parseInt(d,10)||9222);const i=await E().catch(()=>null);i&&m(i),r(!1),A({title:"CDP endpoint saved",detail:`${o}:${parseInt(d,10)||9222} is now configured.`,tone:"positive",dedupeKey:"settings:cdp",dedupeMode:"replace"})}catch(i){j(i instanceof Error?i.message:String(i))}finally{p(!1)}}),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-500",placeholder:"localhost",value:o,onChange:a=>x(a.target.value),"aria-label":"CDP host"}),e.jsx("input",{className:"w-24 rounded border border-zinc-700 bg-zinc-900 px-2 py-1 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-1 focus:ring-zinc-500",placeholder:"9222",value:d,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 ie(){const s=V(),{dashboard:m}=W(),l=m?.settings??s?.dashboard?.settings,r=Q(!s,s?.health).data??s?.health??Z,[o,x]=n.useState(null),[d,g]=n.useState(!1),[h,p]=n.useState(!1),[a,i]=n.useState(""),[v,N]=n.useState(!1),[S,z]=n.useState(null),[P,C]=n.useState(!1);return l?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:[l.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.jsx("dd",{className:"font-mono text-xs",children:t.model})]}),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-zinc-500",children:t.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>x(o===t.name?null:t.name),children:o===t.name?"Cancel":t.state==="ready"?t.name.toLowerCase()==="local"?"Update config":"Update key":"Configure"})}),o===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:l.google.state==="ready"?"positive":"caution",children:l.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-zinc-500",children:l.google.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>g(!d),children:d?"Cancel":l.google.state==="ready"?"Update OAuth app":"Configure Google OAuth"})}),d&&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:l.bing.state==="ready"?"positive":"caution",children:l.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-zinc-500",children:l.bing.detail}),e.jsx("div",{className:"mt-2",children:e.jsx(f,{type:"button",variant:"outline",size:"sm",onClick:()=>p(!h),children:h?"Cancel":l.bing.state==="ready"?"Update API key":"Configure Bing"})}),h&&e.jsxs("div",{className:"mt-3 rounded-lg border border-zinc-800 bg-zinc-900/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-zinc-500",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-zinc-500 hover:text-zinc-300 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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none",placeholder:"Bing Webmaster Tools API key",value:a,onChange:t=>i(t.target.value)})]}),e.jsxs("p",{className:"text-[11px] text-zinc-500",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-rose-400",children:S}),P&&e.jsx("p",{className:"text-xs text-emerald-400",children:"Bing API key updated."}),e.jsx(f,{type:"button",size:"sm",disabled:!a.trim()||v,onClick:k(async()=>{if(a.trim()){N(!0),z(null),C(!1);try{await _(a.trim()),i(""),C(!0),p(!1),A({title:"Bing API key updated",detail:"Dashboard Bing credentials were saved.",tone:"positive",dedupeKey:"settings:bing",dedupeMode:"replace"})}catch(t){z(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:F(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:F(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:l.selfHostNotes.map(t=>e.jsx("li",{children:t},t))}),e.jsx("p",{className:"supporting-copy",children:l.bootstrapNote})]})})]}):null}export{ie as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e,h as V,u as R,f as L,L as E}from"./vendor-tanstack-Dq7p98wZ.js";import{c as T,br as U,bs as B,bt as I,bu as q,bv as A,bw as O,B as z,i as $,bx as W,aI as _,l as F,by as k,g as N,bz as G,T as H,bA as M}from"./index-nnF1LnyK.js";import{a as J,b as Q,c as K,d as Z,t as Y,R as X}from"./server-traffic-DjRISEZ-.js";import{e as P,A as ee}from"./extract-error-message-DD5MibWI.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-recharts-DWvKDyBF.js";import"./vendor-markdown-DK7fbRNb.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"}]],ne=T("cloud",te);const re=[["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"}]],se=T("triangle",re);function oe({open:t,onOpenChange:a,projectName:s}){const[r,n]=l.useState("pick");l.useEffect(()=>{t&&n("pick")},[t]);const o=()=>{a(!1),n("pick")};return e.jsx(U,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(B,{children:r==="pick"?e.jsx(ie,{onPick:n}):r==="wordpress"?e.jsx(de,{projectName:s,onBack:()=>n("pick"),onClose:o}):r==="vercel"?e.jsx(pe,{projectName:s,onBack:()=>n("pick"),onClose:o}):e.jsx(ue,{projectName:s,onBack:()=>n("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:ne},{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:se}];function ie({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(I,{children:[e.jsx(q,{children:"Connect a traffic source"}),e.jsx(A,{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:s,tagline:r,description:n,icon:o})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-start gap-4 rounded-lg border border-zinc-800 bg-zinc-900/30 p-4 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-zinc-800 bg-zinc-950 text-zinc-300 group-hover:text-zinc-100",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-zinc-100",children:s}),e.jsx("span",{className:"text-[11px] text-zinc-500",children:r})]}),e.jsx("span",{className:"text-xs leading-5 text-zinc-500",children:n})]})]},a))})]})}function ce({title:t,description:a,onBack:s}){return e.jsxs(I,{children:[e.jsxs("button",{type:"button",onClick:s,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-xs text-zinc-500 transition-colors hover:text-zinc-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(q,{children:t}),e.jsx(A,{children:a})]})}function le(t,a){const s=V();return async(r,n)=>{await W(t,r),n?.(),a(),s({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function w(t,a){const[s,r]=l.useState(null),n=le(t,a);return{error:s,runConnect:async i=>{r(null);const d=i.validate();if(d){r(d);return}let u;try{u=await i.mutate()}catch(c){r(P(c));return}try{await n(u.id,i.onConnected)}catch(c){r(`Source connected, but starting the initial backfill failed: ${P(c)}`)}}}}function S({title:t,description:a,projectName:s,onBack:r,onClose:n,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(ce,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:$(async c=>{c.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:s,disabled:!0,className:"w-full rounded border border-zinc-700 bg-zinc-900/50 px-2 py-1.5 text-sm text-zinc-300"})}),u,d?e.jsx("p",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-zinc-800/60 pt-4",children:[e.jsx(z,{type:"button",variant:"ghost",size:"sm",onClick:n,children:"Close"}),e.jsx(z,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function de({projectName:t,onBack:a,onClose:s}){const[r,n]=l.useState(""),[o,i]=l.useState(""),[d,u]=l.useState(""),[c,j]=l.useState(""),f=J(t||null),{error:g,runConnect:b}=w(t,s),y=()=>b({validate:()=>r.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:r.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:c.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(S,{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:s,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:r,onChange:m=>n(m.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:m=>i(m.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:m=>u(m.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:c,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})})]})}function ue({projectName:t,onBack:a,onClose:s}){const[r,n]=l.useState(""),[o,i]=l.useState(""),[d,u]=l.useState(""),[c,j]=l.useState(""),[f,g]=l.useState(""),b=K(t||null),{error:y,runConnect:m}=w(t,s),C=()=>m({validate:()=>r.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:r.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:c.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async x=>{if(!x)return;const D=await x.text();g(D)};return e.jsxs(S,{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:s,onSubmit:C,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:r,onChange:x=>n(x.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:x=>i(x.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:x=>u(x.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:c,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:x=>g(x.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 font-mono text-[11px] text-zinc-200 placeholder-zinc-600 focus:border-zinc-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-zinc-400 hover:text-zinc-200",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:x=>{h(x.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-zinc-800 px-2 py-1",children:"Or upload a key file"})]})]})]})}function pe({projectName:t,onBack:a,onClose:s}){const[r,n]=l.useState(""),[o,i]=l.useState(""),[d,u]=l.useState(""),[c,j]=l.useState("production"),[f,g]=l.useState(""),b=Q(t||null),{error:y,runConnect:m}=w(t,s),C=()=>m({validate:()=>r.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:r.trim(),teamId:o.trim(),token:d.trim(),environment:c,displayName:f.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(S,{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:s,onSubmit:C,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:r,onChange:h=>n(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:c,onChange:h=>j(h.target.value),className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})})]})}function p({label:t,description:a,required:s,children:r}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-xs font-medium text-zinc-200",children:[t,s?e.jsx("span",{className:"ml-1 text-rose-400",children:"*"}):null]}),r,e.jsx("span",{className:"text-[11px] text-zinc-500",children:a})]})}function xe(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),s=Math.floor(a/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const r=Math.floor(s/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function ze(){const[t,a]=l.useState(""),[s,r]=l.useState(!1),o=R(_({client:F})).data??[],i=l.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(z,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),disabled:!i,children:[e.jsx(k,{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(c=>e.jsx("button",{type:"button",className:`filter-chip ${i===c.name?"filter-chip-active":""}`,"aria-pressed":i===c.name,onClick:()=>a(c.name),children:c.displayName??c.name},c.id))}),i?d.isLoading?e.jsx(N,{className:"p-6 text-center text-sm text-zinc-500",children:"Loading sources…"}):u.length===0?e.jsxs(N,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-zinc-300",children:["No traffic sources connected for ",i,"."]}),e.jsx("p",{className:"mt-1 text-xs text-zinc-500",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(z,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),children:[e.jsx(k,{className:"size-3.5"}),"Connect a source"]})})]}):e.jsx(me,{projectName:i,sources:u}):e.jsx(N,{className:"p-6 text-center text-sm text-zinc-500",children:"No projects yet."})]}),e.jsx(oe,{open:s,onOpenChange:r,projectName:i})]})}function me({projectName:t,sources:a}){const s=L({queries:a.map(n=>({...G({client:F,path:{name:t,id:n.id}}),staleTime:3e4}))}),r=a.map((n,o)=>({source:n,detail:s[o]?.data,isLoading:s[o]?.isLoading??!1}));return e.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-zinc-900/50 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",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 crawler"}),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",children:"24h samples"}),e.jsx("th",{className:"px-4 py-2 text-right"})]})}),e.jsx("tbody",{className:"divide-y divide-zinc-800/60",children:r.map(({source:n,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-zinc-900/40 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-zinc-100",children:n.displayName}),e.jsxs("div",{className:"text-[11px] text-zinc-500 font-mono",children:[n.sourceType," · ",n.id.slice(0,8)]})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(H,{tone:Y(n.status),children:n.status}),n.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-[11px] text-rose-400/80",title:n.lastError,children:n.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-zinc-300",children:xe(n.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:i?"—":v(o?.totals24h.crawlerHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:i?"—":v(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:i?"—":v(o?.totals24h.aiReferralHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-300",children:i?"—":v(o?.totals24h.sampleCount??0)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(E,{to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:n.id},className:"inline-flex items-center gap-1 text-xs text-zinc-300 hover:text-zinc-100",children:[e.jsx(X,{className:"size-3"}),"View"]})})]},n.id))})]}),e.jsxs("p",{className:"border-t border-zinc-800/60 px-4 py-2 text-[11px] text-zinc-600",children:["Showing ",a.filter(n=>n.status!==M.archived).length," active source",a.length===1?"":"s"," for ",t,". Same shape as ",e.jsxs("code",{className:"text-zinc-400",children:["canonry traffic status ",t," --format json"]}),"."]})]})}export{ze as TrafficPage};
|
|
1
|
+
import{r as l,j as e,h as V,u as R,f as L,L as E}from"./vendor-tanstack-Dq7p98wZ.js";import{c as T,br as U,bs as B,bt as I,bu as q,bv as A,bw as O,B as v,i as $,bx as W,aI as _,l as F,by as k,g as C,bz as G,T as H,bA as M}from"./index-CbDkoDBH.js";import{a as J,b as Q,c as K,d as Z,t as Y,R as X}from"./server-traffic-3xxyOEIX.js";import{e as P,A as ee}from"./extract-error-message-BGhWiJPr.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-recharts-DWvKDyBF.js";import"./vendor-markdown-DK7fbRNb.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"}]],ne=T("cloud",te);const re=[["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"}]],se=T("triangle",re);function oe({open:t,onOpenChange:a,projectName:s}){const[r,n]=l.useState("pick");l.useEffect(()=>{t&&n("pick")},[t]);const o=()=>{a(!1),n("pick")};return e.jsx(U,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(B,{children:r==="pick"?e.jsx(ie,{onPick:n}):r==="wordpress"?e.jsx(de,{projectName:s,onBack:()=>n("pick"),onClose:o}):r==="vercel"?e.jsx(pe,{projectName:s,onBack:()=>n("pick"),onClose:o}):e.jsx(ue,{projectName:s,onBack:()=>n("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:ne},{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:se}];function ie({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(I,{children:[e.jsx(q,{children:"Connect a traffic source"}),e.jsx(A,{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:s,tagline:r,description:n,icon:o})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-start gap-4 rounded-lg border border-zinc-800 bg-zinc-900/30 p-4 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-zinc-800 bg-zinc-950 text-zinc-300 group-hover:text-zinc-100",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-zinc-100",children:s}),e.jsx("span",{className:"text-[11px] text-zinc-500",children:r})]}),e.jsx("span",{className:"text-xs leading-5 text-zinc-500",children:n})]})]},a))})]})}function ce({title:t,description:a,onBack:s}){return e.jsxs(I,{children:[e.jsxs("button",{type:"button",onClick:s,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-xs text-zinc-500 transition-colors hover:text-zinc-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(q,{children:t}),e.jsx(A,{children:a})]})}function le(t,a){const s=V();return async(r,n)=>{await W(t,r),n?.(),a(),s({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function w(t,a){const[s,r]=l.useState(null),n=le(t,a);return{error:s,runConnect:async i=>{r(null);const d=i.validate();if(d){r(d);return}let u;try{u=await i.mutate()}catch(c){r(P(c));return}try{await n(u.id,i.onConnected)}catch(c){r(`Source connected, but starting the initial backfill failed: ${P(c)}`)}}}}function S({title:t,description:a,projectName:s,onBack:r,onClose:n,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(ce,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:$(async c=>{c.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:s,disabled:!0,className:"w-full rounded border border-zinc-700 bg-zinc-900/50 px-2 py-1.5 text-sm text-zinc-300"})}),u,d?e.jsx("p",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-zinc-800/60 pt-4",children:[e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:n,children:"Close"}),e.jsx(v,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function de({projectName:t,onBack:a,onClose:s}){const[r,n]=l.useState(""),[o,i]=l.useState(""),[d,u]=l.useState(""),[c,j]=l.useState(""),f=J(t||null),{error:g,runConnect:b}=w(t,s),y=()=>b({validate:()=>r.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:r.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:c.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(S,{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:s,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:r,onChange:m=>n(m.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:m=>i(m.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:m=>u(m.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:c,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})})]})}function ue({projectName:t,onBack:a,onClose:s}){const[r,n]=l.useState(""),[o,i]=l.useState(""),[d,u]=l.useState(""),[c,j]=l.useState(""),[f,g]=l.useState(""),b=K(t||null),{error:y,runConnect:m}=w(t,s),z=()=>m({validate:()=>r.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:r.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:c.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async x=>{if(!x)return;const D=await x.text();g(D)};return e.jsxs(S,{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:s,onSubmit:z,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:r,onChange:x=>n(x.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:x=>i(x.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:x=>u(x.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:c,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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:x=>g(x.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 font-mono text-[11px] text-zinc-200 placeholder-zinc-600 focus:border-zinc-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-zinc-400 hover:text-zinc-200",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:x=>{h(x.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-zinc-800 px-2 py-1",children:"Or upload a key file"})]})]})]})}function pe({projectName:t,onBack:a,onClose:s}){const[r,n]=l.useState(""),[o,i]=l.useState(""),[d,u]=l.useState(""),[c,j]=l.useState("production"),[f,g]=l.useState(""),b=Q(t||null),{error:y,runConnect:m}=w(t,s),z=()=>m({validate:()=>r.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:r.trim(),teamId:o.trim(),token:d.trim(),environment:c,displayName:f.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(S,{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:s,onSubmit:z,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:r,onChange:h=>n(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:c,onChange:h=>j(h.target.value),className:"w-full rounded border border-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 focus:border-zinc-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-zinc-700 bg-transparent px-2 py-1.5 text-sm text-zinc-200 placeholder-zinc-600 focus:border-zinc-500 focus:outline-none"})})]})}function p({label:t,description:a,required:s,children:r}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-xs font-medium text-zinc-200",children:[t,s?e.jsx("span",{className:"ml-1 text-rose-400",children:"*"}):null]}),r,e.jsx("span",{className:"text-[11px] text-zinc-500",children:a})]})}function xe(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),s=Math.floor(a/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const r=Math.floor(s/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function N(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function ze(){const[t,a]=l.useState(""),[s,r]=l.useState(!1),o=R(_({client:F})).data??[],i=l.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(v,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),disabled:!i,children:[e.jsx(k,{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(c=>e.jsx("button",{type:"button",className:`filter-chip ${i===c.name?"filter-chip-active":""}`,"aria-pressed":i===c.name,onClick:()=>a(c.name),children:c.displayName??c.name},c.id))}),i?d.isLoading?e.jsx(C,{className:"p-6 text-center text-sm text-zinc-500",children:"Loading sources…"}):u.length===0?e.jsxs(C,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-zinc-300",children:["No traffic sources connected for ",i,"."]}),e.jsx("p",{className:"mt-1 text-xs text-zinc-500",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(v,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),children:[e.jsx(k,{className:"size-3.5"}),"Connect a source"]})})]}):e.jsx(me,{projectName:i,sources:u}):e.jsx(C,{className:"p-6 text-center text-sm text-zinc-500",children:"No projects yet."})]}),e.jsx(oe,{open:s,onOpenChange:r,projectName:i})]})}function me({projectName:t,sources:a}){const s=L({queries:a.map(n=>({...G({client:F,path:{name:t,id:n.id}}),staleTime:3e4}))}),r=a.map((n,o)=>({source:n,detail:s[o]?.data,isLoading:s[o]?.isLoading??!1}));return e.jsxs("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-zinc-900/50 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",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 crawler"}),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-zinc-800/60",children:r.map(({source:n,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-zinc-900/40 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-zinc-100",children:n.displayName}),e.jsxs("div",{className:"text-[11px] text-zinc-500 font-mono",children:[n.sourceType," · ",n.id.slice(0,8)]})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(H,{tone:Y(n.status),children:n.status}),n.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-[11px] text-rose-400/80",title:n.lastError,children:n.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-zinc-300",children:xe(n.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:i?"—":N(o?.totals24h.crawlerHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:i?"—":N(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-zinc-100",children:i?"—":N(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:n.id},className:"inline-flex items-center gap-1 text-xs text-zinc-300 hover:text-zinc-100",children:[e.jsx(X,{className:"size-3"}),"View"]})})]},n.id))})]}),e.jsxs("p",{className:"border-t border-zinc-800/60 px-4 py-2 text-[11px] text-zinc-600",children:["Showing ",a.filter(n=>n.status!==M.archived).length," active source",a.length===1?"":"s"," for ",t,". Same shape as ",e.jsxs("code",{className:"text-zinc-400",children:["canonry traffic status ",t," --format json"]}),"."]})]})}export{ze as TrafficPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,A as pe,B as ge,r as m,L as be}from"./vendor-tanstack-Dq7p98wZ.js";import{I as je,bB as x,T as ye,B as Ne,g as I,bC as ve,bD as we}from"./index-CbDkoDBH.js";import{A as Z,e as Se}from"./extract-error-message-BGhWiJPr.js";import{d as K,e as ze,C as q,a as J,c as ke}from"./ChartPrimitives-9Kx3gzQL.js";import{e as Ce,f as Te,g as Ae,t as Re,R as Ie}from"./server-traffic-3xxyOEIX.js";import{R as $e,B as Le,a as Ue,X as De,Y as Fe,T as He,b as E,d as O}from"./vendor-recharts-DWvKDyBF.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-markdown-DK7fbRNb.js";function B({value:t,label:a,delta:n,tone:r,description:u,tooltip:i,isNumeric:c=!0,progress:o,providerCoverage:d}){const y=2*Math.PI*48,h=Number.parseInt(t,10),C=typeof o=="number"&&Number.isFinite(o)?Math.min(Math.max(o,0),100)/100:c&&!Number.isNaN(h)?Math.min(h/100,1):.5,N=y*(1-C);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-${r}`,cx:"60",cy:"60",r:48,strokeWidth:6,strokeDasharray:y,strokeDashoffset:N,transform:"rotate(-90 60 60)"})]}),e.jsx("div",{className:"gauge-center",children:e.jsx("span",{className:c?"gauge-value":"gauge-value-text",children:t.split(" / ")[0]})})]}),e.jsxs("p",{className:"gauge-label",children:[a,i&&e.jsx(je,{text:i})]}),e.jsx("p",{className:"gauge-delta",children:n}),d&&e.jsx("p",{className:"gauge-provider-coverage",children:d}),e.jsx("p",{className:"gauge-description",children:u})]})}const Me=[{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"}];function Ee(t){return t==="all"?null:Number.parseInt(t[0],10)}function le(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return t.botId;case x["ai-referral"]:return t.product}}function ie(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return t.pathNormalized;case x["ai-referral"]:return t.landingPathNormalized}}function ce(t,a){if(a==="hour")return t;const n=new Date(t),r=n.getFullYear(),u=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return`${r}-${u}-${i}`}function Oe(t,a,n){const r=a.pathQuery.trim().toLowerCase(),u=Ee(a.statusClass);return t.filter(i=>!(a.selectedBucket&&ce(i.tsHour,n)!==a.selectedBucket||a.identity&&le(i)!==a.identity||a.operator&&i.operator!==a.operator||r&&!ie(i).toLowerCase().includes(r)||u!==null&&Math.floor(i.status/100)!==u))}function Be(t,a){if(!t||typeof t!="object")return null;const n=t.activeTooltipIndex;let r;if(typeof n=="number")r=n;else if(typeof n=="string"&&n!=="")r=Number(n);else return null;return!Number.isInteger(r)||r<0||r>=a.length?null:a[r]?.bucket??null}const L=[{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}],ee=L.find(t=>t.label==="7d")??L[2],te=K[0],se=K[2],ae=K[1],re=ve();function oe(t){const a=new Date(t);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:00`}function Pe(t){const a=new Date(`${t}T00:00:00`);return`${a.getMonth()+1}/${a.getDate()}`}function T(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 r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ne({canGoBack:t,className:a}){const n="inline-flex items-center gap-1";if(t){const r=()=>{window.history.back()};return e.jsxs("button",{type:"button",onClick:r,className:`${n} ${a??""}`,children:[e.jsx(Z,{className:"size-3"})," Back"]})}return e.jsxs(be,{to:"/traffic",className:`${n} ${a??""}`,children:[e.jsx(Z,{className:"size-3"})," All sources"]})}function st(){const t=pe({strict:!1}),a=t.projectName??"",n=ge(),r=t.sourceId??"",[u,i]=m.useState(ee.value),[c,o]=m.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[d,w]=m.useState(null),[p,y]=m.useState(""),[h,C]=m.useState(""),[N,U]=m.useState(""),[z,D]=m.useState("all"),[W,G]=m.useState(null),[Y,X]=m.useState(null),b=m.useMemo(()=>L.find(s=>s.value===u)??ee,[u]),F=Ce(a||null,r||null),j=Te(a||null,{kind:"all",sourceId:r||void 0,sinceMinutes:u,limit:b.fetchLimit}),R=Ae(a||null,r||null),l=F.data,v=j.data?.events??[],S=j.data?.totals,H=m.useMemo(()=>v.filter(s=>{switch(s.kind){case x.crawler:return c.has("crawler");case x["ai-user-fetch"]:return c.has("ai-user-fetch");case x["ai-referral"]:return c.has("ai-referral")}}),[v,c]),ue=m.useMemo(()=>{const s=new Set;for(const f of v)s.add(le(f));return p&&s.add(p),[...s].sort((f,g)=>f.localeCompare(g))},[v,p]),de=m.useMemo(()=>{const s=new Set;for(const f of v)s.add(f.operator);return h&&s.add(h),[...s].sort((f,g)=>f.localeCompare(g))},[v,h]),Q=m.useMemo(()=>Oe(H,{selectedBucket:d,identity:p,operator:h,pathQuery:N,statusClass:z},b.granularity),[H,d,p,h,N,z,b.granularity]),V=m.useMemo(()=>d?$(d,b.granularity):null,[d,b.granularity]),k=m.useMemo(()=>_e(v,b.granularity,j.data?.windowStart,j.data?.windowEnd),[v,b.granularity,j.data?.windowStart,j.data?.windowEnd]),M=s=>{o(f=>{const g=new Set(f);return g.has(s)?g.size>1&&g.delete(s):g.add(s),g})},xe=s=>{const f=Be(s,k);f&&w(g=>g===f?null:f)},he=()=>{w(null),y(""),C(""),U(""),D("all")},me=!!(d||p||h||N.trim()||z!=="all"),fe=async()=>{G(null),X(null);try{const s=await R.mutateAsync({sinceMinutes:60});X(`Pulled ${s.pulledEvents} entries · ${s.crawlerHits} crawler · ${s.aiReferralHits} AI referral · ${s.unknownHits} unknown`)}catch(s){G(Se(s))}};return!a||!r?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-zinc-500",children:"Missing project name or source id in URL."})}):F.isLoading?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-zinc-500",children:"Loading source…"})}):F.isError||!l?e.jsxs("div",{className:"page-container",children:[e.jsx("p",{className:"text-sm text-rose-300",children:"Could not load this source."}),e.jsx(ne,{canGoBack:n,className:"mt-2 text-xs text-zinc-400 hover:text-zinc-200"})]}):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(ne,{canGoBack:n,className:"text-xs text-zinc-500 hover:text-zinc-200"}),e.jsx("h1",{className:"page-title mt-2",children:l.displayName}),e.jsxs("p",{className:"page-subtitle",children:[l.sourceType," · project ",e.jsx("span",{className:"text-zinc-300",children:a})," ·",e.jsx("span",{className:"ml-1 font-mono text-zinc-400",children:l.id})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{tone:Re(l.status),children:l.status}),e.jsxs(Ne,{type:"button",variant:"outline",size:"sm",disabled:R.isPending,onClick:()=>{fe()},children:[e.jsx(Ie,{className:`size-3.5 ${R.isPending?"animate-spin":""}`}),R.isPending?"Syncing…":"Sync now"]})]})]}),W?e.jsx("div",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:W}):null,Y?e.jsx("div",{className:"rounded-md border border-emerald-800/50 bg-emerald-950/30 px-3 py-2 text-xs text-emerald-200",children:Y}):null,e.jsxs("section",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(B,{label:"24h crawler hits",value:String(l.totals24h.crawlerHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.totals24h.crawlerHits>0?"positive":"neutral",description:"Bulk machine crawl — GPTBot, OAI-SearchBot, PerplexityBot, Googlebot, etc.",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.crawlerHits/1e3*100))}),e.jsx(B,{label:"24h AI user fetches",value:String(l.totals24h.aiUserFetchHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.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(l.totals24h.aiUserFetchHits/1e3*100))}),e.jsx(B,{label:"24h AI referral sessions",value:String(l.totals24h.aiReferralHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.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(l.totals24h.aiReferralHits/1e3*100))})]}),e.jsxs("section",{children:[e.jsx("p",{className:"mb-4 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Latest sync run"}),l.latestRun?e.jsxs(I,{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-zinc-100",children:["Status: ",e.jsx("span",{className:"font-medium",children:l.latestRun.status})]}),e.jsxs("span",{className:"text-zinc-500",children:["Started: ",T(l.latestRun.startedAt)]}),l.latestRun.finishedAt?e.jsxs("span",{className:"text-zinc-500",children:["Finished: ",T(l.latestRun.finishedAt)]}):null,e.jsx("span",{className:"font-mono text-[11px] text-zinc-600",children:l.latestRun.runId})]}),l.latestRun.error?e.jsx("p",{className:"mt-2 rounded border border-rose-900/40 bg-rose-950/30 px-3 py-2 text-xs text-rose-300",children:l.latestRun.error}):null]}):e.jsx(I,{className:"px-4 py-3 text-sm text-zinc-500",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-zinc-500",children:"Events"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-zinc-50",children:b.granularity==="day"?"Daily rollups":"Hourly rollups"}),S?e.jsxs("p",{className:"mt-1.5 text-xs text-zinc-500",children:[S.crawlerHits.toLocaleString("en-US")," crawler ·"," ",S.aiUserFetchHits.toLocaleString("en-US")," AI user fetches ·"," ",S.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",b.label," · ",re]}):null]}),e.jsx("div",{className:"filter-row mb-0",role:"toolbar","aria-label":"Window",children:L.map(s=>e.jsx("button",{type:"button",className:`filter-chip ${u===s.value?"filter-chip-active":""}`,"aria-pressed":u===s.value,onClick:()=>{i(s.value),w(null)},children:s.label},s.value))})]}),e.jsxs(I,{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(_,{label:"Crawler",color:te,count:S?.crawlerHits??0,active:c.has("crawler"),onToggle:()=>M("crawler")}),e.jsx(_,{label:"AI user fetches",color:se,count:S?.aiUserFetchHits??0,active:c.has("ai-user-fetch"),onToggle:()=>M("ai-user-fetch")}),e.jsx(_,{label:"AI referral sessions",color:ae,count:S?.aiReferralHits??0,active:c.has("ai-referral"),onToggle:()=>M("ai-referral")})]}),j.isError?e.jsxs("p",{className:"py-12 text-center text-xs text-rose-400",children:["Failed to load events: ",j.error instanceof Error?j.error.message:"Unknown error"]}):j.isLoading?e.jsx("p",{className:"py-12 text-center text-xs text-zinc-500",children:"Loading events…"}):k.length===0?e.jsx("p",{className:"py-12 text-center text-xs text-zinc-500",children:"No events in this window."}):e.jsx("div",{className:"h-72",children:e.jsx($e,{children:e.jsxs(Le,{data:k,margin:{top:4,right:4,bottom:0,left:0},onClick:xe,style:{cursor:"pointer"},children:[e.jsx(Ue,{stroke:ze,strokeDasharray:"3 3"}),e.jsx(De,{dataKey:"label",tick:J,stroke:q,interval:"preserveStartEnd",minTickGap:b.granularity==="day"?24:32}),e.jsx(Fe,{tick:J,stroke:q,allowDecimals:!1}),e.jsx(He,{...ke}),c.has("crawler")?e.jsx(E,{dataKey:"crawler",name:"Crawler",fill:te,stackId:"a",children:k.map(s=>e.jsx(O,{fillOpacity:d&&d!==s.bucket?.25:1},s.bucket))}):null,c.has("ai-user-fetch")?e.jsx(E,{dataKey:"aiUserFetch",name:"AI user fetch",fill:se,stackId:"a",children:k.map(s=>e.jsx(O,{fillOpacity:d&&d!==s.bucket?.25:1},s.bucket))}):null,c.has("ai-referral")?e.jsx(E,{dataKey:"aiReferral",name:"AI referral",fill:ae,stackId:"a",children:k.map(s=>e.jsx(O,{fillOpacity:d&&d!==s.bucket?.25:1},s.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-zinc-500",children:"Event rows"}),e.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:["Showing ",e.jsx("span",{className:"tabular-nums text-zinc-300",children:Q.length.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-zinc-500",children:H.length.toLocaleString("en-US")})," events · ",re]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{"aria-label":"Filter by identity",value:p,onChange:s=>y(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[e.jsx("option",{value:"",children:"All identities"}),ue.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsxs("select",{"aria-label":"Filter by operator",value:h,onChange:s=>C(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[e.jsx("option",{value:"",children:"All operators"}),de.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsx("select",{"aria-label":"Filter by HTTP status class",value:z,onChange:s=>D(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:Me.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))}),e.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:N,onChange:s=>U(s.target.value),className:"w-44 rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600"})]})]}),me?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[V?e.jsx(A,{label:`Bucket: ${V}`,onClear:()=>w(null)}):null,p?e.jsx(A,{label:`Identity: ${p}`,onClear:()=>y("")}):null,h?e.jsx(A,{label:`Operator: ${h}`,onClear:()=>C("")}):null,N.trim()?e.jsx(A,{label:`Path: ${N.trim()}`,onClear:()=>U("")}):null,z!=="all"?e.jsx(A,{label:`Status: ${z}`,onClear:()=>D("all")}):null,e.jsx("button",{type:"button",onClick:he,className:"text-xs text-zinc-500 underline-offset-4 hover:text-zinc-200 hover:underline",children:"Clear all"})]}):null,e.jsx(Ye,{events:Q})]})]})}function P(t,a){return{bucket:t,label:a,crawler:0,aiUserFetch:0,aiReferral:0}}function $(t,a){return a==="day"?Pe(t):oe(t)}function _e(t,a,n,r){const u=new Map;for(const i of t){const c=ce(i.tsHour,a);let o=u.get(c);switch(o||(o=P(c,$(c,a)),u.set(c,o)),i.kind){case x.crawler:o.crawler+=i.hits;break;case x["ai-user-fetch"]:o.aiUserFetch+=i.hits;break;case x["ai-referral"]:o.aiReferral+=i.hits;break}}if(n&&r){const i=new Date(n),c=new Date(r);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 w=o.getUTCFullYear(),p=String(o.getUTCMonth()+1).padStart(2,"0"),y=String(o.getUTCDate()).padStart(2,"0"),h=`${w}-${p}-${y}`;u.has(h)||u.set(h,P(h,$(h,a))),o.setUTCDate(o.getUTCDate()+1)}}else{const o=new Date(i);for(o.setUTCMinutes(0,0,0);o<=c;){const d=o.toISOString();u.has(d)||u.set(d,P(d,$(d,a))),o.setUTCHours(o.getUTCHours()+1)}}}return[...u.values()].sort((i,c)=>i.bucket<c.bucket?-1:i.bucket>c.bucket?1:0)}function A({label:t,onClear:a}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-zinc-700 bg-zinc-800/60 px-2.5 py-1 text-[11px] text-zinc-200",children:[t,e.jsx("button",{type:"button",onClick:a,"aria-label":`Clear ${t}`,className:"rounded-full p-0.5 text-zinc-400 hover:bg-zinc-700/60 hover:text-zinc-100",children:e.jsx(we,{className:"size-3"})})]})}function _({label:t,color:a,count:n,active:r,onToggle:u}){return e.jsxs("button",{type:"button",onClick:u,"aria-pressed":r,className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium transition ${r?"border-zinc-700 bg-zinc-800/60 text-zinc-100":"border-zinc-800 bg-transparent text-zinc-500 hover:text-zinc-300"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`size-2 rounded-full transition-opacity ${r?"opacity-100":"opacity-30"}`,style:{backgroundColor:a}}),e.jsx("span",{children:t}),e.jsx("span",{className:`tabular-nums ${r?"text-zinc-400":"text-zinc-600"}`,children:n.toLocaleString("en-US")})]})}function Ke(t){switch(t){case x.crawler:return"Crawler";case x["ai-user-fetch"]:return"AI hit";case x["ai-referral"]:return"AI referral"}}function We(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return t.botId;case x["ai-referral"]:return t.product}}function Ge(t){switch(t.kind){case x.crawler:case x["ai-user-fetch"]:return`${t.verificationStatus} · HTTP ${t.status}`;case x["ai-referral"]:return`${t.evidenceType} · ${t.sourceDomain}`}}function Ye({events:t}){return t.length===0?e.jsx(I,{className:"p-6 text-center text-sm text-zinc-500",children:"No event rows match the current filters."}):e.jsx("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-zinc-900/50 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",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:"Hits"})]})}),e.jsx("tbody",{className:"divide-y divide-zinc-800/60",children:t.map((a,n)=>e.jsxs("tr",{className:"hover:bg-zinc-900/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-zinc-300",children:oe(a.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-zinc-300",children:Ke(a.kind)}),e.jsxs("td",{className:"px-4 py-2 text-zinc-100",children:[We(a),e.jsx("span",{className:"ml-2 text-[11px] text-zinc-500",children:a.operator})]}),e.jsx("td",{className:"px-4 py-2 text-zinc-300",children:Ge(a)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-zinc-300",children:ie(a)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-zinc-100",children:a.hits})]},`${a.kind}:${a.tsHour}:${n}`))})]})})}export{st as TrafficSourceDetailPage};
|
package/assets/assets/{extract-error-message-DD5MibWI.js → extract-error-message-BGhWiJPr.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./index-
|
|
1
|
+
import{c as t}from"./index-CbDkoDBH.js";const o=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],a=t("arrow-left",o);function n(e){return e instanceof Error?e.message:String(e)}export{a as A,n as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProjectPage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ProjectPage-D0UqSqe7.js","./vendor-tanstack-Dq7p98wZ.js","./RunRow-D-DTu1PA.js","./ChartPrimitives-9Kx3gzQL.js","./server-traffic-3xxyOEIX.js","./vendor-recharts-DWvKDyBF.js","./trash-2-dppRdHYI.js","./vendor-radix-B57xfQbP.js","./vendor-markdown-DK7fbRNb.js","./RunsPage-CrBpgwkO.js","./SettingsPage-Bgsi9tZ2.js","./BacklinksPage-buvZ4ZOd.js","./TrafficPage-DAHXrzqz.js","./extract-error-message-BGhWiJPr.js","./TrafficSourceDetailPage-DCcDN3VD.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{c as aw,d as iw,Q as sw,M as rw,r as $,q as Ue,j as f,L as rt,a as ow,e as ks,u as cn,f as lw,h as dc,k as cw,l as uw,m as Xb,O as Jb,n as Ka,o as Ai,p as dw,s as Bt,t as Fb,v as Gs,x as fw,y as pw,z as mw}from"./vendor-tanstack-Dq7p98wZ.js";import{S as hw,O as Df,P as Wb,C as Rf,a as ev,T as Mf,D as tv,R as nv}from"./vendor-radix-B57xfQbP.js";import{c as av}from"./vendor-recharts-DWvKDyBF.js";import{M as gw}from"./vendor-markdown-DK7fbRNb.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 Qd={exports:{}},Kr={},Yd={exports:{}},Xd={};var Ay;function yw(){return Ay||(Ay=1,(function(e){function n(U,F){var de=U.length;U.push(F);e:for(;0<de;){var je=de-1>>>1,ie=U[je];if(0<l(ie,F))U[je]=F,U[de]=ie,de=je;else break e}}function i(U){return U.length===0?null:U[0]}function r(U){if(U.length===0)return null;var F=U[0],de=U.pop();if(de!==F){U[0]=de;e:for(var je=0,ie=U.length,Qe=ie>>>1;je<Qe;){var Q=2*(je+1)-1,le=U[Q],te=Q+1,ce=U[te];if(0>l(le,de))te<ie&&0>l(ce,le)?(U[je]=ce,U[te]=de,je=te):(U[je]=le,U[Q]=de,je=Q);else if(te<ie&&0>l(ce,de))U[je]=ce,U[te]=de,je=te;else break e}}return F}function l(U,F){var de=U.sortIndex-F.sortIndex;return de!==0?de:U.id-F.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,m=d.now();e.unstable_now=function(){return d.now()-m}}var g=[],b=[],v=1,S=null,w=3,_=!1,C=!1,N=!1,T=!1,R=typeof setTimeout=="function"?setTimeout:null,G=typeof clearTimeout=="function"?clearTimeout:null,H=typeof setImmediate<"u"?setImmediate:null;function K(U){for(var F=i(b);F!==null;){if(F.callback===null)r(b);else if(F.startTime<=U)r(b),F.sortIndex=F.expirationTime,n(g,F);else break;F=i(b)}}function X(U){if(N=!1,K(U),!C)if(i(g)!==null)C=!0,J||(J=!0,ve());else{var F=i(b);F!==null&&pe(X,F.startTime-U)}}var J=!1,D=-1,M=5,oe=-1;function ke(){return T?!0:!(e.unstable_now()-oe<M)}function _e(){if(T=!1,J){var U=e.unstable_now();oe=U;var F=!0;try{e:{C=!1,N&&(N=!1,G(D),D=-1),_=!0;var de=w;try{t:{for(K(U),S=i(g);S!==null&&!(S.expirationTime>U&&ke());){var je=S.callback;if(typeof je=="function"){S.callback=null,w=S.priorityLevel;var ie=je(S.expirationTime<=U);if(U=e.unstable_now(),typeof ie=="function"){S.callback=ie,K(U),F=!0;break t}S===i(g)&&r(g),K(U)}else r(g);S=i(g)}if(S!==null)F=!0;else{var Qe=i(b);Qe!==null&&pe(X,Qe.startTime-U),F=!1}}break e}finally{S=null,w=de,_=!1}F=void 0}}finally{F?ve():J=!1}}}var ve;if(typeof H=="function")ve=function(){H(_e)};else if(typeof MessageChannel<"u"){var et=new MessageChannel,re=et.port2;et.port1.onmessage=_e,ve=function(){re.postMessage(null)}}else ve=function(){R(_e,0)};function pe(U,F){D=R(function(){U(e.unstable_now())},F)}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(U){U.callback=null},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return w},e.unstable_next=function(U){switch(w){case 1:case 2:case 3:var F=3;break;default:F=w}var de=w;w=F;try{return U()}finally{w=de}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(U,F){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var de=w;w=U;try{return F()}finally{w=de}},e.unstable_scheduleCallback=function(U,F,de){var je=e.unstable_now();switch(typeof de=="object"&&de!==null?(de=de.delay,de=typeof de=="number"&&0<de?je+de:je):de=je,U){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=de+ie,U={id:v++,callback:F,priorityLevel:U,startTime:de,expirationTime:ie,sortIndex:-1},de>je?(U.sortIndex=de,n(b,U),i(g)===null&&U===i(b)&&(N?(G(D),D=-1):N=!0,pe(X,de-je))):(U.sortIndex=ie,n(g,U),C||_||(C=!0,J||(J=!0,ve()))),U},e.unstable_shouldYield=ke,e.unstable_wrapCallback=function(U){var F=w;return function(){var de=w;w=F;try{return U.apply(this,arguments)}finally{w=de}}}})(Xd)),Xd}var _y;function bw(){return _y||(_y=1,Yd.exports=yw()),Yd.exports}var zy;function vw(){if(zy)return Kr;zy=1;var e=bw(),n=aw(),i=iw();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 m(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 b(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 p=u.alternate;if(p===null){if(o=u.return,o!==null){s=o;continue}break}if(u.child===p.child){for(p=u.child;p;){if(p===s)return g(u),t;if(p===o)return g(u),a;p=p.sibling}throw Error(r(188))}if(s.return!==o.return)s=u,o=p;else{for(var y=!1,x=u.child;x;){if(x===s){y=!0,s=u,o=p;break}if(x===o){y=!0,o=u,s=p;break}x=x.sibling}if(!y){for(x=p.child;x;){if(x===s){y=!0,s=p,o=u;break}if(x===o){y=!0,o=p,s=u;break}x=x.sibling}if(!y)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 v(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=v(t),a!==null)return a;t=t.sibling}return null}var S=Object.assign,w=Symbol.for("react.element"),_=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),H=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),oe=Symbol.for("react.activity"),ke=Symbol.for("react.memo_cache_sentinel"),_e=Symbol.iterator;function ve(t){return t===null||typeof t!="object"?null:(t=_e&&t[_e]||t["@@iterator"],typeof t=="function"?t:null)}var et=Symbol.for("react.client.reference");function re(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===et?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case N:return"Fragment";case R:return"Profiler";case T:return"StrictMode";case X:return"Suspense";case J:return"SuspenseList";case oe:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case C:return"Portal";case H:return t.displayName||"Context";case G:return(t._context.displayName||"Context")+".Consumer";case K:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case D:return a=t.displayName||null,a!==null?a:re(t.type)||"Memo";case M:a=t._payload,t=t._init;try{return re(t(a))}catch{}}return null}var pe=Array.isArray,U=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},je=[],ie=-1;function Qe(t){return{current:t}}function Q(t){0>ie||(t.current=je[ie],je[ie]=null,ie--)}function le(t,a){ie++,je[ie]=t.current,t.current=a}var te=Qe(null),ce=Qe(null),ne=Qe(null),Ne=Qe(null);function tt(t,a){switch(le(ne,a),le(ce,t),le(te,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?Yg(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=Yg(a),t=Xg(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Q(te),le(te,t)}function xe(){Q(te),Q(ce),Q(ne)}function $e(t){t.memoizedState!==null&&le(Ne,t);var a=te.current,s=Xg(a,t.type);a!==s&&(le(ce,t),le(te,s))}function Ze(t){ce.current===t&&(Q(te),Q(ce)),Ne.current===t&&(Q(Ne),Ir._currentValue=de)}var Ct,zn;function Tt(t){if(Ct===void 0)try{throw Error()}catch(s){var a=s.stack.trim().match(/\n( *(at )?)/);Ct=a&&a[1]||"",zn=-1<s.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+Ct+t+zn}var Fs=!1;function Ei(t,a){if(!t||Fs)return"";Fs=!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 q=V}Reflect.construct(t,[],Y)}else{try{Y.call()}catch(V){q=V}t.call(Y.prototype)}}else{try{throw Error()}catch(V){q=V}(Y=t())&&typeof Y.catch=="function"&&Y.catch(function(){})}}catch(V){if(V&&q&&typeof V.stack=="string")return[V.stack,q.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 p=o.DetermineComponentFrameRoot(),y=p[0],x=p[1];if(y&&x){var A=y.split(`
|
|
@@ -207,4 +207,4 @@ spec:
|
|
|
207
207
|
`);de(Fe)}}catch(ee){zn(ee instanceof Error?ee.message:"Failed to generate queries")}finally{Ze(!1)}}},Pn=async()=>{if(!oe)return;const ee=Fa;if(ee.length!==0){Ri(!0),Oi(null);try{await GN(oe,ee),Mc(!0),await r(),w(4)}catch(Fe){Oi(Fe instanceof Error?Fe.message:"Failed to save competitors")}finally{Ri(!1)}}},$i=async()=>{const ee=Bi.trim();if(ee){ga(!0),Cn(null);try{await PN("gemini",{apiKey:ee}),un({title:"Gemini configured",detail:"Provider is ready — continuing setup.",tone:"positive",dedupeKey:"setup:gemini:configured",dedupeMode:"drop"}),vo(""),await r()}catch(Fe){Cn(Fe instanceof Error?Fe.message:"Failed to save Gemini key")}finally{ga(!1)}}},Wa=async()=>{if(oe){yo(!0);try{const ee=await Mi.mutateAsync({projectName:oe,projectLabel:N||_||oe,sourceAction:"setup-launch"});bo(ee.id),Bc(!0),await r()}catch{}finally{yo(!1)}}},Kn=()=>w(ee=>Math.max(0,ee-1)),So=(()=>{switch(S){case 0:return f.jsxs(wn,{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:b.healthChecks.map(ee=>f.jsxs("div",{className:"health-check-row",children:[f.jsxs("div",{children:[f.jsx("p",{className:"run-row-title",children:ee.label}),f.jsx("p",{className:"supporting-copy",children:ee.detail}),ee.id==="provider"&&ee.state!=="ready"&&f.jsxs("div",{className:"mt-3 rounded-md border border-zinc-800/60 bg-zinc-900/40 p-3 space-y-2",children:[f.jsxs("p",{className:"text-xs text-zinc-400",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-emerald-400 hover:text-emerald-300 underline underline-offset-2",children:"aistudio.google.com"}),")."]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"password",value:Bi,onChange:Fe=>vo(Fe.target.value),placeholder:"AI... (paste here)",className:"flex-1 rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-sm text-zinc-100 placeholder:text-zinc-600 focus:border-zinc-600 focus:outline-none font-mono",disabled:tr}),f.jsx(Le,{type:"button",size:"sm",disabled:tr||!Bi.trim(),onClick:xn($i),children:tr?"Saving...":"Save"})]}),qt&&f.jsx("p",{className:"text-xs text-rose-400",children:qt}),f.jsxs("p",{className:"text-[11px] text-zinc-600",children:["Other providers (OpenAI, Claude, Perplexity) configurable later via"," ",f.jsx(rt,{to:"/settings",className:"text-zinc-500 hover:text-zinc-300 underline underline-offset-2",children:"/settings"}),"."]})]})]}),f.jsx(Bn,{tone:ee.state==="ready"?"positive":"caution",title:ee.id==="api"?Us(g.apiStatus):ee.id==="worker"?Us(g.workerStatus):ee.detail,children:ee.state==="ready"?"Ready":"Attention"})]},ee.id))}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Le,{type:"button",disabled:!qc,onClick:()=>w(1),children:"Continue"})]})]});case 1:return f.jsxs(wn,{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-zinc-300",children:["Project ",f.jsx("span",{className:"text-zinc-100 font-medium",children:oe})," created successfully."]}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsx(Le,{type:"button",onClick:()=>w(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:ee=>C(ee.target.value)}),mt&&mt!==_?f.jsxs("p",{className:"supporting-copy",children:["Slug: ",mt]}):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:N,onChange:ee=>T(ee.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:ee=>G(ee.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:H,onChange:ee=>K(ee.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:ee=>J(ee.target.value.toLowerCase())})]})]}),f.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3 cursor-pointer hover:border-zinc-700",children:[f.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-zinc-700 bg-zinc-950",checked:D,onChange:ee=>M(ee.target.checked)}),f.jsxs("span",{className:"flex-1",children:[f.jsx("span",{className:"block text-sm text-zinc-100",children:"Auto-extract backlinks"}),f.jsxs("span",{className:"block text-xs text-zinc-500 mt-0.5",children:["When a new Common Crawl release syncs, automatically extract backlinks for this project."," ",f.jsx(rt,{to:"/backlinks",className:"text-emerald-400 hover:text-emerald-300 underline underline-offset-2",children:"Manage backlinks"})]})]})]}),et?f.jsx("p",{className:"text-rose-400 text-sm",children:et}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsx(Le,{type:"button",disabled:!mt||!R||pe,onClick:xn(Li),children:pe?"Creating...":"Create project"})]})]})]});case 2:return f.jsxs(wn,{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"})]}),je?f.jsxs(Bn,{tone:"positive",children:[qn.length," saved"]}):f.jsxs(Bn,{tone:"neutral",children:[qn.length," quer",qn.length!==1?"ies":"y"]})]}),f.jsx("p",{className:"supporting-copy",children:"Enter the search queries you want to track. One per line."}),je?f.jsxs("div",{className:"compact-stack",children:[f.jsx("ul",{className:"detail-list",children:qn.map(ee=>f.jsx("li",{children:ee},ee))}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsx(Le,{type:"button",onClick:()=>w(3),children:"Continue"})]})]}):f.jsxs("div",{className:"compact-stack",children:[ce.length>0?f.jsxs("div",{className:"compact-stack",children:[f.jsxs("div",{className:"flex items-center gap-2 text-zinc-500 text-xs uppercase tracking-wide",children:[f.jsx("span",{className:"flex-1 border-t border-zinc-800"}),"auto-generate",f.jsx("span",{className:"flex-1 border-t border-zinc-800"})]}),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:ne,onChange:ee=>Ne(ee.target.value),children:ce.map(ee=>f.jsxs("option",{value:ee.name,children:[ee.displayName??ee.name,ee.model?` (${ee.model})`:""]},ee.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:tt,onChange:ee=>xe(Number(ee.target.value)),children:[3,5,10,15,20].map(ee=>f.jsx("option",{value:ee,children:ee},ee))})]}),f.jsx(Le,{type:"button",variant:"outline",disabled:$e||!ne,onClick:xn(Ui),children:$e?"Analyzing site...":"Generate"})]}),Ct?f.jsx("p",{className:"text-rose-400 text-sm",children:Ct}):null]}):null,f.jsxs("div",{className:"flex items-center gap-2 text-zinc-500 text-xs uppercase tracking-wide",children:[f.jsx("span",{className:"flex-1 border-t border-zinc-800"}),"or type manually",f.jsx("span",{className:"flex-1 border-t border-zinc-800"})]}),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:F,onChange:ee=>de(ee.target.value)})]}),Qe?f.jsx("p",{className:"text-rose-400 text-sm",children:Qe}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsx(Le,{type:"button",disabled:qn.length===0||le,onClick:xn(qi),children:le?"Saving...":`Save ${qn.length} quer${qn.length!==1?"ies":"y"}`})]})]})]});case 3:return f.jsxs(wn,{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"})]}),Ei?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."}),Ei?f.jsxs("div",{className:"compact-stack",children:[f.jsx("ul",{className:"detail-list",children:Fa.map(ee=>f.jsx("li",{children:ee},ee))}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsx(Le,{type:"button",onClick:()=>w(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:Tt,onChange:ee=>Fs(ee.target.value)})]}),Ws?f.jsx("p",{className:"text-rose-400 text-sm",children:Ws}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:()=>w(4),children:"Skip"}),f.jsx(Le,{type:"button",disabled:Fa.length===0||Di,onClick:xn(Pn),children:Di?"Saving...":`Save ${Fa.length} competitor${Fa.length!==1?"s":""}`})]})]})]})]});case 4:{const ee=Lc.data,Fe=ee?.status==="completed"||ee?.status==="partial"||ee?.status==="failed"||ee?.status==="cancelled",ei=ee?.snapshots??[],xo=ei.filter(Tn=>Tn.citationState==="cited").length,wo=ei.filter(Tn=>Tn.answerMentioned===!0).length,nr=new Set(ei.map(Tn=>Tn.query).filter(Tn=>!!Tn)).size,ar=go?Fe&&(ee?.status==="completed"||ee?.status==="partial")?f.jsx(Bn,{tone:"positive",children:"Complete"}):Fe?f.jsx(Bn,{tone:"negative",children:"Failed"}):f.jsx(Bn,{tone:"caution",children:"Running"}):null;return f.jsxs(wn,{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"})]}),ar]}),go?Fe?ee?.status==="failed"?f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-rose-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(Le,{type:"button",onClick:()=>{v({to:_e?`/projects/${_e}`:"/"})},children:"Open project"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("p",{className:"text-zinc-300",children:["Sweep complete. Your first answer-visibility snapshot for"," ",f.jsx("span",{className:"text-zinc-100 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-zinc-800/60 bg-zinc-900/30 p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Mentioned"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:[wo,f.jsxs("span",{className:"text-zinc-600 text-lg",children:[" / ",nr]})]}),f.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"queries with brand in answer"})]}),f.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Cited"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:[xo,f.jsxs("span",{className:"text-zinc-600 text-lg",children:[" / ",nr]})]}),f.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"queries with domain in sources"})]}),f.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Snapshots"}),f.jsx("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:ei.length}),f.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"total (query × provider)"})]})]}),f.jsx("p",{className:"text-[11px] text-zinc-500 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(Le,{type:"button",onClick:()=>{v({to:_e?`/projects/${_e}`:"/"})},children:"Open project dashboard →"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-zinc-300",children:"Sweep running — typically 30-60s. Polling every 2s…"}),f.jsx("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3 text-xs text-zinc-500",children:f.jsxs("p",{children:["Status: ",f.jsx("span",{className:"text-zinc-300",children:ee?.status??"queued"})]})}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Le,{type:"button",variant:"outline",onClick:()=>{v({to:_e?`/projects/${_e}`:"/"})},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-zinc-100 font-medium",children:oe}),"."]}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsx(Le,{type:"button",disabled:Lt,onClick:xn(Wa),children:Lt?"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(q5,{current:S,labels:L5}),f.jsx("section",{className:"setup-wizard",children:So})]})}function $5(){return f.jsx("div",{className:"page-container",children:f.jsx("section",{className:"page-section",children:f.jsxs(wn,{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(Le,{asChild:!0,children:f.jsx(rt,{to:"/",children:"Return to overview"})})]})})})}const Ti=Gs(()=>Is(()=>import("./ProjectPage-DtL3LFne.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url),"ProjectPage"),V5=Gs(()=>Is(()=>import("./RunsPage-UxZ93-cg.js"),__vite__mapDeps([9,1,2,7,5,8]),import.meta.url),"RunsPage"),G5=Gs(()=>Is(()=>import("./SettingsPage-Cr5_EGbk.js"),__vite__mapDeps([10,1,7,5,8]),import.meta.url),"SettingsPage"),I5=Gs(()=>Is(()=>import("./BacklinksPage-DVmaM864.js"),__vite__mapDeps([11,1,6,7,5,8]),import.meta.url),"BacklinksPage"),H5=Gs(()=>Is(()=>import("./TrafficPage-CUC_lfTe.js"),__vite__mapDeps([12,1,4,13,7,5,8]),import.meta.url),"TrafficPage"),Z5=Gs(()=>Is(()=>import("./TrafficSourceDetailPage-DARPL2TU.js"),__vite__mapDeps([14,1,13,3,4,5,7,8]),import.meta.url),"TrafficSourceDetailPage");function P5(){return f.jsx(yD,{children:f.jsx(gD,{})})}const Wt=dw()({component:P5,validateSearch:e=>({runId:typeof e.runId=="string"?e.runId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0})}),K5=Bt({getParentRoute:()=>Wt,path:"/",component:SD,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Ks({client:ae}));if(n&&n.length===0)throw Fb({to:"/setup"})}}),Q5=Bt({getParentRoute:()=>Wt,path:"/projects",component:O5}),Ja=Bt({getParentRoute:()=>Wt,path:"/projects/$projectId",component:()=>f.jsx(Jb,{})}),Y5=Bt({getParentRoute:()=>Ja,path:"/",component:()=>f.jsx(Ti,{tab:"overview"})}),X5=Bt({getParentRoute:()=>Ja,path:"/search-console",component:()=>f.jsx(Ti,{tab:"search-console"})}),J5=Bt({getParentRoute:()=>Ja,path:"/discovery",component:()=>f.jsx(Ti,{tab:"discovery"})}),F5=Bt({getParentRoute:()=>Ja,path:"/report",component:()=>f.jsx(Ti,{tab:"report"})}),W5=Bt({getParentRoute:()=>Ja,path:"/activity",component:()=>f.jsx(Ti,{tab:"activity"})}),eR=Bt({getParentRoute:()=>Ja,path:"/backlinks",component:()=>f.jsx(Ti,{tab:"backlinks"})}),tR=Bt({getParentRoute:()=>Ja,path:"/settings",component:()=>f.jsx(Ti,{tab:"settings"})}),nR=Bt({getParentRoute:()=>Wt,path:"/runs",component:V5}),aR=Bt({getParentRoute:()=>Wt,path:"/settings",component:G5,beforeLoad:({context:e})=>{}}),iR=Bt({getParentRoute:()=>Wt,path:"/setup",component:U5,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Ks({client:ae}));if(n&&n.length>0)throw Fb({to:"/"})}}),sR=Bt({getParentRoute:()=>Wt,path:"/backlinks",component:I5}),rR=Bt({getParentRoute:()=>Wt,path:"/traffic",component:H5}),oR=Bt({getParentRoute:()=>Wt,path:"/traffic/$projectName/$sourceId",component:Z5}),lR=Bt({getParentRoute:()=>Wt,path:"*",component:$5}),cR=Wt.addChildren([K5,Q5,Ja.addChildren([Y5,X5,J5,F5,W5,eR,tR]),nR,aR,iR,sR,rR,oR,lR]);function uR(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const Yb=uR(),dR=Yb==="/"?"":Yb.replace(/\/$/,"");function fR(e,n){return fw({routeTree:cR,basepath:dR||"/",context:{queryClient:e},...n?.initialEntries})}const pR=6e4;function mR(){const[e,n]=$.useState(Fd()?"ready":"checking"),[i,r]=$.useState(""),[l,c]=$.useState(""),[d,m]=$.useState(null),[g,b]=$.useState(!1),[v,S]=$.useState(!1),w=$.useRef(null),_=$.useRef(null),C=()=>{if(!w.current){const R=mk();_.current=R,w.current=fR(R)}return{queryClient:_.current,router:w.current}};$.useEffect(()=>{if(Fd())return;let R=!1;return Dy().then(G=>{R||(G.authenticated?n("ready"):n(G.setupRequired?"setup":"login"))}).catch(G=>{R||(m(G instanceof Error?G.message:"Failed to reach the Canonry API"),n("login"))}),()=>{R=!0}},[]),$.useEffect(()=>{if(e!=="ready"||Fd())return;const R=setInterval(()=>{Dy().then(G=>{G.authenticated||(S(!0),n(G.setupRequired?"setup":"login"))}).catch(()=>{})},pR);return Oy(()=>{S(!0),n("login")}),()=>{clearInterval(R),Oy(null)}},[e]);const N=async R=>{if(R.preventDefault(),!i.trim()||i.trim().length<8){m("Password must be at least 8 characters");return}if(i!==l){m("Passwords do not match");return}b(!0),m(null);try{if(!(await HN(i.trim())).authenticated){m("Setup failed");return}r(""),c(""),S(!1),n("ready")}catch(G){m(G instanceof In||G instanceof Error?G.message:"Setup failed")}finally{b(!1)}},T=async R=>{if(R.preventDefault(),!!i.trim()){b(!0),m(null);try{if(!(await ZN(i.trim())).authenticated){m("Incorrect password");return}r(""),S(!1),n("ready")}catch(G){m(G instanceof In||G instanceof Error?G.message:"Authentication failed")}finally{b(!1)}}};if(e==="ready"){const{queryClient:R,router:G}=C();return f.jsx(pw,{client:R,children:f.jsx(mw,{router:G})})}return f.jsx("div",{className:"min-h-screen bg-zinc-950 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(wn,{className:"surface-card w-full",children:e==="checking"?f.jsx(Ql,{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(Nf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),f.jsx(kf,{children:"Create a dashboard password"}),f.jsx(Af,{children:"Choose a password to protect the Canonry dashboard. You will use this to sign in on future visits."})]}),f.jsx(Ql,{children:f.jsxs("form",{className:"space-y-4",onSubmit:xn(N),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-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-zinc-400",children:"Confirm password"}),f.jsx("input",{className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-600",type:"password",value:l,onChange:R=>c(R.target.value),placeholder:"Re-enter password"})]}),d?f.jsx("p",{className:"text-sm text-rose-400",children:d}):null,f.jsx(Le,{type:"submit",disabled:g||!i.trim()||!l.trim(),children:g?"Setting up…":"Create password & open dashboard"})]})})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Nf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),f.jsx(kf,{children:"Sign in to Canonry"}),f.jsx(Af,{children:"Enter your dashboard password to continue."})]}),f.jsxs(Ql,{children:[v?f.jsx("p",{className:"mb-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-300",children:"Your session expired — please sign in again."}):null,f.jsxs("form",{className:"space-y-4",onSubmit:xn(T),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-600",type:"password",value:i,onChange:R=>r(R.target.value),placeholder:"Dashboard password"})]}),d?f.jsx("p",{className:"text-sm text-rose-400",children:d}):null,f.jsx(Le,{type:"submit",disabled:g||!i.trim(),children:g?"Signing in…":"Open dashboard"})]})]})]})})})})}const Z1=document.getElementById("root");if(!Z1)throw new Error("Expected #root element for web app bootstrap.");xw.createRoot(Z1).render(f.jsx($.StrictMode,{children:f.jsx(mR,{})}));export{vM as $,zR as A,Le as B,ic as C,$M as D,GM as E,IM as F,jM as G,qR as H,$l as I,LR as J,$R as K,un as L,KR as M,PM as N,KM as O,X4 as P,VR as Q,HM as R,lO as S,Bn as T,ZM as U,VM as V,UR as W,GR as X,QM as Y,fM as Z,bM as _,m6 as a,FR as a$,In as a0,SM as a1,vR as a2,Zk as a3,DM as a4,Ik as a5,Wk as a6,Ee as a7,n4 as a8,Fl as a9,ER as aA,OR as aB,BM as aC,DR as aD,RR as aE,BR as aF,MR as aG,uo as aH,op as aI,L3 as aJ,B5 as aK,It as aL,qN as aM,AR as aN,SR as aO,xR as aP,_R as aQ,$N as aR,LN as aS,GN as aT,wR as aU,S6 as aV,hO as aW,YM as aX,JM as aY,XN as aZ,FM as a_,xM as aa,gf as ab,r6 as ac,d6 as ad,f6 as ae,p6 as af,IR as ag,Ks as ah,HR as ai,lp as aj,s6 as ak,tM as al,x6 as am,_M as an,kM as ao,zM as ap,CM as aq,NM as ar,AM as as,kR as at,NR as au,jR as av,TR as aw,qM as ax,pb as ay,LM as az,$f as b,JR as b0,WM as b1,XM as b2,OM as b3,QR as b4,YR as b5,XR as b6,WR as b7,xc as b8,g6 as b9,TM as bA,ap as bB,UM as bC,Hs as bD,o6 as bE,u6 as bF,lM as bG,rM as bH,oM as bI,sM as bJ,l6 as bK,fp as ba,PN as bb,CR as bc,ZR as bd,PR as be,mp as bf,eM as bg,Us as bh,mb as bi,uM as bj,pM as bk,hM as bl,gM as bm,wv as bn,dM as bo,mM as bp,yM as bq,J4 as br,X0 as bs,n3 as bt,J0 as bu,F0 as bv,Uk as bw,cM as bx,qy as by,c6 as bz,at as c,WC as d,h6 as e,RM as f,wn as g,Ab as h,xn as i,wM as j,e6 as k,ae as l,t6 as m,n6 as n,i6 as o,a6 as p,nM as q,iM as r,aM as s,_0 as t,hp as u,y6 as v,b6 as w,v6 as x,EM as y,MM as z};
|
|
210
|
+
competitor2.com`,value:Tt,onChange:ee=>Fs(ee.target.value)})]}),Ws?f.jsx("p",{className:"text-rose-400 text-sm",children:Ws}):null,f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:()=>w(4),children:"Skip"}),f.jsx(Le,{type:"button",disabled:Fa.length===0||Di,onClick:xn(Pn),children:Di?"Saving...":`Save ${Fa.length} competitor${Fa.length!==1?"s":""}`})]})]})]})]});case 4:{const ee=Lc.data,Fe=ee?.status==="completed"||ee?.status==="partial"||ee?.status==="failed"||ee?.status==="cancelled",ei=ee?.snapshots??[],xo=ei.filter(Tn=>Tn.citationState==="cited").length,wo=ei.filter(Tn=>Tn.answerMentioned===!0).length,nr=new Set(ei.map(Tn=>Tn.query).filter(Tn=>!!Tn)).size,ar=go?Fe&&(ee?.status==="completed"||ee?.status==="partial")?f.jsx(Bn,{tone:"positive",children:"Complete"}):Fe?f.jsx(Bn,{tone:"negative",children:"Failed"}):f.jsx(Bn,{tone:"caution",children:"Running"}):null;return f.jsxs(wn,{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"})]}),ar]}),go?Fe?ee?.status==="failed"?f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-rose-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(Le,{type:"button",onClick:()=>{v({to:_e?`/projects/${_e}`:"/"})},children:"Open project"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsxs("p",{className:"text-zinc-300",children:["Sweep complete. Your first answer-visibility snapshot for"," ",f.jsx("span",{className:"text-zinc-100 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-zinc-800/60 bg-zinc-900/30 p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Mentioned"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:[wo,f.jsxs("span",{className:"text-zinc-600 text-lg",children:[" / ",nr]})]}),f.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"queries with brand in answer"})]}),f.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Cited"}),f.jsxs("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:[xo,f.jsxs("span",{className:"text-zinc-600 text-lg",children:[" / ",nr]})]}),f.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"queries with domain in sources"})]}),f.jsxs("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Snapshots"}),f.jsx("p",{className:"text-2xl font-bold tabular-nums text-zinc-50 mt-1",children:ei.length}),f.jsx("p",{className:"text-[11px] text-zinc-500 mt-0.5",children:"total (query × provider)"})]})]}),f.jsx("p",{className:"text-[11px] text-zinc-500 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(Le,{type:"button",onClick:()=>{v({to:_e?`/projects/${_e}`:"/"})},children:"Open project dashboard →"})]})]}):f.jsxs("div",{className:"compact-stack",children:[f.jsx("p",{className:"text-zinc-300",children:"Sweep running — typically 30-60s. Polling every 2s…"}),f.jsx("div",{className:"rounded-md border border-zinc-800/60 bg-zinc-900/30 p-3 text-xs text-zinc-500",children:f.jsxs("p",{children:["Status: ",f.jsx("span",{className:"text-zinc-300",children:ee?.status??"queued"})]})}),f.jsxs("div",{className:"setup-nav",children:[f.jsx("span",{}),f.jsx(Le,{type:"button",variant:"outline",onClick:()=>{v({to:_e?`/projects/${_e}`:"/"})},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-zinc-100 font-medium",children:oe}),"."]}),f.jsxs("div",{className:"setup-nav",children:[f.jsx(Le,{type:"button",variant:"outline",onClick:Kn,children:"Back"}),f.jsx(Le,{type:"button",disabled:Lt,onClick:xn(Wa),children:Lt?"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(q5,{current:S,labels:L5}),f.jsx("section",{className:"setup-wizard",children:So})]})}function $5(){return f.jsx("div",{className:"page-container",children:f.jsx("section",{className:"page-section",children:f.jsxs(wn,{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(Le,{asChild:!0,children:f.jsx(rt,{to:"/",children:"Return to overview"})})]})})})}const Ti=Gs(()=>Is(()=>import("./ProjectPage-D0UqSqe7.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url),"ProjectPage"),V5=Gs(()=>Is(()=>import("./RunsPage-CrBpgwkO.js"),__vite__mapDeps([9,1,2,7,5,8]),import.meta.url),"RunsPage"),G5=Gs(()=>Is(()=>import("./SettingsPage-Bgsi9tZ2.js"),__vite__mapDeps([10,1,7,5,8]),import.meta.url),"SettingsPage"),I5=Gs(()=>Is(()=>import("./BacklinksPage-buvZ4ZOd.js"),__vite__mapDeps([11,1,6,7,5,8]),import.meta.url),"BacklinksPage"),H5=Gs(()=>Is(()=>import("./TrafficPage-DAHXrzqz.js"),__vite__mapDeps([12,1,4,13,7,5,8]),import.meta.url),"TrafficPage"),Z5=Gs(()=>Is(()=>import("./TrafficSourceDetailPage-DCcDN3VD.js"),__vite__mapDeps([14,1,13,3,4,5,7,8]),import.meta.url),"TrafficSourceDetailPage");function P5(){return f.jsx(yD,{children:f.jsx(gD,{})})}const Wt=dw()({component:P5,validateSearch:e=>({runId:typeof e.runId=="string"?e.runId:void 0,evidenceId:typeof e.evidenceId=="string"?e.evidenceId:void 0})}),K5=Bt({getParentRoute:()=>Wt,path:"/",component:SD,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Ks({client:ae}));if(n&&n.length===0)throw Fb({to:"/setup"})}}),Q5=Bt({getParentRoute:()=>Wt,path:"/projects",component:O5}),Ja=Bt({getParentRoute:()=>Wt,path:"/projects/$projectId",component:()=>f.jsx(Jb,{})}),Y5=Bt({getParentRoute:()=>Ja,path:"/",component:()=>f.jsx(Ti,{tab:"overview"})}),X5=Bt({getParentRoute:()=>Ja,path:"/search-console",component:()=>f.jsx(Ti,{tab:"search-console"})}),J5=Bt({getParentRoute:()=>Ja,path:"/discovery",component:()=>f.jsx(Ti,{tab:"discovery"})}),F5=Bt({getParentRoute:()=>Ja,path:"/report",component:()=>f.jsx(Ti,{tab:"report"})}),W5=Bt({getParentRoute:()=>Ja,path:"/activity",component:()=>f.jsx(Ti,{tab:"activity"})}),eR=Bt({getParentRoute:()=>Ja,path:"/backlinks",component:()=>f.jsx(Ti,{tab:"backlinks"})}),tR=Bt({getParentRoute:()=>Ja,path:"/settings",component:()=>f.jsx(Ti,{tab:"settings"})}),nR=Bt({getParentRoute:()=>Wt,path:"/runs",component:V5}),aR=Bt({getParentRoute:()=>Wt,path:"/settings",component:G5,beforeLoad:({context:e})=>{}}),iR=Bt({getParentRoute:()=>Wt,path:"/setup",component:U5,beforeLoad:({context:e})=>{const n=e.queryClient.getQueryData(Ks({client:ae}));if(n&&n.length>0)throw Fb({to:"/"})}}),sR=Bt({getParentRoute:()=>Wt,path:"/backlinks",component:I5}),rR=Bt({getParentRoute:()=>Wt,path:"/traffic",component:H5}),oR=Bt({getParentRoute:()=>Wt,path:"/traffic/$projectName/$sourceId",component:Z5}),lR=Bt({getParentRoute:()=>Wt,path:"*",component:$5}),cR=Wt.addChildren([K5,Q5,Ja.addChildren([Y5,X5,J5,F5,W5,eR,tR]),nR,aR,iR,sR,rR,oR,lR]);function uR(){return typeof window<"u"&&window.__CANONRY_CONFIG__?.basePath?window.__CANONRY_CONFIG__.basePath:"/"}const Yb=uR(),dR=Yb==="/"?"":Yb.replace(/\/$/,"");function fR(e,n){return fw({routeTree:cR,basepath:dR||"/",context:{queryClient:e},...n?.initialEntries})}const pR=6e4;function mR(){const[e,n]=$.useState(Fd()?"ready":"checking"),[i,r]=$.useState(""),[l,c]=$.useState(""),[d,m]=$.useState(null),[g,b]=$.useState(!1),[v,S]=$.useState(!1),w=$.useRef(null),_=$.useRef(null),C=()=>{if(!w.current){const R=mk();_.current=R,w.current=fR(R)}return{queryClient:_.current,router:w.current}};$.useEffect(()=>{if(Fd())return;let R=!1;return Dy().then(G=>{R||(G.authenticated?n("ready"):n(G.setupRequired?"setup":"login"))}).catch(G=>{R||(m(G instanceof Error?G.message:"Failed to reach the Canonry API"),n("login"))}),()=>{R=!0}},[]),$.useEffect(()=>{if(e!=="ready"||Fd())return;const R=setInterval(()=>{Dy().then(G=>{G.authenticated||(S(!0),n(G.setupRequired?"setup":"login"))}).catch(()=>{})},pR);return Oy(()=>{S(!0),n("login")}),()=>{clearInterval(R),Oy(null)}},[e]);const N=async R=>{if(R.preventDefault(),!i.trim()||i.trim().length<8){m("Password must be at least 8 characters");return}if(i!==l){m("Passwords do not match");return}b(!0),m(null);try{if(!(await HN(i.trim())).authenticated){m("Setup failed");return}r(""),c(""),S(!1),n("ready")}catch(G){m(G instanceof In||G instanceof Error?G.message:"Setup failed")}finally{b(!1)}},T=async R=>{if(R.preventDefault(),!!i.trim()){b(!0),m(null);try{if(!(await ZN(i.trim())).authenticated){m("Incorrect password");return}r(""),S(!1),n("ready")}catch(G){m(G instanceof In||G instanceof Error?G.message:"Authentication failed")}finally{b(!1)}}};if(e==="ready"){const{queryClient:R,router:G}=C();return f.jsx(pw,{client:R,children:f.jsx(mw,{router:G})})}return f.jsx("div",{className:"min-h-screen bg-zinc-950 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(wn,{className:"surface-card w-full",children:e==="checking"?f.jsx(Ql,{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(Nf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"First-time setup"}),f.jsx(kf,{children:"Create a dashboard password"}),f.jsx(Af,{children:"Choose a password to protect the Canonry dashboard. You will use this to sign in on future visits."})]}),f.jsx(Ql,{children:f.jsxs("form",{className:"space-y-4",onSubmit:xn(N),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-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-zinc-400",children:"Confirm password"}),f.jsx("input",{className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-600",type:"password",value:l,onChange:R=>c(R.target.value),placeholder:"Re-enter password"})]}),d?f.jsx("p",{className:"text-sm text-rose-400",children:d}):null,f.jsx(Le,{type:"submit",disabled:g||!i.trim()||!l.trim(),children:g?"Setting up…":"Create password & open dashboard"})]})})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Nf,{children:[f.jsx("p",{className:"eyebrow eyebrow-soft",children:"Dashboard access"}),f.jsx(kf,{children:"Sign in to Canonry"}),f.jsx(Af,{children:"Enter your dashboard password to continue."})]}),f.jsxs(Ql,{children:[v?f.jsx("p",{className:"mb-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-300",children:"Your session expired — please sign in again."}):null,f.jsxs("form",{className:"space-y-4",onSubmit:xn(T),children:[f.jsxs("label",{className:"block space-y-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-zinc-400",children:"Password"}),f.jsx("input",{autoFocus:!0,className:"w-full rounded-md border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none transition focus:border-zinc-600",type:"password",value:i,onChange:R=>r(R.target.value),placeholder:"Dashboard password"})]}),d?f.jsx("p",{className:"text-sm text-rose-400",children:d}):null,f.jsx(Le,{type:"submit",disabled:g||!i.trim(),children:g?"Signing in…":"Open dashboard"})]})]})]})})})})}const Z1=document.getElementById("root");if(!Z1)throw new Error("Expected #root element for web app bootstrap.");xw.createRoot(Z1).render(f.jsx($.StrictMode,{children:f.jsx(mR,{})}));export{vM as $,zR as A,Le as B,ic as C,$M as D,GM as E,IM as F,jM as G,qR as H,$l as I,LR as J,$R as K,un as L,KR as M,PM as N,KM as O,X4 as P,VR as Q,HM as R,lO as S,Bn as T,ZM as U,VM as V,UR as W,GR as X,QM as Y,fM as Z,bM as _,m6 as a,FR as a$,In as a0,SM as a1,vR as a2,Zk as a3,DM as a4,Ik as a5,Wk as a6,Ee as a7,n4 as a8,Fl as a9,ER as aA,OR as aB,BM as aC,DR as aD,RR as aE,BR as aF,MR as aG,uo as aH,op as aI,L3 as aJ,B5 as aK,It as aL,qN as aM,AR as aN,SR as aO,xR as aP,_R as aQ,$N as aR,LN as aS,GN as aT,wR as aU,S6 as aV,hO as aW,YM as aX,JM as aY,XN as aZ,FM as a_,xM as aa,gf as ab,r6 as ac,d6 as ad,f6 as ae,p6 as af,IR as ag,Ks as ah,HR as ai,lp as aj,s6 as ak,tM as al,x6 as am,_M as an,kM as ao,zM as ap,CM as aq,NM as ar,AM as as,kR as at,NR as au,jR as av,TR as aw,qM as ax,pb as ay,LM as az,$f as b,JR as b0,WM as b1,XM as b2,OM as b3,QR as b4,YR as b5,XR as b6,WR as b7,xc as b8,g6 as b9,TM as bA,ap as bB,UM as bC,Hs as bD,o6 as bE,u6 as bF,lM as bG,rM as bH,oM as bI,sM as bJ,l6 as bK,fp as ba,PN as bb,CR as bc,ZR as bd,PR as be,mp as bf,eM as bg,Us as bh,mb as bi,uM as bj,pM as bk,hM as bl,gM as bm,wv as bn,dM as bo,mM as bp,yM as bq,J4 as br,X0 as bs,n3 as bt,J0 as bu,F0 as bv,Uk as bw,cM as bx,qy as by,c6 as bz,at as c,WC as d,h6 as e,RM as f,wn as g,Ab as h,xn as i,wM as j,e6 as k,ae as l,t6 as m,n6 as n,i6 as o,a6 as p,nM as q,iM as r,aM as s,_0 as t,hp as u,y6 as v,b6 as w,v6 as x,EM as y,MM as z};
|