import{j as e}from"./query-vendor-CZu0EHPe.js";import{r as l,j as Je}from"./react-vendor-0bvDbF03.js";import{c as Xe,u as Ye,a as Ee,s as V,b as I,m as ne,d as Qe,C as Ze,A as et,e as tt,f as st,g as se,h as ke,i as ae,j as at,k as Le,B as rt,G as nt,S as lt,W as ot,X as it}from"./index-DEpNou_V.js";import{S as Me,D as ct,a as dt,b as mt,c as ut}from"./StoryDetailModal-ZJoeOqED.js";import{S as Ae,m as ht}from"./slider-CY1Hlgsw.js";import{S as Fe,g as ft,a as xt}from"./sesl-badge-utils-BvAx6z8X.js";import{C as gt}from"./chevron-left-EWjkKM88.js";import{I as pt}from"./input-BSL1lW-a.js";import{C as _e,a as Ie,b as Re}from"./collapsible-DAjtmWxP.js";import{u as bt}from"./use-mobile-BN2Z-RJr.js";import{B as vt}from"./BreadcrumbNavigation-Bg8Iidj6.js";import{S as C}from"./skeleton-QFJGP4Cz.js";import{u as Pe}from"./i18n-vendor-Bg2yf_Zw.js";import{B as jt}from"./bookmark-CLGT7blh.js";import{S as wt}from"./search-gqQGlNPa.js";import{R as St}from"./rotate-ccw-B4gEu7tY.js";import"./supabase-vendor-CNV44oIa.js";import"./helmet-vendor-NlTFkN97.js";import"./card-BSpjaxcF.js";import"./AnimatedStoryCard-Cvk8YMPU.js";import"./book-check-BdVj-jy5.js";import"./clock-C3i5wTfF.js";import"./file-text-DikHwwi9.js";import"./index-gBos023E.js";/**
 * @license lucide-react v0.554.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Nt=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Ct=Xe("sliders-horizontal",Nt),yt=()=>{const[r,i]=l.useState(new Set),[p,d]=l.useState(!0),{user:u}=Ye(),{toast:S}=Ee(),x=!!u;l.useEffect(()=>{(async()=>{if(!x||!u){i(new Set),d(!1);return}try{const{data:g,error:n}=await V.from("reading_cart").select("story_id").eq("user_id",u.id);if(n)throw n;const w=new Set(g?.map(m=>m.story_id)||[]);i(w)}catch(g){console.error("Error fetching reading cart:",g),S({title:"Error",description:"Failed to load reading cart items.",variant:"destructive"})}finally{d(!1)}})()},[x,u,S]);const y=(o,g)=>{i(n=>{const w=new Set(n);return g?w.add(o):w.delete(o),w})},c=o=>r.has(o),b=r.size;return{isStoryInCart:c,updateCartState:y,isLoading:p,cartCount:b}},Te=({className:r,...i})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:I("mx-auto flex w-full justify-center",r),...i});Te.displayName="Pagination";const De=l.forwardRef(({className:r,...i},p)=>e.jsx("ul",{ref:p,className:I("flex flex-row items-center gap-1",r),...i}));De.displayName="PaginationContent";const z=l.forwardRef(({className:r,...i},p)=>e.jsx("li",{ref:p,className:I("",r),...i}));z.displayName="PaginationItem";const q=({className:r,isActive:i,size:p="pillIcon",disabled:d,...u})=>e.jsx(ne.a,{"aria-current":i?"page":void 0,"aria-disabled":d||void 0,tabIndex:d?-1:void 0,whileHover:d?void 0:{scale:1.05},whileTap:d?void 0:{scale:.95},transition:{type:"spring",stiffness:400,damping:20},className:I(Qe({variant:i?"primary":"ghost",size:p}),"text-sm font-semibold cursor-pointer",i?"shadow-md":"text-ink border border-nature-forest/25 bg-white/70 hover:bg-nature-honey/40 hover:border-nature-forest/50",d&&"opacity-50 pointer-events-none",r),...u});q.displayName="PaginationLink";const Be=({className:r,...i})=>e.jsx(q,{"aria-label":"Go to previous page",size:"pillIcon",className:I(r),...i,children:e.jsx(gt,{className:"h-4 w-4"})});Be.displayName="PaginationPrevious";const Oe=({className:r,...i})=>e.jsx(q,{"aria-label":"Go to next page",size:"pillIcon",className:I(r),...i,children:e.jsx(Ze,{className:"h-4 w-4"})});Oe.displayName="PaginationNext";const kt=()=>e.jsxs("div",{className:"h-full rounded-lg overflow-hidden bg-white shadow-md",children:[e.jsx(C,{className:"h-48 w-full"}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(C,{className:"h-6 w-16"}),e.jsx(C,{className:"h-6 w-20"})]}),e.jsx(C,{className:"h-6 w-3/4 mb-2"}),e.jsx(C,{className:"h-4 w-full mb-2"}),e.jsx(C,{className:"h-4 w-2/3"})]}),e.jsxs("div",{className:"p-4 pt-0 flex gap-2",children:[e.jsx(C,{className:"h-5 w-12"}),e.jsx(C,{className:"h-5 w-16"}),e.jsx(C,{className:"h-5 w-14"})]})]}),Lt=(r,i,p)=>{const d=(c,b)=>{const o=new Date(c.createdAt||0).getTime();return new Date(b.createdAt||0).getTime()-o},u=c=>p.includes(c);if(i==="paid"||i==="admin"){const c=r.filter(o=>!u(o.id)).sort(d),b=r.filter(o=>u(o.id)).sort(d);return[...c,...b]}if(i==="free"){const c=r.filter(n=>n.accessLevel==="free"&&!u(n.id)).sort(d),b=r.filter(n=>n.accessLevel==="guest"&&!u(n.id)).sort(d),o=r.filter(n=>(n.accessLevel==="free"||n.accessLevel==="guest")&&u(n.id)).sort(d),g=r.filter(n=>n.accessLevel==="paid").sort(d);return[...c,...b,...o,...g]}const S=r.filter(c=>c.accessLevel==="guest").sort(d),x=r.filter(c=>c.accessLevel==="free").sort(d),y=r.filter(c=>c.accessLevel==="paid").sort(d);return[...S,...x,...y]},At=({stories:r,readStoryIds:i,isStoryInCart:p,updateCartState:d,getLocalizedPath:u,canAccessStory:S,isAuthenticated:x,visible:y,onOpenDetails:c})=>{const{t:b}=Pe("stories"),[o,g]=l.useState(!1),n=l.useMemo(()=>[...r].sort((m,N)=>{const h=m.createdAt?new Date(m.createdAt).getTime():0;return(N.createdAt?new Date(N.createdAt).getTime():0)-h}).slice(0,8),[r]);if(n.length===0)return null;const w=[...n,...n];return e.jsx(et,{initial:!1,children:y&&e.jsxs(ne.section,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.28,ease:"easeOut"},className:"mb-8 overflow-hidden","aria-label":b("badge.new",{defaultValue:"New!"}),children:[e.jsx("div",{className:"flex items-center mb-3 px-1",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-nature-coral text-white font-semibold text-sm px-3 py-1 rounded-full",children:[e.jsx(jt,{className:"h-4 w-4"}),b("badge.new",{defaultValue:"New!"})]})}),e.jsx("div",{className:"newest-rail-mask relative",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),onTouchStart:()=>g(!0),onTouchEnd:()=>g(!1),children:e.jsx("div",{className:`newest-rail-track flex gap-4 w-max ${o?"is-paused":""}`,children:w.map((m,N)=>e.jsx("div",{className:"w-[170px] sm:w-[190px] md:w-[210px] flex-shrink-0","aria-hidden":N>=n.length?"true":void 0,children:e.jsx(Me,{story:m,isMarkedAsRead:i.includes(String(m.id)),isInCart:p(m.id),onCartChange:d,index:N%n.length,getLocalizedPath:u,hasAccess:S(m.accessLevel||"paid"),isAuthenticated:x,onOpenDetails:c})},`${m.id}-${N}`))})})]},"newest-rail")})},re={backgroundColor:"color-mix(in srgb, var(--nature-forest) 10%, white)",borderColor:"color-mix(in srgb, var(--nature-forest) 30%, transparent)"},P=({children:r,onRemove:i})=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border text-nature-forest pl-3 pr-1.5 py-1 text-xs font-medium",style:re,children:[r,e.jsx("button",{onClick:i,"aria-label":"Remove filter",className:"rounded-full p-0.5 text-nature-forest hover:opacity-70",children:e.jsx(it,{className:"h-3 w-3"})})]}),Zt=()=>{const[r,i]=l.useState([]),[p,d]=l.useState(!0),[u,S]=Je(),[x,y]=l.useState(u.get("search")||""),[c,b]=l.useState(u.get("age")||"all"),[o,g]=l.useState(u.get("level")||"all"),[n,w]=l.useState(()=>u.get("theme")?.split(",").filter(Boolean)||[]),[m,N]=l.useState(u.get("sesl")||"all"),[h,T]=l.useState([0,600]),[v,G]=l.useState([0,1e3]),[D,le]=l.useState(!1),[W,$e]=l.useState(!1),[oe,Ke]=l.useState(!1),{t:a}=Pe("stories"),{getLocalizedPath:B}=tt(),ie=()=>{y(""),b("all"),g("all"),w([]),N("all"),T([0,600]),G([0,1e3])},{toast:H}=Ee(),{canAccessStory:U,isAuthenticated:R,userType:ce}=st(),J=ce==="admin",Ve=bt(),{isStoryInCart:X,updateCartState:Y}=yt(),[O,de]=l.useState([]),[k,me]=l.useState(1),[F,Q]=l.useState(null),Z=20,ue=l.useRef(null),E=[{label:a("theme.all"),value:"all"},{label:a("theme.adventure_curiosity"),value:"Adventure & Curiosity"},{label:a("theme.anger_frustration"),value:"Anger & Frustration"},{label:a("theme.confidence_determination"),value:"Confidence & Determination"},{label:a("theme.fear_courage"),value:"Fear & Courage"},{label:a("theme.friendship_teamwork"),value:"Friendship & Teamwork"},{label:a("theme.fun_wit"),value:"Fun & Wit"},{label:a("theme.jealousy_appreciation"),value:"Jealousy & Appreciation"},{label:a("theme.kindness_empathy"),value:"Kindness & Empathy"},{label:a("theme.magic_wonder"),value:"Magic & Wonder"},{label:a("theme.nature_animals"),value:"Nature & Animals"},{label:a("theme.problem_solution"),value:"Problem & Solution"},{label:a("theme.sadness_loss"),value:"Sadness & Loss"}],M=l.useCallback(async()=>{console.log("fetchReadStories running, isAuthenticated:",R);try{const{data:t}=await V.auth.getSession(),s=t.session?.user;if(console.log("User session in fetchReadStories:",s?s.id:"No user"),!s){console.log("No user found, clearing read story IDs"),de([]);return}const{data:f,error:L}=await V.from("story_completions").select("story_id").eq("user_id",s.id).eq("mark_as_read",!0);if(L){console.error("Error fetching read stories:",L);return}if(f){console.log("Raw read stories data:",f);const A=f.map(_=>String(_.story_id));console.log("Processed read story IDs:",A),de(A)}}catch(t){console.error("Error fetching read stories:",t)}},[R]);l.useEffect(()=>{(async()=>{d(!0);try{console.log("Fetching stories using security definer function for listing...");const{data:s,error:f}=await V.rpc("get_stories_for_listing");if(f){console.error("Error fetching stories:",f),H({title:a("toast.loadError"),description:a("toast.loadErrorDescription"),variant:"destructive"});return}if(console.log("Raw Supabase data:",s),s){const L=s.map(A=>{const _=A.access_level;return ht({...A,text:"",audio_url:"",word_timestamps:[],access_level:_||"paid"})});console.log("Mapped stories:",L),i(L)}}catch(s){console.error("Error in fetchStories:",s),H({title:a("toast.loadError"),description:a("toast.loadErrorDescription"),variant:"destructive"})}finally{d(!1)}})()},[H]),l.useEffect(()=>{M()},[M]),l.useEffect(()=>{const t=()=>{document.hidden||(console.log("Page became visible, refreshing read stories..."),M())},s=()=>{console.log("Window focused, refreshing read stories..."),M()};return document.addEventListener("visibilitychange",t),window.addEventListener("focus",s),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("focus",s)}},[M]),l.useEffect(()=>{const t=new URLSearchParams;x&&t.set("search",x),c&&c!=="all"&&t.set("age",c),o&&o!=="all"&&t.set("level",o),n.length>0&&t.set("theme",n.join(",")),m&&m!=="all"&&t.set("sesl",m),S(t),me(1)},[x,c,o,n,m,S]);const ze=r.filter(t=>{console.log("Filtering story:",t.title,{searchTerm:x,ageFilter:c,levelFilter:o,themeFilter:n,seslFilter:m,story:{ageRange:t.ageRange,cefrLevel:t.cefrLevel,theme:t.theme,duration:t.duration,wordCount:t.wordCount,seslScore:t.seslScore}});const s=!x||t.title.toLowerCase().includes(x.toLowerCase())||t.description.toLowerCase().includes(x.toLowerCase()),f=c==="all"||se(t.cefrLevel)===c,L=o==="all"||t.cefrLevel===o,A=n.length===0||Array.isArray(t.theme)&&n.every(j=>t.theme.some(Ue=>Ue.toLowerCase()===j.toLowerCase())),_=m==="all"||(()=>{if(t.seslScore===void 0||t.seslScore===null)return!1;const j=t.seslScore;switch(m){case"very_easy":return j>=0&&j<=250;case"easy":return j>=251&&j<=450;case"medium":return j>=451&&j<=650;case"hard":return j>=651&&j<=800;case"very_hard":return j>=801&&j<=1e3;default:return!0}})(),Ne=t.duration>=h[0]&&t.duration<=h[1],Ce=t.wordCount>=v[0]&&t.wordCount<=v[1],ye=s&&f&&L&&A&&_&&Ne&&Ce;return console.log("Story matches filters:",ye,{searchMatch:s,ageMatch:f,levelMatch:L,themeMatch:A,seslMatch:_,durationMatch:Ne,wordCountMatch:Ce}),ye}),$=Lt(ze,ce,O);console.log("Sorted stories count:",$.length);const he=(k-1)*Z,qe=he+Z,fe=$.slice(he,qe),K=Math.ceil($.length/Z),xe=x.trim()!==""||c!=="all"||o!=="all"||n.length>0||m!=="all"||h[0]!==0||h[1]!==600||v[0]!==0||v[1]!==1e3,Ge=l.useMemo(()=>{const t={};return r.forEach(s=>{s.cefrLevel&&(t[s.cefrLevel]=(t[s.cefrLevel]||0)+1)}),t},[r]),We=l.useMemo(()=>{const t={};return Fe.forEach(s=>{t[s.labelKey]=0}),r.forEach(s=>{if(s.seslScore==null)return;const f=ft(s.seslScore);t[f]=(t[f]||0)+1}),t},[r]),ge=[o!=="all",n.length>0,m!=="all",h[0]!==0||h[1]!==600,v[0]!==0||v[1]!==1e3].filter(Boolean).length,He=t=>{y(t.target.value)},pe=t=>{if(g(t),t==="all")b("all");else{const s=se(t);s&&s!=="Unknown"&&b(s)}},ee=t=>{w(s=>s.includes(t)?s.filter(f=>f!==t):[...s,t])},be=t=>{N(t)},te=t=>{me(t),setTimeout(()=>{ue.current?.scrollIntoView({behavior:"smooth",block:"start"})},50)},ve=e.jsxs("div",{className:"relative flex-1",children:[e.jsx(wt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground","aria-hidden":"true"}),e.jsx(pt,{id:"search",type:"text","aria-label":a("search.label"),placeholder:a("search.placeholder"),value:x,onChange:He,className:"pl-9 focus-visible:border-nature-forest focus-visible:ring-nature-forest"})]}),je=t=>e.jsxs("button",{className:"flex items-center gap-2 whitespace-nowrap rounded-full bg-white/70 px-4 h-10 text-sm font-semibold text-nature-forest transition-colors hover:bg-nature-forest hover:text-white",style:{border:"1px solid color-mix(in srgb, var(--nature-forest) 25%, transparent)"},"aria-expanded":D,children:[e.jsx(Ct,{className:"h-4 w-4","aria-hidden":"true"}),a("filters.label"),ge>0&&e.jsx("span",{className:"bg-nature-coral text-white rounded-full text-[11px] font-bold leading-none px-1.5 py-1",children:ge}),t&&e.jsx(Le,{className:`h-4 w-4 transition-transform duration-300 ${D?"rotate-180":""}`,"aria-hidden":"true"})]}),we=xe&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[o!=="all"&&e.jsxs(P,{onRemove:()=>pe("all"),children:[ke[o]?.shortLabel," · ",se(o)," ",a("age.years")]}),m!=="all"&&e.jsx(P,{onRemove:()=>be("all"),children:a(`sesl.difficulty.${m}`)}),n.map(t=>e.jsx(P,{onRemove:()=>ee(t),children:E.find(s=>s.value===t)?.label},t)),(h[0]!==0||h[1]!==600)&&e.jsxs(P,{onRemove:()=>T([0,600]),children:[a("duration.label"),": ",Math.floor(h[0]/60),":",(h[0]%60).toString().padStart(2,"0")," – ",Math.floor(h[1]/60),":",(h[1]%60).toString().padStart(2,"0")]}),(v[0]!==0||v[1]!==1e3)&&e.jsxs(P,{onRemove:()=>G([0,1e3]),children:[v[0],"–",v[1]," ",a("wordCount.words")]}),e.jsx("button",{onClick:ie,className:"text-xs text-muted-foreground hover:text-nature-forest underline underline-offset-2 px-1",children:a("filters.clearAll")})]}),Se=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("p",{className:"text-sm font-semibold text-ink",children:a("sesl.filterLabel")}),e.jsx("a",{href:B("/research"),target:"_blank",rel:"noopener noreferrer",className:"text-xs text-nature-forest hover:underline",children:a("readMore")})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Fe.map(t=>{const s=m===t.labelKey;return e.jsxs("button",{onClick:()=>be(s?"all":t.labelKey),className:`flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-semibold transition-all ${xt(t.labelKey)} ${s?"!border-2 !border-ink":""}`,children:[e.jsx("span",{children:a(`sesl.difficulty.${t.labelKey}`)}),J&&e.jsx("span",{className:"text-[10px] font-normal opacity-80",children:We[t.labelKey]||0}),s&&e.jsx(ae,{className:"h-3 w-3","aria-hidden":"true"})]},t.labelKey)})}),e.jsx("hr",{className:"my-5",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 10%, transparent)"}}),e.jsx("p",{className:"text-sm font-semibold text-ink mb-3",children:a("level.label")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:at.map(t=>{const s=ke[t],f=o===t;return e.jsxs("button",{onClick:()=>pe(f?"all":t),className:`flex flex-col items-center rounded-2xl border px-3 py-2 min-w-[84px] text-xs font-semibold transition-all ${f?"border-2 border-nature-forest bg-nature-forest/10 text-nature-forest":"border-border text-ink bg-white hover:border-nature-forest/40"}`,children:[e.jsxs("span",{children:[s.shortLabel," · ",s.ageBand," ",a("age.years")]}),J&&e.jsx("span",{className:"text-[10px] font-normal opacity-80 mt-0.5",children:Ge[t]||0})]},t)})}),e.jsx("hr",{className:"my-5",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 10%, transparent)"}}),e.jsx("p",{className:"text-sm font-semibold text-ink mb-3",children:a("theme.label")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:E.filter(t=>t.value!=="all").slice(0,6).map(t=>{const s=n.includes(t.value);return e.jsxs("button",{onClick:()=>ee(t.value),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition-all ${s?"text-nature-forest font-semibold":"border-border text-muted-foreground bg-transparent hover:border-nature-forest"}`,style:s?re:void 0,children:[t.label,s&&e.jsx(ae,{className:"h-3 w-3","aria-hidden":"true"})]},t.value)})}),E.filter(t=>t.value!=="all").length>6&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`flex flex-wrap gap-2 mt-2 ${W?"":"hidden"}`,children:E.filter(t=>t.value!=="all").slice(6).map(t=>{const s=n.includes(t.value);return e.jsxs("button",{onClick:()=>ee(t.value),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs font-medium transition-all ${s?"text-nature-forest font-semibold":"border-border text-muted-foreground bg-transparent hover:border-nature-forest"}`,style:s?re:void 0,children:[t.label,s&&e.jsx(ae,{className:"h-3 w-3","aria-hidden":"true"})]},t.value)})}),e.jsx("button",{onClick:()=>$e(!W),className:"text-xs font-semibold text-nature-forest hover:underline mt-2",children:W?a("filters.fewerThemes"):a("filters.moreThemes",{count:E.filter(t=>t.value!=="all").length-6})})]}),e.jsx("hr",{className:"my-5",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 10%, transparent)"}}),e.jsxs(_e,{open:oe,onOpenChange:Ke,children:[e.jsx(Ie,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-semibold text-ink",children:[e.jsx(Le,{className:`h-4 w-4 transition-transform duration-300 ${oe?"rotate-180":""}`,"aria-hidden":"true"}),a("filters.more")]})}),e.jsx(Re,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mt-4",children:[e.jsxs("div",{"data-vaul-no-drag":"",children:[e.jsxs("label",{className:"text-sm font-medium text-muted-foreground mb-2 block",children:[a("duration.label"),": ",Math.floor(h[0]/60),":",(h[0]%60).toString().padStart(2,"0")," – ",Math.floor(h[1]/60),":",(h[1]%60).toString().padStart(2,"0")]}),e.jsx(Ae,{value:h,onValueChange:T,max:600,min:0,step:30,className:"w-full",trackClassName:"bg-nature-forest/5 border border-nature-forest/25",rangeClassName:"bg-nature-forest",thumbClassName:"border-nature-forest"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{children:["0 ",a("duration.minutes")]}),e.jsxs("span",{children:["10 ",a("duration.minutes")]})]})]}),e.jsxs("div",{"data-vaul-no-drag":"",children:[e.jsxs("label",{className:"text-sm font-medium text-muted-foreground mb-2 block",children:[a("wordCount.label"),": ",v[0]," – ",v[1]]}),e.jsx(Ae,{value:v,onValueChange:G,max:1e3,min:0,step:50,className:"w-full",trackClassName:"bg-nature-forest/5 border border-nature-forest/25",rangeClassName:"bg-nature-forest",thumbClassName:"border-nature-forest"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mt-1",children:[e.jsxs("span",{children:["0 ",a("wordCount.words")]}),e.jsxs("span",{children:["1000 ",a("wordCount.words")]})]})]})]})})]}),e.jsx("div",{className:"flex justify-end pt-4 mt-1 border-t",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 10%, transparent)"},children:e.jsxs(rt,{onClick:ie,variant:"outline",className:"rounded-full text-nature-forest hover:bg-nature-forest hover:text-white",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 25%, transparent)"},children:[e.jsx(St,{className:"h-4 w-4 mr-2"}),a("filters.resetAll")]})})]});return e.jsxs(e.Fragment,{children:[e.jsx(nt,{}),e.jsx(lt,{title:a("meta.title"),description:a("meta.description"),keywords:a("meta.keywords",{defaultValue:""})||void 0,canonical:"/stories"}),e.jsx("div",{className:"min-h-screen bg-page-surface",children:e.jsxs("div",{className:"container pt-4 pb-6 md:pt-6 md:pb-8",children:[e.jsx(vt,{}),e.jsx("div",{className:"mb-12",children:e.jsxs("div",{className:"flex flex-col lg:flex-row items-center justify-center gap-3 md:gap-6 lg:gap-8",children:[e.jsx("div",{className:"w-32 h-32 lg:w-44 lg:h-44 flex-shrink-0",children:e.jsx(ne.div,{animate:{y:[0,-8,0]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:e.jsx("img",{src:"https://cdn.storysparkle.org/ui_elements/Hero%20Icons/StoryLibrary.webp",alt:"Story Library",className:"w-full h-full object-contain drop-shadow-2xl"})})}),e.jsxs("div",{className:"flex flex-col items-center lg:items-start text-center lg:text-left",children:[e.jsx("h1",{className:"text-[22px] lg:text-[32px] font-bold mb-4 text-ink",children:a("header.title")}),e.jsx("p",{className:"text-sm lg:text-xl text-nature-forest inline-block",children:a("header.subtitle")}),e.jsx(ot,{slug:"choose-the-right-reading-level",className:"mt-3"})]})]})}),!p&&e.jsx(At,{stories:r,readStoryIds:O,isStoryInCart:X,updateCartState:Y,getLocalizedPath:B,canAccessStory:t=>U(t),isAuthenticated:R,visible:!xe,onOpenDetails:Q}),Ve?e.jsxs(ct,{open:D,onOpenChange:le,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-3",children:[ve,e.jsx(dt,{asChild:!0,children:je(!1)})]}),we,e.jsx(mt,{className:"max-h-[85vh] bg-page-surface",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 10%, transparent)"},children:e.jsx("div",{className:"overflow-y-auto px-5 pb-8 pt-1",children:Se})})]}):e.jsxs(_e,{open:D,onOpenChange:le,className:"mb-8",children:[e.jsxs("div",{className:"flex gap-2 items-center mb-3",children:[ve,e.jsx(Ie,{asChild:!0,children:je(!0)})]}),we,e.jsx(Re,{children:e.jsx("div",{className:"page-card p-6 mb-8",children:Se})})]}),J&&e.jsx("div",{className:"mb-6",children:e.jsxs("h2",{className:"text-2xl font-semibold text-ink",children:[$.length," Stories Found"]})}),e.jsx("div",{ref:ue,className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4 md:gap-5",children:p?Array.from({length:8}).map((t,s)=>e.jsx(kt,{},s)):fe.length>0?fe.map((t,s)=>e.jsx(Me,{story:t,isMarkedAsRead:O.includes(String(t.id)),isInCart:X(t.id),onCartChange:Y,index:s,getLocalizedPath:B,hasAccess:U(t.accessLevel||"paid"),isAuthenticated:R,onOpenDetails:Q},t.id)):e.jsxs("div",{className:"col-span-2 sm:col-span-3 lg:col-span-4 xl:col-span-5 text-center py-8",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-500",children:a("error.noStoriesTitle")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:a("error.noStoriesDescription")})]})}),K>1&&e.jsx(Te,{className:"mt-8",children:e.jsxs(De,{children:[e.jsx(z,{children:e.jsx(Be,{onClick:()=>k>1&&te(k-1),disabled:k===1})}),Array.from({length:K},(t,s)=>s+1).map(t=>e.jsx(z,{children:e.jsx(q,{isActive:k===t,onClick:()=>te(t),children:t})},t)),e.jsx(z,{children:e.jsx(Oe,{onClick:()=>k<K&&te(k+1),disabled:k===K})})]})})]})}),e.jsx(ut,{story:F,onClose:()=>Q(null),getLocalizedPath:B,hasAccess:F?U(F.accessLevel||"paid"):!0,isAuthenticated:R,isInCart:F?X(F.id):!1,onCartChange:Y,isMarkedAsRead:F?O.includes(String(F.id)):!1})]})};export{Zt as default};