PageSourceSearch

https://viddler.com/assets/video-player-BSQHXzn0.js

js viddler.com collected 2026-10-02 02:14:11 UTC 67,723 bytes, 14 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0f211-423e-7503-8a03-cc66b606ccda")}catch(e){}}();import{c as Xe,e as oe,a as ve,r as f,j as e,B as U,L as qe,f as B,q as z,b as et,T as nt,g as ge,l as tt,X as st,u as ot,y as lt,d as ct,i as dt,o as ut}from"./index-DCg2N-ax.js";import{S as he}from"./skeleton-BbcAkOmt.js";import{V as _e}from"./video-player-with-overlay-aezT5sql.js";import{c as mt,V as ze}from"./video-password-gate-CKEf_TV6.js";import{E as ht}from"./embed-domain-control-CD6MYqlT.js";import{u as ne}from"./useMutation-Df4QW_om.js";import{h as pt,a as ft}from"./plan-features-DZgjurG7.js";import{S as xt}from"./shield-check-KCjnGfe-.js";import{L as X}from"./loader-circle-CKiHIFiC.js";import{L as gt}from"./lock-open-3Wm5vFdP.js";import{L as Be}from"./lock-SvHQVsFl.js";import{C as Pe}from"./crown-Dz5I0HQl.js";import{C as Ke,E as vt}from"./embed-dialog-v2-Dif_ig2K.js";import{T as Ve}from"./textarea-DRLMX-DK.js";import{A as yt,a as wt}from"./avatar-BzdQiLo8.js";import{T as rt}from"./trash-2-XhZrIdrv.js";import{S as bt}from"./switch-CNdHWF2h.js";import{C as jt}from"./chart-column-CpT9o1m5.js";import{D as Nt}from"./download-C-n2vFkf.js";import{U as Ct}from"./user-check-D8ZxCJW7.js";import{U as kt}from"./users-CS-a_uKC.js";import{r as Pt,u as St,V as Mt}from"./viewer-identity-gate--nlZVcrY.js";import{V as Et}from"./index-B0LeN49S.js";import{I as at}from"./input-DF5Vgg2m.js";import{C as It}from"./circle-alert-CU2Mfb3O.js";import{S as Le}from"./share-2-BWJDXH04.js";import{C as Qe}from"./clock-fV7L302f.js";import{C as Ge}from"./calendar-AYhVkk-8.js";import{U as Tt}from"./user-C1AC_hFd.js";import"./card-4KC-09AD.js";import"./earth-DSc5h_aK.js";import"./dialog-CRWD3cb6.js";import"./index-BNMS4r7V.js";import"./Combination-D44KBVv3.js";import"./label-CIYHSsxI.js";import"./select-Cw1T19G4.js";import"./index-BIQ3rZoK.js";import"./index-B6Z-4f_8.js";import"./index-DHiXYaPs.js";import"./index-D4hsugv3.js";import"./copy-CQ5EKnpp.js";import"./hls-CBWh4ACH.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Rt=Xe("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
7 * @license lucide-react v0.453.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ut=Xe("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);function Lt({videoId:a,uniqueId:i,isPasswordProtected:p}){const{toast:c}=oe(),{user:b}=ve(),u=pt(b),[o,x]=f.useState(!1),[n,P]=f.useState(""),[y,T]=f.useState(""),[j,E]=f.useState(null),G=()=>{z.invalidateQueries({queryKey:[`/api/videos/${a}`]}),i&&z.invalidateQueries({queryKey:[`/api/videos/${i}`]}),z.invalidateQueries({queryKey:["/api/videos"]})},$=ne({mutationFn:async F=>B("PATCH",`/api/videos/${a}/protection`,{enabled:!0,password:F}),onSuccess:()=>{c({title:"Password protection on",description:"Viewers now need the password to watch."}),x(!1),P(""),T(""),G()},onError:async F=>{var K,D,le;const q=((le=await((D=(K=F==null?void 0:F.response)==null?void 0:K.json)==null?void 0:D.call(K)))==null?void 0:le.message)||"Could not enable protection. Please try again.";c({title:"Error",description:q,variant:"destructive"})}}),h=ne({mutationFn:async()=>B("PATCH",`/api/videos/${a}/protection`,{enabled:!1}),onSuccess:()=>{c({title:"Password protection off",description:"Anyone with the link can watch again."}),G()},onError:()=>{c({title:"Error",description:"Could not disable protection. Please try again.",variant:"destructive"})}}),l=$.isPending||h.isPending,H=()=>{if(E(null),n.length<4){E("Password must be at least 4 characters.");return}if(n!==y){E("Passwords don't match.");return}$.mutate(n)};return p?e.jsxs("div",{className:"mt-6 rounded-lg border border-border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"h-5 w-5 text-green-600","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Password protected"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:u?"Viewers must enter the password to watch (here and in embeds).":"Protection stays on for safety. Upgrade to Pro to change the password, or turn it off below."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[u&&e.jsx(U,{variant:"outline",size:"sm",onClick:()=>{x(F=>!F),E(null)},disabled:l,children:"Change password"}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>h.mutate(),disabled:l,children:[h.isPending?e.jsx(X,{className:"h-4 w-4 animate-spin"}):e.jsx(gt,{className:"h-4 w-4 mr-1"}),"Turn off"]})]})]}),u&&o&&e.jsxs("div",{className:"mt-4 flex flex-col gap-2 max-w-sm",children:[e.jsx("input",{type:"password",autoComplete:"new-password",placeholder:"New password",value:n,onChange:F=>P(F.target.value),className:"rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("input",{type:"password",autoComplete:"new-password",placeholder:"Confirm new password",value:y,onChange:F=>T(F.target.value),className:"rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"}),j&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:j}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(U,{size:"sm",onClick:H,disabled:l,children:[$.isPending?e.jsx(X,{className:"h-4 w-4 animate-spin mr-1"}):null,"Save new password"]}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>{x(!1),E(null)},disabled:l,children:"Cancel"})]})]})]}):e.jsxs("div",{className:"mt-6 rounded-lg border border-border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-5 w-5 text-muted-foreground","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["Secret Password ",e.jsxs("span",{className:"ml-1 inline-flex items-center rounded-full bg-primary/15 text-primary px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide",children:[e.jsx(Pe,{className:"h-3 w-3 mr-0.5"})," Pro"]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:u?"Off. Anyone with the link can watch. Turn on to require a password.":"Pro feature. Upgrade to require a password to watch (here and in embeds)."})]})]}),u?!o&&e.jsx(U,{variant:"outline",size:"sm",onClick:()=>{x(!0),E(null)},children:"Set a password"}):e.jsx(U,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs(qe,{href:"/pricing",children:[e.jsx(Pe,{className:"h-4 w-4 mr-1"})," Upgrade"]})})]}),u&&o&&e.jsxs("div",{className:"mt-4 flex flex-col gap-2 max-w-sm",children:[e.jsx("input",{type:"password",autoComplete:"new-password",placeholder:"Password (min 4 characters)",value:n,onChange:F=>P(F.target.value),className:"rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("input",{type:"password",autoComplete:"new-password",placeholder:"Confirm password",value:y,onChange:F=>T(F.target.value),className:"rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"}),j&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:j}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(U,{size:"sm",onClick:H,disabled:l,children:[$.isPending?e.jsx(X,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(Be,{className:"h-4 w-4 mr-1"}),"Turn on protection"]}),e.jsx(U,{size:"sm",variant:"ghost",onClick:()=>{x(!1),E(null)},disabled:l,children:"Cancel"})]})]})]})}function He({video:a}){const{user:i}=ve(),{toast:p}=oe(),[,c]=et(),b=a.storageState,u=a.aspectRatio?a.aspectRatio.replace(":","/"):void 0,o="w-full h-full bg-black/80 text-white flex flex-col items-center justify-center text-center p-6",x=u?{aspectRatio:u}:void 0,n=u?"w-full":"w-full aspect-video",P=b==="restoring"||b==="archiving";f.useEffect(()=>{if(!P)return;const j=setInterval(()=>{z.invalidateQueries({queryKey:["/api/videos/"+a.id]})},5e3);return()=>clearInterval(j)},[P,a.id]);const y=ne({mutationFn:async()=>(await B("POST","/api/videos/"+a.id+"/restore")).json(),onSuccess:()=>
11{p({title:"Restoring video",description:"We're bringing this video back online. It'll be ready shortly."}),z.invalidateQueries({queryKey:["/api/videos/"+a.id]})},onError:j=>{const E=String((j==null?void 0:j.message)||"");if(E.includes("403")||E.includes("requiresSubscription")){p({title:"Subscription required",description:"An active subscription is required to restore archived videos.",variant:"destructive",action:e.jsx(nt,{altText:"Subscribe",onClick:()=>c("/pricing"),children:"Subscribe"})});return}p({title:"Restore failed",description:"Something went wrong. Please try again.",variant:"destructive"})}});if(P)return e.jsx("div",{className:n,style:x,children:e.jsxs("div",{className:o,children:[e.jsx(X,{className:"h-10 w-10 animate-spin mb-4 text-primary"}),e.jsx("p",{className:"text-center text-sm text-gray-200",children:"Restoring this video… this can take a minute or two."})]})});const T=(i==null?void 0:i.subscriptionStatus)==="active"||(i==null?void 0:i.isAdmin);return e.jsx("div",{className:n,style:x,children:e.jsxs("div",{className:o,children:[e.jsx(Rt,{className:"h-10 w-10 mb-4 text-gray-300"}),e.jsx("p",{className:"text-center font-semibold text-lg mb-2",children:"This video has been archived"}),T?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-center text-sm text-gray-300 mb-4 max-w-md",children:"Bring it back online. It'll be ready in about a minute."}),e.jsx(U,{onClick:()=>y.mutate(),disabled:y.isPending,children:y.isPending?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}),"Restoring..."]}):"Restore video"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-center text-sm text-gray-300 mb-4 max-w-md",children:"Subscribe to restore this video and keep it available."}),e.jsx(U,{onClick:()=>c("/pricing"),children:"Subscribe"})]})]})})}const qt=["❤️","👍","🔥","👏"];function Ae(a){const i=Math.max(0,Math.floor(a)),p=Math.floor(i/3600),c=Math.floor(i%3600/60),b=i%60;return p>0?`${p}:${String(c).padStart(2,"0")}:${String(b).padStart(2,"0")}`:`${c}:${String(b).padStart(2,"0")}`}function $t(a){return new Date(a).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function Ft(a){return a.trim().split(/\s+/).map(i=>i[0]).slice(0,2).join("").toUpperCase()||"U"}function At({videoApiId:a,playerRef:i,authorName:p}){const{user:c}=ve(),{toast:b}=oe(),u=[`/api/videos/${a}/comments`],{data:o,isLoading:x}=ge({queryKey:u,queryFn:async()=>await(await B("GET",`/api/videos/${a}/comments`,void 0,{omitCredentials:!1})).json(),enabled:!!a}),n=(o==null?void 0:o.comments)||[],P=n.reduce((A,O)=>{var Y;return A+1+(((Y=O.replies)==null?void 0:Y.length)||0)},0),[y,T]=f.useState(""),[j,E]=f.useState(null),[G,$]=f.useState(!1),h=f.useRef(null),l=f.useCallback(()=>{var O,Y,ue,pe;const A=((Y=(O=i.current)==null?void 0:O.getCurrentTime)==null?void 0:Y.call(O))??0;(pe=(ue=i.current)==null?void 0:ue.pause)==null||pe.call(ue),E(A),$(!0)},[i]),H=ne({mutationFn:async A=>await(await B("POST",`/api/videos/${a}/comments`,A,{omitCredentials:!1})).json(),onSuccess:()=>{z.invalidateQueries({queryKey:u}),T(""),E(null),$(!1)},onError:()=>b({title:"Couldn't post comment",description:"Please try again.",variant:"destructive"})}),F=ne({mutationFn:async A=>{await B("DELETE",`/api/comments/${A}`,void 0,{omitCredentials:!1})},onSuccess:()=>z.invalidateQueries({queryKey:u}),onError:()=>b({title:"Couldn't delete comment",variant:"destructive"})}),q=ne({mutationFn:async({commentId:A,emoji:O})=>{await B("POST",`/api/comments/${A}/reactions`,{emoji:O},{omitCredentials:!1})},onSuccess:()=>z.invalidateQueries({queryKey:u})}),K=()=>{b({title:"Sign in to join the conversation",description:"Comments require an account."})},D=A=>{var O,Y;A!=null&&((Y=(O=i.current)==null?void 0:O.seekTo)==null||Y.call(O,A))},le=()=>{y.trim()&&H.mutate({body:y.trim(),videoTs:j,parentId:null})},ce=p?`Respond to ${p.split(/\s+/)[0]}…`:"Add a comment…";return e.jsxs("div",{className:"flex flex-col h-full",children:[c?e.jsxs("div",{className:`rounded-lg border bg-card p-3 transition-shadow ${G?"ring-1 ring-primary/30":""}`,children:[e.jsx(Ve,{ref:h,value:y,onChange:A=>T(A.target.value),onFocus:l,placeholder:ce,className:"min-h-[44px] resize-none border-0 focus-visible:ring-0 p-0 shadow-none text-sm",maxLength:2e3}),(G||y)&&e.jsxs("div",{className:"flex items-center justify-between mt-2 pt-2 border-t",children:[e.jsx("button",{type:"button",onClick:()=>D(j),className:"text-xs font-medium text-blue-600 hover:underline",title:"Jump to this moment",children:j!=null?`at ${Ae(j)}`:""}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{T(""),$(!1),E(null)},children:"Cancel"}),e.jsx(U,{size:"sm",disabled:!y.trim()||H.isPending,onClick:le,children:H.isPending?e.jsx(X,{className:"h-4 w-4 animate-spin"}):j!=null?`Comment at ${Ae(j)}`:"Comment"})]})]})]}):e.jsx("div",{className:"rounded-lg border bg-muted/40 px-4 py-3 text-sm text-muted-foreground",children:"Sign in to leave a comment."}),e.jsxs("h3",{className:"text-sm font-semibold mt-4 mb-3",children:[P," ",P===1?"Comment":"Comments"]}),x?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm py-4",children:[e.jsx(X,{className:"h-4 w-4 animate-spin"})," Loading comments…"]}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No comments yet. Be the first to add one."}):e.jsx("div",{className:"space-y-6",children:n.map(A=>e.jsx(it,{comment:A,currentUserId:(c==null?void 0:c.id)??null,canComment:!!c,onSeek:D,onDelete:O=>F.mutate(O),onReact:(O,Y)=>c?q.mutate({commentId:O,emoji:Y}):K(),onReply:(O,Y)=>c?H.mutate({body:Y,videoTs:null,parentId:O}):K(),isReplyPending:H.isPending},A.id))})]})}function it({comment:a,currentUserId:i,canComment:p,isReply:c=!1,onSeek:b,onDelete:u,onReact:o,onReply:x,isReplyPending:n}){const{toast:P}=oe(),[y,T]=f.useState(!1),[j,E]=f.useState(""),G=i!=null&&a.userId===i,$=()=>{if(!p){P({title:"Sign in to reply",description:"Comments require an account."});return}T(h=>!h)};return e.jsx("div",{className:c?"pl-4 border-l-2 border-muted ml-2":"",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(yt,{className:"h-8 w-8 shrink-0",children:e.jsx(wt,{className:"text-xs",children:Ft(a.authorName)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-sm",children:a.authorName}),a.videoTs!=null&&e.jsxs("button",{type:"button",onClick:()=>b(a.videoTs),className:"inline-flex items-center rounded-full bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-600 hover:bg-blue-100",title:"Jump to this moment",children:["Commented at ",Ae(a.videoTs)]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:$t(a.createdAt)}),G&&e.jsx("button",{type:"button",onClick:()=>u(a.id),className:"ml-auto text-muted-foreground hover:text-destructive",title:"Delete","aria-label":"Delete comment",children:e.jsx(rt,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap break-words",children:a.body}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 flex-wrap",children:[a.reactions.map(h=>e.jsxs("button",{type:"button","aria-label":`React ${h.emoji}`,"aria-pressed":h.mine,onClick:()=>o(a.id,h.emoji),className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs transition-colors ${h.mine?"border-blue-400 bg-blue-50":"border-transparent bg-muted hover:bg-muted/70"}`,children:[e.jsx("span",{children:h.emoji}),e.jsx("span",{className:"text-muted-foreground",children:h.count})]},h.emoji)),e.jsx("div",{className:"inline-flex items-center gap-0.5 ml-1",children:qt.filter(h=>!a.reactions.some(l=>l.emoji===h)).map(h=>e.jsx("button",{type:"button","aria-label":`React ${h}`,onClick:()=>o(a.id,h),className:"text-sm opacity-40 hover:opacity-100 transition-opacity px-0.5",children:h},h))}),!c&&e.jsx("button",{type:"button",onClick:$,className:"ml-2 text-xs font-semibold text-muted-foreground hover:text-foreground",children:"Reply"})]}),y&&!c&&e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx(Ut,{className:"h-4 w-4 text-muted-foreground mt-2 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Ve,{value:j,onChange:h=>E(h.target.value),placeholder:"Write a reply…",className:"min-h-[56px] resize-none text-sm",maxLength:2e3,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{T(!1),E("")},children:"Cancel"}),e.jsx(U,{size:"sm",disabled:!j.trim()||n,onClick:()=>{x(a.id,j.trim()),E(""),T(!1)},children:"Reply"})]})]})]}),a.replies&&a.replies.length>0&&e.jsx("div",{className:"mt-4 space-y-4",children:a.replies.map(h=>e.jsx(it,{comment:h,currentUserId:i,canComment:p,isReply:!0,onSeek:b,onDelete:u,onReact:o,onReply:x,isReplyPending:n},h.id))})]})]})})}function Ye({videoApiId:a,playerRef:i,authorName:p}){return e.jsxs("section",{className:"w-full border rounded-xl bg-card overflow-hidden",children:[e.jsx("div",{className:"px-4 pt-3 pb-2 border-b",children:e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:"Comments"})}),e.jsx("div",{className:"p-4",children:e.jsx(At,{videoApiId:a,playerRef:i,authorName:p})})]})}function Vt(a){return a<60?`${a}s`:`${Math.floor(a/60)}m ${Math.round(a%60)}s`}function Dt(a){const i=new Date(a);return i.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+i.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function Ot({videoId:a,videoApiId:i}){const{toast:p}=oe(),{data:c,isLoading:b}=ge({queryKey:[`/api/videos/${i}/viewers`],refetchInterval:3e4}),u=ne({mutationFn:async n=>B("PATCH",`/api/videos/${a}/viewer-identity`,{required:n}),onSuccess:(n,P)=>{p({title:P?"Viewer identification on":"Viewer identification off",description:P?"Viewers must enter the
11ir name and email before watching (here and in embeds).":"Anyone can watch without identifying."}),z.invalidateQueries({queryKey:[`/api/videos/${i}/viewers`]}),z.invalidateQueries({queryKey:[`/api/videos/${i}`]}),z.invalidateQueries({queryKey:[`/api/videos/${a}`]})},onError:n=>{var y;const P=((y=n==null?void 0:n.response)==null?void 0:y.status)??(n==null?void 0:n.status);p(P===403?{title:"Pro feature",description:"Viewer identification requires Pro or above. Upgrade to turn it on.",variant:"destructive"}:{title:"Error",description:"Could not update the setting. Please try again.",variant:"destructive"})}}),o=c==null?void 0:c.summary,x=!!(c!=null&&c.gated);return e.jsxs("div",{className:"mt-6 rounded-lg border border-border p-4","data-testid":"viewers-panel",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(jt,{className:"h-5 w-5 text-primary","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["Who watched ",e.jsxs("span",{className:"ml-1 inline-flex items-center rounded-full bg-primary/15 text-primary px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide",children:[e.jsx(Pe,{className:"h-3 w-3 mr-0.5"})," Pro"]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Proof of viewing: a per-viewer watch record for this video."})]})]}),c&&c.viewers.length>0&&(x?e.jsx(U,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs(qe,{href:"/pricing",children:[e.jsx(Pe,{className:"h-4 w-4 mr-1"})," Upgrade to export"]})}):e.jsx(U,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs("a",{href:`/api/videos/${i}/viewers.csv`,download:!0,children:[e.jsx(Nt,{className:"h-4 w-4 mr-1"})," Export CSV"]})}))]}),x&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-primary/30 bg-primary/5 px-3 py-2 mt-3",children:[e.jsxs("p",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",children:"Named viewer reports start on Pro."})," ","Upgrade to reveal names and emails, require viewer identity, and export CSV reports."]}),e.jsx(U,{asChild:!0,size:"sm",children:e.jsx(qe,{href:"/pricing",children:"Upgrade"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-muted/50 px-3 py-2 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ct,{className:"h-4 w-4 text-muted-foreground","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:"Require viewers to identify"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:x?"Pro feature. Upgrade to ask viewers for name + email before playback.":"Ask for name + email before playback (site and embeds). Logged-in viewers are identified automatically."})]})]}),e.jsx(bt,{checked:!!(c!=null&&c.requireViewerIdentity),disabled:b||u.isPending||x&&!(c!=null&&c.requireViewerIdentity),onCheckedChange:n=>u.mutate(n),"aria-label":"Require viewers to identify before watching"})]}),b?e.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:e.jsx(X,{className:"h-5 w-5 animate-spin"})}):!c||c.viewers.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1 py-8 text-center text-muted-foreground",children:[e.jsx(kt,{className:"h-6 w-6","aria-hidden":"true"}),e.jsx("p",{className:"text-sm",children:"No viewer sessions yet"}),e.jsx("p",{className:"text-xs",children:"When someone watches this video (here or in an embed), they'll show up here."})]}):e.jsxs(e.Fragment,{children:[o&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3 text-xs",children:[e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1",children:[o.total," viewer",o.total===1?"":"s"]}),e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1",children:[o.identified," identified"]}),e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1",children:[o.completionRate,"% completed"]}),e.jsxs("span",{className:"rounded-full bg-secondary px-2.5 py-1",children:["avg ",o.avgPercentWatched,"% watched"]})]}),e.jsx("div",{className:"mt-3 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-muted-foreground border-b border-border",children:[e.jsx("th",{className:"py-2 pr-3 font-medium",children:"Viewer"}),e.jsx("th",{className:"py-2 pr-3 font-medium",children:"Watched"}),e.jsx("th",{className:"py-2 pr-3 font-medium",children:"Progress"}),e.jsx("th",{className:"py-2 pr-3 font-medium",children:"Where"}),e.jsx("th",{className:"py-2 font-medium",children:"Last seen"})]})}),e.jsx("tbody",{children:c.viewers.map(n=>e.jsxs("tr",{className:"border-b border-border/50 last:border-0",children:[e.jsx("td",{className:"py-2 pr-3",children:n.viewerName||n.viewerEmail?e.jsxs("div",{className:x?"blur-[3px] select-none pointer-events-none":void 0,"aria-hidden":x||void 0,children:[e.jsx("div",{className:"font-medium",children:n.viewerName||n.viewerEmail}),n.viewerName&&n.viewerEmail&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n.viewerEmail})]}):e.jsx("span",{className:"text-muted-foreground",children:"Anonymous"})}),e.jsx("td",{className:"py-2 pr-3 whitespace-nowrap",children:Vt(n.watchedSeconds)}),e.jsx("td",{className:"py-2 pr-3",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-[110px]",children:[e.jsx("div",{className:"h-1.5 w-16 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${n.completed?"bg-green-500":"bg-primary"}`,style:{width:`${n.percentWatched}%`}})}),e.jsxs("span",{className:"text-xs whitespace-nowrap",children:[n.percentWatched,"%",n.completed?" ✓":""]})]})}),e.jsx("td",{className:"py-2 pr-3 text-xs text-muted-foreground",children:n.context==="embed"?n.pageUrl&&new URL(n.pageUrl,"https://x").hostname||"embed":"viddler.com"}),e.jsx("td",{className:"py-2 text-xs text-muted-foreground whitespace-nowrap",children:Dt(n.lastSeenAt)})]},n.id))})]})})]})]})}const Wt=[{emoji:"❤️",label:"heart"},{emoji:"👍",label:"yes"},{emoji:"🔥",label:"fire"},{emoji:"👏",label:"clap"},{emoji:"🎉",label:"yay"},{emoji:"👀",label:"eyes"}];function Ze({videoApiId:a}){const{user:i}=ve(),{toast:p}=oe(),c=[`/api/videos/${a}/reactions`],{data:b}=ge({queryKey:c,queryFn:async()=>await(await B("GET",`/api/videos/${a}/reactions`,void 0,{omitCredentials:!1})).json(),enabled:!!a}),u=new Map(((b==null?void 0:b.reactions)||[]).map(n=>
vendor: 3,742 bytes, lines 11-12
11[n.emoji,n])),o=ne({mutationFn:async n=>{await B("POST",`/api/videos/${a}/reactions`,{emoji:n},{omitCredentials:!1})},onSuccess:()=>z.invalidateQueries({queryKey:c}),onError:()=>p({title:"Couldn't react",variant:"destructive"})}),x=n=>{if(!i){p({title:"Sign in to react",description:"Reactions require an account."});return}o.mutate(n)};return e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap","aria-label":"Video reactions",children:[Wt.map(({emoji:n,label:P})=>{const y=u.get(n),T=y==null?void 0:y.mine;return e.jsxs("button",{type:"button","aria-label":P,"aria-pressed":!!T,onClick:()=>x(n),className:`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 text-sm transition-colors ${T?"border-blue-400 bg-blue-50":"border-border bg-background hover:bg-muted"}`,children:[e.jsx("span",{"aria-hidden":!0,children:n}),y&&y.count>0&&e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:y.count})]},n)}),!i&&e.jsx("a",{href:"/login",className:"text-xs text-muted-foreground hover:text-foreground hover:underline ml-1 self-center",children:"Sign in to react"})]})}var De={};(function a(i,p,c,b){var u=!!(i.Worker&&i.Blob&&i.Promise&&i.OffscreenCanvas&&i.OffscreenCanvasRenderingContext2D&&i.HTMLCanvasElement&&i.HTMLCanvasElement.prototype.transferControlToOffscreen&&i.URL&&i.URL.createObjectURL),o=typeof Path2D=="function"&&typeof DOMMatrix=="function",x=function(){if(!i.OffscreenCanvas)return!1;var r=new OffscreenCanvas(1,1),s=r.getContext("2d");s.fillRect(0,0,1,1);var m=r.transferToImageBitmap();try{s.createPattern(m,"no-repeat")}catch{return!1}return!0}();function n(){}function P(r){var s=p.exports.Promise,m=s!==void 0?s:i.Promise;return typeof m=="function"?new m(r):(r(n,n),null)}var y=function(r,s){return{transform:function(m){if(r)return m;if(s.has(m))return s.get(m);var v=new OffscreenCanvas(m.width,m.height),w=v.getContext("2d");return w.drawImage(m,0,0),s.set(m,v),v},clear:function(){s.clear()}}}(x,new Map),T=function(){var r=Math.floor(16.666666666666668),s,m,v={},w=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(s=function(N){var k=Math.random();return v[k]=requestAnimationFrame(function g(C){w===C||w+r-1<C?(w=C,delete v[k],N()):v[k]=requestAnimationFrame(g)}),k},m=function(N){v[N]&&cancelAnimationFrame(v[N])}):(s=function(N){return setTimeout(N,r)},m=function(N){return clearTimeout(N)}),{frame:s,cancel:m}}(),j=function(){var r,s,m={};function v(w){function N(k,g){w.postMessage({options:k||{},callback:g})}w.init=function(g){var C=g.transferControlToOffscreen();w.postMessage({canvas:C},[C])},w.fire=function(g,C,R){if(s)return N(g,null),s;var V=Math.random().toString(36).slice(2);return s=P(function(L){function W(Q){Q.data.callback===V&&(delete m[V],w.removeEventListener("message",W),s=null,y.clear(),R(),L())}w.addEventListener("message",W),N(g,V),m[V]=W.bind(null,{data:{callback:V}})}),s},w.reset=function(){w.postMessage({reset:!0});for(var g in m)m[g](),delete m[g]}}return function(){if(r)return r;if(!c&&u){var w=["var CONFETTI, SIZE = {}, module = {};","("+a.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {","  if (msg.data.options) {","    CONFETTI(msg.data.options).then(function () {","      if (msg.data.callback) {","        postMessage({ callback: msg.data.callback });","      }","    });","  } else if (msg.data.reset) {","    CONFETTI && CONFETTI.reset();","  } else if (msg.data.resize) {","    SIZE.width = msg.data.resize.width;","    SIZE.height = msg.data.resize.height;","  } else if (msg.data.canvas) {","    SIZE.width = msg.data.canvas.width;","    SIZE.height = msg.data.canvas.height;","    CONFETTI = module.exports.create(msg.data.canvas);","  }","}"].join(`
12`);
vendor: 4,237 bytes, line 12
12try{r=new Worker(URL.createObjectURL(new Blob([w])))}catch(N){return typeof console!==void 0&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",N),null}v(r)}return r}}(),E={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function G(r,s){return s?s(r):r}function $(r){return r!=null}function h(r,s,m){return G(r&&$(r[s])?r[s]:E[s],m)}function l(r){return r<0?0:Math.floor(r)}function H(r,s){return Math.floor(Math.random()*(s-r))+r}function F(r){return parseInt(r,16)}function q(r){return r.map(K)}function K(r){var s=String(r).replace(/[^0-9a-f]/gi,"");return s.length<6&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]),{r:F(s.substring(0,2)),g:F(s.substring(2,4)),b:F(s.substring(4,6))}}function D(r){var s=h(r,"origin",Object);return s.x=h(s,"x",Number),s.y=h(s,"y",Number),s}function le(r){r.width=document.documentElement.clientWidth,r.height=document.documentElement.clientHeight}function ce(r){var s=r.getBoundingClientRect();r.width=s.width,r.height=s.height}function A(r){var s=document.createElement("canvas");return s.style.position="fixed",s.style.top="0px",s.style.left="0px",s.style.pointerEvents="none",s.style.zIndex=r,s}function O(r,s,m,v,w,N,k,g,C){r.save(),r.translate(s,m),r.rotate(N),r.scale(v,w),r.arc(0,0,1,k,g,C),r.restore()}function Y(r){var s=r.angle*(Math.PI/180),m=r.spread*(Math.PI/180);return{x:r.x,y:r.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:r.startVelocity*.5+Math.random()*r.startVelocity,angle2D:-s+(.5*m-Math.random()*m),tiltAngle:(Math.random()*(.75-.25)+.25)*Math.PI,color:r.color,shape:r.shape,tick:0,totalTicks:r.ticks,decay:r.decay,drift:r.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:r.gravity*3,ovalScalar:.6,scalar:r.scalar,flat:r.flat}}function ue(r,s){s.x+=Math.cos(s.angle2D)*s.velocity+s.drift,s.y+=Math.sin(s.angle2D)*s.velocity+s.gravity,s.velocity*=s.decay,s.flat?(s.wobble=0,s.wobbleX=s.x+10*s.scalar,s.wobbleY=s.y+10*s.scalar,s.tiltSin=0,s.tiltCos=0,s.random=1):(s.wobble+=s.wobbleSpeed,s.wobbleX=s.x+10*s.scalar*Math.cos(s.wobble),s.wobbleY=s.y+10*s.scalar*Math.sin(s.wobble),s.tiltAngle+=.1,s.tiltSin=Math.sin(s.tiltAngle),s.tiltCos=Math.cos(s.tiltAngle),s.random=Math.random()+2);var m=s.tick++/s.totalTicks,v=s.x+s.random*s.tiltCos,w=s.y+s.random*s.tiltSin,N=s.wobbleX+s.random*s.tiltCos,k=s.wobbleY+s.random*s.tiltSin;if(r.fillStyle="rgba("+s.color.r+", "+s.color.g+", "+s.color.b+", "+(1-m)+")",r.beginPath(),o&&s.shape.type==="path"&&typeof s.shape.path=="string"&&Array.isArray(s.shape.matrix))r.fill($e(s.shape.path,s.shape.matrix,s.x,s.y,Math.abs(N-v)*.1,Math.abs(k-w)*.1,Math.PI/10*s.wobble));else if(s.shape.type==="bitmap"){var g=Math.PI/10*s.wobble,C=Math.abs(N-v)*.1,R=Math.abs(k-w)*.1,V=s.shape.bitmap.width*s.scalar,L=s.shape.bitmap.height*s.scalar,W=new DOMMatrix([Math.cos(g)*C,Math.sin(g)*C,-Math.sin(g)*R,Math.cos(g)*R,s.x,s.y]);W.multiplySelf(new DOMMatrix(s.shape.matrix));var Q=r.createPattern(y.transform(s.shape.bitmap),"no-repeat");Q.setTransform(W),r.globalAlpha=1-m,r.fillStyle=Q,r.fillRect(s.x-V/2,s.y-L/2,V,L),r.globalAlpha=1}else if(s.shape==="circle")r.ellipse?r.ellipse(s.x,s.y,Math.abs(N-v)*s.ovalScalar,Math.abs(k-w)*s.ovalScalar,Math.PI/10*s.wobble,0,2*Math.PI):O(r,s.x,s.y,Math.abs(N-v)*s.ovalScalar,Math.abs(k-w)*s.ovalScalar,Math.PI/10*s.wobble,0,2*Math.PI);else if(s.shape==="star")for(var S=Math.PI/2*3,Z=4*s.scalar,re=8*s.scalar,ae=s.x,J=s.y,de=5,ie=Math.PI/de;de--;)ae=s.x+Math.cos(S)*re,J=s.y+Math.sin(S)*re,r.lineTo(ae,J),S+=ie,ae=s.x+Math.cos(S)*Z,J=s.y+Math.sin(S)*Z,r.lineTo(ae,J),S+=ie;else r.moveTo(Math.floor(s.x),Math.floor(s.y)),r.lineTo(Math.floor(s.wobbleX),Math.floor(w)),r.lineTo(Math.floor(N),Math.floor(k)),r.lineTo(Math.floor(v),Math.floor(s.wobbleY));return r.closePath(),r.fill(),s.tick<s.totalTicks}function pe(r,s,m,v,w){var N=s.slice(),k=r.getContext("2d"),g,C,R=P(function(V){function L(){g=C=null,k.clearRect(0,0,v.width,v.height),y.clear(),w(),V()}function W(){c&&!(v.width===b.width&&v.height===b.height)&&(v.width=r.width=b.
vendor: 4,151 bytes, line 12
12width,v.height=r.height=b.height),!v.width&&!v.height&&(m(r),v.width=r.width,v.height=r.height),k.clearRect(0,0,v.width,v.height),N=N.filter(function(Q){return ue(k,Q)}),N.length?g=T.frame(W):L()}g=T.frame(W),C=L});return{addFettis:function(V){return N=N.concat(V),R},canvas:r,promise:R,reset:function(){g&&T.cancel(g),C&&C()}}}function se(r,s){var m=!r,v=!!h(s||{},"resize"),w=!1,N=h(s,"disableForReducedMotion",Boolean),k=u&&!!h(s||{},"useWorker"),g=k?j():null,C=m?le:ce,R=r&&g?!!r.__confetti_initialized:!1,V=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,L;function W(S,Z,re){for(var ae=h(S,"particleCount",l),J=h(S,"angle",Number),de=h(S,"spread",Number),ie=h(S,"startVelocity",Number),Se=h(S,"decay",Number),Me=h(S,"gravity",Number),Ee=h(S,"drift",Number),Ne=h(S,"colors",q),Fe=h(S,"ticks",Number),Ce=h(S,"shapes"),Ie=h(S,"scalar"),Te=!!h(S,"flat"),ke=D(S),d=ae,_=[],I=r.width*ke.x,M=r.height*ke.y;d--;)_.push(Y({x:I,y:M,angle:J,spread:de,startVelocity:ie,color:Ne[d%Ne.length],shape:Ce[H(0,Ce.length)],ticks:Fe,decay:Se,gravity:Me,drift:Ee,scalar:Ie,flat:Te}));return L?L.addFettis(_):(L=pe(r,_,C,Z,re),L.promise)}function Q(S){var Z=N||h(S,"disableForReducedMotion",Boolean),re=h(S,"zIndex",Number);if(Z&&V)return P(function(ie){ie()});m&&L?r=L.canvas:m&&!r&&(r=A(re),document.body.appendChild(r)),v&&!R&&C(r);var ae={width:r.width,height:r.height};g&&!R&&g.init(r),R=!0,g&&(r.__confetti_initialized=!0);function J(){if(g){var ie={getBoundingClientRect:function(){if(!m)return r.getBoundingClientRect()}};C(ie),g.postMessage({resize:{width:ie.width,height:ie.height}});return}ae.width=ae.height=null}function de(){L=null,v&&(w=!1,i.removeEventListener("resize",J)),m&&r&&(document.body.contains(r)&&document.body.removeChild(r),r=null,R=!1)}return v&&!w&&(w=!0,i.addEventListener("resize",J,!1)),g?g.fire(S,ae,de):W(S,ae,de)}return Q.reset=function(){g&&g.reset(),L&&L.reset()},Q}var me;function ee(){return me||(me=se(null,{useWorker:!0,resize:!0})),me}function $e(r,s,m,v,w,N,k){var g=new Path2D(r),C=new Path2D;C.addPath(g,new DOMMatrix(s));var R=new Path2D;return R.addPath(C,new DOMMatrix([Math.cos(k)*w,Math.sin(k)*w,-Math.sin(k)*N,Math.cos(k)*N,m,v])),R}function fe(r){if(!o)throw new Error("path confetti are not supported in this browser");var s,m;typeof r=="string"?s=r:(s=r.path,m=r.matrix);var v=new Path2D(s),w=document.createElement("canvas"),N=w.getContext("2d");if(!m){for(var k=1e3,g=k,C=k,R=0,V=0,L,W,Q=0;Q<k;Q+=2)for(var S=0;S<k;S+=2)N.isPointInPath(v,Q,S,"nonzero")&&(g=Math.min(g,Q),C=Math.min(C,S),R=Math.max(R,Q),V=Math.max(V,S));L=R-g,W=V-C;var Z=10,re=Math.min(Z/L,Z/W);m=[re,0,0,re,-Math.round(L/2+g)*re,-Math.round(W/2+C)*re]}return{type:"path",path:s,matrix:m}}function t(r){var s,m=1,v="#000000",w='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';typeof r=="string"?s=r:(s=r.text,m="scalar"in r?r.scalar:m,w="fontFamily"in r?r.fontFamily:w,v="color"in r?r.color:v);var N=10*m,k=""+N+"px "+w,g=new OffscreenCanvas(N,N),C=g.getContext("2d");C.font=k;var R=C.measureText(s),V=Math.ceil(R.actualBoundingBoxRight+R.actualBoundingBoxLeft),L=Math.ceil(R.actualBoundingBoxAscent+R.actualBoundingBoxDescent),W=2,Q=R.actualBoundingBoxLeft+W,S=R.actualBoundingBoxAscent+W;V+=W+W,L+=W+W,g=new OffscreenCanvas(V,L),C=g.getContext("2d"),C.font=k,C.fillStyle=v,C.fillText(s,Q,S);var Z=1/m;return{type:"bitmap",bitmap:g.transferToImageBitmap(),matrix:[Z,0,0,Z,-V*Z/2,-L*Z/2]}}p.exports=function(){return ee().apply(this,arguments)},p.exports.reset=function(){ee().reset()},p.exports.create=se,p.exports.shapeFromPath=fe,p.exports.shapeFromText=t})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),De,!1);const _t=De.exports;De.exports.create;function Je({videoId:a,initialValue:i,fieldName:p,isInlineEdit:c=!0,disabled:b=!1,multiline:u=!1,placeholder:o="",maxLength:x=100}){const[n,P]=f.useState(!1),[y,T]=f.useState(i||""),j=f.useRef(null),{toast:E}=oe();f.useEffect(()=>{T(i||"")},[i]),f.useEffect(()=>{n&&j.current&&j.current.focus()},[n]);const G=async()=>
12{if(y===i){P(!1);return}try{await B("PATCH",`/api/videos/${a}/${p}`,{[p]:y}),z.invalidateQueries({queryKey:[`/api/videos/${a}`]}),E({title:"Success",description:`${p.charAt(0).toUpperCase()+p.slice(1)} updated successfully`}),P(!1)}catch(l){console.error(`Error updating ${p}:`,l),E({title:"Error",description:`Failed to update ${p}. Please try again.`,variant:"destructive"})}},$=()=>{T(i||""),P(!1)},h=l=>{l.key==="Enter"&&!u?G():l.key==="Escape"&&$()};return n?e.jsxs("div",{className:"flex flex-col space-y-2",children:[u?e.jsx(Ve,{ref:j,value:y,onChange:l=>T(l.target.value),onKeyDown:h,placeholder:o,rows:4,maxLength:x,className:"resize-none"}):e.jsx(at,{ref:j,value:y,onChange:l=>T(l.target.value),onKeyDown:h,placeholder:o,maxLength:x,className:p==="title"?"min-w-[300px] md:min-w-[500px]":""}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(U,{size:"sm",variant:"default",onClick:G,children:[e.jsx(tt,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsxs(U,{size:"sm",variant:"secondary",onClick:$,children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),"Cancel"]})]})]}):e.jsxs("div",{className:`relative group ${c?"cursor-pointer":""}`,onClick:c&&!b?()=>P(!0):void 0,children:[u?e.jsx("p",{className:"whitespace-pre-wrap",children:i||e.jsxs("span",{className:"text-muted-foreground italic",children:["No ",p," provided"]})}):e.jsx("span",{children:i||e.jsxs("span",{className:"text-muted-foreground italic",children:["No ",p," provided"]})}),!b&&!c&&e.jsx(U,{variant:"ghost",size:"sm",className:"ml-2",onClick:()=>P(!0),children:"Edit"})]})}function zt({videoId:a,initialValue:i,disabled:p=!1}){const[c,b]=f.useState(!1),[u,o]=f.useState(i||""),[x,n]=f.useState(""),P=f.useRef(null),{toast:y}=oe(),{user:T}=ve(),{logEvent:j}=ot(),E=ft(T),G=()=>{j("custom_url_upgrade_clicked",void 0,{videoId:a}),y({title:"Custom URLs are a Pro feature",description:"Upgrade to set a custom viddler.com/your-name link."})};f.useEffect(()=>{o(i||"")},[i]),f.useEffect(()=>{c&&P.current&&P.current.focus()},[c]);const $=q=>!q||/^[a-zA-Z0-9_-]+$/.test(q),h=async q=>{if(!q||q.trim()===""||q===i)return!0;try{return(await(await fetch(`/api/videos/check-url/${q}`)).json()).available}catch(K){return console.error("Error checking URL availability:",K),!1}},l=async()=>{var q,K;if(n(""),u===i){b(!1);return}if(!$(u)){n("Custom URL can only contain letters, numbers, dashes and underscores");return}try{if(!await h(u)){n("This custom URL is already in use");return}await B("PATCH",`/api/videos/${a}/custom-url`,{customUrl:u}),z.invalidateQueries({queryKey:[`/api/videos/${a}`]}),y({title:"Success",description:"Custom URL updated successfully"}),b(!1)}catch(D){console.error("Error updating custom URL:",D),(q=D==null?void 0:D.message)!=null&&q.includes("already in use")?n("This custom URL is already in use"):(K=D==null?void 0:D.message)!=null&&K.startsWith("403")?(G(),b(!1)):y({title:"Error",description:"Failed to update custom URL. Please try again.",variant:"destructive"})}},H=()=>{o(i||""),n(""),b(!1)},F=q=>{q.key==="Enter"?l():q.key==="Escape"&&H()};return c?e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-center absolute inset-y-0 left-0 pl-3 pointer-events-none",children:e.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:"viddler.com/"})}),e.jsx(at,{ref:P,value:u,onChange:q=>o(q.target.value),onKeyDown:F,placeholder:"my-video-name",className:"pl-[105px]",maxLength:50})]}),x&&e.jsx("p",{className:"text-sm text-destructive",children:x}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use only letters, numbers, hyphens and underscores"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(U,{size:"sm",variant:"default",onClick:l,children:[e.jsx(tt,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsxs(U,{size:"sm",variant:"secondary",onClick:H,children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),"Cancel"]})]})]}):i?e.jsx("div",{className:"inline-flex items-center rounded-md bg-primary/10 px-2.5 py-1.5 text-sm font-medium transition-colors hover:bg-primary/20 cursor-pointer group",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"viddler.com/"}),e.jsx("strong",{className:"ml-0.5 text-primary",children:i}),e.jsxs("div",{className:"ml-2 flex items-center space-x-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{className:"text-primary/80 hover:text-primary",title:"Copy URL",onClick:q=>{q.stopPropagation();const K=`https://viddler.com/${i}`;navigator.clipboard.writeText(K),y({title:"Link Copied",description:"Custom URL copied to clipboard"})},children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-3.5 w-3.5",children:[e.jsx("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),e.jsx("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}),!p&&e.jsx("button",{className:"text-primary/80 hover:text-primary",title:E?"Edit URL":"Custom URLs are a Pro feature",onClick:q=>{if(q.stopPropagation(),!E){G();return}b(!0)},children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-3.5 w-3.5",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})})]})]})}):E?e.jsxs("div",{className:"inline-flex items-center rounded-md bg-muted px-2.5 py-1.5 text-sm font-medium text-muted-foreground hover:bg-muted/80 cursor-pointer",onClick:()=>!p&&b(!0),children:[e.jsx("span",{children:"No custom URL"}),!p&&e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"ml-1.5 h-3.5 w-3.5",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})]}):e.jsxs(qe,{href:"/pricing",onClick:()=>j("custom_url_upgrade_clicked",void 0,{videoId:a}),className:"inline-flex items-center rounded-md bg-muted px-2.5 py-1.5 text-sm font-medium text-muted-foreground hover:bg-muted/80 cursor-pointer",children:[e.jsx(Pe,{className:"mr-1.5 h-3.5 w-3.5 text-primary"}),e.jsx("span",{children:"Custom URL"}),e.jsx("span",{className:"ml-1.5 inline-flex items-center rounded-full bg-primary/15 text-primary px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide",children:"Pro"})]})}function Bt(){var P,y,T;const{user:a}=ve(),i=lt(),p=f.useRef(0),c=f.useRef(0),b=ge({queryKey:["/api/usage"],enabled:!!a}),u=ge({queryKey:["/api/usage/check-limit"],enabled:!!a,refetchOnWindowFocus:!0}),o=ne({mutationFn:async j=>(await B("POST","/api/usage/track",{minutes:j})).json(),onSuccess:()=>{i.invalidateQueries({queryKey:["/api/usage"]}),i.invalidateQueries({queryKey:["/api/usage/check-limit"]})}}),x=f.useCallback(j=>{if(!a)return;const E=Date.now(),G=j/60;if(c.current+=G,E-p.current>=6e4&&c.current>=1){const $=Math.floor(c.current);$>0&&(o.mutate($),c.current-=$,p.current=E)}},[a,o]),n=f.useCallback(()=>
12{if(!a||c.current<.1)return;const j=Math.max(.1,c.current);j>0&&(o.mutate(j),c.current=0)},[a,o]);return{usage:b.data,usageCheck:u.data,isLoading:b.isLoading||u.isLoading,trackWatchTime:x,flushWatchTime:n,canWatch:((P=u.data)==null?void 0:P.canWatch)??!0,isApproachingLimit:((y=u.data)==null?void 0:y.isApproachingLimit)??!1,isAtLimit:((T=u.data)==null?void 0:T.isAtLimit)??!1,refetchUsage:()=>{i.invalidateQueries({queryKey:["/api/usage"]}),i.invalidateQueries({queryKey:["/api/usage/check-limit"]})}}}function Kt(a){return!1}function Qt({videoId:a}){const{toast:i}=oe(),p=ne({mutationFn:async()=>await B("POST",`/api/videos/${a}/claim`),onSuccess:()=>{z.invalidateQueries({queryKey:[`/api/videos/${a}`]}),i({title:"Success",description:"You now own this video!"})},onError:c=>{console.error("Error claiming video:",c),i({title:"Error",description:"Failed to claim this video. Please try again.",variant:"destructive"})}});return e.jsx(U,{onClick:()=>p.mutate(),disabled:p.isPending,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"mr-2 h-4 w-4 animate-spin"}),"Claiming..."]}):"Claim This Video"})}function $s({overrideVideoId:a,params:i}){ct();let p;i&&i.id?p=i.id:p=dt().id;const[c,b]=et(),{toast:u}=oe(),{user:o}=ve(),[x,n]=f.useState(!1),[P,y]=f.useState(!1),[T,j]=f.useState(!1),[E,G]=f.useState(!1),$=f.useRef(!1),h=f.useRef(!1),[l,H]=f.useState(null),[F,q]=f.useState(()=>Pt()),{trackWatchTime:K,flushWatchTime:D,isApproachingLimit:le,isAtLimit:ce}=Bt(),[A,O]=f.useState(!1),[Y,ue]=f.useState(!0),pe=f.useRef(0),se=f.useRef(0),me=f.useRef(null),ee=a?String(a):p,$e=typeof window<"u"?window.__VIDDLER_VIDEO_BOOTSTRAP__:void 0,fe=ge({queryKey:[`/api/videos/${ee}`],enabled:!!ee,initialData:$e,initialDataUpdatedAt:0,queryFn:async()=>{try{return await(await B("GET",`/api/videos/${ee}`,void 0,{omitCredentials:!0})).json()}catch(d){throw console.error("Error fetching video:",d),d}}}),t=fe.data,r=fe.isLoading,s=fe.isError;f.useEffect(()=>{const d=new URLSearchParams(window.location.search),_=d.get("quality_upgrade"),I=d.get("quality_session"),M=d.get("quality_video");if(_==="canceled"&&!$.current){/^\d+$/.test(M||"")&&sessionStorage.removeItem(`viddler_quality_checkout:${M}`),$.current=!0,u({title:"Your video stays in 1080p",description:"Nothing was charged. You can upgrade it later from your account."}),window.history.replaceState({},"",window.location.pathname);return}if(!I||!/^cs_[A-Za-z0-9_]+$/.test(I))return;let xe=!1,te;$.current||($.current=!0,u({title:"Your quality upgrade is underway",description:"We are reprocessing this video in premium quality. This page will update automatically."}));const ye=async()=>{var we,be,Re,Ue;try{const Oe=await fetch(`/api/billing/checkout/${encodeURIComponent(I)}/status`,{credentials:"same-origin",cache:"no-store"});if(!Oe.ok)throw new Error("status unavailable");const je=await Oe.json(),We=(we=je.qualityUpgrade)==null?void 0:we.status;if(xe)return;if(We==="completed"){(be=je.qualityUpgrade)!=null&&be.videoId&&sessionStorage.removeItem(`viddler_quality_checkout:${je.qualityUpgrade.videoId}`),await fe.refetch(),u({title:"Premium quality is ready",description:"This same Viddler link now serves the upgraded version."}),window.history.replaceState({},"",window.location.pathname);return}if(We==="failed"){if((Re=je.qualityUpgrade)!=null&&Re.terminal){(Ue=je.qualityUpgrade)!=null&&Ue.videoId&&sessionStorage.removeItem(`viddler_quality_checkout:${je.qualityUpgrade.videoId}`),u({title:"The quality upgrade could not be completed",description:"Your current 1080p version is still available. Please contact support if you would like help."}),window.history.replaceState({},"",window.location.pathname);return}h.current||(h.current=!0,u({title:"We are retrying the quality upgrade",description:"Your current 1080p version is still available. We will keep working on the premium version."}))}}catch{}te=window.setTimeout(ye,5e3)};return ye(),()=>{xe=!0,te&&window.clearTimeout(te)}},[u,fe.refetch]),f.useEffect(()=>{t&&o&&t.userId===o.id&&n(!0)},[t,o]),f.useEffect(()=>{if(!t||!l)return;const d=t.playbackVersion||t.muxPlaybackId,_=t.playbackVersion?l.playbackVersion:l.playbackId;d&&d!==_&&(mt(t.uniqueId||t.id),H(null))},[t==null?void 0:t.id,t==null?void 0:t.muxPlaybackId,t==null?void 0:t.playbackVersion,t==null?void 0:t.uniqueId,l==null?void 0:l.playbackId,l==null?void 0:l.playbackVersion]),f.useEffect(()=>{if(!!(t&&o&&t.userId===o.id)&&(t!=null&&t.isPasswordProtected||t!=null&&t.domainRestricted||t!=null&&t.signedPlaybackRequired)&&!l){let _=!1;return(async()=>{try{const M=await(await B("GET",`/api/videos/${t.id}
12/owner-token`)).json();!_&&(M!=null&&M.token)&&H(M)}catch(I){console.error("Failed to fetch owner playback token:",I)}})(),()=>{_=!0}}},[t==null?void 0:t.id,t==null?void 0:t.isPasswordProtected,t==null?void 0:t.domainRestricted,t==null?void 0:t.signedPlaybackRequired,o==null?void 0:o.id,l]),f.useEffect(()=>{const d=!!(t&&o&&t.userId===o.id);if((t!=null&&t.domainRestricted||t!=null&&t.signedPlaybackRequired)&&!t.isPasswordProtected&&!d&&!l){let _=!1;return B("GET",`/api/videos/${t.id}/share-token`,void 0,{omitCredentials:!0}).then(I=>I.json()).then(I=>{!_&&(I!=null&&I.token)&&H(I)}).catch(I=>console.error("Failed to fetch share playback token:",I)),()=>{_=!0}}},[t==null?void 0:t.id,t==null?void 0:t.domainRestricted,t==null?void 0:t.signedPlaybackRequired,t==null?void 0:t.isPasswordProtected,o==null?void 0:o.id,l]);const m=(t==null?void 0:t.muxPlaybackId)==="pending";f.useEffect(()=>{if(t&&(m||t.isMetadataGenerating)){const d=setInterval(()=>{z.invalidateQueries({queryKey:[`/api/videos/${ee}`]})},5e3);return()=>{clearInterval(d)}}},[t==null?void 0:t.id,m,t==null?void 0:t.isMetadataGenerating,ee,z]);const w=ge({queryKey:[`/api/videos/${(t==null?void 0:t.id)||ee}/contributors`],enabled:!!(ee||t!=null&&t.id),queryFn:async()=>{try{return await(await B("GET",`/api/videos/${(t==null?void 0:t.id)||ee}/contributors`,void 0,{omitCredentials:!0})).json()}catch(d){throw console.error("Error fetching contributors:",d),d}}}).data;w!=null&&w.contributors;const N=()=>{y(!0)},k=()=>{const d=(t==null?void 0:t.id)||ee;z.invalidateQueries({queryKey:[`/api/videos/${d}`]}),z.invalidateQueries({queryKey:[`/api/videos/${d}/contributors`]}),u({title:"Funding Successful",description:"Thank you for supporting this content!"})},g=async(d,_,I)=>{try{console.log("Processing funding from redirect",{videoIdOrUniqueId:d,amount:_,viewCount:I});let M;if(t)M=t.id,console.log(`Using current video's ID: ${M} for funding request`);else if(/^\d+$/.test(d))M=parseInt(d),console.log(`Parsed numeric ID: ${M} for funding request`);else{console.log(`Looking up video by uniqueId: ${d}`);try{const te=await B("GET",`/api/videos/by-id/${d}`);if(te&&typeof te=="object"&&"id"in te)M=te.id,console.log(`Found video by uniqueId. Using numeric ID: ${M}`);else throw new Error(`Failed to find video with uniqueId: ${d}`)}catch(te){console.error("Error looking up video by uniqueId:",te),M=ee?parseInt(String(ee)):0,console.log(`Falling back to URL param ID: ${M}`)}}if(!M||isNaN(M))throw new Error(`Invalid video ID: ${M}`);console.log(`Final API videoId: ${M} for funding request`);const xe=await B("POST",`/api/videos/${M}/fund`,{amount:_,viewCount:I,isAnonymous:!1,contributorName:(o==null?void 0:o.username)||"Supporter",contributorEmail:o==null?void 0:o.email});return console.log("Funding response:",xe),t&&t.id===M&&(z.invalidateQueries({queryKey:[`/api/videos/${M}`]}),z.invalidateQueries({queryKey:[`/api/videos/${t.uniqueId}`]}),z.invalidateQueries({queryKey:[`/api/videos/by-id/${t.uniqueId}`]})),!0}catch(M){return console.error("Error funding video from redirect:",M),u({title:"Funding Error",description:"There was an error processing your payment completion.",variant:"destructive"}),!1}};f.useEffect(()=>{const d=()=>{const M=window.location.hash.substring(1).split("?");return M.length>1?new URLSearchParams(M[1]):new URLSearchParams},_=()=>{if(window.history.replaceState){const I=new URL(window.location.href);I.searchParams.delete("payment_success"),I.searchParams.delete("video_id"),I.searchParams.delete("amount"),I.searchParams.delete("views"),window.history.replaceState({},document.title,I.pathname)}};if(t&&!E){const I=new URLSearchParams(window.location.search),M=d(),xe=I.get("payment_success")||M.get("payment_success"),te=I.get("video_id")||M.get("video_id"),ye=I.get("amount")||M.get("amount"),we=I.get("views")||M.get("views");if(xe==="true"&&te){console.log("Found payment success parameters",{paymentSuccess:xe,paymentVideoId:te,paymentAmount:ye,paymentViews:we}),_();const be=we?parseInt(we):10,Re=ye?parseInt(ye):Math.round(t.pricePerView*be*100);g(te,Re,be).then(Ue=>{Ue&&(k(),u({title:"Payment Successful",description:`Thank you for funding this video with ${be} views!`}),_t({particleCount:150,spread:70,origin:{y:.6}}))}),G(!0)}}},[t,E]),f.useEffect(()=>{t&&!x&&(async()=>{try{await B("POST",`/api/videos/${t.id}/view`,{}),z.invalidateQueries({queryKey:[`/api/videos/${t.id}`]})}catch(_){console.error("Failed to record view:",_)}})()},[t==null?void 0:t.id,x]),f.useEffect(()=>{const d=()=>{ue(!document.hidden)};return document.addEventListener("visibilitychange",d),()=>{document.removeEventListener("visibilitychange",d)}},[]);const C=St({videoApiId:(t==null?void 0:t.uniqueId)||(t==null?void 0:t.id),context:"site",duration:t==null?void 0:t.duration,identity:F,enabled:!!t&&!x}),R=f.useCallback(d=>
12{if(C.onTimeUpdate(d),!o||ce||!A||!Y)return;const _=d-pe.current;if(_>0&&_<5&&(se.current+=_),pe.current=d,se.current>=60){const I=Math.floor(se.current/60);K(I*60),se.current=se.current%60}},[o,ce,A,Y,K,C]);f.useEffect(()=>{!A&&se.current>0&&o&&(D(),se.current=0)},[A,o,D]),f.useEffect(()=>()=>{se.current>0&&D()},[D]);const V=f.useCallback(d=>{O(d),d||C.flush(),!d&&se.current>0&&(D(),se.current=0)},[D,C]),[L,W]=f.useState(!1);f.useEffect(()=>{le&&o&&!ce&&!L&&(u({title:"Watch Time Limit",description:"You're approaching your monthly watch limit. Consider upgrading for more time."}),W(!0))},[le,ce,o,u,L]);const Q=async()=>{if(t)try{let d=window.location.href;t.customUrl&&(d=`https://viddler.com/${t.customUrl}`),await navigator.clipboard.writeText(d),u({title:"Link Copied",description:t.customUrl?"Custom link copied to clipboard":"Video link copied to clipboard"})}catch{u({title:"Failed to Copy",description:"Could not copy link to clipboard",variant:"destructive"})}},S=()=>{j(!0)};if(r)return e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(he,{className:"aspect-video w-full mb-8 rounded-lg"}),e.jsx(he,{className:"h-8 w-3/4 mb-4"}),e.jsxs("div",{className:"flex gap-4 mb-6",children:[e.jsx(he,{className:"h-6 w-28"}),e.jsx(he,{className:"h-6 w-28"})]}),e.jsx(he,{className:"h-24 w-full mb-6"}),e.jsx(he,{className:"h-48 w-full mb-8 rounded-lg"}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(he,{className:"h-10 w-32"}),e.jsx(he,{className:"h-10 w-32"})]})]});if(s||!t)return e.jsxs("div",{className:"container mx-auto px-4 py-8 text-center",children:[e.jsx(It,{className:"w-16 h-16 text-red-500 mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"mb-6",children:"The video you're looking for doesn't exist or may have been removed."}),e.jsx(U,{onClick:()=>b("/"),children:"Return to Home"})]});const Z=new URLSearchParams(window.location.search),re=["poW867","5J2eUv","is33jX"],ae=t.title&&(t.title.toLowerCase().includes("vertical")||t.title.toLowerCase().includes("portrait")||t.title.toLowerCase().includes("9:16"))||t.description&&(t.description.toLowerCase().includes("vertical")||t.description.toLowerCase().includes("portrait")||t.description.toLowerCase().includes("9:16")),J=t.aspectRatio||Z.get("ratio")||(re.includes(t.uniqueId)||ae?"9:16":"16:9"),de=J==="9:16",ie=!!(t.storageState&&t.storageState!=="active"),Se=!!t.requireViewerIdentity&&!o&&!F,Me=ie||t.locked&&!l||t.isPasswordProtected&&!l||Se,[Ee,Ne]=J.split(":").map(Number),Fe=Ee>0&&Ne>0?Ee/Ne:16/9,Ce=de?450:900,Ie=Me?{maxWidth:`${Ce}px`,margin:"0 auto"}:{aspectRatio:J.replace(":","/"),width:"100%",maxWidth:`min(${Ce}px, calc((100dvh - 11rem) * ${Fe.toFixed(4)}))`,margin:"0 auto"},Te=Me?"bg-muted mx-auto mb-6 rounded-xl":"bg-muted overflow-hidden mx-auto mb-6 rounded-xl shadow-lg",ke=()=>e.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full bg-black/95 text-white px-6 text-center",style:{minHeight:"320px"},children:[e.jsx(X,{className:"h-8 w-8 animate-spin mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"Your video is processing"}),e.jsx("p",{className:"text-sm text-white/60 mt-1",children:"This usually takes under a minute. The video will start automatically when it's ready."})]});return e.jsxs("div",{className:"opus-home",style:ut,children:[t.muxPlaybackId&&!t.locked&&e.jsx(Et,{title:t.title,description:t.description||`Watch ${t.title} - A video hosted on Viddler`,thumbnailUrl:t.thumbnailUrl||`https://image.mux.com/${t.muxPlaybackId}/thumbnail.jpg?time=5`,videoId:t.uniqueId,indexable:Kt()}),o?e.jsx("div",{className:"container mx-auto py-6 px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:Te,style:Ie,children:t.storageState&&t.storageState!=="active"?e.jsx(He,{video:t}):m?e.jsx(ke,{}):(t.isPasswordProtected||t.domainRestricted||t.signedPlaybackRequired)&&!l?x||!t.isPasswordProtected?e.jsx("div",{className:"flex items-center justify-center w-full h-full bg-black/95 text-white",style:{minHeight:"320px"},children:e.jsx(X,{className:"h-6 w-6 animate-spin"})}):e.jsx(ze,{videoIdParam:t.uniqueId||t.id,title:t.title,onUnlocked:d=>H(d)}):e.jsx(_e,{ref:me,playbackId:(l==null?void 0:l.playbackId)||t.muxPlaybackId,playbackToken:l==null?void 0:l.token,thumbnailToken:l==null?void 0:l.thumbnailToken,posterUrl:l!=null&&l.token?void 0:t.thumbnailUrl||`https://image.mux.com/${t.muxPlaybackId}/thumbnail.jpg?time=5`,title:t.title,videoId:t.id,availableViews:t.availableViews,onUnlockCl
12ick:N,isUploader:x,aspectRatio:J,onPlayStateChange:V,onTimeUpdate:R,isPlaybackBlocked:ce&&!x,blockMessage:"You've reached your monthly watch limit. Upgrade your plan to continue watching."})}),e.jsx("div",{className:"mt-3",children:e.jsx(Ze,{videoApiId:t.uniqueId||t.id})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center",children:[o&&x&&!t.isMetadataGenerating?e.jsx("h1",{className:"text-2xl font-bold",children:e.jsx(Je,{videoId:t.id,initialValue:t.title,fieldName:"title",placeholder:"Enter video title",maxLength:100})}):e.jsx("h1",{className:"text-2xl font-bold",children:t.title}),t.isMetadataGenerating&&e.jsx("div",{className:"ml-2 text-primary",title:"AI is generating metadata...",children:e.jsx(X,{className:"h-5 w-5 animate-spin"})})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",children:[e.jsx(Qe,{className:"h-3 w-3 mr-1"}),t.duration>=60?`${Math.round(t.duration/60)} min`:`${Math.round(t.duration)} sec`]}),x&&e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",children:[e.jsx(Tt,{className:"h-3 w-3 mr-1"}),"You"]}),e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",children:[e.jsx(Ge,{className:"h-3 w-3 mr-1"}),new Date(t.createdAt).toLocaleDateString()]}),o&&x&&!t.isMetadataGenerating?e.jsx(zt,{videoId:t.id,initialValue:t.customUrl}):t.customUrl?e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-primary/20 text-primary hover:bg-primary/30 cursor-pointer",onClick:()=>{const d=`https://viddler.com/${t.customUrl}`;navigator.clipboard.writeText(d),u({title:"Link Copied",description:"Custom URL copied to clipboard"})},children:[e.jsx(Le,{className:"h-3 w-3 mr-1"}),"viddler.com/",t.customUrl]}):o&&x&&t.isMetadataGenerating&&e.jsx("div",{className:"inline-flex items-center rounded-md bg-muted px-2.5 py-0.5 text-xs font-medium text-muted-foreground",children:e.jsx("span",{children:"Custom URL unavailable during generation"})}),t.isMetadataGenerating&&e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-primary/20 text-primary",children:[e.jsx(X,{className:"h-3 w-3 mr-1 animate-spin"}),"AI generating metadata..."]})]}),e.jsxs("div",{className:"mt-4 mb-6",children:[e.jsx("div",{className:"text-lg font-medium mb-2",children:"Description"}),o&&x&&!t.isMetadataGenerating?e.jsx(Je,{videoId:t.id,initialValue:t.description,fieldName:"description",multiline:!0,placeholder:"Enter video description",maxLength:2e3}):e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.description||"No description provided"})]}),e.jsx("div",{className:"mt-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium mb-4",children:"Actions"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(U,{onClick:Q,children:[e.jsx(Le,{className:"mr-2 h-4 w-4"}),"Share"]}),e.jsxs(U,{variant:"outline",onClick:S,children:[e.jsx(Ke,{className:"mr-2 h-4 w-4"}),"Embed"]}),x&&t.userId&&e.jsxs(U,{variant:"destructive",onClick:async()=>{if(window.confirm("Are you sure you want to delete this video?"))try{await(await B("DELETE",`/api/videos/${t.id}`,void 0,{omitCredentials:!1})).json(),z.invalidateQueries({queryKey:["/api/videos"]}),b("/",{replace:!0}),u({title:"Video Deleted",description:"Your video has been deleted successfully"})}catch(d){console.error("Error deleting video:",d),u({title:"Error",description:"Failed to delete video. Please try again.",variant:"destructive"})}},children:[e.jsx(rt,{className:"mr-2 h-4 w-4"}),"Delete Video"]}),!x&&!t.userId&&o&&e.jsx(Qt,{videoId:t.id})]}),x&&t.userId&&e.jsx(Lt,{videoId:t.id,uniqueId:t.uniqueId,isPasswordProtected:!!t.isPasswordProtected}),x&&t.userId&&e.jsx("div",{className:"mt-3",children:e.jsx(ht,{videoId:t.id,initialDomains:t.allowedEmbedDomains||[],entitled:!!t.embedDomainEntitled,compact:!0})}),x&&t.userId&&e.jsx(Ot,{videoId:t.id,videoApiId:t.uniqueId||t.id})]})})]})]}),e.jsx("div",{className:"w-full mt-2",children:e.jsx(Ye,{videoApiId:t.uniqueId||t.id,playerRef:me,authorName:t.authorName||void 0})})]})}):e.jsx("div",{className:"container mx-auto py-6 px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("div",{className:Te+" w-full",style:Ie,children:t.storageState&&t.storageState!=="active"?e.jsx(He,{video:t}):m?e.jsx(ke,{}):t.locked&&!l&&t.isPasswordProtected?e.jsx(ze,{videoIdParam:t.uniqueId||t.id,title:t.title,onUnlocked:d=>H(d)}):t.locked&&!l?e.jsx("div",{className:"flex items-center justify-center w-full h-full bg-black/95 text-white",style:{minHeight:"320px"},children:e.jsx(X,{className:"h-6 w-6 animate-spin"})}):Se?e.jsx(Mt,{title:t.title,onIdentified:d=>q(d)}):e.jsx(_e,{ref:me,playbackId:(l==null?void 0:l.playbackId)||t.muxPlaybackId,playbackToken:l==null?void 0:l.token,thumbnailToken:l==null?void 0:l.thumbnailToken,posterUrl:l!=null&&l.token?void 0:t.thumbnailUrl||`https://image.mux.com/${t.muxPlaybackId}/thumbnail.jpg?time=5`,title:t.title,videoId:t.id,availableViews:t.availableViews,onUnlockCl
12ick:N,isUploader:x,aspectRatio:J,onPlayStateChange:V,onTimeUpdate:R})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3 flex-wrap",children:[e.jsx(Ze,{videoApiId:t.uniqueId||t.id}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(U,{size:"sm",onClick:Q,children:[e.jsx(Le,{className:"mr-2 h-4 w-4"}),"Share"]}),e.jsxs(U,{size:"sm",variant:"outline",onClick:S,children:[e.jsx(Ke,{className:"mr-2 h-4 w-4"}),"Embed"]})]})]}),e.jsxs("div",{className:"text-left mt-4 mb-4",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:t.title}),t.isMetadataGenerating&&e.jsx("div",{className:"ml-2 text-primary",title:"AI is generating metadata...",children:e.jsx(X,{className:"h-5 w-5 animate-spin"})})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",children:[e.jsx(Qe,{className:"h-3 w-3 mr-1"}),t.duration>=60?`${Math.round(t.duration/60)} min`:`${Math.round(t.duration)} sec`]}),e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",children:[e.jsx(Ge,{className:"h-3 w-3 mr-1"}),new Date(t.createdAt).toLocaleDateString()]}),t.customUrl&&e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-primary/20 text-primary hover:bg-primary/30 cursor-pointer",onClick:()=>{const d=`https://viddler.com/${t.customUrl}`;navigator.clipboard.writeText(d),u({title:"Link Copied",description:"Custom URL copied to clipboard"})},children:[e.jsx(Le,{className:"h-3 w-3 mr-1"}),"viddler.com/",t.customUrl]}),t.isMetadataGenerating&&e.jsxs("div",{className:"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-primary/20 text-primary",children:[e.jsx(X,{className:"h-3 w-3 mr-1 animate-spin"}),"AI generating metadata..."]})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.description})]})]}),e.jsx("div",{className:"w-full mt-2",children:e.jsx(Ye,{videoApiId:t.uniqueId||t.id,playerRef:me,authorName:t.authorName||void 0})})]})}),e.jsx(vt,{open:T,onOpenChange:d=>j(d),videoId:t.id,title:t.title,aspectRatio:J,customUrl:t.customUrl,source:"video_page",requireViewerIdentity:!!t.requireViewerIdentity})]})}export{$s as default};
13
14//# chunkId=01a0f211-423e-7503-8a03-cc66b606ccda

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.