1import{k as d,j as e,L as b}from"./react-vendor-CmuEGgtt.js";import{R as y}from"./site-CMMCmqVg.js";import"./x-CAppInM7.js";import"./radix-26y85DbF.js";import"./motion-DxYJUoZ7.js";const N=new Set;function x(t){try{const s=new URL(t,window.location.href);if(s.protocol!=="http:"&&s.protocol!=="https:")return null;const r=s.protocol==="http:"&&(s.port===""||s.port==="80")||s.protocol==="https:"&&(s.port===""||s.port==="443"),i=s.hostname.toLowerCase(),n=r?"":`:${s.port}`;return`${s.protocol}//${i}${n}`}catch{return null}}function w(t){const s=x(t);if(!s)return!1;const r=x(window.location.href);return!(s===r||N.has(s))}function S(t){return t.has("link[stylesheet]")||t.has("link[preload]")||t.has("link[modulepreload]")||t.has("script")||t.has("css-url")||t.has("img-lcp")||t.has("img")||t.has("iframe")||t.has("fetch")?"preconnect":"dns-prefetch"}const v=new Set(["preconnect","dns-prefetch","preload","modulepreload","prefetch"]);function E(){const t=new Map;return document.head.querySelectorAll("link[rel]").forEach(r=>{const i=(r.rel||"").toLowerCase();if(!v.has(i))return;const n=r.getAttribute("href");if(!n)return;const c=x(n);if(!c)return;const u=r.hasAttribute("crossorigin"),l=t.get(c)??[];l.some(p=>p.kind===i&&p.crossOrigin===u)||l.push({kind:i,crossOrigin:u}),t.set(c,l)}),t}function A(t,s){const r=new Set(s.map(i=>i.kind));return t==="preconnect"?r.has("preconnect")||r.has("preload")||r.has("modulepreload")?"ok":r.has("dns-prefetch")||r.has("prefetch")?"partial":"missing":r.has("preconnect")||r.has("dns-prefetch")||r.has("preload")||r.has("modulepreload")||r.has("prefetch")?"ok":"missing"}const j=["fonts.gstatic.com","use.typekit.net"];function O(t,s){const r=(()=>{try{return new URL(t).hostname}catch{return""}})(),i=s.find(n=>n.kind==="preconnect");if(i&&j.includes(r)&&!i.crossOrigin)return"preconnect is missing the crossorigin attribute (font origins require it)."}function m(t,s,r){if(!w(s))return;const i=x(s);if(!i)return;let n=t.get(i);n||(n={origin:i,sources:new Set,sampleUrls:[],hints:[],recommended:"dns-prefetch",status:"missing"},t.set(i,n)),n.sources.add(r),n.sampleUrls.length<3&&!n.sampleUrls.includes(s)&&n.sampleUrls.push(s)}function L(){const t=new Map;return document.querySelectorAll("img[src]").forEach((s,r)=>{m(t,s.src,r===0?"img-lcp":"img")}),document.querySelectorAll("source[srcset], img[srcset]").forEach(s=>{(s.getAttribute("srcset")||"").split(",").forEach(i=>{const n=i.trim().split(/\s+/)[0];n&&m(t,n,"img")})}),document.querySelectorAll("script[src]").forEach(s=>{m(t,s.src,"script")}),document.head.querySelectorAll("link[href]").forEach(s=>{const r=(s.rel||"").toLowerCase(),i=s.getAttribute("href");i&&(r==="stylesheet"?m(t,i,"link[stylesheet]"):r==="preload"?m(t,i,"link[preload]"):r==="modulepreload"&&m(t,i,"link[modulepreload]"))}),document.querySelectorAll("iframe[src]").forEach(s=>{m(t,s.src,"iframe")}),typeof performance<"u"&&performance.getEntriesByType&&performance.getEntriesByType("resource").forEach(r=>{if(!r.name)return;let i="fetch";switch(r.initiatorType){case"css":i="css-url";break;case"img":i="img";break;case"script":i="script";break;case"link":i="link[stylesheet]";break;case"iframe":i="iframe";break;case"xmlhttprequest":case"fetch":i="fetch";break}m(t,r.name,i)}),t}function R(){const t=L(),s=E(),r=[];t.forEach(n=>{n.hints=s.get(n.origin)??[],n.recommended=S(n.sources),n.status=A(n.recommended,n.hints),n.warning=O(n.origin,n.hints),r.push(n)});const i={missing:0,partial:1,ok:2};return r.sort((n,c)=>i[n.status]!==i[c.status]?i[n.status]-i[c.status]:!!n.warning!=!!c.warning?n.warning?-1:1:n.origin.localeCompare(c.origin)),r}const U={ok:"OK",partial:"Partial",missing:"Missing"},T={ok:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30",partial:"bg-amber-500/15 text-amber-300 border-amber-500/30",missing:"bg-rose-500/15 text-rose-300 border-rose-500/30"};function _(){y({title:"Origin Audit â Musick Creek Falls",description:"Internal audit of every external origin used at runtime and whether it has a preconnect or dns-prefetch hint."}),d.useEffect(()=>{let o=document.head.querySelector('meta[name="robots"]');const a=o?.getAttribute("content")??null;return o||(o=document.createElement("meta"),o.setAttribute("name","robots"),document.head.appendChild(o)),o.setAttribute("content","noindex,nofollow"),()=>{a!==null&&o.setAttribute("content",a)}},[]);
1const[t,s]=d.useState([]),[r,i]=d.useState(null),[n,c]=d.useState("all"),u=()=>{s(R()),i(new Date)};d.useEffect(()=>{const o=setTimeout(u,800);return()=>clearTimeout(o)},[]);const l=d.useMemo(()=>t.reduce((o,a)=>(o[a.status]+=1,o.total+=1,o),{missing:0,partial:0,ok:0,total:0}),[t]),p=d.useMemo(()=>n==="all"?t:t.filter(o=>o.status===n),[t,n]),f=d.useMemo(()=>{const o=t.filter(a=>a.status==="missing"||a.status==="partial"||a.warning);return o.length?o.map(a=>{const g=(()=>{try{return new URL(a.origin).hostname}catch{return""}})(),k=a.recommended==="preconnect"&&(j.includes(g)||g.endsWith(".gstatic.com"));return`<link rel="${a.recommended}" href="${a.origin}"${k?" crossorigin":""} />`}).join(` 2`):""},[t]);return e.jsx("main",{className:"min-h-screen bg-background text-foreground",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-6 py-12",children:[e.jsxs("div",{className:"mb-8 flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground",children:"Internal · performance"}),e.jsx("h1",{className:"mt-2 font-display text-4xl text-foreground",children:"Origin Audit"}),e.jsxs("p",{className:"mt-2 max-w-2xl text-sm text-muted-foreground",children:["Every external origin loaded by the current page is listed below, alongside the resource hints declared in ",e.jsx("code",{children:"<head>"}),". Visit"," ",e.jsx(b,{className:"underline",to:"/explore",children:"/explore"})," ","or"," ",e.jsx(b,{className:"underline",to:"/directions",children:"/directions"})," ","first to surface map tile and widget origins, then return here and click rescan."]})]}),e.jsx("button",{onClick:u,className:"rounded-md border border-border bg-card px-4 py-2 text-sm font-medium text-foreground transition hover:bg-accent",children:"Rescan"})]}),e.jsxs("div",{className:"mb-6 grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(h,{label:"Total origins",value:l.total}),e.jsx(h,{label:"OK",value:l.ok,tone:"ok"}),e.jsx(h,{label:"Partial",value:l.partial,tone:"partial"}),e.jsx(h,{label:"Missing",value:l.missing,tone:"missing"})]}),e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[["all","missing","partial","ok"].map(o=>e.jsx("button",{onClick:()=>c(o),className:`rounded-full border px-3 py-1 text-xs uppercase tracking-wide transition ${n===o?"border-primary bg-primary/10 text-primary":"border-border bg-card/50 text-muted-foreground hover:text-foreground"}`,children:o},o)),r&&e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:["Last scan: ",r.toLocaleTimeString()]})]}),e.jsx("div",{className:"overflow-hidden rounded-lg border border-border bg-card/40",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-xs uppercase tracking-wide text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3",children:"Origin"}),e.jsx("th",{className:"px-4 py-3",children:"Used by"}),e.jsx("th",{className:"px-4 py-3",children:"Hint present"}),e.jsx("th",{className:"px-4 py-3",children:"Recommended"}),e.jsx("th",{className:"px-4 py-3",children:"Status"})]})}),e.jsxs("tbody",{children:[p.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-8 text-center text-muted-foreground",children:"No origins match this filter."})}),p.map(o=>e.jsxs("tr",{className:"border-t border-border/60 align-top",children:[e.jsxs("td",{className:"px-4 py-3 font-mono text-xs text-foreground",children:[o.origin,o.sampleUrls.length>0&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:[o.sampleUrls.length," sample URL(s)"]}),e.jsx("ul",{className:"mt-1 space-y-1 text-[10px] text-muted-foreground",children:o.sampleUrls.map(a=>e.jsx("li",{className:"break-all",children:a},a))})]})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:[...o.sources].map(a=>e.jsx("span",{className:"rounded border border-border bg-muted/40 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:a},a))})}),e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground",children:o.hints.length?o.hints.map(a=>`${a.kind}${a.crossOrigin?" (crossorigin)":""}`).join(", "):"â"}),e.jsx("td",{className:"px-4 py-3 text-xs text-foreground",children:o.recommended}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-wide ${T[o.status]}`,children:U[o.status]}),o.warning&&e.jsxs("p",{className:"mt-1 text-[10px] text-amber-300",children:["â ",o.warning]})]})]},o.origin))]})]})}),f&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h2",{className:"font-display text-xl text-foreground",children:"Suggested hints to add"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Paste these into ",e.jsx("code",{children:"index.html"})," inside ",e.jsx("code",{children:"<head>"}),":"]}),e.jsx("pre",{className:"mt-3 overflow-x-auto rounded-md border border-border bg-muted/40 p-4 text-xs text-foreground",children:e.jsx("code",{children:f})})]})]})})}function h({label:t,value:s,tone:r}){const i=r==="ok"?"text-emerald-300":r==="partial"?"text-amber-300":r==="missing"?"text-rose-300":"text-foreground";return e.jsxs("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("p",{className:`mt-1 text-2xl font-semibold ${i}`,children:s})]})}export{_ as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.