PageSourceSearch

https://capitaineaventure.fr/assets/OptimizedStoryCard-DJf6odxI.js

js capitaineaventure.fr collected 2026-09-24 14:22:43 UTC 6,658 bytes, 1 lines download raw bytes

1import{a as L,j as t}from"./vendor-query-CnVJgDtS.js";import{r as u,u as $,L as q}from"./vendor-react-B9UTwVUJ.js";import{B as c}from"./badge-CGmXKLhB.js";import{B as G}from"./index-Cx49XYBu.js";import{toast as f}from"./index-CqtmjIGR.js";import{S as Q}from"./StoryRatingBadge-C83DHpSO.js";import{p as K}from"./purify.es-BKfhsMPj.js";import{unmarkStoryAsRead as W}from"./user-Dhpo8ZFM.js";import{E as H}from"./themes-wHKdMhXe.js";import{F as J}from"./FavoriteButton-DiPfbifw.js";import{A as V}from"./award-CAZMR6Q9.js";import{S as X}from"./sparkles-Cy9dIcCr.js";import{R as Y}from"./rocket-NFJKrjfA.js";import{T as Z}from"./triangle-alert-DFWs3IRB.js";import{R}from"./rotate-ccw-CXB76rZi.js";const U=e=>e?e.replace(/IMG_principale\.webp$/,"IMG_principale_light.webp"):"/placeholder.svg",P=u.memo(({story:e,index:n,activeProfileId:s,profileAgeRange:r,isRead:i,onPrefetch:m,isUserLoggedIn:l=!1,isSubscribed:d=!1,hideNewBadge:C=!1,redirectToFreeStories:y=!1,ownedStoryIds:T=[],availableCredits:ae=0,hasAudio:S=!1,priority:b=!1,isFavorite:k=!1})=>{const w=$(),h=L(),x=r?ee(e.ageRange,r):!0,F=r?te(e.ageRange,r):!1,E=r?re(e.ageRange,r):!1,O=u.useCallback(()=>{m&&!i&&m(e.id)},[m,e.id,i]);u.useMemo(()=>e.description?K.sanitize(e.description,{ALLOWED_TAGS:["b","i","em","strong","span","br"],ALLOWED_ATTR:["lang","class"]}):"",[e.description]);const A=u.useCallback(a=>
1{if(!l)return;const o=d&&e.storyType==="premium",p=e.is_custom_story===!0;if(r&&!x&&!o&&!p){a.preventDefault(),a.stopPropagation(),f.error("Cette histoire n'est pas adaptée à la tranche d'âge de ce profil.");return}!s&&e.storyType==="gratuit"&&f.info("Crée ou sélectionne un profil aventurier !",{id:"create-child-profile-hint",duration:6e3,action:{label:"Choisir un profil",onClick:()=>w("/profile")}})},[r,x,s,w,e.storyType,l,d,e.id,e.is_custom_story,y]),I=T.includes(e.id);l&&e.storyType==="premium"&&!d&&!I&&e.is_free_demo;const M=!l&&e.storyType==="premium",j=a=>(a||"").replace(/[\u{1F000}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu,"").trim(),v=a=>j(a).toLowerCase();u.useMemo(()=>{const a=Array.isArray(e.themes)?e.themes:[];if(a.length===0)return null;for(const o of a){const p=v(o),_=H.find(B=>{const g=v(B.name);return g===p||g.includes(p)||p.includes(g)});if(_)return j(_.name)}return null},[e.themes]);const z=u.useCallback(async a=>{if(a.preventDefault(),a.stopPropagation(),sessionStorage.setItem(`restart-story-${e.id}`,"true"),!s){f.error("Vous devez être connecté pour rejouer une histoire");return}try{sessionStorage.removeItem(`story-progress-${e.id}`),await W(e.id,s),h.invalidateQueries({queryKey:["readStories"]}),h.invalidateQueries({queryKey:["stories"]}),f.success("L'histoire recommence depuis le début !"),setTimeout(()=>{window.location.href=`/reader/${e.id}`},500)}catch{f.error("Erreur lors de la réinitialisation de l'histoire")}},[e.id,s,h]),N=e.slug?e.slug.replace(/prenom/gi,"capitaine-aventure"):void 0,D=N?`/histoires/${N}`:`/histoires/${e.id}`;return l&&!d&&!x&&!e.is_custom_story?null:t.jsx(t.Fragment,{children:t.jsx(q,{to:D,"aria-label":`Lire l'histoire : ${e.title}`,className:"story-card block shadow-lg transform transition-all duration-300 opacity-100",onClick:A,onMouseEnter:O,children:t.jsxs("div",{className:"relative overflow-hidden rounded-xl aspect-[3/4] touch-feedback",children:[t.jsx("img",{src:U(e.coverImage),alt:e.title,width:300,height:400,className:"story-card-image w-full h-full object-cover",loading:b?"eager":"lazy",decoding:"async",fetchPriority:b?"high":"low",onError:a=>{const o=a.currentTarget;if(e.coverImage&&o.dataset.originalFallback!=="true"){o.dataset.originalFallback="true",o.src=e.coverImage;return}o.onerror=null,o.src="/placeholder.svg"}}),t.jsxs("div",{className:"absolute top-0 left-0 right-0 flex justify-between items-start p-2 z-10",children:[t.jsxs("div",{className:"flex gap-1 flex-wrap",children:[t.jsx(Q,{storyId:e.id}),e.featured&&t.jsxs(c,{className:"border border-amber-200 bg-gradient-to-r from-amber-500 to-orange-500 text-white text-xs font-bold shadow-lg",children:[t.jsx(V,{className:"mr-1 h-3 w-3"}),"Coup de cœur"]}),e.is_custom_story&&t.jsxs(c,{className:"bg-gradient-to-r from-primary to-purple-500 text-white text-xs font-bold shadow-lg animate-pulse",children:[t.jsx(X,{className:"w-3 h-3 mr-1"}),"Rien qu’à toi"]}),M&&!e.is_custom_story&&t.jsx(c,{className:"bg-amber-500 text-white text-xs font-bold",children:"✨ Premium"}),F&&!e.is_custom_story&&t.jsx(c,{className:"bg-emerald-500 text-white text-xs font-medium",children:"🌱 Facile"}),!C&&e.createdAt&&se(e.createdAt)&&!e.is_custom_story&&t.jsx(c,{variant:"secondary",className:"bg-gradient-to-r from-yellow-400 to-orange-500 text-white text-xs font-bold",children:"Nouveau"}),E&&!e.is_custom_story&&t.jsxs(c,{className:"bg-gradient-to-r from-amber-500 to-orange-600 text-white text-xs font-bold",children:[t.jsx(Y,{className:"w-3 h-3 mr-1"}),"Avancé"]}),S&&t.jsx(c,{className:"bg-emerald-600 text-white text-xs font-medium",children:"🔊"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(J,{storyId:e.id,profileId:s,size:"sm",initialFavorite:k}),!x&&t.jsx(c,{variant:"secondary",className:"bg-red-500 text-white",children:t.jsx(Z,{size:12})})]})]}),i&&s&&!e.is_custom_story&&t.jsx("div",{className:"absolute bottom-2 left-2 z-20",children:t.jsx(G,{size:"sm",variant:"secondary",onClick:z,className:"bg-primary/90 hover:bg-primary text-primary-foreground shadow-lg",title:"Rejouer cette histoire",children:t.jsx(R,{size:16})})}),t.jsxs("div",{className:"story-card-content bg-gradient-to-t from-black/90 via-black/70 to-transparent pt-10",children:[e.isGenerated&&t.jsx(c,{variant:"outline",className:"bg-primary/30 text-white border-primary/10 text-xs mb-1",children:"AI"}),t.jsx("h3",{className:"font-semibold text-base sm:text-lg leading-tight mb-1 text-balance",children:e.title})]})]})})})});P.displayName="OptimizedStoryCard";function ee(e,n){const s=["4-6","7-9","10-12","13-15","16+"],r=s.indexOf(n),i=s.indexOf(e);if(r===-1||i===-1){const l=e.includes("+")?99:parseInt(e.split("-")[1],10)||99,d=n.includes("+")?99:parseInt(n.split("-")[1],10)||99;return l<=d+3}return i>=Math.max(0,r-(n==="16+"?2:1))&&i<=Math.min(s.length-1,r+1)}function te(e,n){const s=["4-6","7-9","10-12","13-15","16+"],r=s.indexOf(n),i=s.indexOf(e);if(r===-1||i===-1){const m=e.includes("+")?99:parseInt(e.split("-")[1],10)||99,l=parseInt(n.split("-")[0],10)||0;return m<l}return i<r}function re(e,n){const s=["4-6","7-9","10-12","13-15","16+"],r=s.indexOf(n),i=s.indexOf(e);return r===-1||i===-1?!1:i>r}function se(e){const n=new Date(e);return(new Date().getTime()-n.getTime())/(1e3*60*60*24)<=7}export{P as O};

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.