PageSourceSearch

https://analyticsindiamag.com/assets/ResearchDetail-tSxlauGp.js

js analyticsindiamag.com collected 2026-09-24 08:27:01 UTC 15,346 bytes, 2 lines download raw bytes

1import{ac as K,e as Q,r,u as V,z as X,a as Y,s as A,j as e,ah as w,m as o,L as p,F as k,B as a,o as d,H as Z,y as E,A as ee}from"./index-KSWbwNeY.js";import _ from"./Footer-DPSMpmUX.js";import{p as C}from"./purify.es--yiYCWnk.js";import{s as se}from"./sanitizeHTML-3eQ8Vumw.js";import{u as te}from"./useSocialEmbeds-B7QAt7bJ.js";import{_ as ae,a as re,D as ie,P as ne}from"./index-be_ejrxk.js";import{A as oe}from"./arrow-left-1kEvYP7w.js";import{D as U}from"./download-BtORIOsS.js";import{C as le}from"./calendar-Cdsbx2VF.js";import{B as O}from"./book-open-DS7Nmuzn.js";import{C as $}from"./chevron-left-C0OR5oyH.js";import{L as de}from"./lock-DNHSxtLD.js";import{f as ce}from"./format-hhvI2L0z.js";import{p as me}from"./parseISO-BHcD4hpi.js";import"./twitter-yEUqfNJX.js";import"./linkedin-B1bA0DJP.js";import"./youtube-CwivUiPT.js";import"./facebook-DahhNxAJ.js";import"./htmlDecoder-Cz23cfvH.js";import"./tiny-invariant-CopsF_GD.js";import"./en-US-BOoww7nS.js";ae.workerSrc=`//unpkg.com/pdfjs-dist@${re}/build/pdf.worker.min.mjs`;const Ae=()=>{const{slug:g}=K(),M=Q(),[s,T]=r.useState(null),[F,I]=r.useState(!0),[i,B]=r.useState(null),[j,L]=r.useState(!1),[x,R]=r.useState(!1),[n,W]=r.useState(0),[l,u]=r.useState(1),[H,G]=r.useState(360),S=r.useRef(null),P=r.useRef(null);te(P,[s==null?void 0:s.description,s==null?void 0:s.id]);const{user:b}=V(),{status:y,loading:q}=X(),{toast:N}=Y(),h=!!b&&((y==null?void 0:y.hasSubscription)||!!(s!=null&&s.is_free));r.useEffect(()=>{const t=S.current;if(!t)return;const c=new ResizeObserver(f=>{for(const m of f)G(m.contentRect.width-48)});return c.observe(t),()=>c.disconnect()},[i]),r.useEffect(()=>{g&&J()},[g]),r.useEffect(()=>{s&&h&&!i&&!j&&v()},[s,h,i,j]);const J=async()=>{try{const{data:t,error:c}=await A.from("research_reports").select("id, title, slug, description, cover_image_url, pdf_url, published_at, is_free").eq("slug",g).eq("is_published",!0).single();if(c)throw c;T(t)}catch(t){console.error("Error fetching research report:",t),N({variant:"destructive",title:"Report not found",description:"The requested research report could not be found."}),M("/research")}finally{I(!1)}},v=async()=>{if(s){L(!0);try{const t=await A.functions.invoke("get-research-pdf",{body:{reportId:s.id}});if(t.error)throw t.error;B(t.data.signedUrl)}catch(t){console.error("Error fetching PDF:",t),N({variant:"destructive",title:"Unable to load PDF",description:t.message||"Please try again later."})}finally{L(!1)}}},z=async()=>{if(!(!i||x)){R(!0);try{let t=await fetch(i);if(t.status===401||t.status===403){if(await v(),!i)throw new Error("Could not refresh download link");t=await fetch(i)}if(!t.ok)throw new Error(`Download failed (${t.status})`);const c=await t.blob(),f=URL.createObjectURL(c),m=document.createElement("a");m.href=f,m.download=s!=null&&s.title?`${s.title}.pdf`:"report.pdf",document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(f)}catch(t){console.error("Download error:",t),N({variant:"destructive",title:"Download failed",description:"Unable to download the report. Please try again."})}finally{R(!1)}}},D=t=>{try{return ce(me(t),"MMM dd, yyyy")}catch{return t}};return F||q?e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(w,{}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs(o.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"text-center",children:[e.jsx(p,{className:"h-8 w-8 animate-spin text-primary mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3 font-sans",children:"Loading report…"})]})}),e.jsx(_,{})]}):s?e.jsxs("div",{className:"min-h-screen flex flex-col",style:{background:"linear-gradient(135deg, hsl(210 40% 98%), hsl(200 30% 96%), hsl(180 20% 97%))"},children:[e.jsxs(Z,{children:[e.jsxs("title",{children:[s.title," | AIM Research"]}),e.jsx("meta",{name:"description",content:s.description?C.sanitize(s.description,{ALLOWED_TAGS:[]}).slice(0,160):`Research report: ${s.title}`}),e.jsx("link",{rel:"canonical",href:`https://analyticsindiamag.com/research/${s.slug}`}),e.jsx("meta",{property:"og:title",content:s.title}),e.jsx("meta",{property:"og:description",content:s.description?C.sanitize(s.description,{ALLOWED_TAGS:[]}).slice(0,160):`Research report: ${s.title}`}),e.jsx("meta",{property:"og:type",content:"article"}),e.jsx("meta",{property:"og:url",content:`https://analyticsindiamag.com/research/${s.slug}`}),s.cover_image_url&&e.jsx("meta",{property:"og:image",content:s.cover_image_url}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"Report",headline:s.title,de
1scription:s.description?C.sanitize(s.description,{ALLOWED_TAGS:[]}).slice(0,300):void 0,image:s.cover_image_url||void 0,datePublished:s.published_at,url:`https://analyticsindiamag.com/research/${s.slug}`,publisher:{"@type":"Organization",name:"AIM",logo:{"@type":"ImageObject",url:"https://analyticsindiamag.com/favicon.png"}},mainEntityOfPage:`https://analyticsindiamag.com/research/${s.slug}`})})]}),e.jsx(w,{}),e.jsxs("main",{className:"flex-1",children:[e.jsx(o.div,{initial:{y:-20,opacity:0},animate:{y:0,opacity:1},transition:{duration:.3},className:"sticky top-0 z-40 bg-background/80 backdrop-blur-xl border-b border-border/50",children:e.jsx("div",{className:"container mx-auto px-4 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"rounded-full h-8 px-3 text-xs shrink-0",children:e.jsxs(d,{to:"/research",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mr-1.5"}),"Back"]})}),e.jsxs("div",{className:"hidden sm:block min-w-0",children:[e.jsx("h1",{className:"font-light text-sm truncate font-sans",children:s.title}),e.jsx("p",{className:"text-[11px] text-muted-foreground font-sans font-light",children:D(s.published_at)})]})]}),h?e.jsxs(a,{variant:"outline",size:"sm",onClick:z,disabled:!i||x,className:"rounded-full h-8 px-4 text-xs gap-1.5 shrink-0",children:[x?e.jsx(p,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(U,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:x?"Downloading…":"Download"})]}):s.is_free&&!b?e.jsx(a,{size:"sm",asChild:!0,className:"rounded-full h-8 px-4 text-xs shrink-0",children:e.jsx(d,{to:`/auth?returnTo=${encodeURIComponent(`/research/${s.slug}`)}`,children:"Sign in to read"})}):e.jsx(a,{size:"sm",asChild:!0,className:"rounded-full h-8 px-4 text-xs shrink-0",children:e.jsx(d,{to:"/subscribe",children:"Subscribe"})})]})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6 md:py-10 max-w-5xl",children:[e.jsxs(o.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},transition:{duration:.5,ease:"easeOut"},className:"flex flex-col md:flex-row gap-6 md:gap-8 mb-8 md:mb-10",children:[e.jsxs("div",{className:"flex-1 md:w-2/3 min-w-0",children:[e.jsx("h2",{className:"text-2xl md:text-3xl lg:text-4xl font-light font-sans tracking-tight text-foreground leading-snug mb-3",children:s.title}),e.jsxs("div",{className:"flex items-center gap-3 mb-5 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(le,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs font-sans font-light",children:D(s.published_at)})]}),n>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-xs font-sans font-light",children:[n," pages"]})]}),s.is_free&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-medium bg-emerald-500/10 text-emerald-700 border border-emerald-500/20 font-sans",children:"Free"})]}),s.description&&e.jsx(o.div,{ref:P,initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.5,delay:.15},className:"prose prose-sm md:prose-base max-w-none font-sans font-light prose-headings:font-sans prose-headings:font-light prose-headings:tracking-tight prose-p:text-muted-foreground prose-p:leading-[1.8] prose-p:mb-5 prose-li:text-muted-foreground prose-li:leading-[1.8] prose-h2:text-lg prose-h3:text-base [&_p]:mb-5 [&_br+br]:hidden [&_iframe]:w-full [&_iframe]:rounded-lg [&_iframe]:my-4",dangerouslySetInnerHTML:{__html:se(s.description).replace(/<\/p>\s*<p/g,`</p>
2<p`)}})]}),s.cover_image_url&&e.jsx(o.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.6,delay:.1},className:"md:w-1/3 shrink-0",children:e.jsx("div",{className:"rounded-2xl overflow-hidden shadow-lg group sticky top-24",children:e.jsx("img",{src:s.cover_image_url,alt:s.title,className:"w-full object-cover transition-transform duration-700 group-hover:scale-[1.02]"})})})]}),e.jsx(o.div,{initial:{opacity:0,y:16}
2,animate:{opacity:1,y:0},transition:{duration:.5,delay:.25},children:h?e.jsx("div",{className:"rounded-2xl border border-border/50 overflow-hidden bg-muted/10 shadow-sm",children:j?e.jsx("div",{className:"flex items-center justify-center h-[60vh]",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"h-12 w-12 rounded-full border-2 border-muted mx-auto"}),e.jsx(p,{className:"h-12 w-12 animate-spin text-primary absolute inset-0 mx-auto"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-4 font-sans",children:"Preparing your report…"})]})}):i?e.jsxs("div",{children:[n>1&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border/50 bg-background/50 backdrop-blur-sm",children:[e.jsx(a,{variant:"ghost",size:"sm",onClick:()=>u(t=>Math.max(1,t-1)),disabled:l<=1,className:"rounded-full h-8 w-8 p-0",children:e.jsx($,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-foreground font-sans tabular-nums",children:l}),e.jsx("span",{className:"text-xs text-muted-foreground font-sans",children:"/"}),e.jsx("span",{className:"text-xs text-muted-foreground font-sans tabular-nums",children:n})]}),e.jsx(a,{variant:"ghost",size:"sm",onClick:()=>u(t=>Math.min(n,t+1)),disabled:l>=n,className:"rounded-full h-8 w-8 p-0",children:e.jsx(E,{className:"h-4 w-4"})})]}),e.jsx("div",{ref:S,className:"flex justify-center py-4 md:py-6 min-h-[60vh] bg-muted/20 overflow-hidden",children:e.jsx(ie,{file:i,onLoadSuccess:({numPages:t})=>W(t),loading:e.jsx("div",{className:"flex items-center justify-center h-[50vh]",children:e.jsx(p,{className:"h-8 w-8 animate-spin text-primary"})}),error:e.jsxs("div",{className:"flex flex-col items-center justify-center h-[40vh] gap-4",children:[e.jsx(k,{className:"h-10 w-10 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground font-sans",children:"Failed to load PDF"}),e.jsxs(a,{onClick:z,className:"rounded-full",size:"sm",children:[e.jsx(U,{className:"h-3.5 w-3.5 mr-1.5"}),"Download Instead"]})]}),children:e.jsx(ee,{mode:"wait",children:e.jsx(o.div,{initial:{opacity:0,x:10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:{duration:.2},children:e.jsx(ne,{pageNumber:l,width:Math.min(H,900),renderTextLayer:!0,renderAnnotationLayer:!0,className:"shadow-lg rounded-lg overflow-hidden"})},l)})})}),n>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 px-4 py-3 border-t border-border/50 bg-background/50 sm:hidden",children:[e.jsxs(a,{variant:"outline",size:"sm",onClick:()=>u(t=>Math.max(1,t-1)),disabled:l<=1,className:"rounded-full h-9 flex-1 text-xs",children:[e.jsx($,{className:"h-3.5 w-3.5 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-sans tabular-nums shrink-0",children:[l,"/",n]}),e.jsxs(a,{variant:"outline",size:"sm",onClick:()=>u(t=>Math.min(n,t+1)),disabled:l>=n,className:"rounded-full h-9 flex-1 text-xs",children:["Next",e.jsx(E,{className:"h-3.5 w-3.5 ml-1"})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-[40vh]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"h-10 w-10 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 font-sans",children:"Unable to load report"}),e.jsx(a,{onClick:v,className:"rounded-full",size:"sm",children:"Try Again"})]})})}):s.is_free&&!b?e.jsxs("div",{className:"relative rounded-2xl border border-border/50 bg-card overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-500/5 via-transparent to-primary/5"}),e.jsxs("div",{className:"relative p-8 md:p-12 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center h-14 w-14 rounded-2xl bg-emerald-500/10 mb-5",children:e.jsx(O,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold font-sans mb-2 tracking-tight",children:"Free to read"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-7 max-w-sm mx-auto font-sans leading-relaxed",children:"Sign in with a free account to read and download this report."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5 justify-center",children:[e.jsx(a,{asChild:!0,size:"lg",className:"rounded-full px-8 font-sans",children:e.jsx(d,{to:`/auth?returnTo=${encodeURIComponent(`/research/${s.slug}`)}`,children:"Sign in"})}),e.jsx(a,{variant:"ghost",asChild:!0,size:"lg",className:"rounded-full px-8 font-sans text-muted-foreground",children:e.jsx(d,{to:"/research",children:"Browse Reports"})})]})]})]}):e.jsxs("div",{className:"relative rounded-2xl border border-border/50 bg-card overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/5 via-trans
2parent to-accent/5"}),e.jsxs("div",{className:"relative p-8 md:p-12 text-center",children:[e.jsx(o.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},transition:{duration:.4,delay:.1},className:"inline-flex items-center justify-center h-14 w-14 rounded-2xl bg-muted/50 mb-5",children:e.jsx(de,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold font-sans mb-2 tracking-tight",children:"Subscribe to Access"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-7 max-w-sm mx-auto font-sans leading-relaxed",children:"Unlock this report and our complete research library with a subscription."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5 justify-center",children:[e.jsx(a,{asChild:!0,size:"lg",className:"rounded-full px-8 font-sans",children:e.jsx(d,{to:"/subscribe",children:"Subscribe Now"})}),e.jsx(a,{variant:"ghost",asChild:!0,size:"lg",className:"rounded-full px-8 font-sans text-muted-foreground",children:e.jsx(d,{to:"/research",children:"Browse Reports"})})]})]})]})})]})]}),e.jsx(_,{})]}):e.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[e.jsx(w,{}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs(o.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center",children:[e.jsx(k,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-semibold mb-4 font-sans",children:"Report Not Found"}),e.jsx(a,{asChild:!0,className:"rounded-full",children:e.jsx(d,{to:"/research",children:"Browse All Reports"})})]})}),e.jsx(_,{})]})};export{Ae 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.