PageSourceSearch

https://lawfirminnovations.com/assets/AiVisibilityDetail-C8TQTitZ.js

js lawfirminnovations.com collected 2026-10-09 22:03:23 UTC 50,540 bytes, 50 lines download raw bytes

1import{c as Je,R as B,q as Ae,r as G,o as Xe,j as e,L as Qe,X as Ze,J as $}from"./main-C1Rs6n4C.js";import{supabase as J}from"./client-CiAYsF0C.js";import{B as U}from"./button-Dsou5oIf.js";import{I as X}from"./input-CQs8BPDe.js";import{T as Pe}from"./textarea-BT70jDef.js";import{L as re}from"./loader-circle-7Ic7Fb3C.js";import{A as et}from"./arrow-left-BzvQ5xdG.js";import{T as tt}from"./trending-up-Byhhk7pc.js";import{u as at,i as rt,D as it,f as st,L as ge,a as ue,C as nt,A as lt,b as oe,c as ot,d as je,e as ct,g as dt,G as mt,h as ze,j as Ce,E as pt,k as ut,X as Ge,Y as Be,l as ft,R as ht,m as xt,T as gt,n as bt,F as yt}from"./generateCategoricalChart-BsHzkQQq.js";import{P as be}from"./plus-stJJy1R3.js";import{S as _e}from"./save-BnWFSn7H.js";import{D as Oe}from"./download-BLxmphtx.js";import{P as ye}from"./play-J5wfMk0k.js";import{T as Le}from"./trash-2-C4j7i4AY.js";import{C as vt}from"./chevron-down-DLax6u5v.js";import{C as jt}from"./chevron-right-B9L_hGni.js";import{E as De}from"./external-link-ZvwyeGGn.js";import{R as Nt}from"./refresh-cw-2B87XD9e.js";import{E as kt}from"./eye-D9YH9oap.js";import{C as Me}from"./circle-alert-4n0GWZ6q.js";import{C as wt}from"./circle-check--gNV-Jn-.js";import{T as St}from"./triangle-alert-95y2tKct.js";import{C as At}from"./circle-minus-Bvg-RS_H.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Pt=Je("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]),ie=[{key:"technical",title:"Section 1 — Technical Foundation",items:[{id:"1.1",label:"Raw HTML contains firm name + practice content",auto:!0},{id:"1.2",label:"GSC URL Inspection shows fully rendered content"},{id:"1.3",label:"Indexed in Bing (ChatGPT's index)"},{id:"1.4",label:"Prerender layer verified OR site is SSR"},{id:"1.5",label:"Organization/LegalService JSON-LD in static HTML",auto:!0},{id:"1.6",label:"Person schema on every attorney bio (bar #, memberOf, sameAs)",auto:!0},{id:"1.7",label:"FAQPage schema matching visible page content",auto:!0},{id:"1.8",label:"Articles: author Person ref, datePublished/dateModified, 'Last reviewed by'",auto:!0},{id:"1.9",label:"robots.txt allows GPTBot, OAI-SearchBot, ClaudeBot, PerplexityBot, Google-Extended, Bingbot",auto:!0},{id:"1.10",label:"llms.txt + llms-full.txt live at root",auto:!0},{id:"1.11",label:"sitemap.xml complete; submitted to GSC AND Bing",auto:!0},{id:"1.12",label:"NAP identical across site, GBP, Avvo, Justia, FindLaw, State Bar"}]},{key:"content",title:"Section 2 — Content Extractability (sample top 5 money pages)",items:[{id:"2.1",label:"40–60 word definitive answer directly under H1"},{id:"2.2",label:"Question-format H2s, each followed by 2–3 sentence answer"},{id:"2.3",label:"FAQ section present and mirrored in schema"},{id:"2.4",label:"Claims/statistics attributed inline (statute, court, year)"},{id:"2.5",label:"Topic cluster: 5+ supporting pages interlinked per core PA"},{id:"2.6",label:"Updated within 90 days, visible date"},{id:"2.7",label:"Compliance: no outcome guarantees, no 'specialist' without cert, required bar disclaimers"}]},{key:"authority",title:"Section 3 — Authority & Off-Site",items:[{id:"3.1",label:"Directory profiles complete: Avvo, Justia, FindLaw, Super Lawyers, State Bar"},{id:"3.2",label:"Featured in 1+ independent 'best [PA] lawyer in [city]' roundup"},{id:"3.3",label:"50+ Google reviews with ongoing velocity; recent replies"},{id:"3.4",label:"Reddit/community presence or mentions in legal threads"},{id:"3.5",label:"1+ original data asset published (e.g., county filing statistics)"},{id:"3.6",label:"Wikipedia/Wikidata entity if notable; Knowledge Panel claimed"}]}],Ct=["ChatGPT","Perplexity","Google AIO","Gemini","Claude","Copilot"],_t=[{category:"local",prompt:"best {PA} lawyer in {city}"},{category:"local",prompt:"top rated {PA} attorney near {city}"},{category:"info",prompt:"what is my case worth after a car accident in {city}"},{category:"info",prompt:"how long do I have to file a {PA} claim in {city}"},{category:"comp",prompt:"{firm} vs {competitor}"},{category:"brand",prompt:"{firm} reviews"},{category:"brand",prompt:"is {firm} a good law firm"},{category:"alt",prompt:"alternatives to {competitor} in {city}"},{category:"voice",prompt:"{PA} lawyer near me {city}"},{category:"voice",prompt:"who is the best {PA} attorney in {city}"}];function Ot(i){if(!i||i.length===0)return null;const t=i.filter(d=>d.mentioned==="Y"||d.mentioned==="N");if(t.length===0)return null;const s=i.filter(d=>d.mentioned==="Y"),r=Math.round(s.length/t.length*10),c=d=>d==="1"?10:d==="2"?7:d==="3"?5:d==="4+"?3:0,m=s.map(d=>c(d.position||"")).filter(d=>d>0),p=m.length?Math.round(m.reduce((d,S)=>d+S,0)/m.length):0,h=d=>d==="+"?10:d==="0"?6:d==="-"?0:null,y=s.map(d=>h(d.sentiment||"")).filter(d=>d!=null),v=y.length?Math.round(y.reduce((d,S)=>d+S,0)/y.length):0,A=s.filter(d=>
6d.accurate==="Y"||d.accurate==="N"),N=A.length?Math.round(A.filter(d=>d.accurate==="Y").length/A.length*10):0,k=Array.from(new Set(i.map(d=>d.category))),_=new Set(s.map(d=>d.category)),j=k.length?Math.round(_.size/k.length*10):0,O=Array.from(new Set(i.map(d=>d.engine))).map(d=>{const S=i.filter(E=>E.engine===d&&(E.mentioned==="Y"||E.mentioned==="N"));return S.length?S.filter(E=>E.mentioned==="Y").length/S.length:null}).filter(d=>d!=null);let T=10;if(O.length>1){const d=O.reduce((M,R)=>M+R,0)/O.length,S=O.reduce((M,R)=>M+(R-d)**2,0)/O.length,E=Math.sqrt(S)*10;T=Math.max(0,Math.round(10-E))}const D=[r,p,v,N,j,T],Y=Math.round(D.reduce((d,S)=>d+S,0)/D.length*10);return{presence:r,position:p,sentiment:v,accuracy:N,completeness:j,consistency:T,overall:Y}}var Lt=["type","layout","connectNulls","ref"];function ne(i){"@babel/helpers - typeof";return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(i)}function Dt(i,t){if(i==null)return{};var s=Et(i,t),r,c;if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(i);for(c=0;c<m.length;c++)r=m[c],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(i,r)&&(s[r]=i[r])}return s}function Et(i,t){if(i==null)return{};var s={},r=Object.keys(i),c,m;for(m=0;m<r.length;m++)c=r[m],!(t.indexOf(c)>=0)&&(s[c]=i[c]);return s}function ce(){return ce=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(i[r]=s[r])}return i},ce.apply(this,arguments)}function Ee(i,t){var s=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);t&&(r=r.filter(function(c){return Object.getOwnPropertyDescriptor(i,c).enumerable})),s.push.apply(s,r)}return s}function V(i){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?Ee(Object(s),!0).forEach(function(r){K(i,r,s[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(s)):Ee(Object(s)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(s,r))})}return i}function se(i){return Ft(i)||Tt(i)||$t(i)||Rt()}function Rt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
7In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $t(i,t){if(i){if(typeof i=="string")return Ne(i,t);var s=Object.prototype.toString.call(i).slice(8,-1);if(s==="Object"&&i.constructor&&(s=i.constructor.name),s==="Map"||s==="Set")return Array.from(i);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return Ne(i,t)}}function Tt(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function Ft(i){if(Array.isArray(i))return Ne(i)}function Ne(i,t){(t==null||t>i.length)&&(t=i.length);for(var s=0,r=new Array(t);s<t;s++)r[s]=i[s];return r}function zt(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}function Re(i,t){for(var s=0;s<t.length;s++){var r=t[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,Ue(r.key),r)}}function Gt(i,t,s){return t&&Re(i.prototype,t),s&&Re(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}function Bt(i,t,s){return t=he(t),Mt(i,Ie()?Reflect.construct(t,s||[],he(i).constructor):t.apply(i,s))}function Mt(i,t){if(t&&(ne(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return te(i)}function Ie(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ie=function(){return!!i})()}function he(i){return he=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},he(i)}function te(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function It(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),t&&ke(i,t)}function ke(i,t){return ke=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,c){return r.__proto__=c,r},ke(i,t)}function K(i,t,s){return t=Ue(t),t in i?Object.defineProperty(i,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[t]=s,i}function Ue(i){var t=Ut(i,"string");return ne(t)=="symbol"?t:String(t)}function Ut(i,t){if(ne(i)!="object"||!i)return i;var s=i[Symbol.toPrimitive];if(s!==void 0){var r=s.call(i,t||"default");if(ne(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}var Q=function(i){It(t,i);function t(){var s;zt(this,t);for(var r=arguments.length,c=new Array(r),m=0;m<r;m++)c[m]=arguments[m];return s=Bt(this,t,[].concat(c)),K(te(s),"state",{isAnimationFinished:!0,totalLength:0}),K(te(s),"generateSimpleStrokeDasharray",function(p,h){return"".concat(h,"px ").concat(p-h,"px")}),K(te(s),"getStrokeDasharray",function(p,h,y){var v=y.reduce(function(T,D){return T+D});if(!v)return s.generateSimpleStrokeDasharray(h,p);for(var A=Math.floor(p/v),N=p%v,k=h-p,_=[],j=0,w=0;j<y.length;w+=y[j],++j)if(w+y[j]>N){_=[].concat(se(y.slice(0,j)),[N-w]);break}var O=_.length%2===0?[0,k]:[k];return[].concat(se(t.repeat(y,A)),se(_),O).map(function(T){return"".concat(T,"px")}).join(", ")}),K(te(s),"id",at("recharts-line-")),K(te(s),"pathRef",function(p){s.mainCurve=p}),K(te(s),"handleAnimationEnd",function(){s.setState({isAnimationFinished:!0}),s.props.onAnimationEnd&&s.props.onAnimationEnd()}),K(te(s),"handleAnimationStart",function(){s.setState({isAnimationFinished:!1}),s.props.onAnimationStart&&s.props.onAnimationStart()}),s}
vendor: 4,884 bytes, line 7
7return Gt(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();this.setState({totalLength:r})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();r!==this.state.totalLength&&this.setState({totalLength:r})}}},{key:"getTotalLength",value:function(){var r=this.mainCurve;try{return r&&r.getTotalLength&&r.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(r,c){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var m=this.props,p=m.points,h=m.xAxis,y=m.yAxis,v=m.layout,A=m.children,N=st(A,pt);if(!N)return null;var k=function(w,O){return{x:w.x,y:w.y,value:w.value,errorVal:ze(w.payload,O)}},_={clipPath:r?"url(#clipPath-".concat(c,")"):null};return B.createElement(ge,_,N.map(function(j){return B.cloneElement(j,{key:"bar-".concat(j.props.dataKey),data:p,xAxis:h,yAxis:y,layout:v,dataPointFormatter:k})}))}},{key:"renderDots",value:function(r,c,m){var p=this.props.isAnimationActive;if(p&&!this.state.isAnimationFinished)return null;var h=this.props,y=h.dot,v=h.points,A=h.dataKey,N=ue(this.props,!1),k=ue(y,!0),_=v.map(function(w,O){var T=V(V(V({key:"dot-".concat(O),r:3},N),k),{},{value:w.value,dataKey:A,cx:w.x,cy:w.y,index:O,payload:w.payload});return t.renderDotItem(y,T)}),j={clipPath:r?"url(#clipPath-".concat(c?"":"dots-").concat(m,")"):null};return B.createElement(ge,ce({className:"recharts-line-dots",key:"dots"},j),_)}},{key:"renderCurveStatically",value:function(r,c,m,p){var h=this.props,y=h.type,v=h.layout,A=h.connectNulls;h.ref;var N=Dt(h,Lt),k=V(V(V({},ue(N,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(m,")"):null,points:r},p),{},{type:y,layout:v,connectNulls:A});return B.createElement(nt,ce({},k,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(r,c){var m=this,p=this.props,h=p.points,y=p.strokeDasharray,v=p.isAnimationActive,A=p.animationBegin,N=p.animationDuration,k=p.animationEasing,_=p.animationId,j=p.animateNewValues,w=p.width,O=p.height,T=this.state,D=T.prevPoints,Y=T.totalLength;return B.createElement(lt,{begin:A,duration:N,isActive:v,easing:k,from:{t:0},to:{t:1},key:"line-".concat(_),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(d){var S=d.t;if(D){var E=D.length/h.length,M=h.map(function(F,le){var W=Math.floor(le*E);if(D[W]){var Z=D[W],ee=oe(Z.x,F.x),de=oe(Z.y,F.y);return V(V({},F),{},{x:ee(S),y:de(S)})}if(j){var xe=oe(w*2,F.x),me=oe(O/2,F.y);return V(V({},F),{},{x:xe(S),y:me(S)})}return V(V({},F),{},{x:F.x,y:F.y})});return m.renderCurveStatically(M,r,c)}var R=oe(0,Y),I=R(S),P;if(y){var q="".concat(y).split(/[,\s]+/gim).map(function(F){return parseFloat(F)});P=m.getStrokeDasharray(I,Y,q)}else P=m.generateSimpleStrokeDasharray(Y,I);return m.renderCurveStatically(h,r,c,{strokeDasharray:P})})}},{key:"renderCurve",value:function(r,c){var m=this.props,p=m.points,h=m.isAnimationActive,y=this.state,v=y.prevPoints,A=y.totalLength;return h&&p&&p.length&&(!v&&A>0||!ot(v,p))?this.renderCurveWithAnimation(r,c):this.renderCurveStatically(p,r,c)}},{key:"render",value:function(){var r,c=this.props,m=c.hide,p=c.dot,h=c.points,y=c.className,v=c.xAxis,A=c.yAxis,N=c.top,k=c.left,_=c.width,j=c.height,w=c.isAnimationActive,O=c.id;if(m||!h||!h.length)return null;var T=this.state.isAnimationFinished,D=h.length===1,Y=Ae("recharts-line",y),d=v&&v.allowDataOverflow,S=A&&A.allowDataOverflow,E=d||S,M=je(O)?this.id:O,R=(r=ue(p,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},I=R.r,P=I===void 0?3:I,q=R.strokeWidth,F=q===void 0?2:q,le=ct(p)?p:{},W=le.clipDot,Z=W===void 0?!0:W,ee=P*2+F;return B.createElement(ge,{className:Y},d||S?B.createElement("defs",null,B.createElement("clipPath",{id:"clipPath-".concat(M)},B.createElement("rect",{x:d?k:k-_/2,y:S?N:N-j/2,width:d?_:_*2,height:S?j:j*2})),!Z&&B.createElement("clipPath",{id:"clipPath-dots-".concat(M)},B.createElement("rect",{x:k-ee/2,y:N-ee/2,width:_+ee,height:j+ee}))):null,!D&&this.renderCurve(E,M),this.renderErrorBar(E,M),(D||p)&&this.renderDots(E,Z,M),(!w||T)&&dt.renderCallByParent(this.props,h))}}],[{key:"getDerivedStateFromProps",value:function(r,c){return r.animationId!==c.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:c.curPoints}:r.points!==c.curPoints?{curPoints:r.points}:null}},{key:"repeat",value:function(r,c){for(var m=r.length%2!==0?[].concat(se(r),[0]):r,p=[],h=0;h<c;++h)p=[].concat(se(p),se(m));return p}},{key:"renderDotItem",value:function(r,c){var m;if(B.isValidElement(r))m=B.cloneElement(r,c);else if(rt(r))m=r(c);else{var p=Ae("recharts-line-dot",typeof r!="boolean"?r.className:"");m=B.createElement(it,ce({},c,{className:p}))}return m}}]),t}(G.PureComponent);K(Q,"displayName","Line");K(Q,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendT
7ype:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!mt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});K(Q,"getComposedData",function(i){var t=i.props,s=i.xAxis,r=i.yAxis,c=i.xAxisTicks,m=i.yAxisTicks,p=i.dataKey,h=i.bandSize,y=i.displayedData,v=i.offset,A=t.layout,N=y.map(function(k,_){var j=ze(k,p);return A==="horizontal"?{x:Ce({axis:s,ticks:c,bandSize:h,entry:k,index:_}),y:je(j)?null:r.scale(j),value:j,payload:k}:{x:je(j)?null:s.scale(j),y:Ce({axis:r,ticks:m,bandSize:h,entry:k,index:_}),value:j,payload:k}});return V({points:N,layout:A},v)});var Vt=ut({chartName:"LineChart",GraphicalChild:Q,axisComponents:[{axisType:"xAxis",AxisComp:Ge},{axisType:"yAxis",AxisComp:Be}],formatAxisMap:ft});const $e="1.0",Te="1.0",Fe={"2.1":"1.0","2.2":"1.0","2.3":"1.0","2.4":"1.0","2.5":"1.0","2.6":"1.0","2.7":"1.0"},fe=({value:i,onClick:t,target:s,label:r})=>{const c=i===s,m={pass:"bg-emerald-500/20 border-emerald-500/50 text-emerald-300",fail:"bg-red-500/20 border-red-500/50 text-red-300",partial:"bg-yellow-500/20 border-yellow-500/50 text-yellow-300",na:"bg-lfi-paper border-lfi-black/15 text-lfi-gray"};return e.jsx("button",{type:"button",onClick:t,className:`px-2 py-1 text-[10px] uppercase tracking-wider font-semibold rounded-md border transition-all ${c?m[s]:"border-lfi-black/10 text-lfi-gray/60 hover:text-lfi-gray hover:border-lfi-black/20"}`,children:r})},ve=({s:i})=>i==="pass"?e.jsx(wt,{className:"w-4 h-4 text-emerald-600"}):i==="fail"?e.jsx(Me,{className:"w-4 h-4 text-red-600"}):i==="partial"?e.jsx(St,{className:"w-4 h-4 text-amber-600"}):e.jsx(At,{className:"w-4 h-4 text-lfi-gray/50"});function fa(){const{id:i}=Xe(),[t,s]=G.useState(null),[r,c]=G.useState(null),[m,p]=G.useState(!1),[h,y]=G.useState(!1),[v,A]=G.useState(null),[N,k]=G.useState(null),[_,j]=G.useState(new Set),[w,O]=G.useState(new Set),T=new Set(["fail","partial"]),[D,Y]=G.useState(T),[d,S]=G.useState(null),[E,M]=G.useState([]);G.useEffect(()=>{i&&(async()=>{const{data:a}=await J.from("ai_visibility_audits").select("*").eq("id",i).maybeSingle();if(a){s(a);const{data:n}=await J.from("sites").select("id,url,label").eq("id",a.site_id).maybeSingle();c(n);const{data:l}=await J.from("ai_visibility_audits").select("month, scores").eq("site_id",a.site_id).order("month",{ascending:!0});l&&M(l.map(o=>{var f,C,g,b,u;return{month:o.month,overall:((f=o.scores)==null?void 0:f.overall)??null,presence:((C=o.scores)==null?void 0:C.presence)??null,position:((g=o.scores)==null?void 0:g.position)??null,sentiment:((b=o.scores)==null?void 0:b.sentiment)??null,accuracy:((u=o.scores)==null?void 0:u.accuracy)??null}}))}})()},[i]);const R=G.useMemo(()=>t?Ot(t.prompt_panel||[]):null,[t==null?void 0:t.prompt_panel]),I=G.useMemo(()=>((t==null?void 0:t.pages)||[]).filter(a=>{var n,l;if(w.size===0)return!0;for(const o of w){const f=(l=(n=a.rubric)==null?void 0:n[o])==null?void 0:l.status;if(f&&D.has(f))return!0}return!1}),[t==null?void 0:t.pages,w,D]),P=async a=>{if(!t)return;p(!0);const n={...t,...a};s(n);const{error:l}=await J.from("ai_visibility_audits").update(a).eq("id",t.id);p(!1),l&&$.error(l.message)},q=(a,n,l)=>{if(!t)return;const o={...t.checks||{}},f=o[a]||{status:"na",notes:""};o[a]={...f,[n]:l},P({checks:o})},F=async()=>{if(!(!t||!r)){y(!0);try{const{data:a,error:n}=await J.functions.invoke("ai-visibility-checks",{body:{url:r.url,firm_name:r.label||void 0}});if(n)throw n;const l=a.results,o={...t.checks||{}};for(const f of l)o[f.id]={status:f.status,notes:f.notes};await P({checks:o,auto_check_results:a,auto_checked_at:new Date().toISOString()}),$.success(`Ran ${l.length} automated checks`)}catch(a){$.error(a.message??"Auto-check failed")}finally{y(!1)}}},le=async()=>{if(!t)return;const a=(t.practice_areas||"personal injury").split(",")[0].trim(),n=(t.cities||"your city").split(",")[0].trim(),l=(t.competitors||"competitor").split(",")[0].trim(),o=(r==null?void 0:r.label)||(r==null?void 0:r.url)||"your firm",f={"{PA}":a,"{city}":n,"{state}":"","{competitor}":l,"{firm}":o},C=[];for(const g of _t){let b=g.prompt;
7for(const[u,x]of Object.entries(f))b=b.split(u).join(x);for(const u of Ct)C.push({id:crypto.randomUUID(),category:g.category,prompt:b,engine:u,mentioned:null,position:null,sentiment:null,accurate:null,cited_url:"",competitors:""})}await P({prompt_panel:C}),$.success(`Seeded ${C.length} prompt × engine rows`)},W=(a,n,l)=>{if(!t)return;const o=(t.prompt_panel||[]).map(f=>f.id===a?{...f,[n]:l}:f);P({prompt_panel:o})},Z=async a=>{if(!t)return;if((a&&a.length?a:(t.prompt_panel||[]).map(l=>l.id)).length===0){$.error("No prompts to run");return}A(a&&a.length?new Set(a):"all");try{const{data:l,error:o}=await J.functions.invoke("ai-visibility-run-prompts",{body:{audit_id:t.id,row_ids:a&&a.length?a:void 0}});if(o)throw o;$.success(`Ran ${l.processed} prompt(s) · ${l.errors} error(s)`);const{data:f}=await J.from("ai_visibility_audits").select("*").eq("id",t.id).maybeSingle();f&&s(f)}catch(l){$.error(l.message??"Prompt run failed")}finally{A(null)}},ee=()=>{t&&P({pages:[...t.pages||[],{id:crypto.randomUUID(),url:"",label:""}]})},de=(a,n,l)=>{t&&P({pages:(t.pages||[]).map(o=>o.id===a?{...o,[n]:l}:o)})},xe=a=>{t&&P({pages:(t.pages||[]).filter(n=>n.id!==a)})},me=async a=>{if(!t)return;const n=(t.pages||[]).filter(o=>{var f;return(f=o.url)==null?void 0:f.trim()});if((a!=null&&a.length?n.filter(o=>a.includes(o.id)):n).length===0){$.error("Add at least one page URL first");return}k(a!=null&&a.length?new Set(a):"all");try{const{data:o,error:f}=await J.functions.invoke("ai-visibility-grade-pages",{body:{audit_id:t.id,page_ids:a!=null&&a.length?a:void 0}});if(f)throw f;$.success(`Graded ${o.processed} page(s) · ${o.errors} error(s)`);const{data:C}=await J.from("ai_visibility_audits").select("*").eq("id",t.id).maybeSingle();C&&s(C)}catch(o){$.error(o.message??"Page grading failed")}finally{k(null)}},Ve=()=>{var l,o;if(!t)return;const a=(t.pages||[]).filter(f=>f.rubric);if(a.length===0){$.error("Grade at least one page first");return}const n={...t.checks||{}};for(const f of ie.find(C=>C.key==="content").items){const C={pass:0,partial:0,fail:0,na:0};for(const x of a){const L=((o=(l=x.rubric)==null?void 0:l[f.id])==null?void 0:o.status)??"na";C[L]=(C[L]??0)+1}const g=a.length;let b="partial";C.na===g?b="na":C.pass/g>=.7?b="pass":C.fail/g>=.5&&(b="fail");const u=a.map(x=>{var L,z,ae,H,we,Se;return`${x.label||x.url}: ${((z=(L=x.rubric)==null?void 0:L[f.id])==null?void 0:z.status)??"na"}${(H=(ae=x.rubric)==null?void 0:ae[f.id])!=null&&H.notes?` — ${(Se=(we=x.rubric)==null?void 0:we[f.id])==null?void 0:Se.notes}`:""}`}).join(`
8`);n[f.id]={status:b,notes:u}}P({checks:n}),$.success("Section 2 checklist updated from page grades")},We=()=>{if(!t||I.length===0){$.error("Nothing to export");return}const a=ie.find(x=>x.key==="content").items,n=I.map(x=>x.graded_at).filter(Boolean).sort().pop(),l=[["Site",(r==null?void 0:r.label)||(r==null?void 0:r.url)||""],["Timestamp",n||new Date().toISOString()],["Grader Version",$e],["Rubric Version",Te],["Rubric Items",a.map(x=>`${x.id}@v${Fe[x.id]||"1.0"}`).join("; ")],[""]],o=["Page Label","Page URL",...a.flatMap(x=>[`${x.id} Status`,`${x.id} Evidence`]),"Summary","Graded At"],f=I.map(x=>{var z;const L=[x.label||"",x.url||""];for(const ae of a){const H=(z=x.rubric)==null?void 0:z[ae.id];L.push((H==null?void 0:H.status)||"na",((H==null?void 0:H.notes)||"").replace(/"/g,'"""'))}return L.push((x.summary||"").replace(/"/g,'"""'),x.graded_at||""),L}),C=[...l.map(x=>x.map(L=>`"${L}"`).join(",")),o.join(","),...f.map(x=>x.map(L=>`"${L}"`).join(","))].join(`
9`),g=new Blob([C],{type:"text/csv;charset=utf-8;"}),b=URL.createObjectURL(g),u=document.createElement("a");u.href=b,u.download=`section-2-evidence-${t.month}.csv`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(b),$.success("CSV downloaded")},Ke=()=>{if(!t||I.length===0){$.error("Nothing to export");return}const a=ie.find(u=>u.key==="content").items,n=u=>u==="pass"?"#34d399":u==="fail"?"#f87171":u==="partial"?"#fbbf24":"#9ca3af",l=u=>u==="pass"?"Pass":u==="fail"?"Fail":u==="partial"?"Partial":"N/A",o=I.map(u=>
9u.graded_at).filter(Boolean).sort().pop(),f=`
10<!DOCTYPE html>
11<html>
12<head>
13<meta charset="utf-8">
14<title>Section 2 Evidence — ${(r==null?void 0:r.label)||(r==null?void 0:r.url)||"Audit"}</title>
15<style>
16  body { font-family: Arial, sans-serif; margin: 40px; color: #111; background: #fff; }
17  h1 { font-size: 20px; margin-bottom: 6px; }
18  h2 { font-size: 14px; color: #666; margin-top: 0; margin-bottom: 20px; font-weight: normal; }
19  .meta { font-size: 11px; color: #444; margin-bottom: 20px; }
20  .meta span { display: inline-block; margin-right: 16px; }
21  .page { border: 1px solid #ddd; border-radius: 8px; padding: 16px; margin-bottom: 16px; page-break-inside: avoid; }
22  .page-title { font-size: 14px; font-weight: bold; margin-bottom: 4px; }
23  .page-url { font-size: 11px; color: #666; margin-bottom: 10px; word-break: break-all; }
24  table { width: 100%; border-collapse: collapse; font-size: 11px; }
25  th { text-align: left; padding: 6px 8px; background: #f3f4f6; border-bottom: 1px solid #ddd; }
26  td { padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
27  .badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 10px; font-weight: 600; color: #fff; }
28  .summary { font-size: 11px; color: #444; margin-top: 8px; font-style: italic; }
29  .graded { font-size: 10px; color: #999; margin-top: 6px; }
30</style>
31</head>
32<body>
33<h1>Section 2 — Page Extractability Evidence</h1>
34<h2>${(r==null?void 0:r.label)||(r==null?void 0:r.url)||""} · ${t.month}${w.size>0?" · Filtered":""}</h2>
35<div class="meta">
36  <span><strong>Site:</strong> ${(r==null?void 0:r.label)||(r==null?void 0:r.url)||"N/A"}</span>
37  <span><strong>Timestamp:</strong> ${o?new Date(o).toLocaleString():new Date().toLocaleString()}</span>
38  <span><strong>Grader Version:</strong> ${$e}</span>
39  <span><strong>Rubric Version:</strong> ${Te}</span>
40  <div style="margin-top:6px;color:#666;"><strong>Rubric Items:</strong> ${a.map(u=>`${u.id}@v${Fe[u.id]||"1.0"}`).join(" · ")}</div>
41</div>
42${I.map(u=>{const x=a.map(L=>{var ae;const z=(ae=u.rubric)==null?void 0:ae[L.id];return`<tr><td style="white-space:nowrap;font-weight:600;">${L.id}</td><td>${L.label}</td><td><span class="badge" style="background:${n(z==null?void 0:z.status)}">${l(z==null?void 0:z.status)}</span></td><td>${((z==null?void 0:z.notes)||"No evidence captured").replace(/</g,"&lt;")}</td></tr>`}).join("");return`<div class="page">
43    <div class="page-title">${(u.label||"Unlabeled").replace(/</g,"&lt;")}</div>
44    <div class="page-url">${u.url||""}</div>
45    <table><thead><tr><th>ID</th><th>Item</th><th>Status</th><th>Evidence</th></tr></thead><tbody>${x}</tbody></table>
46    ${u.summary?`<div class="summary">${u.summary.replace(/</g,"&lt;")}</div>`:""}
47    ${u.graded_at?`<div class="graded">Graded ${new Date(u.graded_at).toLocaleString()}</div>`:""}
48  </div>`}).join("")}
49</body>
50</html>`,C=new Blob([f],{type:"text/html"}),g=URL.createObjectURL(C),b=window.open(g,"_blank");b?(b.onload=()=>{b.print()},setTimeout(()=>{b.print()},800)):$.error("Popup blocked — please allow popups for print-to-PDF"),URL.revokeObjectURL(g)},Ye=()=>{t&&P({actions:[...t.actions||[],{id:crypto.randomUUID(),action:"",owner:"",impact:"Med",due:""}]})},pe=(a,n,l)=>{t&&P({actions:(t.actions||[]).map(o=>o.id===a?{...o,[n]:l}:o)})},qe=a=>{t&&P({actions:(t.actions||[]).filter(n=>n.id!==a)})},He=async()=>{!t||!R||(await P({scores:R}),$.success(`Overall score: ${R.overall}/100`))};return t?e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsxs(Qe,{to:"/app/ai-visibility",className:"text-sm text-lfi-gray/80 inline-flex items-center hover:text-lfi-orange transition-colors",children:[e.jsx(et,{className:"w-3 h-3 mr-1"}),"Back to AI Visibility"]}),e.jsx("h1",{className:"text-3xl md:font-heading text-5xl text-lfi-black mt-3",children:(r==null?void 0:r.label)||(r==null?void 0:r.url)}),e.jsxs("div",{className:"text-sm text-lfi-gray/80 mt-2 uppercase tracking-wider",children:[t.month," · ",t.type," ",m&&e.jsx("span",{className:"text-lfi-orange ml-2",children:"saving…"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3 bg-white border border-lfi-black/10 rounded-xl p-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-lfi-gray/60",children:"Platform"}),e.jsx(X,{value:t.platform||"",placeholder:"Lovable CSR / SSR / Other",onChange:a=>P({platform:a.target.value}),className:"bg-white border-lfi-black/10 text-lfi-black h-9 text-sm mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-lfi-gray/60",children:"Practice areas"}),e.jsx(X,{value:t.practice_areas||"",placeholder:"personal injury, criminal defense",onChange:a=>P({practice_areas:a.target.value}),className:"bg-white border-lfi-black/10 text-lfi-black h-9 text-sm mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-lfi-gray/60",children:"Cities"}),e.jsx(X,{value:t.cities||"",placeholder:"Atlanta, Marietta",onChange:a=>P({cities:a.target.value}),className:"bg-white border-lfi-black/10 text-lfi-black h-9 text-sm mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-lfi-gray/60",children:"Named competitors"}),e.jsx(X,{value:t.competitors||"",placeholder:"firm a, firm b",onChange:a=>P({competitors:a.target.value}),className:"bg-white border-lfi-black/10 text-lfi-black h-9 text-sm mt-1"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-7 gap-3",children:[R&&["presence","position","sentiment","accuracy","completeness","consistency"].map(a=>e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-xl p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold tabular-nums text-lfi-orange",children:R[a]??"—"}),e.jsx("div",{className:"text-[10px] text-lfi-gray/80 uppercase tracking-wider mt-1",children:a})]},a)),e.jsxs("div",{className:"bg-lfi-cream border border-lfi-orange/40 rounded-xl p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold tabular-nums text-lfi-orange",children:(R==null?void 0:R.overall)??"—"}),e.jsx("div",{className:"text-[10px] text-lfi-gray uppercase tracking-wider mt-1",children:"Overall"})]})]}),E.length>1&&e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(tt,{className:"w-4 h-4 text-lfi-orange"}),e.jsx("h2",{className:"text-lg font-bold text-lfi-black",children:"Trends — this site"}),e.jsxs("span",{className:"text-[10px] text-lfi-gray/60 uppercase tracking-wider",children:[E.length," audits"]})]}),e.jsx("div",{className:"h-[260px] w-full",children:e.jsx(ht,{width:"100%",height:"100%",children:e.jsxs(Vt,{data:E,margin:{top:6,right:12,left:-10,bottom:0},children:[e.jsx(xt,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.08)"}),e.jsx(Ge,{dataKey:"month",stroke:"rgba(255,255,255,0.5)",fontSize:11}),e.jsx(Be,{stroke:"rgba(255,255,255,0.5)",fontSize:11,domain:[0,100]}),e.jsx(gt,{contentStyle:{background:"#111",border:"1px solid rgba(255,255,255,0.1)",fontSize:12}}),e.jsx(bt,{wrapperStyle:{fontSize:11}}),e.jsx(Q,{type:"monotone",dataKey:"overall",stroke:"#f97316",strokeWidth:2,dot:{r:3}}),e.jsx(Q,{type:"monotone",dataKey:"presence",stroke:"#22d3ee",strokeWidth:1.5,dot:!1}),e.jsx(Q,{type:"monotone",dataKey:"position",stroke:"#a78bfa",strokeWidth:1.5,dot:!1}),e.jsx(Q,{type:"monotone",dataKey:"sentiment",stroke:"#34d399",strokeWidth:1.5,dot:!1}),e.jsx(Q,{type:"monotone",dataKey:"accuracy",stroke:"#fbbf24",strokeWidth:1.5,dot:!1})]})})}),e.jsx("p",{className:"text-[11px] text-lfi-gray/60 mt-2",children:"Overall is on a 0–100 scale; per-dimension scores are 0–10 (shown on the same axis for shape comparison)."})]}),e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-2",children:[e.jsx("h2",{className:"text-lg font-bold text-lfi-black",children:"Section 2 — Page Extractability Grader"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(U,{size:"sm",variant:"outline",onClick:ee,className:"border-lfi-black/15 text-lfi-black hover:bg-lfi-paper hover:text-lfi-black",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),"Add page"]}),e.jsxs(U,{size:"sm",onClick:()=>me(),disabled:N!==null||(t.pages||[]).length===0,className:"bg-lfi-orange hover:bg-lfi-emberDark text-lfi-black",children:[N==="all"?e.jsx(re,{className:"w-3 h-3 mr-1 animate-spin"}):e.jsx(Pt,{className:"w-3 h-3 mr-1"}),N==="all"?"Grading…":`Grade all (${(t.pages||[]).filter(a=>{var n;return(n=a.url)==null?void 0:n.trim()}).length})`]}),e.jsxs(U,{size:"sm",variant:"outline",onClick:Ve,className:"border-lfi-black/15 text-lfi-black hover:bg-lfi-paper hover:text-lfi-black",children:[e.jsx(_e,{className:"w-3 h-3 mr-1"}),"Roll up to checklist"]})]})]}),e.jsx("p",{className:"text-[11px] text-lfi-gray/60 mb-3",children:'Add 3–5 top money pages. The LLM fetches each, scores 2.1–2.7, and writes per-page evidence. "Roll up" maps page-level results to the Section 2 checklist below.'}),(t.pages||[]).length>0&&e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[e.jsx(yt,{className:"w-3 h-3 text-lfi-gray/60"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-lfi-gray/60",children:"Filter pages by rubric item"}),ie.find(n=>n.key==="content").items.map(n=>{const l=w.has(n.id);return e.jsx("button",{onClick:()=>{const o=new Set(w);l?o.delete(n.id):o.add(n.id),O(o)},className:`text-[10px] px-2 py-1 rounded-md border transition-all ${l?"bg-lfi-orange/20 border-lfi-orange/50 text-lfi-orange":"border-lfi-black/10 text-lfi-gray/80 hover:text-lfi-gray hover:border-lfi-black/20"}`,children:n.id},n.id)}),e.jsx("div",{className:"w-px h-4 bg-lfi-paper mx-1"}),["fail","partial"].map(a=>{const n=D.has(a),l=a==="fail"?"text-red-600 border-red-500/40 bg-red-500/10":"text-amber-600 border-yellow-500/40 bg-yellow-500/10";return e.jsx("button",{onClick:()=>{const o=new Set(D);n?o.delete(a):o.add(a),Y(o)},className:`text-[10px] px-2 py-1 rounded-md border transition-all ${n?l:"border-lfi-black/10 text-lfi-gray/80 hover:text-lfi-gray hover:border-lfi-black/20"}`,children:a==="fail"?"Fail":"Partial"},a)}),w.size>0&&e.jsx("button",{onClick:()=>{O(new Set),Y(new Set(["fail","partial"]))},className:"text-lfi-gray/60 hover:text-lfi-gray ml-auto",children:e.jsx(Ze,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-px h-4 bg-lfi-paper mx-1"}),e.jsxs(U,{size:"sm",variant:"outline",onClick:We,className:"border-lfi-black/15 text-lfi-black hover:bg-lfi-paper hover:text-lfi-black h-7 text-[10px] px-2",children:[e.jsx(Oe,{className:"w-3 h-3 mr-1"}),"CSV"]}),e.jsxs(U,{size:"sm",variant:"outline",onClick:Ke,className:"border-lfi-black/15 text-lfi-black hover:bg-lfi-paper hover:text-lfi-black h-7 text-[10px] px-2",children:[e.jsx(Oe,{className:"w-3 h-3 mr-1"}),"PDF"]})]}),(t.pages||[]).length===0?e.jsx("div",{className:"text-lfi-gray/80 text-sm text-center py-8",children:'No pages yet. Click "Add page" and paste a URL.'}):e.jsx("div",{className:"space-y-3",children:I.map(a=>{var n;return e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[e.jsx(X,{value:a.label||"",placeholder:"Label (e.g., PI homepage)",onChange:l=>de(a.id,"label",l.target.value),className:"bg-white border-lfi-black/10 text-lfi-black h-8 text-sm w-[200px]"}),e.jsx(X,{value:a.url||"",placeholder:"https://…",onChange:l=>de(a.id,"url",l.target.value),className:"bg-white border-lfi-black/10 text-lfi-black h-8 text-sm flex-1 min-w-[260px]"}),e.jsx(U,{size:"sm",onClick:()=>me([a.id]),disabled:N!==null||!((n=a.url)!=null&&n.trim()),className:"bg-lfi-orange hover:bg-lfi-emberDark text-lfi-black h-8",children:N instanceof Set&&N.has(a.id)?e.jsx(re,{className:"w-3 h-3 animate-spin"}):e.jsx(ye,{className:"w-3 h-3"})}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>xe(a.id),className:"text-lfi-gray/60 hover:text-red-600 hover:bg-red-500/10 h-8 w-8 p-0",children:e.jsx(Le,{className:"w-3 h-3"})})]}),a.last_error&&e.jsxs("div",{className:"text-xs text-red-600 mb-2",children:["Error: ",a.last_error]}),a.rubric&&(()=>{const l=ie.find(g=>g.key==="content").items,o=l.reduce((g,b)=>{var x,L;const u=((L=(x=a.rubric)==null?void 0:x[b.id])==null?void 0:L.status)??"na";return g[u]=(g[u]??0)+1,g},{}),f=_.has(a.id),C=()=>{const g=new Set(_);g.has(a.id)?g.delete(a.id):g.add(a.id),j(g)};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:C,className:"w-full flex items-center gap-2 mt-2 text-left hover:bg-lfi-paper rounded-md p-2 -mx-2 transition-colors",children:[f?e.jsx(vt,{className:"w-4 h-4 text-lfi-gray/80"}):e.jsx(jt,{className:"w-4 h-4 text-lfi-gray/80"}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs("span",{className:"text-emerald-600",children:[o.pass??0," pass"]}),e.jsxs("span",{className:"text-amber-600",children:[o.partial??0," partial"]}),e.jsxs("span",{className:"text-red-600",children:[o.fail??0," fail"]}),e.jsxs("span",{className:"text-lfi-gray/60",children:[o.na??0," n/a"]}
50)]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1",children:l.map(g=>{var b,u;return e.jsx("div",{className:"flex justify-center",children:e.jsx(ve,{s:(u=(b=a.rubric)==null?void 0:b[g.id])==null?void 0:u.status})},g.id)})}),a.url&&e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",onClick:g=>g.stopPropagation(),className:"text-lfi-gray/60 hover:text-lfi-orange",title:"Open page",children:e.jsx(De,{className:"w-3 h-3"})})]})]}),a.summary&&e.jsxs("div",{className:"text-xs text-lfi-gray italic mt-2 pl-6",children:['"',a.summary,'"']}),f&&e.jsxs("div",{className:"mt-3 border border-lfi-black/10 rounded-lg divide-y divide-white/10 bg-black/20",children:[l.map(g=>{var u,x;const b=(u=a.rubric)==null?void 0:u[g.id];return e.jsxs("div",{className:"p-3 grid grid-cols-[40px,1fr] gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(ve,{s:b==null?void 0:b.status}),e.jsx("span",{className:"text-[10px] font-mono text-lfi-gray/60",children:g.id})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-lfi-black",children:g.label}),e.jsx("div",{className:"text-xs text-lfi-gray mt-1 whitespace-pre-wrap break-words",children:(x=b==null?void 0:b.notes)!=null&&x.trim()?b.notes:e.jsx("span",{className:"text-lfi-gray/50 italic",children:"No evidence captured"})})]})]},g.id)}),a.url&&e.jsxs("div",{className:"p-3 bg-white text-xs flex items-center gap-2",children:[e.jsx("span",{className:"text-lfi-gray/60 uppercase tracking-wider text-[10px]",children:"Cited URL"}),e.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-lfi-orange hover:underline truncate flex items-center gap-1",children:[a.url," ",e.jsx(De,{className:"w-3 h-3 flex-shrink-0"})]})]})]}),a.graded_at&&e.jsxs("div",{className:"text-[10px] text-lfi-gray/50 mt-2 pl-6",children:["Graded ",new Date(a.graded_at).toLocaleString()]})]})})()]},a.id)})})]}),e.jsx("div",{className:"space-y-6",children:ie.map(a=>e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-bold text-lfi-black",children:a.title}),a.key==="technical"&&e.jsxs(U,{size:"sm",onClick:F,disabled:h,className:"bg-lfi-orange hover:bg-lfi-emberDark text-lfi-black",children:[h?e.jsx(re,{className:"w-3 h-3 mr-1 animate-spin"}):e.jsx(Nt,{className:"w-3 h-3 mr-1"}),"Run automated checks"]})]}),e.jsx("div",{className:"space-y-2",children:a.items.map(n=>{var o;const l=(o=t.checks)==null?void 0:o[n.id];return e.jsx("div",{className:"bg-white border border-lfi-black/10 rounded-lg p-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ve,{s:l==null?void 0:l.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono text-lfi-orange",children:n.id}),e.jsx("span",{className:"text-sm text-lfi-black font-medium",children:n.label}),n.auto&&e.jsx("span",{className:"text-[9px] uppercase bg-lfi-orange/15 text-lfi-orange border border-lfi-orange/30 rounded px-1.5 py-0.5",children:"auto"})]}),e.jsxs("div",{className:"flex gap-1 mt-2 flex-wrap",children:[e.jsx(fe,{value:l==null?void 0:l.status,target:"pass",label:"Pass",onClick:()=>q(n.id,"status","pass")}),e.jsx(fe,{value:l==null?void 0:l.status,target:"partial",label:"Partial",onClick:()=>q(n.id,"status","partial")}),e.jsx(fe,{value:l==null?void 0:l.status,target:"fail",label:"Fail",onClick:()=>q(n.id,"status","fail")}),e.jsx(fe,{value:l==null?void 0:l.status,target:"na",label:"N/A",onClick:()=>q(n.id,"status","na")})]}),e.jsx(Pe,{value:(l==null?void 0:l.notes)||"",placeholder:"Notes / evidence",onChange:f=>q(n.id,"notes",f.target.value),className:"bg-white border-lfi-black/10 text-lfi-black text-sm mt-2 min-h-[40px]"})]})]})},n.id)})})]},a.key))}),e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-2",children:[e.jsx("h2",{className:"text-lg font-bold text-lfi-black",children:"Section 4 — Prompt Panel"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(U,{size:"sm",variant:"outline",onClick:le,className:"border-lfi-black/15 text-lfi-black hover:bg-lfi-paper hover:text-lfi-black",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),"Seed default prompts × engines"]}),e.jsxs(U,{size:"sm",onClick:()=>Z(),disabled:v!==null||(t.prompt_panel||[]).length===0,className:"bg-lfi-orange hover:bg-lfi-emberDark text-lfi-black",children:[v==="all"?e.jsx(re,{className:"w-3 h-3 mr-1 animate-spin"}):e.jsx(ye,{className:"w-3 h-3 mr-1"}),v==="all"?"Running…":`Run all (${(t.prompt_panel||[]).length})`]}),e.jsxs(U,{size:"sm",onClick:He,className:"bg-lfi-orange hover:bg-lfi-emberDark text-lfi-black",children:[e.jsx(_e,{className:"w-3 h-3 mr-1"}),"Recompute scores"]})]})]}),e.jsx("p",{className:"text-[11px] text-lfi-gray/60 mb-3",children:"Engines map to Lovable AI models: ChatGPT/Copilot/Perplexity → GPT-5-mini, Gemini → Gemini 3 Flash, Google AIO → Gemini 2.5 Flash, Claude → GPT-5 (no direct Claude API). Results approximate each engine."}),(t.prompt_panel||[]).length===0?e.jsx("div",{className:"text-lfi-gray/80 text-sm text-center py-8",children:'No prompts yet. Click "Seed default prompts" to start.'}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"text-lfi-gray/80 uppercase tracking-wider",children:e.jsxs("tr",{className:"border-b border-lfi-black/10",children:[e.jsx("th",{className:"text-left py-2 px-1",children:"Cat"}),e.jsx("th",{className:"text-left py-2 px-1",children:"Prompt"}),e.jsx("th",{className:"text-left py-2 px-1",children:"Engine"}),e.jsx("th",{className:"text-left py-2 px-1",children:"Ment."}),e.jsx("th",{className:"text-left py-2 px-1",children:"Pos."}),e.jsx("th",{className:"text-left py-2 px-1",children:"Sent."}),e.jsx("th",{className:"text-left py-2 px-1",children:"Acc."}),e.jsx("th",{className:"text-left py-2 px-1",children:"Cited URL"}),e.jsx("th",{className:"text-left py-2 px-1",children:"Competitors"}),e.jsx("th",{className:"text-left py-2 px-1"})]})}),e.jsx("tbody",{children:(t.prompt_panel||[]).map(a=>e.jsxs("tr",{className:"border-b border-lfi-black/5 hover:bg-lfi-paper",children:[e.jsx("td",{className:"py-1 px-1 text-lfi-gray/80 uppercase",children:a.category}),e.jsx("td",{className:"py-1 px-1 text-lfi-black/80 max-w-[260px] truncate",title:a.prompt,children:a.prompt}),e.jsx("td",{className:"py-1 px-1 text-lfi-gray",children:a.engine}),e.jsx("td",{className:"py-1 px-1",children:e.jsxs("select",{value:a.mentioned??"",onChange:n=>W(a.id,"mentioned",n.target.value||null),className:"bg-white border border-lfi-black/10 rounded px-1 py-0.5 text-lfi-black",children:[e.jsx("option",{value:"",className:"bg-lfi-cream",children:"—"}),e.jsx("option",{value:"Y",className:"bg-lfi-cream",children:"Y"}),e.jsx("option",{value:"N",className:"bg-lfi-cream",children:"N"})]})}),e.jsx("td",{className:"py-1 px-1",children:e.jsxs("select",{value:a.position??"",onChange:n=>W(a.id,"position",n.target.value||null),className:"bg-white border border-lfi-black/10 rounded px-1 py-0.5 text-lfi-black",children:[e.jsx("option",{value:"",className:"bg-lfi-cream",children:"—"}),e.jsx("option",{value:"1",className:"bg-lfi-cream",children:"1"}),e.jsx("option",{value:"2",className:"bg-lfi-cream",children:"2"}),e.jsx("option",{value:"3",className:"bg-lfi-cream",children:"3"}),e.jsx("option",{value:"4+",className:"bg-lfi-cream",children:"4+"})]})}),e.jsx("td",{className:"py-1 px-1",children:e.jsxs("select",{value:a.sentiment??"",onChange:n=>W(a.id,"sentiment",n.target.value||null),className:"bg-white border border-lfi-black/10 rounded px-1 py-0.5 text-lfi-black",children:[e.jsx("option",{value:"",className:"bg-lfi-cream",children:"—"}),e.jsx("option",{value:"+",className:"bg-lfi-cream",children:"+"}),e.jsx("option",{value:"0",className:"bg-lfi-cream",children:"0"}),e.jsx("option",{value:"-",className:"bg-lfi-cream",children:"–"})]})}),e.jsx("td",{className:"py-1 px-1",children:e.jsxs("select",{value:a.accurate??"",onChange:n=>W(a.id,"accurate",n.target.value||null),className:"bg-white border border-lfi-black/10 rounded px-1 py-0.5 text-lfi-black",children:[e.jsx("option",{value:"",className:"bg-lfi-cream",children:"—"}),e.jsx("option",{value:"Y",className:"bg-lfi-cream",children:"Y"}),e.jsx("option",{value:"N",className:"bg-lfi-cream",children:"N"})]})}),e.jsx("td",{className:"py-1 px-1",children:e.jsx("input",{value:a.cited_url||"",onChange:n=>W(a.id,"cited_url",n.target.value),className:"bg-white border border-lfi-black/10 rounded px-1 py-0.5 text-lfi-black w-[140px]"})}),e.jsx("td",{className:"py-1 px-1",children:e.jsx("input",{value:a.competitors||"",onChange:n=>W(a.id,"competitors",n.target.value),className:"bg-white border border-lfi-black/10 rounded px-1 py-0.5 text-lfi-black w-[140px]"})}),e.jsxs("td",{className:"py-1 px-1 whitespace-nowrap",children:[e.jsx("button",{onClick:()=>Z([a.id]),disabled:v!==null,title:a.last_error?`Last error: ${a.last_error}`:"Run this prompt",className:"inline-flex items-center justify-center w-6 h-6 rounded hover:bg-lfi-orange/20 text-lfi-orange disabled:opacity-30",children:v instanceof Set&&v.has(a.id)||v==="all"?e.jsx(re,{className:"w-3 h-3 animate-spin"}):e.jsx(ye,{className:"w-3 h-3"})}),a.last_response&&e.jsx("button",{onClick:()=>S(a.last_response),title:"View last AI response",className:"inline-flex items-center justify-center w-6 h-6 rounded hover:bg-lfi-paper text-lfi-gray ml-1",children:e.jsx(kt,{className:"w-3 h-3"})}),a.last_error&&e.jsx(Me,{className:"w-3 h-3 text-red-600 inline ml-1"})]})]},a.id))})]})})]}),e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-2xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-bold text-lfi-black",children:"Section 6 — Action Plan"}),e.jsxs(U,{size:"sm",onClick:Ye,className:"bg-lfi-orange hover:bg-lfi-emberDark text-lfi-black",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),"Add action"]})]}),e.jsxs("div",{className:"space-y-2",children:[(t.actions||[]).map((a,n)=>e.jsxs("div",{className:"grid grid-cols-[24px,1fr,140px,100px,140px,40p
50x] gap-2 items-center",children:[e.jsx("div",{className:"text-lfi-gray/60 text-sm",children:n+1}),e.jsx(X,{value:a.action,placeholder:"Action",onChange:l=>pe(a.id,"action",l.target.value),className:"bg-white border-lfi-black/10 text-lfi-black h-9 text-sm"}),e.jsx(X,{value:a.owner,placeholder:"Owner",onChange:l=>pe(a.id,"owner",l.target.value),className:"bg-white border-lfi-black/10 text-lfi-black h-9 text-sm"}),e.jsxs("select",{value:a.impact,onChange:l=>pe(a.id,"impact",l.target.value),className:"bg-white border border-lfi-black/10 rounded text-lfi-black h-9 px-2 text-sm",children:[e.jsx("option",{value:"High",className:"bg-lfi-cream",children:"High"}),e.jsx("option",{value:"Med",className:"bg-lfi-cream",children:"Med"}),e.jsx("option",{value:"Low",className:"bg-lfi-cream",children:"Low"})]}),e.jsx(X,{type:"date",value:a.due,onChange:l=>pe(a.id,"due",l.target.value),className:"bg-white border-lfi-black/10 text-lfi-black h-9 text-sm"}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>qe(a.id),className:"text-lfi-gray/60 hover:text-red-600 hover:bg-red-500/10 h-9 w-9 p-0",children:e.jsx(Le,{className:"w-3 h-3"})})]},a.id)),(t.actions||[]).length===0&&e.jsx("div",{className:"text-lfi-gray/60 text-sm text-center py-4",children:"No actions yet."})]})]}),e.jsxs("div",{className:"bg-white border border-lfi-black/10 rounded-2xl p-5",children:[e.jsx("h2",{className:"text-lg font-bold text-lfi-black mb-3",children:"Narrative for client report (3 sentences)"}),e.jsx(Pe,{value:t.narrative||"",onChange:a=>P({narrative:a.target.value}),placeholder:"Overall score + trend, biggest win this month, biggest gap and what we're doing about it.",className:"bg-white border-lfi-black/10 text-lfi-black min-h-[100px]"})]}),d&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm grid place-items-center p-6",onClick:()=>S(null),children:e.jsxs("div",{className:"bg-lfi-cream border border-lfi-orange/30 rounded-2xl p-6 max-w-3xl w-full max-h-[80vh] overflow-y-auto",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-bold text-lfi-black",children:"AI response"}),e.jsx("button",{onClick:()=>S(null),className:"text-lfi-gray/60 hover:text-lfi-black",children:"✕"})]}),e.jsx("pre",{className:"whitespace-pre-wrap text-sm text-lfi-black/85 font-sans",children:d})]})})]}):e.jsxs("div",{className:"flex items-center gap-2 text-lfi-gray",children:[e.jsx(re,{className:"w-4 h-4 animate-spin text-lfi-orange"}),"Loading…"]})}export{fa 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.