import{j as r}from"./query-vendor-CZu0EHPe.js";import{C as Ht,b as Ut}from"./card-Cs7m8OeN.js";import{c as Ft,e as Ze,o as Qe,a as zt,u as Vt,f as Wt,I as Yt,s as Ce,m as we,M as V,g as et,O as tt,P as nt,Q as qt,V as Xt,W as Kt,Y as Gt,Z as Jt,_ as Zt,$ as Qt,a0 as en,b as ye,X as tn,H as nn}from"./index-G5OOgpXV.js";import{A as rn}from"./AnimatedStoryCard-D7FhLUbe.js";import{a as rt,g as xe}from"./sesl-badge-utils-BvAx6z8X.js";import{u as Se}from"./i18n-vendor-Cl4-lKeC.js";import{r as K,u as Le,R as o}from"./react-vendor-0bvDbF03.js";import{B as at}from"./book-check-C_l6w8kD.js";import{B as it}from"./bookmark-DTEIyee_.js";import{D as an,a as on,b as sn,c as ln,d as cn}from"./dialog-ItiV5Cma.js";import{U as un}from"./UpgradeButton-BDqxMXnI.js";import{B as dn}from"./book-marked-CxaCAkd-.js";import{C as fn}from"./clock-BCImfdtP.js";import{F as mn}from"./file-text-DB-vdx80.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 pn=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],ot=Ft("gift",pn),hn=({className:e="",onClick:n})=>{const{getLocalizedPath:t}=Ze(),{t:a}=Se("reading-cart");return r.jsx(Qe,{variant:"primary",to:t("/reading-cart"),onClick:n,leftIcon:r.jsx(dn,{}),className:e,children:a("checkCartButton")})},st=({storyId:e,isInCart:n,onCartChange:t,className:a=""})=>{const[s,i]=K.useState(!1),[d,c]=K.useState(!1),{toast:m}=zt(),{t:b}=Se("reading-cart"),{user:h}=Vt(),g=Le(),{getLocalizedPath:p}=Ze(),{userType:O}=Wt(),$=!!h,D=O==="free"||O==="guest",L=async S=>{if(S.preventDefault(),S.stopPropagation(),!$){g(p("/login"));return}i(!0);try{if(n){const{error:y}=await Ce.from("reading_cart").delete().eq("user_id",h?.id).eq("story_id",e);if(y)throw y;t(e,!1)}else{if(D&&h){const{count:u,error:M}=await Ce.from("reading_cart").select("id",{count:"exact",head:!0}).eq("user_id",h.id);if(M)throw M;if((u??0)>=3){c(!0);return}}const{error:y}=await Ce.from("reading_cart").insert({user_id:h?.id,story_id:e});if(y)throw y;t(e,!0)}}catch(y){console.error("Error updating reading cart:",y),m({title:b("toast.error"),description:b("toast.errorDescription"),variant:"destructive"})}finally{i(!1)}},w=`h-5 w-5 transition-colors ${n?"text-red-500 hover:text-red-600":"text-gray-600 hover:text-red-500"} ${s?"animate-pulse":""}`;return r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:L,disabled:s,className:`p-2 rounded-full bg-white/80 backdrop-blur-sm hover:bg-white/90 transition-all duration-200 hover:scale-110 ${a}`,title:n?"Remove from Reading Cart":"Add to Reading Cart",children:r.jsx(Yt,{className:w,fill:n?"currentColor":"none"})}),r.jsx(an,{open:d,onOpenChange:c,children:r.jsxs(on,{className:"sm:max-w-xl",onClick:S=>S.stopPropagation(),onPointerDown:S=>S.stopPropagation(),children:[r.jsxs(sn,{children:[r.jsx(ln,{children:b("cartLimitTitle")}),r.jsx(cn,{children:b("cartLimitReached")})]}),r.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 pt-4",children:[r.jsx(un,{size:"sm",onClick:()=>c(!1)}),r.jsx(hn,{size:"sm",onClick:()=>c(!1)})]})]})})]})},qe=({collected:e=!1,celebrateCollection:n=!1,children:t,className:a="",...s})=>{const i={hidden:{scale:0,rotate:-180,opacity:0},visible:{scale:1,rotate:0,opacity:1,transition:{type:"spring",stiffness:300,damping:20,duration:.6}},collected:{scale:[1,1.3,1],rotate:[0,360],transition:{duration:.8,ease:"easeInOut"}},celebrating:{scale:[1,1.2,1.1,1],rotate:[0,-5,5,0],y:[0,-10,0],transition:{duration:1,repeat:2,ease:"easeInOut"}}},d={hidden:{opacity:0},visible:{opacity:[.5,1,.5],transition:{duration:2,repeat:1/0,ease:"easeInOut"}}};return r.jsxs(we.div,{className:"relative inline-block",variants:i,initial:"hidden",animate:n?"celebrating":e?"collected":"visible",whileHover:{scale:1.05},children:[e&&r.jsx(we.div,{className:"absolute inset-0 rounded-full bg-yellow-400 blur-sm",variants:d,initial:"hidden",animate:"visible"}),r.jsx(V,{className:a,...s,children:t}),n&&r.jsxs(r.Fragment,{children:[r.jsx(we.span,{className:"absolute -top-2 -right-2 text-yellow-400",initial:{opacity:0,scale:0},animate:{opacity:[0,1,0],scale:[0,1.5,0],rotate:[0,180,360]},transition:{duration:1,delay:.2},children:"⭐"}),r.jsx(we.span,{className:"absolute -bottom-2 -left-2 text-yellow-400",initial:{opacity:0,scale:0},animate:{opacity:[0,1,0],scale:[0,1.5,0],rotate:[0,-180,-360]},transition:{duration:1,delay:.4},children:"✨"})]})]})},sr=({story:e,isMarkedAsRead:n=!1,isInCart:t=!1,onCartChange:a,index:s=0,getLocalizedPath:i,hasAccess:d=!0,isAuthenticated:c=!1,onOpenDetails:m})=>{const{t:b}=Se("stories"),h=Le(),g=y=>{if(!y)return!1;const u=new Date(y);return Math.floor((new Date().getTime()-u.getTime())/(1e3*3600*24))<=30},p=i(`/story/${e.id}`),O=()=>d?p:i(c?"/subscription":"/login"),$=()=>{if(m){m(e);return}if(!d&&!c){sessionStorage.setItem("pendingAuthRedirect",p),h(i("/login"),{state:{redirectTo:p}});return}h(O())},D=y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),$())},L=et(e.cefrLevel),w=tt(e.cefrLevel),S=e.accessLevel==="paid";return r.jsx(rn,{index:s,className:"story-card relative h-full rounded-lg overflow-hidden",children:r.jsx("div",{role:"button",tabIndex:0,onClick:$,onKeyDown:D,"aria-label":e.title,className:"cursor-pointer h-full block rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-nature-coral",children:r.jsxs(Ht,{className:"h-full flex flex-col rounded-lg overflow-hidden bg-white shadow-md transition-transform duration-300 hover:-translate-y-1",children:[r.jsxs("div",{className:"relative aspect-square overflow-hidden",children:[r.jsx("div",{className:"w-full h-full transition-transform group-hover:scale-105",children:e.thumbnailVideoUrl?r.jsx("video",{src:e.thumbnailVideoUrl,className:"w-full h-full object-cover",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,onError:y=>{console.error("Thumbnail video failed to load:",y),y.currentTarget.style.display="none";const u=document.createElement("img");u.src=e.thumbnail,u.alt=e.title,u.className="w-full h-full object-cover",y.currentTarget.parentElement?.appendChild(u)}}):r.jsx("img",{src:e.thumbnail,alt:e.title,className:"w-full h-full object-cover"})}),n&&r.jsx("div",{className:"absolute top-2 left-2 z-10",children:r.jsxs(qe,{className:"text-white flex items-center gap-1 bg-nature-forest",variant:"secondary",children:[r.jsx(at,{className:"h-3 w-3"}),b("badge.read")]})}),g(e.createdAt)&&r.jsx("div",{className:"absolute top-2 right-2 z-10",children:r.jsxs(qe,{className:"text-white flex items-center gap-1 bg-nature-coral",variant:"secondary",children:[r.jsx(it,{className:"h-3 w-3"}),b("badge.new")]})}),S&&r.jsx("div",{className:"absolute bottom-2 left-2 z-10",children:r.jsxs(V,{className:"bg-nature-honey text-nature-honey-ink hover:bg-nature-honey text-[10px] font-semibold px-2 py-0.5 flex items-center gap-1 shadow-sm",children:[r.jsx(nt,{className:"h-3 w-3"}),b("accessLevel.paid.label")]})}),!S&&r.jsx("div",{className:"absolute bottom-2 left-2 z-10",children:r.jsxs(V,{className:"bg-nature-purple text-white hover:bg-nature-purple text-[10px] font-semibold px-2 py-0.5 flex items-center gap-1 shadow-sm",children:[r.jsx(ot,{className:"h-3 w-3"}),b("accessLevel.free.label")]})}),a&&r.jsx("div",{className:"absolute bottom-2 right-2 z-20",children:r.jsx(st,{storyId:e.id,isInCart:t,onCartChange:a})})]}),r.jsxs(Ut,{className:"p-3 flex-1 flex flex-col gap-2",children:[r.jsx("h3",{className:"text-sm md:text-base font-semibold text-ink line-clamp-2 leading-snug",children:e.title}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1 mt-auto",children:[e.seslScore!==void 0&&e.seslScore!==null&&r.jsxs(V,{variant:"outline",className:`text-[10px] px-1.5 py-0.5 font-semibold ${rt(xe(e.seslScore))}`,children:[b("sesl.label")," ",e.seslScore," ",b(`sesl.difficulty.${xe(e.seslScore)}`)]}),r.jsxs(V,{variant:"outline",className:"text-[10px] px-1.5 py-0.5 font-semibold border-border bg-white text-ink",children:[L," ",b("age.years")]}),r.jsxs(V,{variant:"outline",className:"text-[10px] px-1.5 py-0.5 font-semibold border-border bg-white text-ink",children:["CEFR ",w.shortLabel]})]})]})]})})})};function gn(e){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",n.appendChild(t),t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}const lt=o.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),ie=()=>{const e=o.useContext(lt);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};gn(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,100%,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,-100%,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(-100%,0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(100%,0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
[data-state=closed]
){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,100%,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,100%,0)}}@keyframes slideFromTop{from{transform:translate3d(0,-100%,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,-100%,0)}}@keyframes slideFromLeft{from{transform:translate3d(-100%,0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(-100%,0,0)}}@keyframes slideFromRight{from{transform:translate3d(100%,0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(100%,0,0)}}`);const wn=24,vn=typeof window<"u"?K.useLayoutEffect:K.useEffect;function Xe(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}function bn(){return Be(/^Mac/)}function xn(){return Be(/^iPhone/)}function Ke(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function yn(){return Be(/^iPad/)||bn()&&navigator.maxTouchPoints>1}function ct(){return xn()||yn()}function Be(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}const ke=typeof document<"u"&&window.visualViewport;function Ge(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function ut(e){for(Ge(e)&&(e=e.parentElement);e&&!Ge(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Sn=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let ve=0,Oe;function Dn(e={}){let{isDisabled:n}=e;vn(()=>{if(!n)return ve++,ve===1&&ct()&&(Oe=Tn()),()=>{ve--,ve===0&&Oe?.()}},[n])}function Tn(){let e,n=0,t=g=>{e=ut(g.target),!(e===document.documentElement&&e===document.body)&&(n=g.changedTouches[0].pageY)},a=g=>{if(!e||e===document.documentElement||e===document.body){g.preventDefault();return}let p=g.changedTouches[0].pageY,O=e.scrollTop,$=e.scrollHeight-e.clientHeight;$!==0&&((O<=0&&p>n||O>=$&&p<n)&&g.preventDefault(),n=p)},s=g=>{let p=g.target;Ae(p)&&p!==document.activeElement&&(g.preventDefault(),p.style.transform="translateY(-2000px)",p.focus(),requestAnimationFrame(()=>{p.style.transform=""}))},i=g=>{let p=g.target;Ae(p)&&(p.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{p.style.transform="",ke&&(ke.height<window.innerHeight?requestAnimationFrame(()=>{Je(p)}):ke.addEventListener("resize",()=>Je(p),{once:!0}))}))},d=()=>{window.scrollTo(0,0)},c=window.pageXOffset,m=window.pageYOffset,b=Xe(Rn(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let h=Xe(de(document,"touchstart",t,{passive:!1,capture:!0}),de(document,"touchmove",a,{passive:!1,capture:!0}),de(document,"touchend",s,{passive:!1,capture:!0}),de(document,"focus",i,!0),de(window,"scroll",d));return()=>{b(),h(),window.scrollTo(c,m)}}function Rn(e,n,t){let a=e.style[n];return e.style[n]=t,()=>{e.style[n]=a}}function de(e,n,t,a){return e.addEventListener(n,t,a),()=>{e.removeEventListener(n,t,a)}}function Je(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=ut(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let a=t.getBoundingClientRect().top,s=e.getBoundingClientRect().top,i=e.getBoundingClientRect().bottom;const d=t.getBoundingClientRect().bottom+wn;i>d&&(t.scrollTop+=s-a)}e=t.parentElement}}function Ae(e){return e instanceof HTMLInputElement&&!Sn.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function Nn(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function jn(...e){return n=>e.forEach(t=>Nn(t,n))}function dt(...e){return K.useCallback(jn(...e),e)}const ft=new WeakMap;function A(e,n,t=!1){if(!e||!(e instanceof HTMLElement))return;let a={};Object.entries(n).forEach(([s,i])=>{if(s.startsWith("--")){e.style.setProperty(s,i);return}a[s]=e.style[s],e.style[s]=i}),!t&&ft.set(e,a)}function En(e,n){if(!e||!(e instanceof HTMLElement))return;let t=ft.get(e);t&&(e.style[n]=t[n])}const P=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function be(e,n){if(!e)return null;const t=window.getComputedStyle(e),a=t.transform||t.webkitTransform||t.mozTransform;let s=a.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[P(n)?13:12]):(s=a.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[P(n)?5:4]):null)}function Cn(e){return 8*(Math.log(e+1)-2)}function $e(e,n){if(!e)return()=>{};const t=e.style.cssText;return Object.assign(e.style,n),()=>{e.style.cssText=t}}function kn(...e){return(...n)=>{for(const t of e)typeof t=="function"&&t(...n)}}const k={DURATION:.5,EASE:[.32,.72,0,1]},mt=.4,On=.25,$n=100,pt=8,ne=16,Pe=26,Me="vaul-dragging";function ht(e){const n=o.useRef(e);return o.useEffect(()=>{n.current=e}),o.useMemo(()=>(...t)=>n.current==null?void 0:n.current.call(n,...t),[])}function Mn({defaultProp:e,onChange:n}){const t=o.useState(e),[a]=t,s=o.useRef(a),i=ht(n);return o.useEffect(()=>{s.current!==a&&(i(a),s.current=a)},[a,s,i]),t}function gt({prop:e,defaultProp:n,onChange:t=()=>{}}){const[a,s]=Mn({defaultProp:n,onChange:t}),i=e!==void 0,d=i?e:a,c=ht(t),m=o.useCallback(b=>{if(i){const g=typeof b=="function"?b(e):b;g!==e&&c(g)}else s(b)},[i,e,s,c]);return[d,m]}function An({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:a,overlayRef:s,fadeFromIndex:i,onSnapPointChange:d,direction:c="bottom",container:m,snapToSequentialPoint:b}){const[h,g]=gt({prop:e,defaultProp:t?.[0],onChange:n}),[p,O]=o.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);o.useEffect(()=>{function x(){O({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const $=o.useMemo(()=>h===t?.[t.length-1]||null,[t,h]),D=o.useMemo(()=>t?.findIndex(x=>x===h),[t,h]),L=t&&t.length>0&&(i||i===0)&&!Number.isNaN(i)&&t[i]===h||!t,w=o.useMemo(()=>{const x=m?{width:m.getBoundingClientRect().width,height:m.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var j;return(j=t?.map(T=>{const _=typeof T=="string";let l=0;if(_&&(l=parseInt(T,10)),P(c)){const B=_?l:p?T*x.height:0;return p?c==="bottom"?x.height-B:-x.height+B:B}const I=_?l:p?T*x.width:0;return p?c==="right"?x.width-I:-x.width+I:I}))!=null?j:[]},[t,p,m]),S=o.useMemo(()=>D!==null?w?.[D]:null,[w,D]),y=o.useCallback(x=>{var j;const T=(j=w?.findIndex(_=>_===x))!=null?j:null;d(T),A(a.current,{transition:`transform ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`,transform:P(c)?`translate3d(0, ${x}px, 0)`:`translate3d(${x}px, 0, 0)`}),w&&T!==w.length-1&&T!==i&&T<i?A(s.current,{transition:`opacity ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`,opacity:"0"}):A(s.current,{transition:`opacity ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`,opacity:"1"}),g(t?.[Math.max(T,0)])},[a.current,t,w,i,s,g]);o.useEffect(()=>{if(h||e){var x;const j=(x=t?.findIndex(T=>T===e||T===h))!=null?x:-1;w&&j!==-1&&typeof w[j]=="number"&&y(w[j])}},[h,e,t,w,y]);function u({draggedDistance:x,closeDrawer:j,velocity:T,dismissible:_}){if(i===void 0)return;const l=c==="bottom"||c==="right"?(S??0)-x:(S??0)+x,I=D===i-1,B=D===0,U=x>0;if(I&&A(s.current,{transition:`opacity ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`}),!b&&T>2&&!U){_?j():y(w[0]);return}if(!b&&T>2&&U&&w&&t){y(w[t.length-1]);return}const F=w?.reduce((z,ee)=>typeof z!="number"||typeof ee!="number"?z:Math.abs(ee-l)<Math.abs(z-l)?ee:z),Z=P(c)?window.innerHeight:window.innerWidth;if(T>mt&&Math.abs(x)<Z*.4){const z=U?1:-1;if(z>0&&$){y(w[t.length-1]);return}if(B&&z<0&&_&&j(),D===null)return;y(w[D+z]);return}y(F)}function M({draggedDistance:x}){if(S===null)return;const j=c==="bottom"||c==="right"?S-x:S+x;(c==="bottom"||c==="right")&&j<w[w.length-1]||(c==="top"||c==="left")&&j>w[w.length-1]||A(a.current,{transform:P(c)?`translate3d(0, ${j}px, 0)`:`translate3d(${j}px, 0, 0)`})}function J(x,j){if(!t||typeof D!="number"||!w||i===void 0)return null;const T=D===i-1;if(D>=i&&j)return 0;if(T&&!j)return 1;if(!L&&!T)return null;const l=T?D+1:D-1,I=T?w[l]-w[l-1]:w[l+1]-w[l],B=x/Math.abs(I);return T?1-B:B}return{isLastSnapPoint:$,activeSnapPoint:h,shouldFade:L,getPercentageDragged:J,setActiveSnapPoint:g,activeSnapPointIndex:D,onRelease:u,onDrag:M,snapPointsOffset:w}}const Pn=()=>()=>{};function Ln(){const{direction:e,isOpen:n,shouldScaleBackground:t,setBackgroundColorOnScale:a,noBodyStyles:s}=ie(),i=o.useRef(null),d=K.useMemo(()=>document.body.style.backgroundColor,[]);function c(){return(window.innerWidth-Pe)/window.innerWidth}o.useEffect(()=>{if(n&&t){i.current&&clearTimeout(i.current);const m=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!m)return;kn(a&&!s?$e(document.body,{background:"black"}):Pn,$e(m,{transformOrigin:P(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${k.DURATION}s`,transitionTimingFunction:`cubic-bezier(${k.EASE.join(",")})`}));const b=$e(m,{borderRadius:`${pt}px`,overflow:"hidden",...P(e)?{transform:`scale(${c()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${c()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{b(),i.current=window.setTimeout(()=>{d?document.body.style.background=d:document.body.style.removeProperty("background")},k.DURATION*1e3)}}},[n,t,d])}let fe=null;function Bn({isOpen:e,modal:n,nested:t,hasBeenOpened:a,preventScrollRestoration:s,noBodyStyles:i}){const[d,c]=o.useState(()=>typeof window<"u"?window.location.href:""),m=o.useRef(0),b=o.useCallback(()=>{if(Ke()&&fe===null&&e&&!i){fe={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:g,innerHeight:p}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-m.current}px`,left:`${-g}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const O=p-window.innerHeight;O&&m.current>=p&&(document.body.style.top=`${-(m.current+O)}px`)}),300)}},[e]),h=o.useCallback(()=>{if(Ke()&&fe!==null&&!i){const g=-parseInt(document.body.style.top,10),p=-parseInt(document.body.style.left,10);Object.assign(document.body.style,fe),window.requestAnimationFrame(()=>{if(s&&d!==window.location.href){c(window.location.href);return}window.scrollTo(p,g)}),fe=null}},[d]);return o.useEffect(()=>{function g(){m.current=window.scrollY}return g(),window.addEventListener("scroll",g),()=>{window.removeEventListener("scroll",g)}},[]),o.useEffect(()=>{t||!a||(e?(!window.matchMedia("(display-mode: standalone)").matches&&b(),n||window.setTimeout(()=>{h()},500)):h())},[e,a,d,n,t,b,h]),{restorePositionSetting:h}}function wt({open:e,onOpenChange:n,children:t,onDrag:a,onRelease:s,snapPoints:i,shouldScaleBackground:d=!1,setBackgroundColorOnScale:c=!0,closeThreshold:m=On,scrollLockTimeout:b=$n,dismissible:h=!0,handleOnly:g=!1,fadeFromIndex:p=i&&i.length-1,activeSnapPoint:O,setActiveSnapPoint:$,fixed:D,modal:L=!0,onClose:w,nested:S,noBodyStyles:y,direction:u="bottom",defaultOpen:M=!1,disablePreventScroll:J=!0,snapToSequentialPoint:x=!1,preventScrollRestoration:j=!1,repositionInputs:T=!0,onAnimationEnd:_,container:l,autoFocus:I=!1}){var B,U;const[F=!1,Z]=gt({defaultProp:M,prop:e,onChange:f=>{n?.(f),!f&&!S&&$t(),setTimeout(()=>{_?.(f)},k.DURATION*1e3),f&&!L&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),f||(document.body.style.pointerEvents="auto")}}),[z,ee]=o.useState(!1),[oe,De]=o.useState(!1),[Nt,Ie]=o.useState(!1),re=o.useRef(null),me=o.useRef(null),Te=o.useRef(null),Re=o.useRef(null),pe=o.useRef(null),se=o.useRef(!1),Ne=o.useRef(null),je=o.useRef(0),ae=o.useRef(!1),_e=o.useRef(0),v=o.useRef(null),He=o.useRef(((B=v.current)==null?void 0:B.getBoundingClientRect().height)||0),Ue=o.useRef(((U=v.current)==null?void 0:U.getBoundingClientRect().width)||0),Ee=o.useRef(0),jt=o.useCallback(f=>{i&&f===ce.length-1&&(me.current=new Date)},[]),{activeSnapPoint:Et,activeSnapPointIndex:le,setActiveSnapPoint:Fe,onRelease:Ct,snapPointsOffset:ce,onDrag:kt,shouldFade:ze,getPercentageDragged:Ot}=An({snapPoints:i,activeSnapPointProp:O,setActiveSnapPointProp:$,drawerRef:v,fadeFromIndex:p,overlayRef:re,onSnapPointChange:jt,direction:u,container:l,snapToSequentialPoint:x});Dn({isDisabled:!F||oe||!L||Nt||!z||!T||!J});const{restorePositionSetting:$t}=Bn({isOpen:F,modal:L,nested:S,hasBeenOpened:z,preventScrollRestoration:j,noBodyStyles:y});function he(){return(window.innerWidth-Pe)/window.innerWidth}function Mt(f){var R,E;!h&&!i||v.current&&!v.current.contains(f.target)||(He.current=((R=v.current)==null?void 0:R.getBoundingClientRect().height)||0,Ue.current=((E=v.current)==null?void 0:E.getBoundingClientRect().width)||0,De(!0),Te.current=new Date,ct()&&window.addEventListener("touchend",()=>se.current=!1,{once:!0}),f.target.setPointerCapture(f.pointerId),je.current=P(u)?f.pageY:f.pageX)}function Ve(f,R){var E,C;let N=f;const Y=(E=window.getSelection())==null?void 0:E.toString(),H=v.current?be(v.current,u):null,W=new Date;if(N.hasAttribute("data-vaul-no-drag")||N.closest("[data-vaul-no-drag]"))return!1;if(u==="right"||u==="left")return!0;if(me.current&&W.getTime()-me.current.getTime()<500)return!1;if(H!==null&&(u==="bottom"?H>0:H<0))return!0;if(Y&&Y.length>0)return!1;if(W.getTime()-((C=pe.current)==null?void 0:C.getTime())<b&&H===0||R)return pe.current=W,!1;for(;N;){if(N.scrollHeight>N.clientHeight){if(N.scrollTop!==0)return pe.current=new Date,!1;if(N.getAttribute("role")==="dialog")return!0}N=N.parentNode}return!0}function At(f){if(v.current&&oe){const R=u==="bottom"||u==="right"?1:-1,E=(je.current-(P(u)?f.pageY:f.pageX))*R,C=E>0,N=i&&!h&&!C;if(N&&le===0)return;const Y=Math.abs(E),H=document.querySelector("[data-vaul-drawer-wrapper]"),W=u==="bottom"||u==="top"?He.current:Ue.current;let q=Y/W;const te=Ot(Y,C);if(te!==null&&(q=te),N&&q>=1||!se.current&&!Ve(f.target,C))return;if(v.current.classList.add(Me),se.current=!0,A(v.current,{transition:"none"}),A(re.current,{transition:"none"}),i&&kt({draggedDistance:E}),C&&!i){const X=Cn(E),ge=Math.min(X*-1,0)*R;A(v.current,{transform:P(u)?`translate3d(0, ${ge}px, 0)`:`translate3d(${ge}px, 0, 0)`});return}const Q=1-q;if((ze||p&&le===p-1)&&(a?.(f,q),A(re.current,{opacity:`${Q}`,transition:"none"},!0)),H&&re.current&&d){const X=Math.min(he()+q*(1-he()),1),ge=8-q*8,Ye=Math.max(0,14-q*14);A(H,{borderRadius:`${ge}px`,transform:P(u)?`scale(${X}) translate3d(0, ${Ye}px, 0)`:`scale(${X}) translate3d(${Ye}px, 0, 0)`,transition:"none"},!0)}if(!i){const X=Y*R;A(v.current,{transform:P(u)?`translate3d(0, ${X}px, 0)`:`translate3d(${X}px, 0, 0)`})}}}o.useEffect(()=>{var f;function R(){if(!v.current||!T)return;const E=document.activeElement;if(Ae(E)||ae.current){var C;const N=((C=window.visualViewport)==null?void 0:C.height)||0,Y=window.innerHeight;let H=Y-N;const W=v.current.getBoundingClientRect().height||0,q=W>Y*.8;Ee.current||(Ee.current=W);const te=v.current.getBoundingClientRect().top;if(Math.abs(_e.current-H)>60&&(ae.current=!ae.current),i&&i.length>0&&ce&&le){const Q=ce[le]||0;H+=Q}if(_e.current=H,W>N||ae.current){const Q=v.current.getBoundingClientRect().height;let X=Q;Q>N&&(X=N-(q?te:Pe)),D?v.current.style.height=`${Q-Math.max(H,0)}px`:v.current.style.height=`${Math.max(X,N-te)}px`}else v.current.style.height=`${Ee.current}px`;i&&i.length>0&&!ae.current?v.current.style.bottom="0px":v.current.style.bottom=`${Math.max(H,0)}px`}}return(f=window.visualViewport)==null||f.addEventListener("resize",R),()=>{var E;return(E=window.visualViewport)==null?void 0:E.removeEventListener("resize",R)}},[le,i,ce]);function ue(f){Pt(),w?.(),f||Z(!1),setTimeout(()=>{i&&Fe(i[0])},k.DURATION*1e3)}function We(){if(!v.current)return;const f=document.querySelector("[data-vaul-drawer-wrapper]"),R=be(v.current,u);A(v.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`}),A(re.current,{transition:`opacity ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`,opacity:"1"}),d&&R&&R>0&&F&&A(f,{borderRadius:`${pt}px`,overflow:"hidden",...P(u)?{transform:`scale(${he()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${he()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${k.DURATION}s`,transitionTimingFunction:`cubic-bezier(${k.EASE.join(",")})`},!0)}function Pt(){!oe||!v.current||(v.current.classList.remove(Me),se.current=!1,De(!1),Re.current=new Date)}function Lt(f){if(!oe||!v.current)return;v.current.classList.remove(Me),se.current=!1,De(!1),Re.current=new Date;const R=be(v.current,u);if(!Ve(f.target,!1)||!R||Number.isNaN(R)||Te.current===null)return;const E=Re.current.getTime()-Te.current.getTime(),C=je.current-(P(u)?f.pageY:f.pageX),N=Math.abs(C)/E;if(N>.05&&(Ie(!0),setTimeout(()=>{Ie(!1)},200)),i){Ct({draggedDistance:C*(u==="bottom"||u==="right"?1:-1),closeDrawer:ue,velocity:N,dismissible:h}),s?.(f,!0);return}if(u==="bottom"||u==="right"?C>0:C<0){We(),s?.(f,!0);return}if(N>mt){ue(),s?.(f,!1);return}var Y;const H=Math.min((Y=v.current.getBoundingClientRect().height)!=null?Y:0,window.innerHeight);var W;const q=Math.min((W=v.current.getBoundingClientRect().width)!=null?W:0,window.innerWidth),te=u==="left"||u==="right";if(Math.abs(R)>=(te?q:H)*m){ue(),s?.(f,!1);return}s?.(f,!0),We()}o.useEffect(()=>(F&&(A(document.documentElement,{scrollBehavior:"auto"}),me.current=new Date),()=>{En(document.documentElement,"scrollBehavior")}),[F]);function Bt(f){const R=f?(window.innerWidth-ne)/window.innerWidth:1,E=f?-ne:0;Ne.current&&window.clearTimeout(Ne.current),A(v.current,{transition:`transform ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`,transform:`scale(${R}) translate3d(0, ${E}px, 0)`}),!f&&v.current&&(Ne.current=setTimeout(()=>{const C=be(v.current,u);A(v.current,{transition:"none",transform:P(u)?`translate3d(0, ${C}px, 0)`:`translate3d(${C}px, 0, 0)`})},500))}function It(f,R){if(R<0)return;const E=(window.innerWidth-ne)/window.innerWidth,C=E+R*(1-E),N=-ne+R*ne;A(v.current,{transform:P(u)?`scale(${C}) translate3d(0, ${N}px, 0)`:`scale(${C}) translate3d(${N}px, 0, 0)`,transition:"none"})}function _t(f,R){const E=P(u)?window.innerHeight:window.innerWidth,C=R?(E-ne)/E:1,N=R?-ne:0;R&&A(v.current,{transition:`transform ${k.DURATION}s cubic-bezier(${k.EASE.join(",")})`,transform:P(u)?`scale(${C}) translate3d(0, ${N}px, 0)`:`scale(${C}) translate3d(${N}px, 0, 0)`})}return o.createElement(Qt,{defaultOpen:M,onOpenChange:f=>{!h&&!f||(f?ee(!0):ue(!0),Z(f))},open:F},o.createElement(lt.Provider,{value:{activeSnapPoint:Et,snapPoints:i,setActiveSnapPoint:Fe,drawerRef:v,overlayRef:re,onOpenChange:n,onPress:Mt,onRelease:Lt,onDrag:At,dismissible:h,handleOnly:g,isOpen:F,isDragging:oe,shouldFade:ze,closeDrawer:ue,onNestedDrag:It,onNestedOpenChange:Bt,onNestedRelease:_t,keyboardIsOpen:ae,modal:L,snapPointsOffset:ce,direction:u,shouldScaleBackground:d,setBackgroundColorOnScale:c,noBodyStyles:y,container:l,autoFocus:I}},t))}const vt=o.forwardRef(function({...e},n){const{overlayRef:t,snapPoints:a,onRelease:s,shouldFade:i,isOpen:d,modal:c}=ie(),m=dt(n,t),b=a&&a.length>0;return c?o.createElement(qt,{onMouseUp:s,ref:m,"data-vaul-overlay":"","data-vaul-snap-points":d&&b?"true":"false","data-vaul-snap-points-overlay":d&&i?"true":"false",...e}):(typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),null)});vt.displayName="Drawer.Overlay";const bt=o.forwardRef(function({onPointerDownOutside:e,style:n,onOpenAutoFocus:t,...a},s){const{drawerRef:i,onPress:d,onRelease:c,onDrag:m,keyboardIsOpen:b,snapPointsOffset:h,modal:g,isOpen:p,direction:O,snapPoints:$,container:D,handleOnly:L,autoFocus:w}=ie(),[S,y]=o.useState(!1),u=dt(s,i),M=o.useRef(null),J=o.useRef(null),x=o.useRef(!1),j=$&&$.length>0;Ln();const T=(l,I,B=0)=>{if(x.current)return!0;const U=Math.abs(l.y),F=Math.abs(l.x),Z=F>U,z=["bottom","right"].includes(I)?1:-1;if(I==="left"||I==="right"){if(!(l.x*z<0)&&F>=0&&F<=B)return Z}else if(!(l.y*z<0)&&U>=0&&U<=B)return!Z;return x.current=!0,!0};o.useEffect(()=>{j&&window.requestAnimationFrame(()=>{y(!0)})},[]);function _(l){M.current=null,x.current=!1,c(l)}return o.createElement(Xt,{"data-vaul-drawer-direction":O,"data-vaul-drawer":"","data-vaul-delayed-snap-points":S?"true":"false","data-vaul-snap-points":p&&j?"true":"false","data-vaul-custom-container":D?"true":"false",...a,ref:u,style:h&&h.length>0?{"--snap-point-height":`${h[0]}px`,...n}:n,onPointerDown:l=>{L||(a.onPointerDown==null||a.onPointerDown.call(a,l),M.current={x:l.pageX,y:l.pageY},d(l))},onOpenAutoFocus:l=>{t?.(l),w||l.preventDefault()},onPointerDownOutside:l=>{if(e?.(l),!g||l.defaultPrevented){l.preventDefault();return}b.current&&(b.current=!1)},onFocusOutside:l=>{if(!g){l.preventDefault();return}},onPointerMove:l=>{if(J.current=l,L||(a.onPointerMove==null||a.onPointerMove.call(a,l),!M.current))return;const I=l.pageY-M.current.y,B=l.pageX-M.current.x,U=l.pointerType==="touch"?10:2;T({x:B,y:I},O,U)?m(l):(Math.abs(B)>U||Math.abs(I)>U)&&(M.current=null)},onPointerUp:l=>{a.onPointerUp==null||a.onPointerUp.call(a,l),M.current=null,x.current=!1,c(l)},onPointerOut:l=>{a.onPointerOut==null||a.onPointerOut.call(a,l),_(J.current)},onContextMenu:l=>{a.onContextMenu==null||a.onContextMenu.call(a,l),_(J.current)}})});bt.displayName="Drawer.Content";const In=250,_n=120,xt=o.forwardRef(function({preventCycle:e=!1,children:n,...t},a){const{closeDrawer:s,isDragging:i,snapPoints:d,activeSnapPoint:c,setActiveSnapPoint:m,dismissible:b,handleOnly:h,isOpen:g,onPress:p,onDrag:O}=ie(),$=o.useRef(null),D=o.useRef(!1);function L(){if(D.current){y();return}window.setTimeout(()=>{w()},_n)}function w(){if(i||e||D.current){y();return}if(y(),(!d||d.length===0)&&b){s();return}if(c===d[d.length-1]&&b){s();return}const M=d.findIndex(x=>x===c);if(M===-1)return;const J=d[M+1];m(J)}function S(){$.current=window.setTimeout(()=>{D.current=!0},In)}function y(){window.clearTimeout($.current),D.current=!1}return o.createElement("div",{onClick:L,onPointerCancel:y,onPointerDown:u=>{h&&p(u),S()},onPointerMove:u=>{h&&O(u)},ref:a,"data-vaul-drawer-visible":g?"true":"false","data-vaul-handle":"","aria-hidden":"true",...t},o.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},n))});xt.displayName="Drawer.Handle";function Hn({onDrag:e,onOpenChange:n,...t}){const{onNestedDrag:a,onNestedOpenChange:s,onNestedRelease:i}=ie();if(!a)throw new Error("Drawer.NestedRoot must be placed in another drawer");return o.createElement(wt,{nested:!0,onClose:()=>{s(!1)},onDrag:(d,c)=>{a(d,c),e?.(d,c)},onOpenChange:d=>{d&&s(d)},onRelease:i,...t})}function Un(e){const n=ie(),{container:t=n.container,...a}=e;return o.createElement(en,{container:t,...a})}const G={Root:wt,NestedRoot:Hn,Content:bt,Overlay:vt,Trigger:Kt,Portal:Un,Handle:xt,Close:Gt,Title:Jt,Description:Zt},yt=({shouldScaleBackground:e=!0,...n})=>r.jsx(G.Root,{shouldScaleBackground:e,...n});yt.displayName="Drawer";const lr=G.Trigger,Fn=G.Portal,St=K.forwardRef(({className:e,...n},t)=>r.jsx(G.Overlay,{ref:t,className:ye("fixed inset-0 z-50 bg-black/80",e),...n}));St.displayName=G.Overlay.displayName;const Dt=K.forwardRef(({className:e,children:n,...t},a)=>r.jsxs(Fn,{children:[r.jsx(St,{}),r.jsxs(G.Content,{ref:a,className:ye("fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-2xl border bg-background",e),...t,children:[r.jsx("div",{className:"mx-auto mt-3 h-1.5 w-10 rounded-full shrink-0",style:{backgroundColor:"color-mix(in srgb, var(--nature-forest) 25%, transparent)"}}),n]})]}));Dt.displayName="DrawerContent";const Tt=K.forwardRef(({className:e,...n},t)=>r.jsx(G.Title,{ref:t,className:ye("text-lg font-semibold leading-none tracking-tight",e),...n}));Tt.displayName=G.Title.displayName;const Rt=K.forwardRef(({className:e,...n},t)=>r.jsx(G.Description,{ref:t,className:ye("text-sm text-muted-foreground",e),...n}));Rt.displayName=G.Description.displayName;function zn(e){return e.toLowerCase().replace(/ & /g,"_").replace(/ /g,"_")}function Vn(e,n){switch(n){case"bn":if(e.descriptionBn)return e.descriptionBn;break;case"es":if(e.descriptionEs)return e.descriptionEs;break;case"zh":case"zh-Hans":case"zh-Hant":if(e.descriptionZh)return e.descriptionZh;break;case"ja":if(e.descriptionJa)return e.descriptionJa;break;case"ko":if(e.descriptionKo)return e.descriptionKo;break;case"th":if(e.descriptionTh)return e.descriptionTh;break;case"vi":if(e.descriptionVi)return e.descriptionVi;break;case"hi":if(e.descriptionHi)return e.descriptionHi;break;case"pt":if(e.descriptionPt)return e.descriptionPt;break;case"fil":if(e.descriptionFil)return e.descriptionFil;break;case"ms":if(e.descriptionMs)return e.descriptionMs;break;case"id":if(e.descriptionId)return e.descriptionId;break;case"my":if(e.descriptionMy)return e.descriptionMy;break;case"km":if(e.descriptionKm)return e.descriptionKm;break;case"lo":if(e.descriptionLo)return e.descriptionLo;break}return e.description}const Wn=e=>{const n=Math.floor(e/60),t=e%60;return`${n}:${t.toString().padStart(2,"0")}`},Yn=e=>{if(!e)return!1;const n=new Date(e);return Math.floor((Date.now()-n.getTime())/(1e3*3600*24))<=30},cr=({story:e,onClose:n,getLocalizedPath:t,hasAccess:a,isAuthenticated:s,isInCart:i=!1,onCartChange:d,isMarkedAsRead:c=!1})=>{const{t:m,i18n:b}=Se("stories"),h=Le();if(!e)return null;const g=t(`/story/${e.id}`),p=Vn(e,b.language),O=et(e.cefrLevel),$=tt(e.cefrLevel),D=e.accessLevel==="paid",L=()=>a?g:t(s?"/subscription":"/login"),w=()=>{if(!a&&!s){sessionStorage.setItem("pendingAuthRedirect",g),h(t("/login"),{state:{redirectTo:g}}),n();return}h(L()),n()};return r.jsx(yt,{open:!!e,onOpenChange:S=>!S&&n(),children:r.jsxs(Dt,{className:"mx-auto w-full max-w-2xl bg-page-surface max-h-[88vh]",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 10%, transparent)"},children:[r.jsx("div",{className:"absolute top-6 right-3 z-50",children:r.jsx("button",{type:"button",onClick:n,"aria-label":m("modal.close"),className:"p-2 rounded-full bg-white/80 backdrop-blur-sm hover:bg-white/90 transition-all duration-200 hover:scale-110 shadow-sm",children:r.jsx(tn,{className:"h-5 w-5 text-gray-600 hover:text-nature-coral transition-colors"})})}),r.jsxs("div",{className:"overflow-y-auto",children:[r.jsx("div",{className:"relative w-full bg-page-surface flex items-center justify-center p-3",children:r.jsxs("div",{className:"relative w-full max-w-[220px] aspect-square rounded-lg overflow-hidden",children:[e.thumbnailVideoUrl?r.jsx("video",{src:e.thumbnailVideoUrl,className:"w-full h-full object-cover rounded-lg",autoPlay:!0,loop:!0,muted:!0,playsInline:!0}):r.jsx("img",{src:e.thumbnail,alt:e.title,className:"w-full h-full object-cover rounded-lg"}),c&&r.jsxs(V,{variant:"outline",className:"absolute top-2 left-2 bg-nature-forest text-white flex items-center gap-1",children:[r.jsx(at,{className:"h-3 w-3"}),m("badge.read")]}),Yn(e.createdAt)&&r.jsxs(V,{variant:"outline",className:"absolute top-2 left-2 bg-nature-coral text-white flex items-center gap-1",style:c?{top:"2.5rem"}:void 0,children:[r.jsx(it,{className:"h-3 w-3"}),m("badge.new")]})]})}),r.jsxs("div",{className:"p-5 md:p-6 space-y-3 bg-white",children:[r.jsx(Tt,{className:"text-ink text-lg md:text-xl font-semibold leading-tight pr-10",children:e.title}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.seslScore!==void 0&&e.seslScore!==null&&r.jsxs(V,{variant:"outline",className:`text-xs font-semibold ${rt(xe(e.seslScore))}`,children:[m("sesl.label")," ",e.seslScore," ",m(`sesl.difficulty.${xe(e.seslScore)}`)]}),r.jsxs(V,{variant:"outline",className:"text-xs font-semibold border-border bg-white text-ink",children:[O," ",m("age.years")]}),r.jsxs(V,{variant:"outline",className:"text-xs font-semibold border-border bg-white text-ink",children:["CEFR ",$.shortLabel]})]}),(e.duration>0||e.wordCount>0)&&r.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-xs text-nature-forest",children:[e.duration>0&&r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(fn,{className:"h-3.5 w-3.5"}),Wn(e.duration)]}),e.wordCount>0&&r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(mn,{className:"h-3.5 w-3.5"}),e.wordCount," ",m("wordCount.words")]})]}),p&&r.jsx(Rt,{className:"text-sm text-nature-forest leading-relaxed",children:p}),Array.isArray(e.theme)&&e.theme.length>0&&r.jsxs("div",{children:[r.jsx("p",{className:"text-[11px] uppercase tracking-wide font-semibold text-nature-forest mb-2",children:m("modal.themes")}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.theme.map(S=>r.jsx(V,{variant:"outline",className:"text-[10px] text-nature-forest",style:{borderColor:"color-mix(in srgb, var(--nature-forest) 20%, transparent)"},children:m(`theme.${zn(S)}`)},S))})]}),e.accessLevel&&r.jsx("div",{children:D?r.jsxs(V,{className:"bg-nature-honey text-nature-honey-ink hover:bg-nature-honey text-[10px] font-semibold px-2 py-0.5 flex items-center gap-1 shadow-sm w-fit",children:[r.jsx(nt,{className:"h-3 w-3"}),m("accessLevel.paid.label")]}):r.jsxs(V,{className:"bg-nature-purple text-white hover:bg-nature-purple text-[10px] font-semibold px-2 py-0.5 flex items-center gap-1 shadow-sm w-fit",children:[r.jsx(ot,{className:"h-3 w-3"}),m("accessLevel.free.label")]})}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[r.jsx(Qe,{variant:"primary",leftIcon:r.jsx(nn,{}),onClick:w,children:m("modal.readStory")}),d&&r.jsx("div",{className:"relative",children:r.jsx(st,{storyId:e.id,isInCart:i,onCartChange:d,className:"!bg-white border border-border"})})]})]})]})]})})};export{yt as D,sr as S,lr as a,Dt as b,cr as c};
//# sourceMappingURL=StoryDetailModal-Cz43hWG8.js.map