PageSourceSearch

https://shopscopeai.com/assets/MarketComparisonPage-Djr3N8Fk.js

js shopscopeai.com collected 2026-10-02 01:43:42 UTC 8,249 bytes, 6 lines download raw bytes

1import{g as G,u as D,r as h,s as T,j as e,aA as H,aH as I,Y as K,_ as U,ai as W}from"./index-D3wDQTTC.js";import{M as Y}from"./PageSkeletons-DFi0DgoT.js";import{E as q}from"./ErrorState-C-QJtHrx.js";import{u as V,E as J}from"./use-shop-data-CD-rr_Bq.js";import{A as P}from"./AiReportCta-CY9knlib.js";import{u as O}from"./ShopReportContext-f3puVvTX.js";import{c as Q}from"./shop-stats-BEm1Z1hc.js";import{U as X}from"./users-CZbwAnK8.js";import"./skeleton-D-NMoZiY.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 Z=G("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]),ee={avg_seo_score:68,avg_price:22.8,avg_rating:4.5,personalization_percent:52,avg_favorites_per_listing:35};function me(){const{t}=D(),{stats:r,loading:w,retrying:S,error:$,retry:L}=V(),{row:x,report:p,generating:f,regenerate:R,startedAt:j,cancel:v}=O(r),[a,A]=h.useState(null),[C,F]=h.useState(!0);h.useEffect(()=>{let s=!1;return(async()=>{const{data:i}=await T.from("market_benchmarks").select("*").eq("category_key","all").maybeSingle();s||(A(i??null),F(!1))})(),()=>{s=!0}},[]);const b=async()=>{const s=await R();s!=null&&s.error&&W({title:t("marketPage.toast.generateReportFailed"),description:s.error,variant:"destructive"})};if(w)return e.jsxs(e.Fragment,{children:[e.jsx(H,{active:!0}),e.jsx(Y,{})]});if($)return e.jsx(q,{title:t("marketPage.error.title"),message:t("marketPage.error.message"),onRetry:L,retrying:S});if(!r.hasData)return e.jsx(J,{});const E=Q(r.currency),M=r.totalListings>0?r.totalFavorites/r.totalListings:0,n=!!a&&a.sample_shops>=3,l=s=>a&&a[s]!==null&&a[s]!==void 0?a[s]:ee[s],k=[{metric:t("marketPage.metrics.avgSeoScore"),yours:r.avgSeoScore,benchmark:l("avg_seo_score"),p25:a==null?void 0:a.p25_seo_score,p75:a==null?void 0:a.p75_seo_score},{metric:t("marketPage.metrics.avgPrice"),yours:r.avgPrice,benchmark:l("avg_price"),p25:a==null?void 0:a.p25_price,p75:a==null?void 0:a.p75_price,prefix:E},{metric:t("marketPage.metrics.reviewRating"),yours:r.avgRating,benchmark:l("avg_rating"),suffix:"★"},{metric:t("marketPage.metrics.personalizationPercent"),yours:r.personalizationPercent,benchmark:l("personalization_percent"),suffix:"%"},{metric:t("marketPage.metrics.favoritesPerListing"),yours:M,benchmark:l("avg_favorites_per_listing"),p25:a==null?void 0:a.p25_favorites_per_listing,p75:a==null?void 0:a.p75_favorites_per_listing}],c=k.filter(s=>s.yours!==null&&s.yours!==void 0),y=c.filter(s=>s.yours>=s.benchmark),o=c.length?Math.round(y.length/c.length*100):null,N=c.filter(s=>s.yours<s.benchmark&&s.benchmark>0).map(s=>({metric:s.metric,shortfall:Math.round((s.benchmark-s.yours)/s.benchmark*100),target:`${s.prefix??""}${s.benchmark%1!==0?s.benchmark.toFixed(1):s.benchmark}${s.suffix??""}`})).sort((s,i)=>i.shortfall-s.shortfall).slice(0,3);return e.jsxs("div",{className:"p-4 md:p-6 max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:t("marketPage.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("marketPage.subtitle")})]}),p&&e.jsx(P,{hasReport:!0,generating:f,onGenerate:b,generatedAt:x==null?void 0:x.generated_at,compact:!0,startedAt:j,onCancel:v})]}),e.jsxs("div",{className:`rounded-lg border px-4 py-3 text-xs flex items-start gap-2 ${n?"border-primary/30 bg-primary/5 text-foreground":"border-border bg-muted/20 text-muted-foreground"}`,children:[n?e.jsx(X,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-primary"}):e.jsx(I,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:C?t("marketPage.benchmarkStatus.loading"):n?e.jsx(e.Fragment,{children:t("marketPage.benchmarkStatus.live",{sampleShops:a.sample_shops,sampleListings:a.sample_listings.toLocaleString()})}):e.jsx(e.Fragment,{children:t("marketPage.benchmarkStatus.smallSample",{count:3})})})]}),o!==null&&e.jsxs("div",{className:"glass-card p-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-primary"})," ",t("marketPage.scorecard")]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["You meet or beat the benchmark on ",y.length," of ",c.length," metrics."]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:`text-3xl font-bold ${o>=60?"text-success":"text-destructive"}`,children:o}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"/100"})]})]}),e.jsx("div",{className:"mt-3 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${o>=60?"bg-primary":"bg-destructive/70"}`,style:{width:`${o}%`}})}),N.length>0&&e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsx("p",{className:"text-xs font-medium",children:t("marketPage.biggestGaps")}),N.map(s=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-destructive/70 flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:s.metric}),e.jsxs("span",{className:"text-muted-foreground",children:[s.shortfall,"% below benchmark — aim for ",s.target]})]},s.metric))]})]}),p?e.jsxs("div",{className:"glass-card p-5 border-l-4 border-l-primary",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(K,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"font-semibold text-sm",children:t("marketPage.aiReportSummary.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:p.marketComparisonSummary})]}):e.jsx(P,{hasReport:!1,generating:f,onGenerate:b,startedAt:j,onCancel:v}),e.jsxs("div",{className:"glass-card p-5",children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-2 mb-6",children:[e.jsx(U,{className:"w-4 h-4 text-primary"})," ",t("marketPage.chartTitle",{benchmarkSource:t(n?"marketPage.benchmarkSource.shops":"marketPage.benchmarkSource.etsy")})]}),e.jsx("div",{className:"space-y-6",children:k.map(s=>{const i=s.yours,m=s.benchmark;if(i==null)return e.jsx("div",{children:e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:s.metric}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t("marketPage.noData")})]})},s.metric);const u=i>=m,_=Math.max(i,m,s.p75??0)*1.2||1,B=i/_*100,z=m/_*100,d=g=>`${s.prefix??""}${g%1!==0?g.toFixed(1):g}${s.suffix??""}`;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.metric}),e.jsx("span",{className:`text-xs font-medium ${u?"text-success":"text-destructive"}`,children:t(u?"marketPage.status.aboveBenchmark":"marketPage.status.belowBenchmark")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground w-16",children:t("marketPage.label.you")}),e.jsx("div",{className:"flex-1 h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${u?"bg-primary":"bg-destructive/70"}`,style:{width:`${B}%`}})}),e.jsx("span",{className:"text-xs font-medium w-16 text-right",children:d(i)})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground w-16",children:t(n?"marketPage.label.benchmark":"marketPage.label.etsyAvg")}),e.jsx("div",{className:"flex-1 h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-muted-foreground
6/30",style:{width:`${z}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground w-16 text-right",children:d(m)})]}),n&&s.p25!==null&&s.p25!==void 0&&s.p75!==null&&s.p75!==void 0&&e.jsx("p",{className:"text-[10px] text-muted-foreground pl-[76px]",children:t("marketPage.typicalRange",{p25:d(s.p25),p75:d(s.p75)})})]})]},s.metric)})})]})]})}export{me 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.