PageSourceSearch

https://clipchat.ai/dist/assets/index-BcChS9zD.js

js clipchat.ai collected 2026-10-05 11:56:19 UTC 53,131 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-fFbGxLEq.js","assets/index-Cc7IhL_s.js","assets/index-D743eS6_.css","assets/vendor-mui-CBxi4-UE.js","assets/vendor-react-DJCar8wk.js","assets/vendor-utils-hGafao2v.js"])))=>i.map(i=>d[i]);
2var e=Object.defineProperty,o=Object.defineProperties,t=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,s=(o,t,i)=>t in o?e(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,n=(e,o)=>{for(var t in o||(o={}))r.call(o,t)&&s(e,t,o[t]);if(i)for(var t of i(o))a.call(o,t)&&s(e,t,o[t]);return e},l=(e,i)=>o(e,t(i));import{j as d,cS as u,B as c,aa as g,hL as p,T as m,aL as v,D as x,I as f,m as h,bg as b,ak as y,b5 as _,at as D,fs as j,bW as w,a4 as S,bp as T,b9 as I,aA as G,aK as C,ac as V,bx as U,eH as L,hM as k,u as O,b as R,Y as A,aE as z,a5 as F,b3 as E,hN as P,d1 as Y,c4 as W,n as M,o as B,f as N,cO as H,g as $,hO as q,aW as Q,hP as J,aX as K,dl as Z,cR as X,ao as ee,al as oe,ag as te,$ as ie,a0 as re,a6 as ae,cj as se,cN as ne,cP as le,hQ as de,aC as ue}from"./vendor-mui-CBxi4-UE.js";import{a as ce,f as ge,b as pe}from"./vendor-react-DJCar8wk.js";import{b as me,s as ve,u as xe,Y as fe,a as he,_ as be,v as ye,cp as _e}from"./main-fFbGxLEq.js";import{S as De,U as je,Y as we}from"./YouTubeUploadModal-D7locvSl.js";import{u as Se}from"./useSimpleToastNotification-YKhq3dyl.js";import{c as Te}from"./cable-Af6IddPp.js";import{a as Ie}from"./actionLogger-BXRfdC3w.js";import"./index-Cc7IhL_s.js";import"./vendor-utils-hGafao2v.js";import"./YouTubePrivacySelector-DKJLqpHO.js";import"./action_cable-Dxo0mV8c.js";const Ge=I(G)(({theme:e})=>({borderRadius:"16px",overflow:"hidden",transition:"all 0.3s ease",height:"100%",display:"flex",flexDirection:"column",boxShadow:"0 4px 12px rgba(0,0,0,0.05)","&:hover":{transform:"translateY(-4px)",boxShadow:"0 12px 20px rgba(0,0,0,0.1)"}})),Ce=e=>{if(!e)return"0:00";return`${Math.floor(e/60)}:${Math.round(e%60).toString().padStart(2,"0")}`},Ve=e=>e.videoDone?"ready":"FAILED"===e.busyTextGeneration||"FAILED"===e.busyAudioGeneration||"FAILED"===e.busyImageGeneration||"FAILED"===e.busyImageToVideo||"FAILED"===e.busyVideoConcatenation?"failed":"BUSY"===e.busyTextGeneration?"generating_text":"COMPLETED"!==e.busyTextGeneration||e.audioDone?"COMPLETED"!==e.busyAudioGeneration||e.picturesDone?"COMPLETED"!==e.busyImageGeneration||e.videoDone?e.status||"pending":"BUSY"===e.busyImageToVideo?"processing_images_to_video":"BUSY"===e.busyVideoConcatenation?"concatenating_videos":"images_ready":"BUSY"===e.busyImageGeneration?"generating_images":"audio_ready":"BUSY"===e.busyAudioGeneration?"generating_audio":"text_ready",Ue=e=>{const o=Ve(e);return"ready"===o?"success":["generating_text","text_ready","generating_audio","audio_ready","generating_images","images_ready","processing_images_to_video","concatenating_videos"].includes(o)?"warning":"failed"===o||"error"===o?"error":"default"},Le=(e,o)=>{const t=Ve(e);switch(t){case"ready":return o("statusReady","Ready");case"generating_text":return o("statusGeneratingText","Generating script");case"text_ready":return o("statusScriptReady","Script ready");case"generating_audio":return o("statusGeneratingAudio","Generating audio");case"audio_ready":return o("statusAudioReady","Audio ready");case"generating_images":return o("statusGeneratingImages","Generating images");case"images_ready":return o("statusImagesReady","Images ready");case"processing_images_to_video":return o("statusProcessingImagesToVideo","Converting images to video");case"concatenating_videos":return o("statusConcatenatingVideos","Creating final video");case"failed":case"error":return o("statusFailed","Failed");default:return t}},ke=({video:e,onViewDetails:o,onCopyLink:t})=>{var i,r;const{t:a}=me("admin"),s=Se(),[I,G]=ce.useState(!1),[O,R]=ce.useState(e.isDriveUploading||!1);ce.useState(null);const[A,z]=ce.useState(!1),[F,E]=ce.useState({uploadedToGoogleDrive:e.uploadedToGoogleDrive||!1,googleDriveFileUrl:e.google_drive_file_url||"",googleDriveFileId:e.google_drive_file_id||"",uploadToGoogleDriveStatus:e.upload_to_google_drive_status||"",uploadToGoogleDriveStartedAt:e.upload_to_google_drive_started_at||null,uploadToGoogleDriveError:e.upload_to_google_drive_error||"",youtubeSubmitted:e.
2youtubeSubmitted||!1,youtubeVideoId:e.youtube_video_id||"",youtubeVideoUrl:e.youtube_video_url||""}),P=ce.useRef(null),Y=ce.useRef(a);ce.useEffect(()=>{Y.current=a},[a]);const W=Ve(e),M="ready"===W,B=["generating_text","text_ready","generating_audio","audio_ready","generating_images","images_ready","processing_images_to_video","concatenating_videos"].includes(W),N="error"===W||"failed"===W,H=e.progress||(e=>{if(e.progress&&e.progress>0)return e.progress;switch(Ve(e)){case"generating_text":return 20;case"text_ready":return 30;case"generating_audio":return 40;case"audio_ready":return 50;case"generating_images":return 60;case"images_ready":return 70;case"processing_images_to_video":return 80;case"concatenating_videos":return 90;case"ready":return 100;case"failed":case"error":return e.progress||0;default:return 0}})(e);ce.useEffect(()=>{E(o=>l(n({},o),{uploadedToGoogleDrive:e.uploadedToGoogleDrive||o.uploadedToGoogleDrive,googleDriveFileUrl:e.google_drive_file_url||o.googleDriveFileUrl,googleDriveFileId:e.google_drive_file_id||o.googleDriveFileId,uploadToGoogleDriveStatus:e.upload_to_google_drive_status||o.uploadToGoogleDriveStatus})),void 0!==e.isDriveUploading&&R(e.isDriveUploading),("completed"===e.upload_to_google_drive_status||e.uploadedToGoogleDrive)&&R(!1)},[e.uploadedToGoogleDrive,e.google_drive_file_url,e.google_drive_file_id,e.upload_to_google_drive_status,e.isDriveUploading]),ce.useEffect(()=>{if(O||"started"===F.uploadToGoogleDriveStatus){ve.info("Adding safety timeout to reset Google Drive spinner if needed","LongVideoCard",{videoId:e.id,currentUploadingState:O,uploadStatus:F.uploadToGoogleDriveStatus,timestamp:(new Date).toISOString()});const o=setTimeout(()=>{(O||"started"===F.uploadToGoogleDriveStatus)&&(ve.warn("Emergency spinner reset triggered - spinner was stuck for 15 seconds","LongVideoCard",{videoId:e.id,forcedReset:!0,timestamp:(new Date).toISOString()}),R(!1),E(e=>l(n({},e),{uploadToGoogleDriveStatus:"completed"})))},15e3);return()=>clearTimeout(o)}},[O,F.uploadToGoogleDriveStatus,e.id]),ce.useEffect(()=>(e&&e.id&&(P.current=Te.subscriptions.create({channel:"LongVideoStatusChannel",video_id:e.id},{connected:()=>{},disconnected:()=>{},received:o=>{ve.info("Received message from long_video_status channel","LongVideoCard",{videoId:e.id,messageType:o.status,messageData:o,timestamp:(new Date).toISOString()}),"google_drive_uploaded"===o.status?(ve.info("Google Drive upload completed notification received","LongVideoCard",{videoId:e.id,googleDriveFileUrl:o.google_drive_file_url,googleDriveFileId:o.google_drive_file_id,timestamp:(new Date).toISOString()}),E({uploadedToGoogleDrive:!0,googleDriveFileUrl:o.google_drive_file_url||o.googleDriveFileUrl,googleDriveFileId:o.google_drive_file_id||o.googleDriveFileId,uploadToGoogleDriveStatus:"completed"}),ve.info("Stopping spinner on WebSocket message","LongVideoCard",{videoId:e.id,timestamp:(new Date).toISOString()}),R(!1),ve.info("Google Drive state updated after successful upload","LongVideoCard",{videoId:e.id,newState:{uploadedToGoogleDrive:!0,googleDriveFileUrl:o.google_drive_file_url,googleDriveFileId:o.google_drive_file_id,uploadToGoogleDriveStatus:"completed",isDriveUploading:!1},timestamp:(new Date).toISOString()}),X(Y.current("googleDriveUploadComplete","Google Drive upload completed!"),"success",{actionText:Y.current("viewFile","View File"),actionHandler:()=>window.open(o.google_drive_file_url,"_blank"),autoHideDuration:8e3})):"youtube_uploaded"===o.status?(ve.info("YouTube upload completed notification received","LongVideoCard",{videoId:e.id,youtubeVideoId:o.youtube_video_id,youtubeVideoUrl:o.youtube_video_url,timestamp:(new Date).toISOString()}),E(e=>l(n({},e),{youtubeSubmitted:!0,youtubeVideoId:o.youtube_video_id,youtubeVideoUrl:o.youtube_video_url})),G(!1),X(o.already_uploaded?Y.current("youtubeVideoAlreadyUploaded","Video was already uploaded to YouTube"):Y.current("youtubeUploadComplete","YouTube upload completed!"),"success",{actionText:Y.current("viewVideo","View Video"),actionHandler:()=>window.open("https://studio.youtube.com/channel","_blank"),autoHideDuration:8e3})):"google_drive_upload_started"===o.status?(ve.info("Google Drive upload started notification received","
2LongVideoCard",{videoId:e.id,message:o.message,timestamp:(new Date).toISOString()}),Q()||"completed"===F.uploadToGoogleDriveStatus||"completed"===e.upload_to_google_drive_status?ve.warn("Ignoring google_drive_upload_started notification for already uploaded video","LongVideoCard",{videoId:e.id,isAlreadyUploaded:Q(),uploadToGoogleDriveStatus:F.uploadToGoogleDriveStatus||e.upload_to_google_drive_status,timestamp:(new Date).toISOString()}):(ve.info("Setting isDriveUploading to true for video that is not already uploaded","LongVideoCard",{videoId:e.id,isAlreadyUploaded:Q(),uploadToGoogleDriveStatus:F.uploadToGoogleDriveStatus,timestamp:(new Date).toISOString()}),R(!0),E(e=>l(n({},e),{uploadToGoogleDriveStatus:"started",uploadToGoogleDriveStartedAt:new Date})),ve.info("Google Drive state updated for started upload","LongVideoCard",{videoId:e.id,newState:{uploadToGoogleDriveStatus:"started",uploadToGoogleDriveStartedAt:(new Date).toISOString(),isDriveUploading:!0},timestamp:(new Date).toISOString()}))):"google_drive_upload_failed"===o.status?(ve.error("Google Drive upload failed notification received","LongVideoCard",{videoId:e.id,error:o.error,timestamp:(new Date).toISOString()}),R(!1),E(e=>l(n({},e),{uploadToGoogleDriveStatus:"failed",uploadToGoogleDriveError:o.error})),ve.error("Google Drive state updated for failed upload","LongVideoCard",{videoId:e.id,newState:{uploadToGoogleDriveStatus:"failed",uploadToGoogleDriveError:o.error,isDriveUploading:!1},timestamp:(new Date).toISOString()}),X(Y.current("googleDriveUploadFailed","Google Drive upload failed: {{error}}",{error:o.error}),"error",{autoHideDuration:1e4})):"youtube_upload_failed"===o.status&&(ve.error("YouTube upload failed notification received","LongVideoCard",{videoId:e.id,error:o.error,timestamp:(new Date).toISOString()}),G(!1),X(Y.current("youtubeUploadFailed","YouTube upload failed: {{error}}",{error:o.error}),"error",{autoHideDuration:1e4}))}})),()=>{P.current&&(Te.subscriptions.remove(P.current),P.current=null)}),[e.id]);const{data:$}=xe(fe,{fetchPolicy:"cache-first"}),q=(null==(r=null==(i=null==$?void 0:$.youtubeConnectionStatus)?void 0:i.accounts)?void 0:r.length)>1,Q=()=>F.uploadedToGoogleDrive||F.googleDriveFileUrl||e.uploadedToGoogleDrive||e.google_drive_file_url,J=()=>{if(Q())return!1;if("completed"===F.uploadToGoogleDriveStatus||"completed"===e.upload_to_google_drive_status)return!1;return"started"===F.uploadToGoogleDriveStatus||"started"===e.upload_to_google_drive_status||O},K=()=>Boolean(F.youtubeSubmitted)||Boolean(F.youtubeVideoId)||Boolean(e.youtubeSubmitted)||Boolean(e.youtube_video_id);he(De,{onCompleted:o=>{var t;const i=o.sendLongVideoToYoutube.response;i.success?i.videoId?(G(!1),E(e=>l(n({},e),{youtubeSubmitted:!0,youtubeVideoId:i.videoId,youtubeVideoUrl:i.videoUrl||""})),ve.info("Successfully uploaded long video to YouTube","LongVideoCard",{videoId:e.id,youtubeVideoId:i.videoId}),X(a("youtubeUploadComplete","YouTube upload completed!"),"success",{actionText:a("viewVideo","View Video"),actionHandler:()=>window.open("https://studio.youtube.com/channel","_blank"),autoHideDuration:8e3})):i.message&&i.message.includes("background")?X(a("youtubeUploadStarted","YouTube upload started in background. It will continue even if you close this page."),"info",{autoHideDuration:6e3}):(G(!1),X(a("successfullyUploadedToYoutube","Successfully uploaded to YouTube!"),"success")):(G(!1),ve.error("YouTube upload failed with response errors","LongVideoCard",{videoId:e.id,errors:o.sendLongVideoToYoutube.errors}),X(a("failedToUploadToYoutube","Failed to upload to YouTube: {{error}}",{error:(null==(t=o.sendLongVideoToYoutube.errors)?void 0:t.join(", "))||a("unknownError","Unknown error")}),"error"))},onError:o=>{G(!1),ve.error("YouTube upload mutation error","LongVideoCard",{videoId:e.id,error:o.message}),X(a("youtubeUploadError","YouTube upload error: {{message}}",{message:o.message}),"error")}});const[Z]=he(je,{onCompleted:o=>{var t,i,r,s;if(setTimeout(()=>{ve.info("Backup timeout: Resetting isDriveUploading flag after timeout","LongVideoCard",{videoId:e.id,message:"Resetting upload flag after 10s timeout",currentState:O}),R(!1),E(e=>l(n({},e),{uploadToGoogleDriveStatus:"started"===e.uploadToGoogleDriveStatus?"completed":e.uploadToGoogleDriveStatus}))},1e4),ve.debug("Google Drive upload mutation response received","
2LongVideoCard",{videoId:e.id,responseData:o,responseStructure:Object.keys(o||{}).join(", ")}),null==(t=null==o?void 0:o.uploadToGoogleDrive)?void 0:t.success){const t=o.uploadToGoogleDrive.fileUrl,i=o.uploadToGoogleDrive.fileId;t?(E(e=>l(n({},e),{uploadedToGoogleDrive:!0,googleDriveFileUrl:t,googleDriveFileId:i||e.googleDriveFileId,uploadToGoogleDriveStatus:"completed"})),R(!1),X(a("successfullyUploadedToDrive","Successfully uploaded to Google Drive!"),"success",{actionText:a("viewFile","View File"),actionHandler:()=>window.open(t,"_blank"),autoHideDuration:8e3})):(E(e=>l(n({},e),{uploadToGoogleDriveStatus:"started",uploadToGoogleDriveStartedAt:new Date})),ve.info("Google Drive upload started in background","LongVideoCard",{videoId:e.id,jobStarted:!0,isDriveUploadingStillActive:!0}),X(a("googleDriveUploadStarted","Google Drive upload started in background. It will continue even if you close this page."),"info",{autoHideDuration:6e3}))}else R(!1),ve.error("Google Drive upload failed","LongVideoCard",{videoId:e.id,errors:(null==(i=null==o?void 0:o.uploadToGoogleDrive)?void 0:i.errors)||["Unknown error structure in response"],responseData:o,flagReset:!0}),X(a("failedToUploadToDrive","Failed to upload to Google Drive: {{error}}",{error:(null==(s=null==(r=null==o?void 0:o.uploadToGoogleDrive)?void 0:r.errors)?void 0:s.join(", "))||a("unknownError","Unknown error")}),"error")},onError:o=>{R(!1),ve.error("Google Drive upload mutation error","LongVideoCard",{videoId:e.id,error:o.message}),X(a("googleDriveUploadError","Google Drive upload error: {{message}}",{message:o.message}),"error")}}),X=(o,t,i={})=>{const r=n({component:"LongVideoCard",metadata:n({videoId:e.id},i)},i);switch(t){case"success":return s.showSuccess(o,r);case"error":return s.showError(o,r);case"warning":return s.showWarning(o,r);default:return s.showInfo(o,r)}},ee=()=>{window.location.href="/create/settings"},oe=()=>{if(!((null==(o=null==$?void 0:$.youtubeConnectionStatus)?void 0:o.connected)||(null==(i=null==(t=null==$?void 0:$.youtubeConnectionStatus)?void 0:t.accounts)?void 0:i.length)>0))return ve.warn("YouTube account not connected - redirecting to settings","LongVideoCard",{videoId:e.id}),void X(a("youtubeAccountNotConnected","YouTube account not connected"),"warning",{actionText:a("connectAccount","Connect Account"),actionHandler:ee,autoHideDuration:1e4});var o,t,i;if(K()&&(F.youtubeVideoId||e.youtube_video_id)){const o=`https://studio.youtube.com/video/${F.youtubeVideoId||e.youtube_video_id}/edit`;return window.open(o,"_blank"),void X(a("openingYoutubeStudio","Opening YouTube Studio to edit the video..."),"info")}z(!0)};return d.jsxs(d.Fragment,{children:[d.jsxs(Ge,{elevation:1,children:[d.jsxs(u,{onClick:()=>o(e.id),sx:{flexGrow:1,display:"flex",flexDirection:"column",alignItems:"stretch"},children:[d.jsxs(c,{sx:{position:"absolute",top:12,left:12,zIndex:1,display:"flex",flexDirection:"row",gap:1},children:[d.jsx(g,{label:Le(e,a),size:"small",color:Ue(e),sx:{borderRadius:"12px",fontWeight:500,boxShadow:"0 2px 4px rgba(0,0,0,0.1)"}}),e.audio_only&&d.jsx(g,{label:a("audioOnly","Audio Only"),size:"small",color:"secondary",icon:d.jsx(p,{fontSize:"small"}),sx:{borderRadius:"12px",fontWeight:500,boxShadow:"0 2px 4px rgba(0,0,0,0.1)"}})]}),(()=>{if(M&&e.thumbnailUrl){const o=ye(e.thumbnailUrl,"640w");return d.jsxs(c,{sx:{position:"relative",pt:"56.25%"},children:[d.jsx(c,{component:"img",src:o,alt:e.title||"Video thumbnail",sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",objectFit:"cover"}}),d.jsx(c,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",opacity:0,transition:"opacity 0.2s","&:hover":{opacity:1}},children:d.jsx(f,{sx:{bgcolor:"rgba(255,255,255,0.9)",color:"primary.main","&:hover":{bgcolor:"white"}},children:d.jsx(C,{fontSize:"large"})})})]})}if(e.picturesDone&&e.images&&e.images.length>0){const o=(Array.isArray(e.images)?[...e.images]:[]).filter(e=>e&&"completed"===e.status).sort((e,o)=>e.position-o.position);if(o.length>0){const t=o[0],i=t.s3Url||t.url;if(i){const o=ye(i,"640w");return d.jsxs(c,{sx:{position:"relative",pt:"56.25%"},children:[d.jsx(c,{component:"img",src:o,alt:e.title||"Video first frame",sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",objectFit:"cover"}}),M&&d.jsx(c,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.3)",opacity:0,transition:"opacity 0.2s","&:hover":{opacity:1}},children:d.jsx(f,{sx:{bgcolor:"rgba(255,255,255,0.9)",color:"primary.main","&:hover":{bgcolor:"white"}},children:d.jsx(C,{fontSize:"large"})})})]})}}}return d.jsx(c,{sx:{pt:"56.25%",position:"relative",bgcolor:"action.hover"},children:d.jsxs(c,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",p:2},children:[d.jsx(V,{sx:{fontSize:48,color:B?"primary.main":N?"error.main":"grey.400",mb:1}}),d.jsx(m,{variant:"body2",color:B?"primary.main":N?"error.main":"text.secondary",align:"center",sx:{mb:1},children:B?a("processingVideo","Processing video..."):N?a("videoFailed","Video failed"):a("noThumbnail","No thumbnail available")}),B&&d.jsx(c,{sx:{width:"80%",mt:1},children:d.jsx(U,{variant:"determinate",value:H,sx:{height:6,borderRadius:3,bgcolor:"rgba(255,255,255,0.5)"}})})]})})})(),d.jsxs(c,{sx:{p:2,flexGrow:1,display:"flex",flexDirection:"column"},children:[d.jsx(m,{variant:"h6",sx:{fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",mb:1,lineHeight:1.2,fontSize:"1.1rem"},children:(()=>
2{if(("theme.custom.custom"===e.title||"theme.custom.custom"===e.theme)&&e.customTheme&&"string"==typeof e.customTheme)return e.customTheme;if(e.title&&"theme.custom.custom"!==e.title)return e.title;if(e.theme&&"theme.custom.custom"!==e.theme){if("string"==typeof e.theme&&!e.theme.includes("custom"))return e.theme.replaceAll("_"," ");if("object"==typeof e.theme&&null!==e.theme){const o=Object.keys(e.theme);for(const t of o)if("string"==typeof e.theme[t]&&!t.includes("custom")&&!e.theme[t].includes("custom"))return e.theme[t].replaceAll("_"," ")}}return e.customTheme&&"string"==typeof e.customTheme?e.customTheme:a("untitledVideo","Untitled video")})()}),d.jsxs(c,{sx:{display:"flex",alignItems:"center",mb:1,color:"text.secondary"},children:[d.jsx(v,{sx:{fontSize:16,mr:.5}}),d.jsx(m,{variant:"body2",children:Ce(e.audioDuration||e.duration||0)})]}),d.jsxs(m,{variant:"caption",color:"text.secondary",sx:{mb:1.5},children:[a("created","Created"),": ",new Date(e.createdAt).toLocaleDateString()]}),N&&e.errorMessage&&d.jsx(m,{variant:"body2",color:"error.main",sx:{mb:1,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.errorMessage}),d.jsx(x,{sx:{my:1}}),d.jsxs(c,{sx:{display:"flex",gap:1,mt:1,flexWrap:"wrap"},children:[e.audio_only&&d.jsx(h,{title:a("audioOnlyStatus","This is audio-only content"),children:d.jsx(g,{size:"small",icon:d.jsx(p,{fontSize:"small"}),label:a("audioOnly","Audio Only"),color:"secondary",variant:"filled"})}),d.jsx(h,{title:a("scriptStatus","Script status"),children:d.jsx(g,{size:"small",icon:d.jsx(L,{fontSize:"small"}),label:a("script","Script"),color:e.textDone?"success":B&&"generating_text"===e.status?"warning":"default",variant:e.textDone?"filled":"outlined"})}),d.jsx(h,{title:a("audioStatus","Audio status"),children:d.jsx(g,{size:"small",icon:d.jsx(p,{fontSize:"small"}),label:a("audio","Audio"),color:e.audioDone?"success":B&&["text_ready","generating_audio"].includes(e.status)?"warning":"default",variant:e.audioDone?"filled":"outlined"})}),d.jsx(h,{title:a("imagesStatus","Images status"),children:d.jsx(g,{size:"small",icon:d.jsx(k,{fontSize:"small"}),label:a("images","Images"),color:e.picturesDone?"success":B&&"generating_images"===e.status?"warning":"default",variant:e.picturesDone?"filled":"outlined"})})]})]})]}),d.jsxs(c,{sx:{p:2,pt:0,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[d.jsxs(c,{sx:{display:"flex"},children:[!e.textOnly&&d.jsx(f,{sx:{color:"grey.600",p:1},disabled:!M,onClick:o=>{o.stopPropagation(),M&&t?t(e.videoUrl):M&&(navigator.clipboard.writeText(e.videoUrl),X(a("linkCopied","Link copied to clipboard"),"info"))},size:"small",children:d.jsx(h,{title:a("shareVideo","Share Video"),children:d.jsx(b,{sx:{fontSize:28}})})}),M&&!e.audio_only&&!e.textOnly&&d.jsx(d.Fragment,{children:d.jsx(f,{sx:{color:"#FF0033",p:1},onClick:e=>{e.stopPropagation(),oe()},disabled:I,size:"small","aria-haspopup":q?"true":"false",children:d.jsx(h,{title:K()?a("alreadyUploadedToYoutube","Already uploaded to YouTube"):q?a("selectYoutubeAccount","Select YouTube account"):a("sendToYoutube","Send to YouTube"),children:I?d.jsx(y,{size:20,color:"inherit"}):d.jsx(_,{variant:"dot",color:"success",invisible:!K(),sx:{"& .MuiBadge-badge":{right:2,top:2}},children:d.jsx(D,{sx:n({fontSize:36,transition:"all 0.2s ease"},K()&&{"&:hover":{transform:"scale(1.15)",filter:"drop-shadow(0 0 2px rgba(76, 175, 80, 0.5))"}})})})})})}),M&&!e.audio_only&&!e.textOnly&&d.jsx(f,{sx:{color:J()||Q()?"#1a73e8":"grey.600",p:1},onClick:o=>{o.stopPropagation(),(()=>{const o=`gdrive_upload_${e.id}_${Date.now()}`;if(ve.info("Google Drive button clicked","LongVideoCard",{videoId:e.id,requestId:o,timestamp:(new Date).toISOString(),userAction:"button_click",buttonType:"google_drive_upload"}),ve.debug("FULL STATE DUMP - Component state at Google Drive button click","LongVideoCard",{videoId:e.id,componentState:{isDriveUploading:O,isYoutubeUploading:I,localVideoState:F,isDriveUploadingFunction:J(),isUploadedFunction:Q()},videoProps:{id:e.id,title:e.title,uploadedToGoogleDrive:e.uploadedToGoogleDrive,google_drive_file_url:e.google_drive_file_url,google_drive_file_id:e.google_drive_file_id,upload_to_google_drive_status:e.upload_to_google_drive_status,upload_to_google_drive_started_at:e.upload_to_google_drive_started_at,upload_to_google_drive_error:e.upload_to_google_drive_error,createdAt:e.createdAt,updatedAt:e.updatedAt,derivedStatus:W,isReady:M,isProcessing:B,isFailed:N},timestamp:(new Date).toISOString()}),ve.debug("Long video state at Google Drive button click","LongVideoCard",{videoId:e.id,requestId:o,title:e.title||"Untitled",status:W,videoUrl:e.videoUrl||null,isReady:M,isProcessing:B,isFailed:N,videoProgress:H,uploadedToGoogleDrive:e.uploadedToGoogleDrive||!1,google_drive_file_url:e.google_drive_file_url||null,google_drive_file_id:e.google_drive_file_id||null,upload_to_google_drive_status:e.upload_to_google_drive_status||null,localUploadedToGoogleDrive:F.uploadedToGoogleDrive||!1,local_google_drive_file_url:F.googleDriveFileUrl||null,local_google_drive_file_id:F.googleDriveFileId||null,local_upload_to_google_drive_status:F.uploadToGoogleDriveStatus||null,isDriveUploading:O,isUploadingToGoogleDrive:J(),calculatedIsUploaded:Q()}),J())return ve.info("Google Drive upload already in progress","LongVideoCard",{videoId:e.id}),void X(a("uploadInProgress","Upload is already in progress..."),"info");const t=F.googleDriveFileUrl||e.google_drive_file_url;if(ve.info("Checking for Google Drive URL","LongVideoCard",{videoId:e.id,driveFileUrl:t||null,localStateUrl:Boolean(F.googleDriveFileUrl),videoStateUrl:Boolean(e.google_drive_file_url)}),t)return ve.info("Opening Google Drive file from LongVideoCard","LongVideoCard",{videoId:e.id,googleDriveUrl:t}),window.open(t,"_blank"),void X(a("openingGoogleDriveFile","Opening existing Google Drive file"),"info");const i=F.uploadedToGoogleDrive||e.uploadedToGoogleDrive;if(ve.info("Checking upload flags","LongVideoCard",{videoId:e.id,isUploadedFlag:i,localStateUploadedFlag:F.uploadedToGoogleDrive||!1,videoStateUploadedFlag:e.uploadedToGoogleDrive||!1}),i){ve.warn("Video marked as uploaded to Google Drive but URL is missing","LongVideoCard",{videoId:e.id,uploadedToGoogleDrive:e.uploadedToGoogleDrive||!1,localUploadedToGoogleDrive:F.uploadedToGoogleDrive||!1,videoUrl:e.videoUrl||null,timestamp:(new Date).toISOString()}),X(a("videoAlreadyUploadedToDrive","This video is already uploaded to Google Drive but the URL is not available"),"warning");const o=window.confirm(a("confirmReuploadToDrive","This video is marked as uploaded to Google Drive, but the URL is not available. Do you want to upload it again?"));if(ve.info("User confirmation for re-upload from uploaded flag","LongVideoCard",{videoId:e.id,confirmResult:o}),!o)return}const r="completed"===F.uploadToGoogleDriveStatus||"completed"===e.upload_to_google_drive_status;if(ve.info("Checking completed status","LongVideoCard",{videoId:e.id,completedStatus:r,localUploadStatus:F.uploadToGoogleDriveStatus||null,videoUploadStatus:e.upload_to_google_drive_status||null}),r){ve.warn("Upload status is completed but Google Drive URL is missing","LongVideoCard",{videoId:e.id,localUploadStatus:F.uploadToGoogleDriveStatus||null,videoUploadStatus:e.upload_to_google_drive_status||null,timestamp:(new Date).toISOString()}),X(a("videoAlreadyUploadedToDrive","Upload is marked as completed but the URL is not available"),"warning");const o=window.confirm(a("confirmReuploadToDrive","The upload is marked as completed, but the URL is not available. Do you want to upload it again?"));if(ve.info("User confirmation for re-upload from completed status","LongVideoCard",{videoId:e.id,confirmResult:o}),!o)return}if(!M)return void X(a("videoNotReady","Video is not ready for Google Drive upload. Please wait for video processing to complete."),"warning");if(!e.videoUrl)return void X(a("noVideoUrlFound","No video URL found to upload."),"error");R(!0),ve.debug("Setting isDriveUploading to TRUE - State check immediately after","LongVideoCard",{videoId:e.id,isDriveUploading:!0,functionCheckResult:J(),timestamp:(new Date).toISOString()}),ve.info("Starting Google Drive upload process for long video","LongVideoCard",{videoId:e.id,requestId:o,videoUrl:e.videoUrl||null,timestamp:(new Date).toISOString(),action:"mutation_start",mutationType:"UPLOAD_LONG_VIDEO_TO_GOOGLE_DRIVE"});const s=Date.now();Z({variables:{input:{videoId:e.id,videoType:"long",videoUrl:e.videoUrl}}}).then(({data:t})=>{const i=Date.now()-s;ve.debug("GraphQL response structure debug log","LongVideoCard",{videoId:e.id,requestId:o,responseTime:i,fullResponseData:t,responseKeys:Object.keys(t||{}),nestedKeys:t?Object.keys(t||{}).map(e=>`${e}: ${Object.keys(t[e]||{}).join(", ")}`):[],timestamp:(new Date).toISOString()}),t&&t.uploadToGoogleDrive?(ve.info("Google Drive upload mutation result for long video","LongVideoCard",{videoId:e.id,requestId:o,responseTime:i,success:t.uploadToGoogleDrive.success||!1,message:t.uploadToGoogleDrive.message||null,fileId:t.uploadToGoogleDrive.fileId||null,fileUrl:t.uploadToGoogleDrive.fileUrl||null,errors:t.uploadToGoogleDrive.errors||[],timestamp:(new Date).toISOString(),action:"mutation_complete",mutationType:"UPLOAD_LONG_VIDEO_TO_GOOGLE_DRIVE"}),t.uploadToGoogleDrive.success?ve.debug("GraphQL Google Drive upload success metadata","LongVideoCard",{videoId:e.id,requestId:o,currentState:{uploadedToGoogleDrive:F.uploadedToGoogleDrive,uploadToGoogleDriveStatus:F.uploadToGoogleDriveStatus,isDriveUploading:O},rawResponse:JSON.stringify(t),responseType:"success",notes:"The mutation was successful. Now waiting for WebSocket notification when the background job completes."}):ve.warn("GraphQL Google Drive upload returned unsuccessful status","LongVideoCard",{videoId:e.id,requestId:o,errors:t.uploadToGoogleDrive.errors||[],rawResponse:JSON.stringify(t),responseType:"unsuccessful"})):ve.warn("Google Drive upload mutation returned unexpected response format","LongVideoCard",{videoId:e.id,requestId:o,responseTime:i,response:JSON.stringify(t),responseStructure:t?Object.keys(t).join(", "):"null data",timestamp:(new Date).toISOString(),action:"mutation_error",errorType:"unexpected_format",mutationType:"UPLOAD_LONG_VIDEO_TO_GOOGLE_DRIVE"})}).catch(t=>{const i=Date.now()-s;ve.error("Google Drive upload mutation error for long video","LongVideoCard",{videoId:e.id,requestId:o,responseTime:i,error:t.message||"Unknown error",errorStack:t.stack||null,timestamp:(new Date).toISOString(),action:"mutation_error",errorType:"exception",mutationType:"UPLOAD_LONG_VIDEO_TO_GOOGLE_DRIVE",resetUIState:"Resetting isDriveUploading to false due to error"}),R(!1)})})()},disabled:J(),size:"small",children:d.jsx(h,{title:Q()?a("alreadyUploadedToDrive","Already uploaded to Google Drive"):J()?a("uploadingToDrive","Upload in progress..."):a("uploadToDrive","Upload to Google Drive"),children:J()?d.jsx(y,{size:20,color:"inherit"}):d.jsx(_,{variant:"dot",color:"success",invisible:!Q(),sx:{"& .MuiBadge-badge":{right:2,top:2}},children:d.jsx(j,{sx:n({fontSize:28,transition:"all 0.2s ease"},Q()&&{"&:hover":{transform:"scale(1.15)",filter:"drop-shadow(0 0 2px #1a73e8)"}})})})})}),M&&!e.textOnly&&d.jsx(f,{sx:{color:"grey.600",p:1},onClick:o=>{o.stopPropagation(),M&&e.videoUrl&&be(()=>import("./main-fFbGxLEq.js").then(e=>e.dc),__vite__mapDeps([0,1,2,3,4,5])).then(o=>{const t=o.default,i=`long_video_${e.id}.mp4`;t(e.videoUrl,i)})},disabled:!M||!e.videoUrl,size:"small",children:d.jsx(h,{title:a("downloadVideo","Download Video"),children:d.jsx(w,{sx:{fontSize:32}})})})]}),d.jsx(S,{variant:"outlined",color:"primary",size:"small",endIcon:d.jsx(T,{}),onClick:t=>{t.stopPropagation(),o(e.id)},sx:{borderRadius:"20px",textTransform:"none"},children:a("details","Details")})]})]}),d.jsx(we,{open:A,onClose:()=>z(!1),video:e,onUploadSuccess:e=>{z(!1),G(!1),E(o=>l(n({},o),{youtubeSubmitted:!0,youtubeVideoId:e.videoId,youtubeVideoUrl:e.videoUrl})),X(a("youtubeUploadStarted","Video upload to YouTube started!"),"success")},videoType:"long"})]})},Oe=e=>{if(!e)return"0:00";return`${Math.floor(e/60)}:${Math.round(e%60).toString().padStart(2,"0")}`},Re=(e,o)=>{switch(e){case"ready":return o("statusReady","Ready");case"generating_text":return o("statusGeneratingText","Generating script");case"text_ready":return o("statusScriptReady","Script ready");case"generating_audio":return o("statusGeneratingAudio","Generating audio");case"generating_images":return o("statusGeneratingImages","Generating images");case"images_ready":return o("statusImagesReady","Images ready");case"ready_for_video":case"processing_video":return o("statusProcessingVideo","Processing video");case"error":case"failed":return o("statusFailed","Failed");default:return e}},Ae=({video:e,onViewDetails:o})=>{const{t:t}=me("admin"),i=O(),r=R(i.breakpoints.down("sm")),a=R(i.breakpoints.down("md")),s="ready"===e.status,n=["generating_text","text_ready","generating_audio","generating_images","images_ready","ready_for_video","processing_video"].includes(e.status),l="error"===e.status||"failed"===e.status,u=e.progress||(e=>{switch(e){case"generating_text":return 20;case"text_ready":return 30;case"generating_audio":return 40;case"generating_images":return 60;case"images_ready":return 80;case"ready_for_video":case"processing_video":return 90;case"ready":return 100;default:return 0}})(e.status);return d.jsx(A,{elevation:1,sx:{p:2,borderRadius:"12px",transition:"all 0.2s ease","&:hover":{boxShadow:"0 4px 12px rgba(0,0,0,0.08)",transform:"translateY(-2px)"}},children:d.jsxs(z,{container:!0,spacing:2,children:[d.jsx(z,{item:!0,xs:4,sm:3,md:2,lg:2,sx:{dis
2play:"flex",alignItems:"center"},children:(()=>{if(s&&e.thumbnailUrl){const o=ye(e.thumbnailUrl,r?"320w":"640w");return d.jsxs(c,{sx:{position:"relative",width:r?"100px":"160px",height:r?"56px":"90px",flexShrink:0},children:[d.jsx(c,{component:"img",src:o,alt:e.title||"Video thumbnail",sx:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}),s&&d.jsx(f,{size:"small",sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",bgcolor:"rgba(255,255,255,0.8)","&:hover":{bgcolor:"white"},width:r?"28px":"36px",height:r?"28px":"36px"},children:d.jsx(C,{fontSize:r?"small":"medium"})})]})}if(e.picturesDone&&e.images&&e.images.length>0){const o=(Array.isArray(e.images)?[...e.images]:[]).filter(e=>e&&"completed"===e.status).sort((e,o)=>e.position-o.position);if(o.length>0){const t=o[0],i=t.s3Url||t.url;if(i){const o=ye(i,r?"320w":"640w");return d.jsxs(c,{sx:{position:"relative",width:r?"100px":"160px",height:r?"56px":"90px",flexShrink:0},children:[d.jsx(c,{component:"img",src:o,alt:e.title||"Video first image",sx:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}),s&&d.jsx(f,{size:"small",sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",bgcolor:"rgba(255,255,255,0.8)","&:hover":{bgcolor:"white"},width:r?"28px":"36px",height:r?"28px":"36px"},children:d.jsx(C,{fontSize:r?"small":"medium"})})]})}}}return d.jsx(c,{sx:{width:r?"100px":"160px",height:r?"56px":"90px",flexShrink:0,bgcolor:"action.hover",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center"},children:d.jsx(V,{sx:{fontSize:r?24:36,color:n?"primary.main":l?"error.main":"grey.400"}})})})()}),d.jsx(z,{item:!0,xs:8,sm:6,md:7,lg:8,children:d.jsxs(c,{sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"center"},children:[d.jsx(c,{sx:{mb:1},children:d.jsx(g,{label:Re(e.status,t),size:"small",color:(b=e.status,"ready"===b?"success":["generating_text","text_ready","generating_audio","generating_images","images_ready","ready_for_video","processing"].includes(b)?"warning":"error"===b||"failed"===b?"error":"default"),sx:{borderRadius:"12px",fontWeight:500}})}),d.jsx(m,{variant:r?"body1":"h6",sx:{fontWeight:600,mb:.5,lineHeight:1.2,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",minHeight:r?"auto":"2.4em"},children:(()=>{if(("theme.custom.custom"===e.title||"theme.custom.custom"===e.theme)&&e.customTheme&&"string"==typeof e.customTheme)return e.customTheme;if(e.title&&"theme.custom.custom"!==e.title)return e.title;if(e.theme&&"theme.custom.custom"!==e.theme){if("string"==typeof e.theme&&!e.theme.includes("custom"))return e.theme.replaceAll("_"," ");if("object"==typeof e.theme&&null!==e.theme){const o=Object.keys(e.theme);for(const t of o)if("string"==typeof e.theme[t]&&!t.includes("custom")&&!e.theme[t].includes("custom"))return e.theme[t].replaceAll("_"," ")}}return e.customTheme&&"string"==typeof e.customTheme?e.customTheme:t("untitledVideo","Untitled video")})()}),d.jsxs(c,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:2,mb:.5},children:[d.jsxs(c,{sx:{display:"flex",alignItems:"center",color:"text.secondary"},children:[d.jsx(v,{sx:{fontSize:16,mr:.5}}),d.jsx(m,{variant:"body2",children:Oe(e.audioDuration||e.duration||0)})]}),d.jsxs(m,{variant:"body2",color:"text.secondary",children:[t("created","Created"),": ",new Date(e.createdAt).toLocaleDateString()]})]}),n&&d.jsx(c,{sx:{mt:1,mb:1},children:d.jsx(U,{variant:"determinate",value:u,sx:{height:5,borderRadius:2}})}),l&&e.errorMessage&&d.jsx(m,{variant:"body2",color:"error.main",sx:{mt:.5,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical"},children:e.errorMessage})]})}),d.jsx(z,{item:!0,xs:12,sm:3,md:3,lg:2,sx:{display:"flex",alignItems:"center"},children:d.jsxs(c,{sx:{width:"100%",display:"flex",justifyContent:a?"flex-start":"flex-end",alignItems:"center",gap:2,flexWrap:"wrap"},children:[r?null:d.jsxs(F,{direction:"row",spacing:1,sx:{mt:a?1:0},children:[d.jsx(h,{title:t("scriptStatus","Script status"),children:d.jsx(g,{size:"small",icon:d.jsx(L,{fontSize:"small"}),label:t("script","Script"),color:e.textDone?"success":n&&"generating_text"===e.status?"warning":"default",variant:e.textDone?"filled":"outlined"})}),d.jsx(h,{title:t("audioStatus","Audio status"),children:d.jsx(g,{size:"small",icon:d.jsx(p,{fontSize:"small"}),label:t("audio","Audio"),color:e.audioDone?"success":n&&["text_ready","generating_audio"].includes(e.status)?"warning":"default",variant:e.audioDone?"filled":"outlined"})}),d.jsx(h,{title:t("imagesStatus","Images status"),children:d.jsx(g,{size:"small",icon:d.jsx(k,{fontSize:"small"}),label:t("images","Images"),color:e.picturesDone?"success":n&&"generating_images"===e.status?"warning":"default",variant:e.picturesDone?"filled":"outlined"})})]}),d.jsx(x,{orientation:"vertical",flexItem:!0,sx:{display:{xs:"none",md:"block"}}}),d.jsx(S,{variant:"outlined",color:"primary",size:"small",endIcon:d.jsx(T,{}),onClick:()=>o(e.id),sx:{borderRadius:"20px",textTransform:"none"},children:t("details","Details")})]})})]})});var b},ze=()=>{const{t:e}=me("admin"),o=ge();return d.jsxs(A,{elevation:0,sx:{p:5,mt:4,borderRadius:4,display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",minHeight:"40vh",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.02)",border:"1px dashed rgba(0, 0, 0, 0.1)"},children:[d.jsx(m,{variant:"h5",gutterBottom:!0,fontWeight:600,children:e("noVideosYet","No videos yet")}),d.jsx(m,{variant:"body1",color:"text.secondary",sx:{maxWidth:500,mb:4},children:e("createFirstLongVideo","You haven't created any long videos yet. Create your first long video by adding text, selecting a style, and generating it with AI.")}),d.jsx(S,{variant:"contained",color:"primary",size:"large",startIcon:d.jsx(E,{}),onClick:()=>{o("/create/long-video")},sx:{borderRadius:"50px",px:4,py:1.2,textTransform:"none",fontSize:"1rem"},children:e("createFirstVideo","Create your first video")})]})},Fe=({onClearFilters:e})=>{const{t:o}=me("admin");return d.jsxs(A,{elevation:0,sx:{p:5,mt:4,borderRadius:4,display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",minHeight:"30vh",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.02)",border:"1px dashed rgba(0, 0, 0, 0.1)"},children:[d.jsx(P,{sx:{fontSize:60,color:"text.secondary",opacity:.7,mb:2}}),d.jsx(m,{variant:"h5",gutterBottom:!0,fontWeight:600,children:o("noMatchingVideos","No matching videos found")}),d.jsx(m,{variant:"body1",color:"text.secondary",sx:{maxWidth:500,mb:4},children:o("noMatchingVideosDescription","We couldn't find any videos matching your current filters. Try adjusting your search criteria.")}),d.jsx(S,{variant:"outlined",color:"primary",onClick:e,sx:{borderRadius:"50px",px:3,py:1,textTransform:"none"},children:o("clearAllFilters","Clear all filters")})]})},Ee=({anchorEl:e,open:o,selectedOption:t,onClose:i})=>{const{t:r}=me("admin"),a=[{id:"newest",label:r("sortNewest","Newest first"),icon:d.jsx(v,{fontSize:"small"})},{id:"oldest",label:r("sortOldest","Oldest first"),icon:d.jsx(v,{fontSize:"small"})},{id:"longest",label:r("sortLongest","Longest first"),icon:d.jsx(Y,{fontSize:"small"})},{id:"shortest",label:r("sortShortest","Shortest first"),icon:d.jsx(Y,{fontSize:"small"})},{id:"name-asc",label:r("sortNameAsc","Name (A-Z)"),icon:d.jsx(W,{fontSize:"small"})},{id:"name-desc",label:r("sortNameDesc","Name (Z-A)"),icon:d.jsx(W,{fontSize:"small"})}];
2return d.jsxs(M,{id:"sort-menu",anchorEl:e,open:o,onClose:()=>i(),MenuListProps:{"aria-labelledby":"sort-button"},PaperProps:{elevation:3,sx:{minWidth:200,maxWidth:"90vw",overflow:"visible",filter:"drop-shadow(0px 2px 8px rgba(0,0,0,0.1))",borderRadius:2,mt:1.5}},transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[d.jsxs(B,{disabled:!0,sx:{opacity:.7},children:[d.jsx(N,{children:d.jsx(H,{fontSize:"small"})}),d.jsx($,{children:r("sortBy","Sort by")})]}),d.jsx(x,{}),a.map(e=>d.jsxs(B,{selected:t===e.id,onClick:()=>{Ie.dropdownItemSelected("sort-menu-option","sort-menu",{selectedOption:e.id,previousOption:t,optionLabel:e.label,component:"long-video-library"}),i(e.id)},sx:{borderLeft:o=>t===e.id?`3px solid ${o.palette.primary.main}`:"3px solid transparent",py:1},children:[d.jsx(N,{children:e.icon}),d.jsx($,{children:e.label})]},e.id))]})},Pe=({anchorEl:e,open:o,selectedFilter:t,onClose:i})=>{const{t:r}=me("admin"),a=[{id:"all",label:r("allStatuses","All statuses"),icon:d.jsx(q,{fontSize:"small",color:"action"})},{id:"done",label:r("completed","Completed"),icon:d.jsx(Q,{fontSize:"small",color:"success"})},{id:"processing",label:r("processing","Processing"),icon:d.jsx(J,{fontSize:"small",color:"warning"})},{id:"failed",label:r("failed","Failed"),icon:d.jsx(K,{fontSize:"small",color:"error"})}];return d.jsxs(M,{id:"filter-menu",anchorEl:e,open:o,onClose:()=>i(),MenuListProps:{"aria-labelledby":"filter-button"},PaperProps:{elevation:3,sx:{minWidth:200,maxWidth:"90vw",overflow:"visible",filter:"drop-shadow(0px 2px 8px rgba(0,0,0,0.1))",borderRadius:2,mt:1.5}},transformOrigin:{horizontal:"right",vertical:"top"},anchorOrigin:{horizontal:"right",vertical:"bottom"},children:[d.jsxs(B,{disabled:!0,sx:{opacity:.7},children:[d.jsx(N,{children:d.jsx(Z,{fontSize:"small"})}),d.jsx($,{children:r("filterBy","Filter by status")})]}),d.jsx(x,{}),a.map(e=>d.jsxs(B,{selected:t===e.id,onClick:()=>{Ie.dropdownItemSelected("filter-menu-option","filter-menu",{selectedOption:e.id,previousOption:t,optionLabel:e.label,component:"long-video-library"}),i(e.id)},sx:{borderLeft:o=>t===e.id?`3px solid ${o.palette.primary.main}`:"3px solid transparent",py:1},children:[d.jsx(N,{children:e.icon}),d.jsx($,{children:e.label})]},e.id))]})},Ye=({viewMode:e="grid"})=>{const o="grid"===e?9:5;return"grid"===e?d.jsx(z,{container:!0,spacing:3,sx:{mt:2},children:Array(o).fill(0).map((e,o)=>d.jsx(z,{item:!0,xs:12,sm:6,md:4,lg:4,children:d.jsxs(c,{sx:{borderRadius:2,overflow:"hidden",boxShadow:"0 2px 8px rgba(0,0,0,0.05)",bgcolor:"background.paper",height:"100%"},children:[d.jsx(X,{variant:"rectangular",width:"100%",height:180,animation:"wave"}),d.jsxs(c,{sx:{p:2},children:[d.jsx(X,{variant:"text",width:"70%",height:32,animation:"wave"}),d.jsx(X,{variant:"text",width:"40%",height:20,animation:"wave"}),d.jsxs(c,{sx:{display:"flex",mt:2,gap:1},children:[d.jsx(X,{variant:"rounded",width:60,height:24,animation:"wave"}),d.jsx(X,{variant:"rounded",width:80,height:24,animation:"wave"})]}),d.jsxs(c,{sx:{display:"flex",justifyContent:"space-between",mt:2,pt:2,borderTop:"1px solid",borderColor:"divider"},children:[d.jsx(X,{variant:"rounded",width:100,height:36,animation:"wave"}),d.jsx(X,{variant:"circular",width:36,height:36,animation:"wave"})]})]})]})},o))}):d.jsx(c,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:Array(o).fill(0).map((e,o)=>d.jsxs(c,{sx:{display:"flex",p:2,borderRadius:2,boxShadow:"0 2px 8px rgba(0,0,0,0.05)",bgcolor:"background.paper",overflow:"hidden"},children:[d.jsx(X,{variant:"rectangular",width:120,height:80,animation:"wave",sx:{borderRadius:1}}),d.jsxs(c,{sx:{ml:2,flexGrow:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[d.jsxs(c,{children:[d.jsx(X,{variant:"text",width:"50%",height:28,animation:"wave"}),d.jsxs(c,{sx:{display:"flex",gap:1,mt:1},children:[d.jsx(X,{variant:"rounded",width:60,height:20,animation:"wave"}),d.jsx(X,{variant:"rounded",width:80,height:20,animation:"wave"}),d.jsx(X,{variant:"rounded",width:70,height:20,animation:"wave"})]})]}),d.jsxs(c,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mt:1},children:[d.jsx(X,{variant:"text",width:"30%",height:20,animation:"wave"}),d.jsx(X,{variant:"rounded",width:90,height:32,animation:"wave"})]})]})]},o))})},We=({error:e,onRetry:o})=>{const{t:t}=me("admin");return d.jsxs(A,{elevation:0,sx:{p:5,mt:4,borderRadius:4,display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",minHeight:"30vh",justifyContent:"center",backgroundColor:"rgba(255, 0, 0, 0.03)",border:"1px dashed rgba(255, 0, 0, 0.2)"},children:[d.jsx(ee,{sx:{fontSize:60,color:"error.main",mb:2}}),d.jsx(m,{variant:"h5",gutterBottom:!0,fontWeight:600,children:t("errorLoadingVideos","Error Loading Videos")}),d.jsx(oe,{severity:"error",sx:{mb:3,maxWidth:500},children:(null==e?void 0:e.message)||t("unknownError","An unknown error occurred")}),d.jsx(m,{variant:"body1",color:"text.secondary",sx:{maxWidth:500,mb:4},children:t("errorLoadingDescription","We encountered a problem while loading your videos. This could be due to a network issue or server problem.")}),d.jsx(S,{variant:"contained",color:"primary",onClick:o,sx:{borderRadius:"50px",px:3,py:1,textTransform:"none"},children:t("tryAgain","Try Again")})]})},Me=()=>{var e;const{t:o}
2=me("admin"),t=O(),i=R(t.breakpoints.down("sm")),r=ge(),a=ce.useRef(null),s=ce.useRef(null),[u,g]=ce.useState([]),[p,v]=ce.useState(0),[x,h]=ce.useState(!0),[b,_]=ce.useState(""),[D,j]=ce.useState("newest"),[w,T]=ce.useState("all"),[I,G]=ce.useState("grid"),[C,V]=ce.useState(!1),[U,L]=ce.useState(!1),[k,A]=ce.useState(new Date),[F,E]=ce.useState(null),[P,Y]=ce.useState(null),[W,M]=ce.useState({open:!1,message:"",severity:"info"}),[B,N]=ce.useState(0),{data:$,loading:q,error:Q,refetch:J,fetchMore:K}=xe(_e,{variables:{limit:24,offset:0},fetchPolicy:"cache-and-network",notifyOnNetworkStatusChange:!0});ce.useEffect(()=>{var e;(null==(e=null==$?void 0:$.longVideos)?void 0:e.videos)&&(g($.longVideos.videos),h($.longVideos.videos.length<$.longVideos.totalCount))},[$]),ce.useEffect(()=>{i&&"grid"===I&&G("list")},[i]),ce.useEffect(()=>{!q&&$&&(A(new Date),L(!1))},[$,q]),ce.useEffect(()=>{const e=new IntersectionObserver(e=>{e[0].isIntersecting&&x&&!C&&!q&&ve()},{threshold:.1});return a.current=e,s.current&&x&&e.observe(s.current),()=>{e&&s.current&&e.unobserve(s.current)}},[x,C,q,p,u]);const X=pe.useMemo(()=>{let e=[...u];if("all"!==w&&(e=e.filter(e=>"done"===w?"ready"===e.status:"processing"===w?["processing","generating_text","text_ready","generating_audio","generating_images","images_ready","ready_for_video"].includes(e.status):"failed"!==w||Boolean(e.errorMessage))),1===B?e=e.filter(e=>e.featured):2===B&&(e=e.filter(e=>"YourCategory"===e.categoryName)),b){const o=b.toLowerCase();e=e.filter(e=>e.title&&e.title.toLowerCase().includes(o))}return e.sort((e,o)=>"newest"===D?new Date(o.createdAt)-new Date(e.createdAt):"oldest"===D?new Date(e.createdAt)-new Date(o.createdAt):"longest"===D?(o.duration||0)-(e.duration||0):"shortest"===D?(e.duration||0)-(o.duration||0):"name-asc"===D?(e.title||"").localeCompare(o.title||""):"name-desc"===D?(o.title||"").localeCompare(e.title||""):0),e},[u,b,D,w,B]),ee=pe.useMemo(()=>u.filter(e=>["processing","generating_text","text_ready","generating_audio","generating_images","images_ready","ready_for_video"].includes(e.status)).length,[u]),ve=()=>{return e=null,o=null,t=function*(){var e,o;if(!x||C||q)return;Ie.buttonClicked("load-more-videos","long-video-library",{currentPage:p,nextPage:p+1,currentVideosCount:u.length,videosPerPage:24,hasMore:x,searchQuery:b,sortBy:D,filterStatus:w,viewMode:I}),V(!0);const t=p+1,i=24*t;try{const r=yield K({variables:{offset:i,limit:24},updateQuery:(e,{fetchMoreResult:o})=>{if(!o)return e;const t=o.longVideos.totalCount,r=i+o.longVideos.videos.length<t;return h(r),{longVideos:l(n({},o.longVideos),{videos:[...e.longVideos.videos,...o.longVideos.videos],__typename:o.longVideos.__typename})}}});(null==(o=null==(e=null==r?void 0:r.data)?void 0:e.longVideos)?void 0:o.videos)&&(g(e=>[...e,...r.data.longVideos.videos]),v(t))}catch(r){fe("Failed to load more videos","error")}finally{V(!1)}},new Promise((i,r)=>{var a=e=>{try{n(t.next(e))}catch(o){r(o)}},s=e=>{try{n(t.throw(e))}catch(o){r(o)}},n=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);n((t=t.apply(e,o)).next())});var e,o,t},fe=(e,o="info")=>{M({open:!0,message:e,severity:o})},he=()=>{M(l(n({},W),{open:!1}))},be=e=>{r(`/create/long-video-detail/${e}`)},ye=e=>{e?navigator.clipboard.writeText(e).then(()=>{fe(o("linkCopied","Link copied to clipboard"),"success")}).catch(e=>{fe(o("copyLinkError","Failed to copy link"),"error")}):fe(o("noLinkAvailable","No video link available"),"warning")};return q&&!$?d.jsx(Ye,{viewMode:I}):Q?d.jsx(We,{error:Q,onRetry:J}):u&&0!==u.length?d.jsxs(c,{sx:{p:2},children:[ee>0&&d.jsxs(c,{sx:{display:"flex",alignItems:"center",bgcolor:"primary.light",color:"primary.dark",borderRadius:2,p:1.5,mb:3},children:[d.jsx(c,{sx:{display:"flex",alignItems:"center",animation:"spin 2s linear infinite",mr:1},children:d.jsx(te,{})}),d.jsxs(m,{variant:"body2",fontWeight:500,children:[ee," video",ee>1?"s":""," currently processing"]}),d.jsx(c,{sx:{flexGrow:1}}),d.jsx(S,{variant:"outlined",size:"small",onClick:()=>{L(!0),v(0),J({limit:24,offset:0}).then(e=>{var o,t;(null==(t=null==(o=null==e?void 0:e.data)?void 0:o.longVideos)?void 0:t.videos)&&(g(e.data.longVideos.videos),h(e.data.longVideos.videos.length<e.data.longVideos.totalCount),fe("Library refreshed","success"))}).catch(e=>{fe("Failed to refresh","error"),L(!1)})},disabled:U,startIcon:U?d.jsx(y,{size:16}):d.jsx(te,{}),sx:{color:"primary.dark",borderColor:"primary.dark"},children:U?"Refreshing...":"Refresh"})]}),d.jsxs(ie,{value:B,onChange:(e,o)=>{N(o)},sx:{mb:3,"& .MuiTabs-indicator":{backgroundColor:"primary.main",height:3,borderRadius:"3px 3px 0 0"}},children:[d.jsx(re,{label:o("allVideos","All Videos"),sx:{textTransform:"none",fontWeight:0===B?600:400,fontSize:"1rem"}}),d.jsx(re,{label:o("featured","Featured"),sx:{textTransform:"none",fontWeight:1===B?600:400,fontSize:"1rem"}}),d.jsx(re,{label:o("recent","Recent"),sx:{textTransform:"none",fontWeight:2===B?600:400,fontSize:"1rem"}})]}),d.jsxs(c,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{xs:"stretch",sm:"center"},mb:3,gap:2},children:[d.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:2},children:[d.jsx(ae,{placeholder:o("searchVideos","Search videos"),variant:"outlined",size:"small",value:b,onChange:e=>_(e.target.value),sx:{maxWidth:{sm:"320px"},".MuiOutlinedInput-root":{borderRadius:"8px",bgcolor:"background.paper",height:"40px"}},InputProps:{startAdornment:d.jsx(se,{position:"start",children:d.jsx(ne,{fontSize:"small"})})}}),!U&&d.jsxs(m,{variant:"caption",color:"text.secondary",sx:{dis
2play:{xs:"none",md:"block"}},children:["Last updated: ",(()=>{const e=new Date,o=Math.floor((e-k)/1e3);if(o<60)return`${o}s ago`;return`${Math.floor(o/60)}m ago`})()]})]}),d.jsxs(c,{sx:{display:"flex",gap:1},children:[d.jsx(S,{variant:"outlined",size:"small",startIcon:d.jsx(H,{}),onClick:e=>E(e.currentTarget),sx:{borderRadius:"100px",textTransform:"none",minWidth:"120px",justifyContent:"flex-start",bgcolor:"background.paper",color:"text.secondary",borderColor:"divider",height:"40px",px:2},children:o(`sortBy_${D}`,D.replace("-"," "))}),d.jsxs(S,{variant:"outlined",size:"small",startIcon:d.jsx(Z,{}),onClick:e=>Y(e.currentTarget),sx:{borderRadius:"100px",textTransform:"none",minWidth:"120px",justifyContent:"flex-start",bgcolor:"background.paper",color:"text.secondary",borderColor:"divider",height:"40px",px:2},children:["all"===w&&o("allStatuses","All statuses"),"done"===w&&o("completed","Completed"),"processing"===w&&o("processing","Processing"),"failed"===w&&o("failed","Failed")]}),!i&&d.jsx(f,{onClick:()=>{G(e=>"grid"===e?"list":"grid")},sx:{border:"1px solid",borderColor:"grey.200",borderRadius:"50%"},children:"grid"===I?d.jsx(le,{}):d.jsx(de,{})})]})]}),X.length>0?d.jsxs(c,{sx:{width:"100%",mt:2},children:["grid"===I?d.jsx(z,{container:!0,spacing:3,children:X.map(e=>d.jsx(z,{item:!0,xs:12,sm:6,md:4,lg:4,children:d.jsx(ke,{video:e,onViewDetails:()=>be(e.id),onCopyLink:ye})},e.id))}):d.jsx(c,{sx:{display:"flex",flexDirection:"column",gap:2},children:X.map(e=>d.jsx(Ae,{video:e,onViewDetails:()=>be(e.id),onCopyLink:ye},e.id))}),x&&d.jsxs(c,{ref:s,sx:{textAlign:"center",py:4,opacity:C?1:0},children:[d.jsx(y,{size:30}),d.jsx(m,{variant:"body2",color:"text.secondary",sx:{mt:1},children:"Loading more videos..."})]})]}):d.jsx(Fe,{onClearFilters:()=>{_(""),T("all"),j("newest"),N(0)}}),d.jsx(Ee,{anchorEl:F,open:Boolean(F),selectedOption:D,onClose:e=>{e&&"object"!=typeof e&&j(e),E(null)}}),d.jsx(Pe,{anchorEl:P,open:Boolean(P),selectedFilter:w,onClose:e=>{e&&"object"!=typeof e&&T(e),Y(null)}}),d.jsx(ue,{open:W.open,autoHideDuration:4e3,onClose:he,anchorOrigin:{vertical:"bottom",horizontal:"center"},children:d.jsx(oe,{onClose:he,severity:W.severity,variant:"filled",sx:{borderRadius:2},children:W.message})})]}):0===(null==(e=null==$?void 0:$.longVideos)?void 0:e.totalCount)?d.jsx(ze,{}):d.jsx(Ye,{viewMode:I})};export{Me 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.