1import{j as e}from"./ui-components-CrH3hhmI.js";import{r as u}from"./react-core-Df-1f7lZ.js";import{an as N}from"./MermaidChart-D-yfamGT.js";import{m as R}from"./marked.esm-DO4tLqqc.js";import k from"./purify.es-MYiLs5cL.js";import{P as j}from"./plyr-DACFKxh0.js";import{aB as m}from"./index-baCrhAE7.js";import"./charts-DACaTPEh.js";import"./editor-wwdhYSyT.js";import"./utils-BZSOOpUI.js";const M=({manifestUrl:s,isAudio:t})=>{const n=u.useRef(null),r=u.useRef(null),l=u.useRef(null),[i,d]=u.useState(!0),[x,o]=u.useState(null),p=u.useCallback(()=>{r.current&&(r.current.destroy(),r.current=null),l.current&&(l.current.destroy(),l.current=null)},[]);return u.useEffect(()=>{if(!s){o("No media source provided"),d(!1);return}const c=n.current;if(!c)return;const f={controls:["play-large","play","progress","current-time","mute","volume","settings"],settings:["speed"]};t||(f.controls.push("captions","pip","airplay","fullscreen"),f.settings.push("quality")),p();const b=a=>{try{c.src=a,r.current=new j(c,f),r.current.on("ready",()=>{d(!1)}),r.current.on("error",y=>{o("Error playing media")})}catch{o("Error initializing player")}},w=()=>{try{if(m.isSupported()){const a=new m({debug:!1,enableWorker:!0,lowLatencyMode:!0,backBufferLength:90});l.current=a,a.attachMedia(c),a.on(m.Events.MEDIA_ATTACHED,()=>{a.loadSource(s)}),a.on(m.Events.MANIFEST_PARSED,(y,g)=>{const v=a.levels.map(h=>h.height);f.quality={default:v[0],options:v,forced:!0,onChange:h=>{h===0?a.currentLevel=-1:a.currentLevel=a.levels.findIndex(E=>E.height===h)}},r.current=new j(c,f),d(!1)}),a.on(m.Events.ERROR,(y,g)=>{if(g.fatal)switch(g.type){case m.ErrorTypes.NETWORK_ERROR:a.startLoad();break;case m.ErrorTypes.MEDIA_ERROR:a.recoverMediaError();break;default:p(),o("Fatal streaming error");break}})}else c.canPlayType("application/vnd.apple.mpegurl")?b(s):o("HLS not supported in this browser")}catch{o("Error setting up stream")}};return s.includes(".m3u8")?w():b(s),()=>{p()}},[s,t,p]),x?e.jsx("div",{className:"relative w-full min-h-[50px]",children:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-200 dark:bg-gray-800",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h4",{className:"text-red-500 mb-2",children:x}),e.jsx("button",{onClick:()=>{o(null),d(!0),p();const c=n.current;c&&c.load()},className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors",children:"Retry"})]})})}):e.jsxs("div",{className:"relative w-full min-h-[50px]",children:[i&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-200 dark:bg-gray-800",children:e.jsx("div",{className:"loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12 animate-spin"})}),t?e.jsx("audio",{ref:n,className:`${i?"hidden":"block"} w-full`,preload:"metadata",crossOrigin:"anonymous"}):e.jsx("video",{ref:n,className:`${i?"hidden":"block"} w-full`,preload:"metadata",crossOrigin:"anonymous",playsInline:!0})]})};function z({title:s,author:t,content:n,image:r,video:l,creators:i}){const d=u.useMemo(()=>i.find(o=>o?.id===t),[t,i]),x=u.useMemo(()=>L(n),[n]);return e.jsxs("div",{className:"hidden md:flex lg:flex mx-auto p-4 border border-gray-700 bg-black text-white shadow-lg rounded-lg flex-col gap-3 w-full",children:[e.jsx("h3",{className:"text-xl font-bold text-white",children:"Preview"}),r&&!l&&e.jsx("img",{src:r,alt:"Article",className:"w-full h-64 object-cover rounded-lg"}),l&&e.jsx("div",{className:"relative w-full object-cover rounded-lg",children:e.jsx(M,{manifestUrl:l,spriteSheetUrl:l})}),e.jsxs("div",{className:"p-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:s}),t&&d&&e.jsxs("p",{className:"mb-4 text-white",children:["By ",d.name]}),!d&&t&&e.jsxs("p",{className:"mb-4 text-white",children:["By ",t]}),e.jsx("div",{className:" text-white min-h-[500px] overflow-y-auto ",children:P(x)})]})]})}function L(s){const t=/```mermaid((.|\n)*?)```/g,n=[];let r=0,l;for(;(l=t.exec(s))!==null;){const i=s.substring(r,l.index);i&&n.push({type:"text",content:i}),n.push({type:"mermaid",content:l[1]}
1),r=t.lastIndex}return r<s?.length&&n.push({type:"text",content:s.substring(r)}),n}function P(s){return s.map((t,n)=>{if(t.type==="text"){const r=R(t.content,{breaks:!0}),l=k.sanitize(r);return e.jsx("div",{className:"markdown-body",dangerouslySetInnerHTML:{__html:l}},n)}else if(t.type==="mermaid")return e.jsx(N,{content:t.content},n);return null})}export{z 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.