1import{s as Q}from"./rolldown-runtime-BgUFPplA.js";import{$s as jr,$t as ha,Bx as no,ES as br,FC as yr,Fl as Sr,Gu as Cr,Hr as Nr,Ii as wr,Lw as cn,Lx as Ar,Ml as Ir,Ni as Tr,Pi as kr,Qr as Gi,Qt as fa,Rd as Rr,Rx as Gs,SS as $r,TS as ao,WS as Pr,Wi as Er,Xl as Lr,Xt as xa,Zt as ga,_x as zs,an as Br,bs as ot,bx as Ys,cn as Dr,cr as No,ds as Mr,du as Fr,eS as Ns,ed as Or,en as va,er as qr,ex as Vr,fn as Qt,fs as Hr,fu as Ur,fx as Ji,gi as Zr,gx as Bn,hx as Te,in as Wr,jl as Kr,jw as ie,ln as Gr,nn as _a,no as oo,nu as Jr,on as zr,pS as io,pw as ce,px as Yn,rn as ja,sn as Yr,tn as ba,un as Qr,ux as be,wS as lo,yS as Xr,yx as Lt}from"./vendor-D2sYtnSq.js";import{$ as ed,C as td,D as wo,Dt as sd,Ft as nd,It as ad,Jt as od,Kt as id,Nt as ld,O as rd,Ot as dd,Pt as cd,T as ud,Xt as md,Yt as pd,a as qs,an as hd,cn as fd,dn as xd,g as ro,h as co,i as zi,j as Ao,k as gd,ln as vd,m as uo,n as _d,nt as jd,on as bd,qt as yd,r as Vs,t as Hs,tt as Sd,w as Cd}from"./vendor-radix-7wwiYcv7.js";import{Ai as mo,Ar as ln,B as Nd,Bt as wd,Di as po,Dr as xn,En as Yi,Ii as Ad,K as Id,Kn as Qi,Li as Td,Mr as kd,N as Rd,Nr as $d,Pr as Pd,Pt as Ed,Qn as ya,R as Xi,Rn as ks,Wn as $n,aa as Ha,ga as Ld,it as el,ji as nn,ki as Bd,kr as Us,ma as Dd,ra as Md,st as tl,ta as ho,va as Pn,xt as Nn,zr as Io}from"./util-Cc90hRJU.js";import{Qn as sl,_n as Fd,la as Od,sa as qd,u as En,wo as Vd}from"./movingZoomHelpers-CMRm4fTk.js";import{E as Hd,Y as Ud,p as Zd,w as nl}from"./amplitude-C4eQ9mmb.js";import{t as al}from"./SafeLocalStorage-BVqrOnpt.js";import{Z as To,d as ko,l as tt,u as ys,y as Ro}from"./utils-BNJoxP0t.js";import{$C as Wd,$x as ol,AC as $o,Cp as Kd,D as il,Dx as Gd,Ex as Jd,Fx as Ss,HD as zd,Hl as Po,Hw as Yd,IE as Qd,Ix as Ue,MD as H,ME as Xd,MT as ec,Ml as tc,Mw as ll,Mx as sc,My as nc,ND as Ut,Nx as ac,Pl as oc,Qh as Cs,Sp as ic,TD as lc,Tx as rc,VD as dc,Xl as un,Yx as Eo,ZC as rl,Zl as cc,Zx as uc,_ as mc,_p as Vt,aS as wn,at as na,bp as Js,cC as dl,ct as cl,ew as Lo,fw as pc,gt as hc,h as it,hn as fc,jC as ul,jT as xc,jw as Bo,lC as Ua,mx as gc,og as aa,pS as fo,ql as Qs,qx as Sa,rO as Do,rg as vc,s as xo,sO as _c,sg as Qn,t as ml,th as js,wD as He,wT as jc,wg as bc,xp as Wt,y as yc,zl as Za}from"./LoadingFullScreen-CJYsF63X.js";import{Ct as Xn,Jr as Sc,Sn as Cc,ea as pl,ln as Nc,q as oa,qi as wc,qn as Ac,qr as Ic,sn as Tc}from"./GAPIContext-D-5o0Wx8.js";import{$ as kc,Ar as Rc,B as $c,Bi as Pc,Bn as Ec,Br as Hn,Dt as Lc,Er as Bc,Fi as hl,Fr as fl,Gn as Dc,Hn as Mc,Hr as Fc,Ii as xl,In as Oc,Ir as qc,Ji as Vc,Jn as Hc,Kn as Uc,La as Zc,Li as Wc,Ln as gl,M as Wa,Mi as Ln,Ni as ea,Pi as sn,Pr as Kt,Ra as Ws,Rn as Kc,Si as rs,Ua as Gc,Ui as Jc,Un as zc,Ur as Yc,V as Qc,Vn as Xc,Vr as eu,Wn as Mo,Yn as tu,Yt as su,Zi as nu,_t as au,br as ou,ca as vl,gt as _l,hi as iu,hn as lu,hr as ru,it as du,la as cu,mr as uu,mt as Ka,na as mu,nr as pu,oa as Ga,pt as Ja,qi as Fo,qn as Oo,rn as qo,s as hu,sa as fu,ta as xu,tr as gu,vi as go,vt as vu,wn as _u,wr as ju,xi as Xs,za as jl,zi as bu,zn as yu,zr as Su}from"./main-HyBMzRwL.js";import{_ as Cu,f as Nu,i as wu,l as Au,m as bl,n as mn,o as Ca,s as Iu,t as Tu,u as ku,v as Ru,y as $u}from"./MagicSubtitleGenericSelect-DBEph4-2.js";import{t as Pu}from"./CollapsibleElement-4nr2mCu_.js";try{let s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new s.Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="794a26c0-54c1-4fb7-ac7e-b05a3a9c4c51",s._sentryDebugIdIdentifier="sentry-dbid-794a26c0-54c1-4fb7-ac7e-b05a3a9c4c51")}catch{}{let s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s._sentryModuleMetadata=s._sentryModuleMetadata||{},s._sentryModuleMetadata[new s.Error().stack]=Object.assign({},s._sentryModuleMetadata[new s.Error().stack],{"_sentryBundlerPluginAppKey:kapwing-app-key":!0})}var Eu=Q(ie()),f=Q(xd());const Lu="1001",Bu="1000",Du="58px",Mu="AllVideos-module_videosContainer_W91V9",Fu="AllVideos-module_wrapper_QRYQM",Ou="AllVideos-module_topRow_RQTGW",qu="AllVideos-module_videoPreviewsColumn_KJL-d",Vu="AllVideos-module_recentChatsColumn_I5J91",Hu="AllVideos-module_bottomRow_v4xi0",Uu="AllVideos-module_videoErrorsColumn_OVZEq",Zu="AllVideos-module_contentContainer_ljjgT",Wu="AllVideos-module_videos_t6zcM",Ku="AllVideos-module_metricsContainer_6-dIc",Gu="AllVideos-module_cluster
1s_vD8Wq",Ju="AllVideos-module_analyticsContainer_sKZiJ",zu="AllVideos-module_showLink_V7Ym9",Yu="AllVideos-module_adminAnalyticsControls_MxAEm",Qu="AllVideos-module_analyticsContainerLeft_04stt";var Pt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Lu,paywallBgZIndex:Bu,collapsedMediaSidebarWidth:Du,videosContainer:Mu,wrapper:Fu,topRow:Ou,videoPreviewsColumn:qu,recentChatsColumn:Vu,bottomRow:Hu,videoErrorsColumn:Uu,contentContainer:Zu,videos:Wu,metricsContainer:Ku,clusters:Gu,analyticsContainer:Ju,showLink:zu,adminAnalyticsControls:Yu,analyticsContainerLeft:Qu};const Xu="1001",em="1000",tm="58px",sm="BlockDomainModal-module_link_KFzTJ",nm="BlockDomainModal-module_overlayContainer_g9rd1",am="BlockDomainModal-module_header_m2rM0",om="BlockDomainModal-module_input_2cbr-",im="BlockDomainModal-module_confirmButton_28hu3";var gn={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Xu,paywallBgZIndex:em,collapsedMediaSidebarWidth:tm,link:sm,overlayContainer:nm,header:am,input:om,confirmButton:im},t=Q(vd());const lm=f.memo(()=>{const s=(0,Eu.c)(12),[e,n]=(0,f.useState)(!1),[a,o]=(0,f.useState)("");let i;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{n(!1)},s[0]=i):i=s[0];const l=i;let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{n(!0)},s[1]=r):r=s[1];const d=r;let c;s[2]!==a?(c=()=>{n(!1),zc(a)},s[2]=a,s[3]=c):c=s[3];const m=c;let h;s[4]===Symbol.for("react.memo_cache_sentinel")?(h=b=>{o(b.target.value)},s[4]=h):h=s[4];const p=h,u=rm;let g;s[5]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsx)("div",{className:gn.link,onClick:d,children:"Block email domain from Suggested Workspaces"}),s[5]=g):g=s[5];let _;s[6]!==m||s[7]!==e||s[8]!==a?(_=e&&(0,t.jsx)(un,{unsetCancelModal:l,noScrollBar:!0,children:(0,t.jsxs)("div",{className:gn.overlayContainer,children:[(0,t.jsx)("div",{className:gn.header,children:"Enter an email domain to block from Suggested Workspaces"}),(0,t.jsx)("div",{children:"e.g. google.com, kapwing.com"}),(0,t.jsx)("br",{}),(0,t.jsx)("input",{className:gn.input,type:"text",value:a,onChange:p,autoFocus:!0,onFocus:u}),(0,t.jsx)("br",{}),(0,t.jsx)("div",{className:gn.confirmButton,onClick:m,children:"Confirm"})]})}),s[6]=m,s[7]=e,s[8]=a,s[9]=_):_=s[9];let v;return s[10]!==_?(v=(0,t.jsxs)(t.Fragment,{children:[g,_]}),s[10]=_,s[11]=v):v=s[11],v});function rm(s){s.target.select()}const dm="1001",cm="1000",um="58px",mm="OnboardingAnalytics-module_container_GqABy",pm="OnboardingAnalytics-module_header_1jJy1",hm="OnboardingAnalytics-module_description_SfpU3";var Rs={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:dm,paywallBgZIndex:cm,collapsedMediaSidebarWidth:um,container:mm,header:pm,description:hm};const fm=()=>{const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)([]),[o,i]=(0,f.useState)([]),[l,r]=(0,f.useState)([]),{domain:d}=document,c=d.startsWith("localhost"),m=d.endsWith(".kapwing-dev.com")||d.startsWith("kapwing-dev")&&d.endsWith(".herokuapp.com")||c&&["3000","4000","5000"].includes(window.location.port)||d.startsWith("192.")||d.startsWith("10.0.")||d.startsWith("10.1.");(0,f.useEffect)(()=>{(async()=>{const _=(await H.admin.getOnboardingData.query({isDev:m})).body.data;e(_.seriesCollapsed.map((v,b)=>{const j=v[0]?.value??0,x=_.seriesLabels[b]?.[1]??"",S=x.split(";"),C=S[0]?.trim()??"",y={occupation:tl(S[1]?.trim()??""),currValue:j};switch(C){case"Work":r(N=>[...N,y]);break;case"School":i(N=>[...N,y]);break;case"Personal Projects":a(N=>[...N,y]);break;default:break}return{label:x,value:j}}))})().catch(console.error)},[]);const h=()=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:Rs.description,children:"Work"}),l.map((g,_)=>(0,t.jsxs)("div",{children:[g.occupation,": ",g.currValue]},`${g.occupation}-${_}`))]}),p=()=>(0,t.jsxs)("div",{children:[(0,t.jsx)("br",{}),(0,t.jsx)("div",{className:Rs.description,children:"School"}),o.map((g,_)=>(0,t.jsxs)("div",{children:[g.occupation,": ",g.currValue]},`${g.occupation}-${_}`))]}),u=()=>(0,t.jsxs)("div",{children:[(0,t.jsx)("br",{}),(0,t.jsx)("div",{className:Rs.description,children:"Personal Projects"}),n.map((g,_)=>(0,t.jsxs)("div",{children:[g.occupation,": ",g.currValue]},`${g.occupation}-${_}`))]});return(0,t.jsxs)("div",{className:Rs.container,children:[(0,t.jsx)("div",{className:Rs.header,children:"Onboarding Analytics"}),s.length>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:Rs.description,children:["Last 24 hours ",(0,t.jsx)("span",{children:m&&"- from KapwingInternal (
1dev)"})]}),(0,t.jsxs)("div",{children:[h(),p(),u()]})]}):(0,t.jsx)("div",{className:Rs.description,children:"Loading stats..."})]})};function xm({timeframe:s="last12",cluster:e=""}){return H.admin.kai.countKaiChats.query({timeframe:s,cluster:e||void 0})}function gm({timeframe:s="last12",proOnly:e=!1,freeOnly:n=!1}){return H.admin.kai.getKaiChats.query({timeframe:s,proOnly:e?"true":void 0,freeOnly:n?"true":void 0})}const vm="1001",_m="1000",jm="58px",bm="RecentChats-module_header_ilZjd",ym="RecentChats-module_showing_gEIWe",Sm="RecentChats-module_selected_3XaBz",Cm="RecentChats-module_unselected_xvTOU",Nm="RecentChats-module_list_iBz1z",wm="RecentChats-module_item_BlxzK",Am="RecentChats-module_itemBody_Gvssf",Im="RecentChats-module_itemHeader_kBNdh",Tm="RecentChats-module_name_-MydE",km="RecentChats-module_meta_Sh-tY",Rm="RecentChats-module_preview_2j3KL",$m="RecentChats-module_emptyState_8Qmq1",Pm="RecentChats-module_messageHistoryList_2vjgu",Em="RecentChats-module_messageHistoryItem_TfB2-",Lm="RecentChats-module_messageHistoryJson_5eC1-",Bm="RecentChats-module_emptyMessages_7I6ls";var st={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:vm,paywallBgZIndex:_m,collapsedMediaSidebarWidth:jm,header:bm,showing:ym,selected:Sm,unselected:Cm,list:Nm,item:wm,itemBody:Am,itemHeader:Im,name:Tm,meta:km,preview:Rm,emptyState:$m,messageHistoryList:Pm,messageHistoryItem:Em,messageHistoryJson:Lm,emptyMessages:Bm},Dm=Q(ie()),Mm=s=>{const e=(0,Dm.c)(26),{timeframe:n}=s,[a,o]=(0,f.useState)(!0);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],e[0]=i):i=e[0];const[l,r]=(0,f.useState)(i),[d,c]=(0,f.useState)("pro"),m=Om;let h;e[1]!==d||e[2]!==n?(h=()=>{o(!0),gm({timeframe:n,proOnly:d==="pro",freeOnly:d==="free"}).then(w=>{const{chats:A}=w;r(A),o(!1)}).catch(w=>{Ue({description:"Failed to load Kai chats",error:w}),o(!1)})},e[1]=d,e[2]=n,e[3]=h):h=e[3];const p=h;let u,g;e[4]!==p?(u=()=>{(function(){p()})()},g=[p],e[4]=p,e[5]=u,e[6]=g):(u=e[5],g=e[6]),(0,f.useEffect)(u,g);let _;e[7]!==l?(_=()=>l.length?(0,t.jsx)("div",{className:st.list,children:l.map(w=>{const A=new Date(w.createdAt),I=m(Date.now()-A.getTime()),D=w,L=Array.isArray(D.messageHistoryArray)?D.messageHistoryArray:w.messageHistory??[];return(0,t.jsx)(be,{to:`/kai/chat/${w._id}`,className:st.item,target:"_blank",rel:"noreferrer",children:(0,t.jsxs)("div",{className:st.itemBody,children:[(0,t.jsxs)("div",{className:st.itemHeader,children:[(0,t.jsx)("div",{className:st.name,children:w.name||"Untitled chat"}),(0,t.jsx)("div",{className:st.meta,children:I})]}),(0,t.jsx)("div",{className:st.preview,children:L.length?(0,t.jsx)("ul",{className:st.messageHistoryList,children:L.map(($,R)=>(0,t.jsx)("li",{className:st.messageHistoryItem,children:(0,t.jsx)("pre",{className:st.messageHistoryJson,children:JSON.stringify($?.content??null,null,2)})},`${w._id}-message-${R}`))}):(0,t.jsx)("div",{className:st.emptyMessages,children:"No messages yet"})})]})},w._id)})}):(0,t.jsx)("div",{className:st.emptyState,children:"No recent chats found."}),e[7]=l,e[8]=_):_=e[8];const v=_;let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("div",{className:st.showing,children:"Recent KAI chats"}),e[9]=b):b=e[9];let j;e[10]!==d?(j=d==="pro"&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:st.selected,children:"Chats by PRO users"}),(0,t.jsx)("div",{onClick:()=>c("free"),className:st.unselected,children:"Chats from FREE users only"}),(0,t.jsx)("div",{onClick:()=>c("all"),className:st.unselected,children:"Chats from ALL users"})]}),e[10]=d,e[11]=j):j=e[11];let x;e[12]!==d?(x=d==="free"&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{onClick:()=>c("pro"),className:st.unselected,children:"Chats by PRO users"}),(0,t.jsx)("div",{className:st.selected,children:"Chats from FREE users only"}),(0,t.jsx)("div",{onClick:()=>c("all"),className:st.unselected,children:"Chats from ALL users"})]}),e[12]=d,e[13]=x):x=e[13];let S;e[14]!==d?(S=d==="all"&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{onClick:()=>c("pro"),className:st.unselected,children:"Chats by PRO users"}),(0,t.jsx)("div",{onClick:()=>c("free"),className:st.unselected,children:"Chats from FREE users only"}),(0,t.jsx)("div",{className:st.selected,children:"Chats from ALL users"})]}),e[14]=d,e[15]=S):S=e[15];let C;e[16]!==j||e[17]!==x||e[18]!==S?(C=(0,t.jsxs)("div",{className:st.header,children:[b,j,x,S]}),e[16]=j,e[17]=x,e[18]=S,e[19]=C):C=e[19];let y;e[20]!==a||e[21]!==v?(y=a?(0,t.jsx)(it,{}):v(),e[20]=a,e[21]=v,e[22]=y):y=e[22];let N;return e[23]!==C||e[24]!==y?(N=(0,t.jsxs)(t.Fragment,{children:[C,y]}),e[23]=C,e[24]=y,e[25]=N):N=e[25],N},Fm=Mm;
1function Om(s){const e=Math.floor(s/1e3);if(e<60)return`${e}s`;const n=Math.floor(e/60);return n<60?`${n}m`:mc(s)}var Na=Q(Qt());function qm({timeframe:s="",cluster:e=""}){return H.admin.processVideoJobs.countInvalid.query({cluster:e,timeframe:s})}function Vm({timeframe:s="",cluster:e=""}){return H.admin.processVideoJobs.countClusterStatus.query({cluster:e,timeframe:s})}function Hm({timeframe:s=""}){return H.admin.processVideoJobs.groupByErrors.query({timeframe:s})}function Um({timeframe:s="",cluster:e=""}){return H.admin.processVideoJobs.countDistinctVideoJobs.query({cluster:e,timeframe:s})}function Zm({skip:s=null,timeframe:e,cluster:n="",proOnly:a=!1}){return H.admin.videos.getVideos.query({skip:s||void 0,timeframe:e,cluster:n||void 0,proOnly:a?"true":void 0})}function Wm({skip:s,timeframe:e,cluster:n=""}){return H.admin.videos.getVideosWithErrors.query({skip:s||void 0,timeframe:e,cluster:n||void 0})}function Km({timeframe:s="last12",cluster:e=""}){return H.admin.videos.countAllVideos.query({timeframe:s,cluster:e||void 0})}function Gm({timeframe:s="last12",cluster:e=""}){return H.admin.videos.countStudioVideos.query({timeframe:s,cluster:e||void 0})}function Jm({timeframe:s="last12",cluster:e=""}){return H.admin.videos.countErrors.query({timeframe:s,cluster:e||void 0})}function zm({timeframe:s="last12",cluster:e=""}){return H.admin.videos.countStudioErrors.query({timeframe:s,cluster:e||void 0})}function Ym({timeframe:s="last12",cluster:e=""}){return H.admin.videos.countDrafts.query({timeframe:s,cluster:e||void 0})}const Qm="1001",Xm="1000",ep="58px",tp="SimpleAnalytics-module_table_MCkZf",sp="SimpleAnalytics-module_tableHeader_qKwf6",np="SimpleAnalytics-module_longRunningRow_hdRHp",ap="SimpleAnalytics-module_count_88yE7",op="SimpleAnalytics-module_countTitle_wRGFW",ip="SimpleAnalytics-module_errorCount_2D5YU",lp="SimpleAnalytics-module_percent_geg--",rp="SimpleAnalytics-module_typeFilter_I8BtF",dp="SimpleAnalytics-module_studioTitle_2xDid",cp="SimpleAnalytics-module_invalid_y83F3",up="SimpleAnalytics-module_kaiChats_ChOI5",mp="SimpleAnalytics-module_lightRow_25uTZ",pp="SimpleAnalytics-module_darkRow_G8h-s";var Qe={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Qm,paywallBgZIndex:Xm,collapsedMediaSidebarWidth:ep,table:tp,tableHeader:sp,longRunningRow:np,count:ap,countTitle:op,errorCount:ip,percent:lp,typeFilter:rp,studioTitle:dp,invalid:cp,kaiChats:up,lightRow:mp,darkRow:pp},Vo={totalVideoCount:0,studioCount:0,draftCount:0,studioErrorCount:0,totalErrorCount:0,invalidVideoCount:0,kaiChatCount:0},hp=class extends f.Component{constructor(s){super(s),this.state={...Vo}}componentDidMount(){this.updateVideoCount()}componentDidUpdate(s){const{timeframe:e,cluster:n}=this.props;(e!==s.timeframe||n!==s.cluster)&&(this.resetCounters(),this.updateVideoCount())}resetCounters=()=>{this.setState({...Vo})};updateVideoCount=async()=>{const{timeframe:s,cluster:e}=this.props;return Promise.all([Km({timeframe:s,cluster:e}).then(n=>{this.setState({totalVideoCount:n})}),Gm({timeframe:s,cluster:e}).then(n=>{this.setState({studioCount:n})}),Ym({timeframe:s,cluster:e}).then(n=>{this.setState({draftCount:n})}),Jm({timeframe:s,cluster:e}).then(n=>{this.setState({totalErrorCount:n})}),zm({timeframe:s,cluster:e}).then(n=>{this.setState({studioErrorCount:n})}),Vm({timeframe:s,cluster:e}).then(n=>{const a=[],o=(n.count||[]).reduce((l,r)=>{const d=r._id.clusterGroup||"",c=r._id.status||"";return a.includes(c)||a.push(c),l[d]?l[d][c]=r.count:l[d]={[c]:r.count},l.total[c]?l.total[c]+=r.count:l.total[c]=r.count,l},{total:{}});a.sort();const i={processVideoJobClusters:{statuses:a,results:o}};this.setState(i)}),Hm({timeframe:s}).then(n=>{const a={processVideoJobErrors:(n.groups||[]).reduce((o,i)=>{const l=i._id.error||"",r=i.count-i.explained;return o[l]={total:i.count,unexplainedCnt:r},o},{})};this.setState(a)}),Um({timeframe:s,cluster:e}).then(n=>{const a={distinctVideoJobCount:n};this.setState(a)}),qm({timeframe:s,cluster:e}).then(n=>{const a={invalidVideoCount:n.count};this.setState(a)}),xm({timeframe:s,cluster:e}).then(n=>{this.setState({kaiChatCount:n})})]).catch(n=>console.error(n.message))};renderCategoriesTable(){const{studioCount:s,draftCount:e,totalVideoCount:n,totalErrorCount:a,studioErrorCount:o,invalidVideoCount:i,kaiChatCount:l}=this.state;return(0,t.jsxs)("table",{role:"grid",className:Qe.table,children:[(0,t.jsx)("thead",{className:Qe.tableHeader,children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:"Category"}),(0,t.jsx)("td",{className:Qe.countTitle,children:"Total"}),(0,t.jsx)("td",{className:Qe.countTitle,children:"Errors"}),(0,t.jsx)("td",{className:Qe.countTitle,children:"%"})]})}),(0,t.jsxs)("tbody",{children:[(0,t.jsxs)("tr",{className:Qe.studioTitle,children:[(0,t.jsx)("td",{children:"Studio"}),(0,t.jsx)("td",{className:Qe.count,children:s}),(0,t.jsx)("td",{className:Qe.count,children:o}),(0,t.jsxs)("td",{className:Qe.count,children:[o&&(o*100/n).toFixed(2),"%"]})]},"Studio"),(0,t.jsxs)("tr",{className:"drafts-title",children:[(0,t.jsx)("td",{children:"Drafts"}),(0,t.jsx)("td",{className:Qe.count,children:e}),(0,t.jsx)("td",{}),(0,t.jsxs)("td",{className:Qe.count,children:[e&&(e*100/(e+n)).toFixed(2),"%"]})]},"Drafts"),(0,t.jsxs)("tr",{className:Qe.kaiChats,children:[(0,t.jsx)("td",{children:"Kai Chats"}),(0,t.jsx)("td",{className:Qe.count,children:l}),(0,t.jsx)("td",{className:Qe.count,children:"-"}),(0,t.jsx)("td",{className:Qe.count,children:"-"})]},"Kai Chats"),(0,t.jsxs)("tr",{className:Qe.invalid,children:[(0,t.jsx)("td",{children:"Invalid"}),(0,t.jsx)("td",{children:"-"}),(0,t.jsx)("td",{className:Qe.count,children:i}),(0,t.jsx)("td",{className:Qe.count,children:i&&(0,t.jsxs)(t.Fragment,{children:[(i*100/n).toFixed(2),"%"]})})]},"Invalid"),(0,t.jsxs)("tr",{className:"errors-title",children:[(0,t.jsx)("td",{children:"Errors"}),(0,t.jsx)("td",{children:"-"}),(0,t.jsx)("td",{className:Qe.count,children:a}),(0,t.jsx)("td",{className:Qe.count,children:n&&(0,t.jsxs)(t.Fragment,{children:[(a*100/n).toFixed(2),"%"]})})]},"Errors")]})]})}
1renderProcessVideoJobStats(){const{processVideoJobClusters:s}=this.state;if(!s)return(0,t.jsx)("div",{});const{statuses:e,results:n}=s,{timeframe:a}=this.props,o=Object.keys(n).sort((i,l)=>i==="total"?-1:l==="total"?1:i.localeCompare(l));return(0,t.jsxs)("table",{role:"grid",className:Qe.table,children:[(0,t.jsx)("thead",{className:Qe.tableHeader,children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:"Cluster"}),e.map(i=>(0,t.jsx)("td",{children:i},i)),(0,t.jsx)("td",{children:"% Failed"})]})}),(0,t.jsx)("tbody",{children:o.map((i,l)=>{const r={timeframe:a};i!=="total"&&(r.clusterGroup=i);const d=`/admin/process_video_jobs${Na.default.stringify({filters:r},{addQueryPrefix:!0})}`,c=n[i];return(0,t.jsxs)("tr",{className:l%2===0?Qe.lightRow:Qe.darkRow,children:[(0,t.jsx)("td",{children:(0,t.jsx)("a",{href:d,children:i})}),e.map(m=>{const h={...r,state:"finished",status:m};return(0,t.jsx)("td",{children:(0,t.jsx)("a",{href:`/admin/process_video_jobs${Na.default.stringify({filters:h},{addQueryPrefix:!0})}`,children:c[m]||""})},m)}),(0,t.jsx)("td",{children:((c.failed||0)/((c.failed||0)+c.success)*100).toFixed(2)})]},i)})})]})}renderProcessVideoJobErrorStats(){const{processVideoJobErrors:s}=this.state;if(!s)return(0,t.jsx)("div",{});const{timeframe:e}=this.props,n=Object.keys(s).sort();return(0,t.jsxs)("table",{role:"grid",className:Qe.table,children:[(0,t.jsx)("thead",{className:Qe.tableHeader,children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:"Error"}),(0,t.jsx)("td",{children:"Count"}),(0,t.jsx)("td",{children:"Unexplained"})]})}),(0,t.jsx)("tbody",{children:n.map((a,o)=>{const i=s[a],l={filters:{state:"finished",status:"failed",errorSubcat:a,timeframe:e}},r=`/admin/process_video_jobs${Na.default.stringify(l,{addQueryPrefix:!0})}`;return(0,t.jsxs)("tr",{className:o%2===0?Qe.lightRow:Qe.darkRow,children:[(0,t.jsx)("td",{children:(0,t.jsx)("a",{href:r,children:a})}),(0,t.jsx)("td",{children:i.total}),(0,t.jsx)("td",{children:i.unexplainedCnt})]},a)})})]})}renderDistinctVideoJobs(){const{distinctVideoJobCount:s}=this.state,{totalCnt:e,count:n}=s||{};return(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{children:"Video Job Count"}),(0,t.jsxs)("div",{children:["Total Jobs: ",e]}),(0,t.jsxs)("div",{children:["Unique Videos: ",n]})]})}render(){const{timeframe:s,timeframeFilters:e}=this.props,{totalVideoCount:n}=this.state,{name:a}=e.find(({value:o})=>o===s);return(0,t.jsx)("div",{className:"admin-video-count",children:(0,t.jsxs)("div",{className:"admin-video-count-types",children:[(0,t.jsx)("div",{className:"admin-video-count-header",children:(0,t.jsxs)("div",{style:{fontSize:18,fontWeight:600,fontFamily:"Open Sans, sans-serif"},children:[(0,t.jsx)("span",{children:n||"Loading"})," total ",a]})}),this.renderCategoriesTable(),this.renderProcessVideoJobStats(),this.renderProcessVideoJobErrorStats(),this.renderDistinctVideoJobs()]})})}},fp=hp;const xp="1001",gp="1000",vp="58px",_p="StripeAnalytics-module_container_140B6",jp="StripeAnalytics-module_header_dLNsC",bp="StripeAnalytics-module_header2_8SNnV",yp="StripeAnalytics-module_description_3JmbA",Sp="StripeAnalytics-module_stats_XunPz",Cp="StripeAnalytics-module_email_zFViV",Np="StripeAnalytics-module_emailLink_qpEi1",wp="StripeAnalytics-module_more_CXmgP";var kt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:xp,paywallBgZIndex:gp,collapsedMediaSidebarWidth:vp,container:_p,header:jp,header2:bp,description:yp,stats:Sp,email:Cp,emailLink:Np,more:wp},Ho=20,Ap=class extends f.Component{constructor(s){super(s),this.state={loading:!0,showMore:!1}}componentDidMount(){Hc().then(s=>{this.setState({...s,loading:!1})}).catch(s=>{Ue({description:"An error occurred with Stripe stats.",error:s})})}renderStats(){const{num_customers:s,num_monthly:e,num_annual:n,business_emails:a=[],showMore:o}=this.state,i=Math.max(a.length-Ho,0),l=o?a:a.slice(0,Math.min(a.length,Ho));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:kt.description,children:"Since last midnight:"}),(0,t.jsxs)("div",{className:kt.stats,children:[(0,t.jsx)("b",{children:s})," new customers"]}),(0,t.jsxs)("div",{className:kt.stats,children:[(0,t.jsx)("b",{children:e})," new monthly subs"]}),(0,t.jsxs)("div",{className:kt.stats,children:[(0,t.jsx)("b",{children:n})," new annual subs"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:kt.header2,children:"Non-
1popular domain emails:"}),(0,t.jsx)("div",{className:kt.description,children:"Click to view customer in Stripe"}),l.map((r,d)=>(0,t.jsx)("div",{className:kt.email,children:(0,t.jsx)("a",{href:`https://dashboard.stripe.com/customers/${r.id}`,target:"_blank",rel:"noopener noreferrer",className:kt.emailLink,children:r.domain})},r.id)),!o&&i&&(0,t.jsxs)("div",{className:kt.more,onClick:()=>this.setState({showMore:!0}),children:["...and ",i," more, click to show"]})]})]})}render(){const{loading:s}=this.state;return(0,t.jsxs)("div",{className:kt.container,children:[(0,t.jsx)("div",{className:kt.header,children:"Stripe Analytics"}),s?(0,t.jsx)("div",{className:kt.description,children:"Loading stats..."}):this.renderStats()]})}},Ip=Ap,Tp=Q(Vr()),kp=class extends f.Component{getDebugStrings=s=>{const e=[],{progressText:n,done:a}=s||{};return a||e.push("Not finished"),!n||!n.length||(n.includes("adjustLayerDimensions")&&n.includes("ZeroDivisionError: float division by zero")&&e.push("Missing dimensions"),n.includes("No space left on device")&&e.push("Disk full"),n.includes("Failed to download input files")&&e.push("Failed download"),n.includes("No URL")&&e.push("Missing download url"),n.includes("Failed to pre-process a segment")&&e.push("failed preprocessing"),n.includes("Filename too long")&&e.push("Filename too long"),n.includes("Action timed out")&&e.push("Timed out"),n.includes("(StringField only accepts string values: ['input_url'])")&&e.push("Split input URLs"),n.includes("Error setting option framerate to value None")&&e.push("Missing framerate"),n.includes("KeyError: 'position'")&&e.push("Position is missing"),n.includes("probeLayer")&&n.includes("TypeError: 'NoneType' object does not support item assignment")&&e.push("Possibly Malformed layer"),n==="Loading ..."&&e.push("Stuck Loading"),n==="Saved ..."&&e.push("Job not start"),n==="Server triggered ..."&&e.push("failed dispatch to worker"),n.includes("google.api_core.exceptions.GatewayTimeout")&&e.push("GCS Gateway Timeout"),n.includes("pymongo.errors.NetworkTimeout")&&e.push("Mongo Netowrk issue"),n.includes("Invalid duration specification for t")&&e.push("Invalid duration"),n.includes("Missing font size")&&e.push("Missing font size"),n.includes("Cannot write to")&&n.includes("Invalid argument")&&e.push("Cannot write to/Invalid filename"),n.includes("Could find no file with path")&&n.includes("and index in the range")&&e.push("Failed split"),n.includes("m3u8")&&e.push("hls/m3u8 extracted"),n.includes("Failed to write frame")&&e.push("Failed to write frame"),n.includes("Input buffer exhausted before END element found")&&e.push("No END element"),n.includes("moov atom not found")&&e.push("moov atom not found"),n.includes("Invalid data found when processing input")&&e.push("Invalid data found"),n.includes("terminated abnormally")&&e.push("terminated abnormally"),n.includes("'Request failed with status code', 404")&&e.push("404"),n.includes("in get_duration")&&e.push("in get_duration"),Object.values(s.allLayers.byId).some(({position:o})=>{if(o==null)return!1;const{height:i,width:l}=o;return[i,l].some(r=>[0,"NaN%"].includes(r))})&&e.push("Height or Width is 0 or NaN")),e};renderErrorInfo(s,e){if(s.draft)return null;const n=new Date-e,a=Math.round(n%864e5%36e5/6e4),o=!s.done&&a<=3;let i=[];return o||(i=this.getDebugStrings(s)),!s.done&&a>3&&i.push("Processing for more than 3 min"),!o&&!i.length?null:o?(0,t.jsx)("div",{children:(0,t.jsx)("span",{style:{color:"purple"},children:"Still processing ..."})}):(0,t.jsx)("div",{children:i?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{style:{color:"red"},children:"Error(s) occurred"}),i.map(l=>(0,t.jsx)("div",{style:{color:"red"},children:l},Tp.v4()))]}):null})}render(){const{video:s}=this.props;let e="videos";
1const{_id:n,draft:a,submittedAt:o}=s,i=il(o);return a&&(e="editor/videos"),(0,t.jsxs)("div",{children:[this.renderErrorInfo(s,o),(0,t.jsx)("div",{className:"small-spacer"}),(0,t.jsxs)("div",{style:{color:"#888",fontSize:"10px"},children:[i," ago"]}),(0,t.jsx)(be,{to:`/${e}/${n}`,className:"video-element-video-video-link",target:"_blank",children:"View Video"})]})}},Rp=kp,$p=class extends f.Component{getLayers(){const{video:s}=this.props;return Object.values(s.allLayers.byId)}render(){const{video:s}=this.props,e=s.fullPath&&s.fullPath.match(/jpg$/)?"Image":"Video",n=this.getLayers().length;let a=!1,o=!1,i=!1,l=!1,r=!1,d=!1;for(const c of this.getLayers())c.type!=="video"&&c.startTime&&c.endTime&&(a=!0),c.type==="shape"?o=!0:c.type==="audio"&&(l=!0),c.animation&&(i=!0),c.removeBg&&(r=!0),c.blurBg&&(d=!0);return(0,t.jsx)("div",{className:"admin-video-container",children:(0,t.jsx)("div",{className:"admin-video-description",children:(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"studio-title",children:["Studio ",e]}),(0,t.jsxs)("div",{children:["Origin: ",(0,t.jsx)("span",{children:s.origin?s.origin:"other"})]}),(0,t.jsxs)("div",{children:["Number of layers: ",n]}),a&&(0,t.jsx)("div",{children:"Has Dynamic Content"}),o&&(0,t.jsx)("div",{children:"Has Shape"}),l&&(0,t.jsx)("div",{children:"Has Audio Layer"}),i&&(0,t.jsx)("div",{children:"Has Animation"}),r&&(0,t.jsx)("div",{children:"Has Removed Background"}),d&&(0,t.jsx)("div",{children:"Has Blurred Background"}),s.draft&&(0,t.jsx)("div",{children:"Draft"}),(0,t.jsx)(Rp,{video:s})]})})})}},Pp=$p,Ep=Q(ie()),Lp=s=>{const e=(0,Ep.c)(2),{video:n}=s;let a;return e[0]!==n?(a=(0,t.jsx)(Pp,{video:n}),e[0]=n,e[1]=a):a=e[1],a},Bp=f.memo(Lp);const Dp="1001",Mp="1000",Fp="58px",Op="VideoErrors-module_header_zOOwT";var qp={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Dp,paywallBgZIndex:Mp,collapsedMediaSidebarWidth:Fp,header:Op},Vp=class extends f.Component{constructor(s){super(s),this.state={loading:!0,loadingMore:!1,skip:0,videos:[]}}componentDidMount(){this.getVideos()}componentDidUpdate(s,e){const{timeframe:n,cluster:a}=this.props,{proOnly:o}=this.state;(n!==s.timeframe||a!==s.cluster||o!==e.proOnly)&&this.getVideos()}getMoreVideos=()=>{const{skip:s}=this.state;this.getVideos(s)};getVideos(s=0){const{timeframe:e,cluster:n}=this.props;this.setState({loading:!0}),s&&this.setState({loadingMore:!0}),Wm({skip:s,timeframe:e,cluster:n}).then(a=>{const{videos:o}=a;this.setState({loading:!1,loadingMore:!1,skip:s+o.length,videos:o})}).catch(a=>{console.error(a.message),this.setState({loading:!1,loadingMore:!1})})}renderVideos=()=>{const{videos:s}=this.state;return(0,t.jsx)(t.Fragment,{children:s.map(e=>(0,t.jsx)(Bp,{video:e},e._id))})};render(){const{loading:s,loadingMore:e}=this.state;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:qp.header,children:"Showing recent videos with errors"}),(0,t.jsxs)("div",{children:[s?(0,t.jsx)(it,{}):this.renderVideos(),(0,t.jsx)("div",{className:"primary-button admin-load-more",onClick:this.getMoreVideos,children:e?"Just a second...":"Load more videos"})]})]})}},Hp=Vp;const Up="1001",Zp="1000",Wp="58px",Kp="ContentPreview-module_container_kKELy",Gp="ContentPreview-module_imagePreview_H6fPM",Jp="ContentPreview-module_imagePreviewUnblurred_bcJ3U";var Un={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Up,paywallBgZIndex:Zp,collapsedMediaSidebarWidth:Wp,container:Kp,imagePreview:Gp,imagePreviewUnblurred:Jp},zp=Q(ie()),Yp=s=>{const e=(0,zp.c)(8),{content:n,blurEnabled:a}=s,o=a===void 0?!0:a;let i;e[0]!==n?(i=Wd(n),e[0]=n,e[1]=i):i=e[1];const l=i,r=o?Un.imagePreview:`${Un.imagePreview} ${Un.imagePreviewUnblurred}`,d=`/videos/${n._id}`;let c;e[2]!==r||e[3]!==l?(c=(0,t.jsx)("img",{src:l,className:r,alt:"Preview",loading:"lazy"}),e[2]=r,e[3]=l,e[4]=c):c=e[4];let m;return e[5]!==d||e[6]!==c?(m=(0,t.jsx)("div",{className:Un.container,children:(0,t.jsx)(be,{to:d,target:"_blank",rel:"noopener noreferrer",children:c})}),e[5]=d,e[6]=c,e[7]=m):m=e[7],m},za=f.memo(Yp);const Qp="1001",Xp="1000",eh="58px",th="VideoPreviews-module_header_D4-WX",sh="VideoPreviews-module_subheader_7KIHq",nh="VideoPreviews-module_showing_aDzTK",ah="VideoPreviews-module_toggleGroup_9-YuF",oh="VideoPreviews-module_selected_sf-OV",ih="VideoPreviews-module_unselected_9a9VJ";var Rt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Qp,paywallBgZIndex:Xp,collapsedMediaSidebarWidth:eh,header:th,subheader:sh,showing:nh,toggleGroup:ah,selected:oh,unselected:ih},lh=class extends f.Component{constructor(s){super(s),this.state={loading:!0,loadingMore:!1,skip:0,proOnly:!0,blurEnabled:!0,videos:[]}}componentDidMount(){this.getVideos()}componentDidUpdate(s,e){const{timeframe:n,cluster:a}=this.props,{proOnly:o}=this.state;(n!==s.timeframe||a!==s.cluster||o!==e.proOnly)&&this.getVideos()}getMoreVideos=()=>{const{skip:s}=this.state;this.getVideos(s)};getVideos(s=0){const{timeframe:e,cluster:n}=this.props,{proOnly:a}=this.state;this.setState({loading:!0}),s&&this.setState({loadingMore:!0}),Zm({skip:s,timeframe:e,cluster:n,proOnly:a}).then(o=>{const{videos:i}=o;this.setState({loading:!1,loadingMore:!1,skip:s+i.length,videos:i})}).catch(o=>{Ue({description:"Failed to load videos",error:o}),this.setState({loading:!1,loadingMore:!1})})}renderVideoElements(){const{videos:s,blurEnabled:e}=this.state;return(0,t.jsx)(t.Fragment,{children:s.map(n=>(0,t.jsx)(za,{content:n,blurEnabled:e},n._id))})}render(){const{loading:s,loadingMore:e,proOnly:n,blurEnabled:a}=this.state;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:Rt.header,children:[(0,t.jsx)("div",{className:Rt.showing,children:"Showing recent:"}),n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:Rt.selected,children:"Content by PRO users"}),(0,t.jsx)("div",{onClick:()=>this.setState({proOnly:!1}),className:Rt.unselected,children:"Content from ALL users"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{onClick:()=>this.setState({proOnly:!0}),className:Rt.unselected,children:"Content by PRO users"}),(0,t.jsx)("div",{className:Rt.selected,children:"Content from ALL users"})]}),(0,t.jsxs)("div",{className:Rt.toggleGroup,children:[(0,t.jsx)("div",{className:Rt.showing,children:"Blur Video Previews:"}),a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:Rt.selected,children:"On"}),(0,t.jsx)("div",{onClick:()=>this.setState({blurEnabled:!1}),className:Rt.unselected,children:"Off"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{onClick:()=>this.setState({blurEnabled:!0}),className:Rt.unselected,children:"On"}),(0,t.jsx)("div",{className:Rt.selected,children:"Off"})]})]})]}),(0,t.jsx)("div",{children:s?(0,t.jsx)(it,{}):this.renderVideoElements()}),(0,t.jsx)("div",{className:"primary-button admin-load-more",onClick:this.getMoreVideos,children:e?"Just a second...":"Load more videos"})]})}},rh=lh,yl=Q(ie()),dh=f.memo(s=>{const e=(0,yl.c)(11),{value:n,onChange:a}=s;let o;e[0]!==a?(o=m=>{a(m.target.value)},e[0]=a,e[1]=o):o=e[1];const i=o;let l,r,d;
1e[2]!==n?(l=(0,t.jsx)(wa,{currentValue:n,label:"All Clusters",value:"all"}),r=(0,t.jsx)(wa,{currentValue:n,label:"Production",value:"production"}),d=(0,t.jsx)(wa,{currentValue:n,label:"Canary",value:"canary"}),e[2]=n,e[3]=l,e[4]=r,e[5]=d):(l=e[3],r=e[4],d=e[5]);let c;return e[6]!==i||e[7]!==l||e[8]!==r||e[9]!==d?(c=(0,t.jsxs)("div",{onChange:i,className:Pt.clusters,children:[l,r,d]}),e[6]=i,e[7]=l,e[8]=r,e[9]=d,e[10]=c):c=e[10],c}),wa=f.memo(s=>{const e=(0,yl.c)(6),{value:n,currentValue:a,label:o}=s,i=a===n;let l;e[0]!==i||e[1]!==n?(l=(0,t.jsx)("input",{type:"radio",value:n,name:n,checked:i,readOnly:!0}),e[0]=i,e[1]=n,e[2]=l):l=e[2];let r;return e[3]!==o||e[4]!==l?(r=(0,t.jsxs)("label",{children:[l,o]}),e[3]=o,e[4]=l,e[5]=r):r=e[5],r}),ch=class extends f.Component{timeframeFilters;constructor(s){super(s),this.timeframeFilters=[{name:"today",value:"today"},{name:"last hour",value:"last1"},{name:"last 12 hours",value:"last12"},{name:"last 24 hours",value:"last24"},{name:"last 48 hours",value:"last48to24"}],this.state={t
1imeframe:"last12",cluster:"all"}}setClusterFilter=s=>this.setState({cluster:s});setTimeframe=s=>this.setState({timeframe:s});renderTimeframeFilter=({name:s,value:e})=>{const{timeframe:n}=this.state;return(0,t.jsx)("tr",{children:n===e?(0,t.jsx)("td",{className:"watermark-filter-active",children:s}):(0,t.jsx)("td",{role:"gridcell",className:"watermark-filter-inactive",onClick:()=>this.setTimeframe(e),children:s})},s)};renderTimeframeFilters(){return(0,t.jsx)("table",{role:"grid",className:"timeframe-filters-table",children:(0,t.jsx)("tbody",{children:this.timeframeFilters.map(this.renderTimeframeFilter)})})}renderFilters(){const{cluster:s}=this.state;return(0,t.jsxs)("div",{className:Pt.adminAnalyticsControls,children:[(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/tools",children:"Admin Tools"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/ai/tools",children:"AI Admin Tools"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/monitor",children:"Monitor Metrics"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/process_video_jobs",children:"Process Video Jobs"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/tasks",children:"Job Tasks"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/validation",children:"Video Tests Validation"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/regression",children:"Regression Videos"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/templates",children:"Go to Template admin page"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/upload",children:"Go to Static Image uploader"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/blocked-accounts",children:"Go to blocked accounts"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/qualified-domains",children:"Qualified domain explorer"}),(0,t.jsx)(be,{className:"admin-see-errors-link",to:"/admin/dev-machines",children:"User dev machines"}),(0,t.jsx)("a",{className:"admin-see-errors-link",href:gl,target:"_blank",rel:"noopener noreferrer",children:"Go to Media Forge admin"}),(0,t.jsx)(lm,{}),(0,t.jsx)(dh,{onChange:this.setClusterFilter,value:s}),this.renderTimeframeFilters()]})}renderVideos(){const{cluster:s,timeframe:e}=this.state;return(0,t.jsxs)("div",{className:Pt.wrapper,children:[(0,t.jsxs)("div",{className:Pt.topRow,children:[(0,t.jsx)("div",{className:Pt.videoPreviewsColumn,children:(0,t.jsx)(rh,{cluster:s,timeframe:e})}),(0,t.jsx)("div",{className:Pt.recentChatsColumn,children:(0,t.jsx)(Fm,{timeframe:e})})]}),(0,t.jsx)("div",{className:Pt.bottomRow,children:(0,t.jsx)("div",{className:Pt.videoErrorsColumn,children:(0,t.jsx)(Hp,{cluster:s,timeframe:e})})})]})}render(){const{timeframe:s,cluster:e}=this.state;return(0,t.jsxs)("div",{className:Pt.videosContainer,children:[(0,t.jsxs)("div",{className:Pt.metricsContainer,children:[(0,t.jsxs)("div",{className:Pt.analyticsContainer,children:[(0,t.jsx)("div",{className:Pt.analyticsContainerLeft,children:(0,t.jsx)(fp,{timeframe:s,cluster:e,timeframeFilters:this.timeframeFilters})}),(0,t.jsx)(Ip,{}),(0,t.jsx)(fm,{})]}),this.renderFilters()]}),this.renderVideos()]})}},uh=ch,ia=Q(ie());async function mh(s){await H.admin.scheduledMarketingEmail.delete.mutate({id:s})}async function ph(s,e){await H.admin.scheduledMarketingEmail.add.mutate({dynamicTemplateId:s,isTest:e})}async function hh(){const{emails:s}=await H.admin.scheduledMarketingEmail.getAll.query();return s}var fh=f.memo(s=>{const e=(0,ia.c)(12),{scheduledEmail:n,triggerRefresh:a}=s,o=n.isTest&&"(test) ";let i;e[0]!==o?(i=(0,t.jsx)("span",{children:o}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==n._id||e[3]!==a?(l=async()=>{await mh(n._id),a()},e[2]=n._id,e[3]=a,e[4]=l):l=e[4];let r;e[5]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Xr,{}),e[5]=r):r=e[5];let d;e[6]!==l?(d=(0,t.jsxs)("button",{onClick:l,type:"button",children:[r," Delete"]}),e[6]=l,e[7]=d):d=e[7];let c;return e[8]!==n.dynamicTemplateId||e[9]!==i||e[10]!==d?(c=(0,t.jsxs)("div",{children:["TemplateId: ",n.dynamicTemplateId," ",i,d]}),e[8]=n.dynamicTemplateId,e[9]=i,e[10]=d,e[11]=c):c=e[11],c}),xh=f.memo(s=>{const e=(0,ia.c)(3),{email:n}=s;let a;return e[0]!==n.dynamicTemplateId||e[1]!==n.sent?(a=(0,t.jsxs)("div",{children:["Sendgrid Id: ",n.dynamicTemplateId," Sent to ",n.sent," users."]}),e[0]=n.dynamicTemplateId,e[1]=n.sent,e[2]=a):a=e[2],a}),gh=f.memo(s=>{const e=(0,ia.c)(20),{triggerRefresh:n,allowNewNonTestEmail:a}=s,[o,i]=(0,f.useState)(""),[l,r]=(0,f.useState)(!0),d=tt();let c;e[0]!==a||e[1]!==d||e[2]!==o||e[3]!==l||e[4]!==n?(c=async j=>{if(j.preventDefault(),!a&&!l){d(He({description:"Please delete the other non-test scheduled email before adding another one",type:"warning"}));return}await ph(o,l),n()},e[0]=a,e[1]=d,e[2]=o,e[3]=l,e[4]=n,e[5]=c):c=e[5];let m;e[6]===Symbol.for("react.memo_cache_sentinel")?(m=j=>{i(j.target.value)},e[6]=m):m=e[6];let h;e[7]!==o?(h=(0,t.jsx)("input",{value:o,onChange:m}),e[7]=o,e[8]=h):h=e[8];let p,u;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("button",{type:"submit",children:"Schedule"}),u=(0,t.jsx)("br",{}),e[9]=p,e[10]=u):(p=e[9],u=e[10]);const g=!l;let _;e[11]!==l?(_=j=>r(!l),e[11]=l,e[12]=_):_=e[12];let v;e[13]!==g||e[14]!==_?(v=(0,t.jsx)("input",{type:"checkbox",checked:g,onChange:_}),e[13]=g,e[14]=_,e[15]=v):v=e[15];let b;return e[16]!==c||e[17]!==h||e[18]!==v?(b=(0,t.jsx)("div",{children:(0,t.jsxs)("form",{onSubmit:c,children:["Sendgrid Template Id:",h,p,u,v,"This is not a test"]})}),e[16]=c,e[17]=h,e[18]=v,e[19]=b):b=e[19],b}),vh=()=>{const s=(0,ia.c)(20),[e,n]=(0,f.useState)();let a;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=function(){(async()=>n(await hh()))()},s[0]=a):a=s[0];const o=a;let i;s[1]===Symbol.for("react.memo_cache_sentinel")?(i=[o],s[1]=i):i=s[1],(0,f.useEffect)(o,i);let l,r,d,c;if(s[2]!==e){const u=e?.filter(jh),g=!u?.filter(bh)?.length;s[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("h3",{children:"Schedule a new email"}),s[7]=l):l=s[7],s[8]!==g?(r=(0,t.jsx)(gh,{triggerRefresh:o,allowNewNonTestEmail:g}),s[8]=g,s[9]=r):r=s[9],s[10]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("h3",{children:"Scheduled:"}),s[10]=d):d=s[10],c=u?.map(_=>(0,t.jsx)(fh,{scheduledEmail:_,triggerRefresh:o},_._id)),s[2]=e,s[3]=l,s[4]=r,s[5]=d,s[6]=c}else l=s[3],r=s[4],d=s[5],c=s[6];let m;s[11]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)("h3",{children:"Sent:"}),s[11]=m):m=s[11];let h;s[12]!==e?(h=e?.filter(yh).map(Sh),s[12]=e,s[13]=h):h=s[13];let p;return s[14]!==l||s[15]!==r||s[16]!==d||s[17]!==c||s[18]!==h?(p=(0,t.jsxs)("div",{children:[l,r,d,c,m,h]}),s[14]=l,s[15]=r,s[16]=d,s[17]=c,s[18]=h,s[19]=p):p=s[19],p},_h=f.memo(vh);function jh(s){return s.sent===0}function bh(s){return!s.isTest}function yh(s){return s.sent!==0}function Sh(s){return(0,t.jsx)(xh,{email:s},s._id)}const Ch="1001",Nh="1000",wh="58px",Ah="BlockedAccounts-module_container_O33h-",Ih="BlockedAccounts-module_header_-nvwx",Th="BlockedAccounts-module_headerText_YVKCm",kh="BlockedAccounts-module_description_djeMX",Rh="BlockedAccounts-module_content_66-7x",$h="BlockedAccounts-module_formContainer_O5w3l",Ph="BlockedAccounts-module_form_dKcR1",Eh="BlockedAccounts-module_formRow_xzHwR",Lh="BlockedAccounts-module_emailInput_ABtjJ",Bh="BlockedAccounts-module_submitButton_F9oJi",Dh="BlockedAccounts-module_loadButton_0naSF",Mh="BlockedAccounts-module_deleteButton_ia8-z",Fh="BlockedAccounts-module_listWrapper_ORa-S",Oh="BlockedAccounts-module_listHeaderRow_LSFef",qh="BlockedAccounts-module_listRow_bdlfi",Vh="BlockedAccounts-module_loadM
1oreContainer_Ph2Ku",Hh="BlockedAccounts-module_noResults_Ko-HW",Uh="BlockedAccounts-module_email_tgiT8",Zh="BlockedAccounts-module_adminEmail_PSqWT";var lt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Ch,paywallBgZIndex:Nh,collapsedMediaSidebarWidth:wh,container:Ah,header:Ih,headerText:Th,description:kh,content:Rh,formContainer:$h,form:Ph,formRow:Eh,emailInput:Lh,submitButton:Bh,loadButton:Dh,deleteButton:Mh,listWrapper:Fh,listHeaderRow:Oh,listRow:qh,loadMoreContainer:Vh,noResults:Hh,email:Uh,adminEmail:Zh},Uo=100,Wh=()=>{const s=tt(),[e,n]=(0,f.useState)(0),[a,o]=(0,f.useState)(""),[i,l]=(0,f.useState)(!1),[r,d]=(0,f.useState)([]),c=async u=>{try{await H.admin.blockedAccounts.delete.mutate({blockedAccountId:u._id.toString()}),d(g=>g.filter(_=>_._id!==u._id)),s(He({description:`Deleted ${u.email} from blocked accounts.`,type:"success"}))}catch(g){console.error("Failed to delete blocked account:",g)}},m=async u=>{if(u.preventDefault(),!!a.trim())try{l(!0);const g=a.trim().toLowerCase(),_=await H.admin.blockedAccounts.add.mutate({email:g});d(v=>[_,...v]),s(He({description:`Submitted! ${g} blocked.`,type:"success"}))}catch(g){let _="An error occurred while blocking the account.";g&&g.message&&(_=g.message),s(He({description:`Failed to block account: ${_}`,type:"error"}))}finally{l(!1)}};(0,f.useEffect)(()=>{(async()=>{const g=await H.admin.blockedAccounts.get.query({skip:e});d(_=>{const v=_.reduce((j,x)=>j.add(x._id.toString()),new Set),b=g.filter(j=>!v.has(j._id));return[..._,...b]})})()},[e]);const h=()=>r?r.length===0?(0,t.jsx)("div",{className:lt.noResults,children:"No blocked accounts found. You can add one above."}):(0,t.jsxs)("div",{className:lt.listWrapper,children:[(0,t.jsxs)("div",{className:lt.listHeaderRow,children:[(0,t.jsx)("div",{className:lt.email,children:"Blocked User"}),(0,t.jsx)("div",{className:lt.adminEmail,children:"Blocked by:"}),(0,t.jsx)("div",{})]}),r.map(u=>{const{_id:g,email:_,adminEmail:v}=u;return(0,t.jsxs)("div",{className:lt.listRow,children:[(0,t.jsx)("div",{className:lt.email,children:_}),(0,t.jsx)("div",{className:lt.adminEmail,children:v||"Unknown (this is bad)"}),(0,t.jsx)("button",{className:lt.deleteButton,onClick:()=>c(u),children:"Unblock"})]},g)})]}):null,p=()=>r.length<Uo?null:(0,t.jsx)("div",{className:lt.loadMoreContainer,children:(0,t.jsx)("button",{className:lt.loadButton,onClick:()=>n(u=>u+Uo),type:"button",children:"Load More"})});return(0,t.jsxs)("div",{className:lt.container,children:[(0,t.jsxs)("div",{className:lt.header,children:[(0,t.jsx)("div",{className:lt.headerText,children:"Welcome to the blocked accounts admin page."}),(0,t.jsx)("div",{className:lt.description,children:"Here you can add email addresses to the blocked accounts list. Any emails on this list will not be able to create new accounts or sign into their current account. When added, if the account exists the current session will also be revoked. Note that adding an email here will not delete the account."})]}),(0,t.jsx)("div",{className:lt.formContainer,children:(0,t.jsx)("form",{onSubmit:m,className:lt.form,children:(0,t.jsxs)("div",{className:lt.formRow,children:[(0,t.jsx)("input",{type:"email",placeholder:"Enter email address to block",value:a,onChange:u=>o(u.target.value),className:lt.emailInput,required:!0,"data-lpignore":"true",autoComplete:"off"}),(0,t.jsx)("button",{type:"submit",className:lt.submitButton,disabled:!a.trim()||i,children:i?"Loading...":"Block Account"})]})})}),(0,t.jsxs)("div",{className:lt.content,children:[h(),p()]})]})},Kh=f.memo(Wh);const Gh="1001",Jh="1000",zh="58px",Yh="EduAdmin-module_container_jxGvn",Qh="EduAdmin-module_header_l2egF",Xh="EduAdmin-module_headerText_DULNg",e0="EduAdmin-module_description_E-ujM",t0="EduAdmin-module_content_stsHn",s0="EduAdmin-module_link_Mgi8G",n0="EduAdmin-module_actions_EB1ew",a0="EduAdmin-module_actionsButton_WaG0n";var Dt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Gh,paywallBgZIndex:Jh,collapsedMediaSidebarWidth:zh,container:Yh,header:Qh,headerText:Xh,description:e0,content:t0,link:s0,actions:n0,actionsButton:a0};const o0="1001",i0="1000",l0="58px",r0="EduTypeformResponses-module_wrapper_n6TVq",d0="EduTypeformResponses-module_header_wqVUK",c0="EduTypeformResponses-module_section_Do7Uo",u0="EduTypeformResponses-module_sectionHeader_LRB5V",m0="EduTypeformResponses-module_scrollContainer_eyil-",p0="EduTypeformResponses-module_user_Yp8Ni",h0="EduTypeformResponses-module_columnHeader_Yy9dC",f0="EduTypeformResponses-module_item_vU-mE",x0="EduTypeformResponses-module_verticalLine_OD7pk";var dt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:o0,paywallBgZIndex:i0,collapsedMediaSidebarWidth:l0,wrapper:r0,header:d0,section:c0,sectionHeader:u0,scrollContainer:m0,user:p0,columnHeader:h0,item:f0,verticalLine:x0};function g0(){return H.admin.edu.getCustomers.query()}function v0(s){return H.admin.edu.bytebot.create.mutate(s)}function Zo(s){return H.admin.edu.bytebot.list.query(s)}function _0(s){return H.admin.edu.bytebot.delete.mutate({name:s.name})}var j0=Q(ie()),b0=()=>{const s=(0,j0.c)(19),[e,n]=(0,f.useState)();let a;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=async()=>{n(await g0())},s[0]=a):a=s[0];const o=a;let i,l;s[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{o()},l=[o],s[1]=i,s[2]=l):(i=s[1],l=s[2]),(0,f.useEffect)(i,l);let r;s[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("div",{className:dt.section,children:(0,t.jsx)("div",{className:dt.header,children:"Edu Admin Page"})}),s[3]=r):r=s[3];let d;s[4]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("div",{className:dt.sectionHeader,children:"Total EDU Customers"}),s[4]=d):d=s[4];const c=e?.length;let m;s[5]!==c?(m=(0,t.jsxs)("div",{className:dt.section,children:[d,(0,t.jsx)("div",{className:dt.user,children:c})]}),s[5]=c,s[6]=m):m=s[6];let h;s[7]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("div",{className:dt.sectionHeader,children:"EDU Customers"}),s[7]=h):h=s[7];let p,u,g;s[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)("span",{className:dt.columnHeader,children:"userID"}),g=(0,t.jsx)("span",{className:dt.verticalLine}),p=(0,t.jsx)("span",{className:dt.columnHeader,children:"userEmail"}),s[8]=p,s[9]=u,s[10]=g):(p=s[8],u=s[9],g=s[10]);let _;s[11]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsxs)("div",{className:dt.user,children:[u,g,p," ",(0,t.jsx)("span",{className:dt.verticalLine}),(0,t.jsx)("span",{className:dt.columnHeader,children:"responseID"})]}),s[11]=_):_=s[11];let v;s[12]!==e?(v=e?.map(S0),s[12]=e,s[13]=v):v=s[13];let b;
1s[14]!==v?(b=(0,t.jsxs)("div",{className:dt.section,children:[h,(0,t.jsxs)("div",{className:dt.scrollContainer,children:[_,v]})]}),s[14]=v,s[15]=b):b=s[15];let j;return s[16]!==b||s[17]!==m?(j=(0,t.jsx)("div",{children:(0,t.jsxs)("div",{className:dt.wrapper,children:[r,m,b]})}),s[16]=b,s[17]=m,s[18]=j):j=s[18],j},y0=f.memo(b0);function S0(s){return(0,t.jsxs)("div",{className:dt.user,children:[(0,t.jsx)("span",{className:dt.item,children:s.userID}),(0,t.jsx)("span",{className:dt.verticalLine}),(0,t.jsx)("span",{className:dt.item,children:s.userEmail}),(0,t.jsx)("span",{className:dt.verticalLine}),(0,t.jsx)("span",{className:dt.item,children:s.responseID})]},s.userID)}const C0="1001",N0="1000",w0="58px",A0="Create-module_container_eROdQ",I0="Create-module_header_bw847",T0="Create-module_headerText_5zzjh",k0="Create-module_description_OU7JM",R0="Create-module_content_LY6Kj",$0="Create-module_link_VekzA",P0="Create-module_submit_1X-J3",E0="Create-module_form_Tr4y3",L0="Create-module_label_kv-uK",B0="Create-module_input_peCxA",D0="Create-module_regenerate_PeIyF";var mt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:C0,paywallBgZIndex:N0,collapsedMediaSidebarWidth:w0,container:A0,header:I0,headerText:T0,description:k0,content:R0,link:$0,submit:P0,form:E0,label:L0,input:B0,regenerate:D0},M0=Q(ie()),F0=()=>{const s=(0,M0.c)(32),e=tt();let n,a,o;s[0]===Symbol.for("react.memo_cache_sentinel")?(n=Qr("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ",8),a=f.useState,o={purchaseCount:1,orderId:n(),app:"sellers/kapwing/apps/kapwing",customerEmail:"[email protected]",termMonths:12},s[0]=n,s[1]=a,s[2]=o):(n=s[0],a=s[1],o=s[2]);const[i,l]=a(o);let r;s[3]!==e||s[4]!==i?(r=async w=>{if(w.preventDefault(),window.confirm(`Are you sure you want to create this license? These are the values you entered: ${JSON.stringify(i)}. Hit OK to submit.`))try{const A=await v0(i);e(He({description:`License successfully created: ${JSON.stringify(A)}`,type:"success"}))}catch(A){Ue({description:"Error creating license",error:A})}},s[3]=e,s[4]=i,s[5]=r):r=s[5];const d=r;let c;s[6]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("div",{className:mt.headerText,children:"Create new license(s)"}),s[6]=c):c=s[6];let m;s[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsxs)("div",{className:mt.header,children:[c,(0,t.jsxs)("div",{className:mt.description,children:["Use this form to create a new license for Google App License partners. Didn't mean to create a new license?"," ",(0,t.jsx)(be,{to:"/admin/edu",className:mt.link,children:"Return to EDU home"}),"."]})]}),s[7]=m):m=s[7];let h;s[8]===Symbol.for("react.memo_cache_sentinel")?(h=w=>{w.persist(),l(A=>({...A,purchaseCount:Number(w.target.value)}))},s[8]=h):h=s[8];let p;s[9]!==i.purchaseCount?(p=(0,t.jsxs)("label",{className:mt.label,children:["Number of Licenses (purchase count)",(0,t.jsx)("input",{className:mt.input,type:"number",placeholder:"Number of licenses",value:i.purchaseCount,onChange:h})]}),s[9]=i.purchaseCount,s[10]=p):p=s[10];let u;s[11]===Symbol.for("react.memo_cache_sentinel")?(u=w=>{w.persist(),l(A=>({...A,customerEmail:w.target.value}))},s[11]=u):u=s[11];let g;s[12]!==i.customerEmail?(g=(0,t.jsxs)("label",{className:mt.label,children:["Customer Email (must be a GSuite domain):",(0,t.jsx)("input",{className:mt.input,type:"text",placeholder:"Customer Email",value:i.customerEmail,onChange:u})]}),s[12]=i.customerEmail,s[13]=g):g=s[13];let _;s[14]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsx)("span",{className:mt.regenerate,onClick:()=>{l(w=>({...w,orderId:n()}))},children:"Generate New ID"}),s[14]=_):_=s[14];let v;s[15]===Symbol.for("react.memo_cache_sentinel")?(v=w=>{w.persist(),l(A=>({...A,orderId:w.target.value}))},s[15]=v):v=s[15];let b;s[16]!==i.orderId?(b=(0,t.jsxs)("label",{className:mt.label,children:["Order ID (can be any random string):",_,(0,t.jsx)("input",{className:mt.input,type:"text",placeholder:"Order ID",value:i.orderId,onChange:v})]}),s[16]=i.orderId,s[17]=b):b=s[17];let j;s[18]===Symbol.for("react.memo_cache_sentinel")?(j=w=>{w.persist(),l(A=>({...A,app:w.target.value}))},s[18]=j):j=s[18];let x;s[19]!==i.app?(x=(0,t.jsxs)("label",{className:mt.label,children:["App Name (can be sellers/kapwing/apps/kapwing or sellers/kapwing/apps/kapwing-dev):",(0,t.jsx)("input",{className:mt.input,type:"text",placeholder:"App Name",value:i.app,onChange:j})]}),s[19]=i.app,s[20]=x):x=s[20];let S;s[21]===Symbol.for("react.memo_cache_sentinel")?(S=w=>{w.persist();let A=12;Number(w.target.value)===1&&(A=1),l(I=>({...I,termMonths:A}))},s[21]=S):S=s[21];let C;s[22]!==i.termMonths?(C=(0,t.jsxs)("label",{className:mt.label,children:["Term Length (can be either 1 or 12):",(0,t.jsx)("input",{className:mt.input,type:"text",placeholder:"1 or 12",value:i.termMonths,onChange:S})]}),s[22]=i.termMonths,s[23]=C):C=s[23];let y;s[24]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsx)("button",{type:"submit",className:mt.submit,children:"Submit"}),s[24]=y):y=s[24];let N;return s[25]!==d||s[26]!==b||s[27]!==x||s[28]!==C||s[29]!==p||s[30]!==g?(N=(0,t.jsxs)("div",{className:mt.container,children:[m,(0,t.jsx)("div",{className:mt.content,children:(0,t.jsxs)("form",{onSubmit:d,className:mt.form,children:[p,g,b,x,C,y]})})]}),s[25]=d,s[26]=b,s[27]=x,s[28]=C,s[29]=p,s[30]=g,s[31]=N):N=s[31],N},O0=f.memo(F0);const q0="1001",V0="1000",H0="58px",U0="LicenseItem-module_license_OQaEA",Z0="LicenseItem-module_licenseLink_xpl8X",W0="LicenseItem-module_licenseRedeemed_9wy9d",K0="LicenseItem-module_licenseNotRedeemed_DvYyN",G0="LicenseItem-module_licenseEmail_rXLca",J0="LicenseItem-module_deleteText_MUuGp",z0="LicenseItem-module_deleteTextDisabled_AhoLN";var $s={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:q0,paywallBgZIndex:V0,collapsedMediaSidebarWidth:H0,license:U0,licenseLink:Z0,licenseRedeemed:W0,licenseNotRedeemed:K0,licenseEmail:G0,deleteText:J0,deleteTextDisabled:z0},Y0=Q(ie()),Q0=s=>{const e=(0,Y0.c)(28),{license:n,updateLicenses:a}=s,o=tt(),[i,l]=(0,f.useState)("Delete");console.info(n);const{name:r,customerEmail:d,purchaseCount:c,redeemUri:m,redeemed:h}=n;let p;e[0]!==o||e[1]!==a?(p=async w=>{l("Deleting...");try{const A=await _0(w);o(He({description:`License successfully deleted: ${JSON.stringify(A)}`,type:"success"})),l("Delete"),await a()}catch(A){Ue({description:"Error deleting license",error:A}),l("Delete")}},e[0]=o,e[1]=a,e[2]=p):p=e[2];const u=p;let g=$s.deleteText;h&&(g=g+` ${$s.deleteTextDisabled}`);let _;e[3]!==d?(_=(0,t.jsx)("div",{className:$s.licenseEmail,children:d}),e[3]=d,e[4]=_):_=e[4];let v;e[5]!==c?(v=(0,t.jsxs)("div",{children:["Purchase count: ",c]}),e[5]=c,e[6]=v):v=e[6];let b;e[7]!==r?(b=(0,t.jsx)("div",{children:r}),e[7]=r,e[8]=b):b=e[8];let j;e[9]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(oo,{}),e[9]=j):j=e[9];let x;e[10]!==m?(x=(0,t.jsx)("div",{children:(0,t.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:$s.licenseLink,children:[m," ",j]})}),e[10]=m,e[11]=x):x=e[11];let S;e[12]!==h?(S=h?(0,t.jsx)("div",{className:$s.licenseRedeemed,children:"Redeemed"}):(0,t.jsx)("div",{className:$s.licenseNotRedeemed,children:"Not redeemed"}),e[12]=h,e[13]=S):S=e[13];let C;e[14]!==u||e[15]!==n?(C=()=>u(n),e[14]=u,e[15]=n,e[16]=C):C=e[16];let y;e[17]!==i||e[18]!==g||e[19]!==C?(y=(0,t.jsx)("div",{children:(0,t.jsx)("div",{onClick:C,className:g,children:i})}),e[17]=i,e[18]=g,e[19]=C,e[20]=y):y=e[20];let N;return e[21]!==_||e[22]!==v||e[23]!==b||e[24]!==x||e[25]!==S||e[26]!==y?(N=(0,t.jsxs)("div",{className:$s.license,children:[_,v,b,x,S,y]}),e[21]=_,e[22]=v,e[23]=b,e[24]=x,e[25]=S,e[26]=y,e[27]=N):N=e[27],N},X0=f.memo(Q0);
1const ef="1001",tf="1000",sf="58px",nf="View-module_container_JsKwa",af="View-module_header_bA2BN",of="View-module_headerText_jpqXY",lf="View-module_description_dZoCz",rf="View-module_content_yCCrJ",df="View-module_link_MHRqV",cf="View-module_licensesContainer_eZyvR";var hs={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:ef,paywallBgZIndex:tf,collapsedMediaSidebarWidth:sf,container:nf,header:af,headerText:of,description:lf,content:rf,link:df,licensesContainer:cf},uf=Q(ie()),mf=()=>{const s=(0,uf.c)(14),e=tt(),[n,a]=(0,f.useState)(!0);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],s[0]=o):o=s[0];const[i,l]=(0,f.useState)(o);let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{(async()=>{l((await Zo({pageSize:100,pageToken:"",filter:""})).standaloneAppLicenses),a(!1)})().catch(hf)},s[1]=r):r=s[1];let d;s[2]!==e?(d=[e],s[2]=e,s[3]=d):d=s[3],(0,f.useEffect)(r,d);let c;s[4]===Symbol.for("react.memo_cache_sentinel")?(c=async()=>{const b={pageSize:100,pageToken:"",filter:""};try{l((await Zo(b)).standaloneAppLicenses)}catch(j){Ue({description:"Error getting licenses",error:j})}},s[4]=c):c=s[4];const m=c;let h;s[5]!==i?(h=()=>i.length?(0,t.jsx)("div",{className:hs.licensesContainer,children:i.map((b,j)=>(0,t.jsx)(X0,{license:b,updateLicenses:m},j))}):(0,t.jsx)("div",{className:hs.licensesContainer,children:"No licenses found. Please create one then come back to view."}),s[5]=i,s[6]=h):h=s[6];const p=h;let u;s[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)("div",{className:hs.headerText,children:"View all licenses"}),s[7]=u):u=s[7];let g;s[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsxs)("div",{className:hs.header,children:[u,(0,t.jsxs)("div",{className:hs.description,children:["Use this page to see all previously created licenses. Didn't mean to view all licenses?"," ",(0,t.jsx)(be,{to:"/admin/edu",className:hs.link,children:"Return to EDU home"}),"."]})]}),s[8]=g):g=s[8];let _;s[9]!==n||s[10]!==p?(_=n?"Loading licenses...":p(),s[9]=n,s[10]=p,s[11]=_):_=s[11];let v;return s[12]!==_?(v=(0,t.jsxs)("div",{className:hs.container,children:[g,(0,t.jsx)("div",{className:hs.content,children:_})]}),s[12]=_,s[13]=v):v=s[13],v},pf=f.memo(mf);function hf(s){Ue({description:"Error getting licenses",error:s})}var Sl=Q(ie()),ff=f.memo(()=>{const s=(0,Sl.c)(5);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:Dt.headerText,children:"Welcome to the EDU admin page!"}),s[0]=e):e=s[0];let n;s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsxs)("a",{href:"https://developers.google.com/app-licensing/getting-started?hl=en_US",className:Dt.link,target:"_blank",rel:"noreferrer",children:["App Licensing API ",(0,t.jsx)(oo,{})]}),s[1]=n):n=s[1];let a;s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)("div",{className:Dt.header,children:[e,(0,t.jsxs)("div",{className:Dt.description,children:["Use this page to provision licenses via the"," ",n,". Looking for the list of Typeform survey responses for the EDU program? Visit"," ",(0,t.jsx)(be,{to:"/admin/edu/survey",className:Dt.link,children:"/admin/edu/survey"}),"."]})]}),s[2]=a):a=s[2];let o;s[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:Dt.headerText,children:"What action would you like to take?"}),s[3]=o):o=s[3];let i;return s[4]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxs)("div",{className:Dt.container,children:[a,(0,t.jsxs)("div",{className:Dt.content,children:[o,(0,t.jsxs)("div",{className:Dt.actions,children:[(0,t.jsx)(be,{to:"/admin/edu/licenses/create",className:Dt.actionsButton,children:"Create new licenses"}),(0,t.jsx)(be,{to:"/admin/edu/licenses/view",className:Dt.actionsButton,children:"View or delete past licenses created"})]})]})]}),s[4]=i):i=s[4],i}),xf=()=>{const s=(0,Sl.c)(5);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(Te,{path:"/survey",element:(0,t.jsx)(y0,{})}),s[0]=e):e=s[0];let n;s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(Te,{path:"/licenses/create",element:(0,t.jsx)(O0,{})}),s[1]=n):n=s[1];let a;s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(Te,{path:"/licenses/view",element:(0,t.jsx)(pf,{})}),s[2]=a):a=s[2];let o;s[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(Te,{path:"/licenses",element:(0,t.jsx)(Yn,{to:"/"})}),s[3]=o):o=s[3];let i;return s[4]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxs)(Bn,{children:[e,n,a,o,(0,t.jsx)(Te,{element:(0,t.jsx)(ff,{}),path:"*"})]}),s[4]=i):i=s[4],i},gf=f.memo(xf);const vf="1001",_f="1000",jf="58px",bf="EditTemplate-module_container_Aj15k",yf="EditTemplate-module_fieldContainer_HKRUc",Sf="EditTemplate-module_formDescription_hOD4Y",Cf="EditTemplate-module_formLabel_NUGnd",Nf="EditTemplate-module_formInput_dMLo1",wf="EditTemplate-module_formTextField_xhd3F",Af="EditTemplate-module_formButton_oqjN8",If="EditTemplate-module_formButtonSelected_eBzHT",Tf="EditTemplate-module_formButtonsSelected_bCZ25",kf="EditTemplate-module_formTextarea_pDB7n",Rf="EditTemplate-module_formContainer_057Fr",$f="EditTemplate-module_button_yQU6L",Pf="EditTemplate-module_buttonLoading_kNbLN",Ef="EditTemplate-module_loader_Z4Uva",Lf="EditTemplate-module_spin_lDTMB",Bf="EditTemplate-module_headerContainer_6nPiV",Df="EditTemplate-module_header_h8jwm",Mf="EditTemplate-module_description_n8VX6",Ff="EditTemplate-module_backLink_YUZqK",Of="EditTemplate-module_templateLink_K5kAT",qf="EditTemplate-module_idReference_JvgaI",Vf="EditTemplate-module_slugLink_MLDa5",Hf="EditTemplate-module_link_KeuTd";var Oe={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:vf,paywallBgZIndex:_f,collapsedMediaSidebarWidth:jf,container:bf,fieldContainer:yf,formDescription:Sf,formLabel:Cf,formInput:Nf,formTextField:wf,formButton:Af,formButtonSelected:If,formButtonsSelected:Tf,formTextarea:kf,formContainer:Rf,button:$f,buttonLoading:Pf,loader:Ef,spin:Lf,headerContainer:Bf,header:Df,description:Mf,backLink:Ff,templateLink:Of,idReference:qf,slugLink:Vf,link:Hf},Uf=Q(ie()),Zf={_id:"",title:"",slug:"",video_id:"",description:"",keywords:""},Wf=()=>{const s=(0,Uf.c)(40),e=tt(),n=Lt(),[a,o]=(0,f.useState)(!1),[i,l]=(0,f.useState)(!1),r=ys(Gf);let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=al.get("CURRENT_TEMPLATE",{disabled:null}),s[0]=d):d=s[0];const c=d;let m;s[1]!==r?(m={...Zf,...r,...c},s[1]=r,s[2]=m):m=s[2];const h=m;let p;s[3]!==h?(p={...h},s[3]=h,s[4]=p):p=s[4];const[u,g]=(0,f.useState)(p);let _;s[5]!==e||s[6]!==n||s[7]!==u?(_=async k=>{k.preventDefault(),o(!0),Ru(u).then(()=>{e(He({description:"Template updated!",bottomLink:{text:"View template >",href:`/explore/${u.slug}`},type:"success"})),o(!1),n("/admin/templates")}
1).catch(T=>{Ue({description:"Error updating template",error:T}),o(!1)})},s[5]=e,s[6]=n,s[7]=u,s[8]=_):_=s[8];const v=_;let b;s[9]!==e||s[10]!==u._id||s[11]!==u.slug?(b=async()=>{l(!0),Cu(u._id.toString()).then(()=>{e(He({description:"Template preview regenerated!",bottomLink:{text:"View template >",href:`/explore/${u.slug}`},type:"success"})),l(!1)}).catch(k=>{Ue({description:"Error regenerating template preview",error:k}),l(!1)})},s[9]=e,s[10]=u._id,s[11]=u.slug,s[12]=b):b=s[12];const j=b;let x;s[13]===Symbol.for("react.memo_cache_sentinel")?(x=k=>{const{name:T,value:E}=k.target;if(T==="video_id"&&E&&E.includes("kapwing.com/videos/")){const O=E.split("/").pop();O&&g(q=>({...q,video_id:O}))}else g(O=>({...O,[T]:E}))},s[13]=x):x=s[13];const S=x,C=Jf;let y;s[14]!==j||s[15]!==v||s[16]!==a||s[17]!==i||s[18]!==u.description||s[19]!==u.keywords||s[20]!==u.slug||s[21]!==u.title||s[22]!==u.video_id?(y=()=>(0,t.jsx)("div",{className:Oe.formContainer,children:(0,t.jsxs)("form",{onSubmit:v,children:[(0,t.jsxs)("div",{className:Oe.fieldContainer,children:[(0,t.jsx)("div",{className:Oe.formLabel,children:"Video ID"}),(0,t.jsx)("div",{className:Oe.formDescription,children:"Paste link to Kapwing video or just input video ID. Changing / updating this field will cause the template thumbnails to be reprocessed."}),(0,t.jsx)("div",{className:Oe.formInput,children:(0,t.jsx)("input",{className:Oe.formTextField,type:"text",name:"video_id",value:u.video_id,onChange:S})})]}),(0,t.jsxs)("div",{className:Oe.fieldContainer,children:[(0,t.jsx)("div",{className:Oe.formLabel,children:"Title"}),(0,t.jsx)("div",{className:Oe.formInput,children:(0,t.jsx)("input",{className:Oe.formTextField,type:"text",name:"title",value:u.title,onChange:S})})]}),(0,t.jsxs)("div",{className:Oe.fieldContainer,children:[(0,t.jsxs)("div",{className:Oe.formLabel,children:["Slug:"," ",(0,t.jsxs)("a",{href:`https://www.kapwing.com/explore/${u.slug}`,target:"_blank",rel:"noreferrer noopener",className:Oe.slugLink,children:[u.slug," ",(0,t.jsx)(jr,{})]})]}),(0,t.jsx)("div",{className:Oe.formDescription,children:"To protect SEO, the template slug cannot be edited. If you need to change the slug, either delete and re-create the template, or ask an engineer to help redirect the original page."})]}),(0,t.jsxs)("div",{className:Oe.fieldContainer,children:[(0,t.jsx)("div",{className:Oe.formLabel,children:"Description"}),(0,t.jsx)("div",{className:Oe.formInput,children:(0,t.jsx)("textarea",{className:Oe.formTextarea,name:"description",value:u.description,onChange:S})})]}),(0,t.jsxs)("div",{className:Oe.fieldContainer,children:[(0,t.jsx)("div",{className:Oe.formLabel,children:"Keywords"}),(0,t.jsxs)("div",{className:Oe.formDescription,children:["Place ",(0,t.jsx)("i",{children:"meme"})," here if you want the template to show up on the meme templates page."]}),(0,t.jsx)("div",{className:Oe.formInput,children:(0,t.jsx)("textarea",{className:Oe.formTextarea,name:"keywords",value:u.keywords||"",onChange:S})})]}),(0,t.jsx)("div",{className:Oe.fieldContainer,children:a?(0,t.jsxs)("button",{className:Oe.buttonLoading,disabled:!0,children:[(0,t.jsx)("span",{children:"Updating ..."})," ",(0,t.jsx)("div",{className:Oe.loader})]}):(0,t.jsx)("button",{className:Oe.button,type:"submit",children:"Update template"})}),(0,t.jsxs)("div",{className:Oe.fieldContainer,children:[(0,t.jsx)("div",{className:Oe.formDescription,children:"Force the preview thumbnail/image to be regenerated from the template's current video, without needing to change the Video ID. Useful if the video was stuck/incomplete when the template was originally created or last updated."}),i?(0,t.jsxs)("button",{className:Oe.buttonLoading,disabled:!0,children:[(0,t.jsx)("span",{children:"Regenerating ..."})," ",(0,t.jsx)("div",{className:Oe.loader})]}):(0,t.jsx)("button",{className:Oe.button,type:"button",onClick:j,children:"Regenerate preview"})]})]})}),s[14]=j,s[15]=v,s[16]=a,s[17]=i,s[18]=u.description,s[19]=u.keywords,s[20]=u.slug,s[21]=u.title,s[22]=u.video_id,s[23]=y):y=s[23];const N=y;let w;s[24]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)("div",{className:Oe.header,children:"Edit Template"}),s[24]=w):w=s[24];let A;s[25]!==u._id?(A=u._id.toString(),s[25]=u._id,s[26]=A):A=s[26];let I;s[27]!==A?(I=(0,t.jsx)("b",{children:A}),s[27]=A,s[28]=I):I=s[28];let D;s[29]===Symbol.for("react.memo_cache_sentinel")?(D=(0,t.jsx)(be,{to:"/admin/templates/new",className:Oe.link,children:"New Template"}),s[29]=D):D=s[29];let L;s[30]===Symbol.for("react.memo_cache_sentinel")?(L=(0,t.jsx)(be,{to:"/admin/templates",className:Oe.link,children:"templates admin"}),s[30]=L):L=s[30];let $;s[31]!==I?($=(0,t.jsxs)("div",{className:Oe.headerContainer,children:[w,(0,t.jsxs)("div",{className:Oe.description,children:["Editing template with ID: ",I,". Need to create a new template? Visit the"," ",D," ","page. Need to edit a different template? First find it on the"," ",L," ","page."]})]}),s[31]=I,s[32]=$):$=s[32];let R;s[33]!==h._id||s[34]!==N||s[35]!==u.slug?(R=(0,t.jsx)("div",{className:Oe.formContainer,children:h._id&&u.slug?N():C()}),s[33]=h._id,s[34]=N,s[35]=u.slug,s[36]=R):R=s[36];let P;return s[37]!==$||s[38]!==R?(P=(0,t.jsxs)("div",{className:Oe.container,children:[$,R]}),s[37]=$,s[38]=R,s[39]=P):P=s[39],P},Kf=Wf;function Gf(s){return s.exploreTemplates.adminAddingTemplate}function Jf(){return(0,t.jsxs)("div",{className:Oe.formContainer,children:[(0,t.jsx)("div",{className:Oe.fieldContainer,children:`You can't edit a template without first selecting the one you want to edit. To edit a template, visit the page for the template you want to edit and click the "Edit" button.`}),(0,t.jsx)("div",{className:Oe.fieldContainer,children:(0,t.jsx)(be,{to:"/admin/templates",children:(0,t.jsx)("button",{className:Oe.button,children:"Go to all templates"})})})]})}const zf="1001",Yf="1000",Qf="58px",Xf="Migrate-module_container_erx6S",ex="Migrate-module_data_vEi2B";var ta={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:zf,paywallBgZIndex:Yf,collapsedMediaSidebarWidth:Qf,container:Xf,data:ex};const tx=[];var sx=Q(ie()),nx=()=>{const s=(0,sx.c)(21);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],s[0]=e):e=s[0];const[n,a]=(0,f.useState)(e),[o,i]=(0,f.useState)(""),[l,r]=(0,f.useState)(0);let d;s[1]===Symbol.for("react.memo_cache_sentinel")?(d=async C=>{C.preventDefault();const y=tx.slice(0,500);for(let N=0;N<y.length;N=N+1){const w=y[N];if(w){i(w),r(N);try{console.info(),console.info("Getting template for Id",w);const{video_id:A,slug:I}=await bl(w);if(!A){console.info("no video id for template",w);continue}console.info(`Getting video for videoId ${A}`);const D=await Wa({id:A,forEditing:!0,forTemplate:!0});console.info("Running export for video",D);const{processVideoJob:L}
1=await Cc({exportLocation:"template-admin-migration",video:D,exportSettings:{...qd,...Od(D)}});console.info("ProcessVideoJob created",L);const{video_id:$,_id:R}=L;a(P=>{const k=[...P,{templateId:w,slug:I,video_id:$,processVideoJobId:R}];try{navigator.clipboard.writeText(JSON.stringify(k))}catch(T){console.error("Failed to copy: ",T)}return k})}catch(A){Ue({description:"Error migrating template",error:A});continue}}}},s[1]=d):d=s[1];const c=d;let m,h,p,u;s[2]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)("h1",{children:"Migrate templates admin page"}),h=(0,t.jsx)("p",{children:"This page is used to re-export all templates. It's placed here in the Kapwing repo because the functions are easier to call from here than in some random python scripts. Place the template IDs you want to reexport into data.ts, then return to this page to run the re-exports."}),p=(0,t.jsx)("button",{type:"submit",onClick:c,children:"Run migration"}),u=(0,t.jsx)("h2",{children:"stats"}),s[2]=m,s[3]=h,s[4]=p,s[5]=u):(m=s[2],h=s[3],p=s[4],u=s[5]);let g;s[6]!==l?(g=(0,t.jsxs)("p",{children:["Current Loop: ",l]}),s[6]=l,s[7]=g):g=s[7];let _;s[8]!==o?(_=(0,t.jsxs)("p",{children:["Current Template: ",o]}),s[8]=o,s[9]=_):_=s[9];let v;s[10]!==g||s[11]!==_?(v=(0,t.jsxs)("div",{children:[u,g,_]}),s[10]=g,s[11]=_,s[12]=v):v=s[12];let b;s[13]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("h2",{children:"data"}),s[13]=b):b=s[13];let j;s[14]!==n?(j=JSON.stringify(n,null,2),s[14]=n,s[15]=j):j=s[15];let x;s[16]!==j?(x=(0,t.jsxs)("div",{className:ta.data,children:[b,(0,t.jsx)("pre",{children:j})]}),s[16]=j,s[17]=x):x=s[17];let S;return s[18]!==x||s[19]!==v?(S=(0,t.jsxs)("div",{className:ta.container,children:[m,h,p,v,x]}),s[18]=x,s[19]=v,s[20]=S):S=s[20],S},ax=nx;const ox=[];var ix=()=>{const s=tt(),[e,n]=(0,f.useState)([]),[a,o]=(0,f.useState)(""),[i,l]=(0,f.useState)(0),r=async d=>{d.preventDefault();const c=ox.slice(0,void 0);for(let m=0;m<c.length;m+=1){const h=c[m];if(h){o(h),l(m);try{console.info(),console.info("Getting template for Id",h);const p=await bl(h);if(console.info("fetched template",p),!p.video_id)throw new Error("Template does not have a video_id");const u=await Wa({id:p.video_id}),{preview:g}=p;if(!g){console.error("Template does not have a preview",h);continue}const{type:_,numLayers:v}=g;if(_!=="image"){console.error("Template is not image type",h);continue}if(v!==1){console.error("Template has more than one layer",h);continue}const{fullPath:b}=g;if(!b){console.error("Template does not have a fullPath",h);continue}const{createLocation:j,lastSaved:x}=u;if(j!=="single-media-migration"){console.error(`Template ${p.slug} is not a single media migration`);continue}const S=new Date(x),C=new Date;if(C.setMonth(C.getMonth()-1),S>C){console.info(`Template ${p.slug} was last saved less than a month ago`);continue}else console.info(`Template ${p.slug} was last saved more than a month ago, will continue with processing`);
1console.info("First create a new video, then turn this single media into a video"),s(lc());const y=await lu({publish:!1,createLocation:"single-media-migration"});if(!y._id){console.error("Failed to create video for template",h);continue}await Ac({url:b,options:{mediaInfo:{width:p.preview.width,height:p.preview.height,type:Yi.Image}}});const N=p.title;await H.video.adminUpdateVideo.mutate({videoId:y._id,updates:{name:N,templateSlug:p.slug,isTemplateVideo:!0}}),console.info(`Getting video for videoId ${y._id}`),await Wa({id:y._id,forEditing:!0,forTemplate:!0}),console.info(`updating template: localhost:3000/explore/${p.slug}`),await $u({templateId:p._id,fieldsToUpdate:{video_id:y._id}}),n(w=>[...w,{id:p._id,template:p.slug,video_id:y._id}])}catch(p){console.error(p),Ue({description:"Error migrating template",error:p});continue}}}};return(0,t.jsxs)("div",{className:ta.container,children:[(0,t.jsx)("h1",{children:"Migrate single media admin page"}),(0,t.jsx)("p",{children:"This page is similar to the migrate page, but it works on single media templates. This is a one time migration to sync single media templates with our normal templates and assign them a video ID that can be used. Place the video IDs that you'd like to run an export on in the videoIds.ts file and run the migration here."}),(0,t.jsx)("button",{type:"submit",onClick:r,children:"Run migration"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{children:"stats"}),(0,t.jsxs)("p",{children:["Current Loop: ",i]}),(0,t.jsxs)("p",{children:["Current Template: ",a]})]}),(0,t.jsxs)("div",{className:ta.data,children:[(0,t.jsx)("h2",{children:"data"}),(0,t.jsx)("pre",{children:JSON.stringify(e,null,2)})]})]})},lx=ix;const rx="1001",dx="1000",cx="58px",ux="NewTemplate-module_container_nfiI4",mx="NewTemplate-module_fieldContainer_5eEvD",px="NewTemplate-module_formDescription_YYN8T",hx="NewTemplate-module_formLabel_5putN",fx="NewTemplate-module_formInput_iJe4S",xx="NewTemplate-module_formTextField_vOGje",gx="NewTemplate-module_formButton_tOuMY",vx="NewTemplate-module_formButtonSelected_TLKD1",_x="NewTemplate-module_formButtonsSelected_FuRbP",jx="NewTemplate-module_formTextarea_GSmgT",bx="NewTemplate-module_formContainer_8fxIA",yx="NewTemplate-module_button_rmZw0",Sx="NewTemplate-module_buttonLoading_SanPo",Cx="NewTemplate-module_loader_wj7Lz",Nx="NewTemplate-module_spin_ovApM",wx="NewTemplate-module_headerContainer_fBL0F",Ax="NewTemplate-module_header_xqVok",Ix="NewTemplate-module_description_e-6lL",Tx="NewTemplate-module_backLink_Sv9y8",kx="NewTemplate-module_templateLink_7f-5X",Rx="NewTemplate-module_idReference_pUFj3";var Ge={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:rx,paywallBgZIndex:dx,collapsedMediaSidebarWidth:cx,container:ux,fieldContainer:mx,formDescription:px,formLabel:hx,formInput:fx,formTextField:xx,formButton:gx,formButtonSelected:vx,formButtonsSelected:_x,formTextarea:jx,formContainer:bx,button:yx,buttonLoading:Sx,loader:Cx,spin:Nx,headerContainer:wx,header:Ax,description:Ix,backLink:Tx,templateLink:kx,idReference:Rx},$x=Q(ie());function Px(s){return s.toLowerCase().replace(/[^\w ]+/g,"").replace(/ +/g,"-")}var Ex=()=>{const s=(0,$x.c)(20),e=tt(),n=Lt(),a=ys(Bx);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o={title:"",slug:"",video_id:"",description:"",keywords:""},s[0]=o):o=s[0];let i=o;if(a){let x;s[1]!==a?(x={...i,...a},s[1]=a,s[2]=x):x=s[2],i=x}const[l,r]=(0,f.useState)(i),[d,c]=(0,f.useState)(!1);let m;s[3]===Symbol.for("react.memo_cache_sentinel")?(m=x=>{const{name:S,value:C}=x.target;if(S==="video_id"&&C&&C.includes("kapwing.com/videos/")){const y=C.split("/").pop();y&&r(N=>({...N,video_id:y}))}else r(S==="title"?y=>({...y,title:C,slug:Px(C)}):y=>({...y,[S]:C}))},s[3]=m):m=s[3];const h=m;let p;s[4]!==e||s[5]!==n||s[6]!==l?(p=async x=>{x.preventDefault(),c(!0),Au(l).then(()=>{e(He({description:"Template updated!",bottomLink:{text:"View template >",href:`/explore/${l.slug}`},type:"success"})),c(!1),n("/admin/templates")}
1).catch(S=>{Ue({description:"Error updating template",error:S}),c(!1)})},s[4]=e,s[5]=n,s[6]=l,s[7]=p):p=s[7];const u=p;let g;s[8]!==u||s[9]!==d||s[10]!==l.description||s[11]!==l.keywords||s[12]!==l.slug||s[13]!==l.title||s[14]!==l.video_id?(g=()=>(0,t.jsx)("div",{className:Ge.formContainer,children:(0,t.jsxs)("form",{onSubmit:u,children:[(0,t.jsxs)("div",{className:Ge.fieldContainer,children:[(0,t.jsx)("div",{className:Ge.formLabel,children:"Video ID"}),(0,t.jsx)("div",{className:Ge.formDescription,children:"Paste link to Kapwing video or just input video ID"}),(0,t.jsx)("div",{className:Ge.formInput,children:(0,t.jsx)("input",{className:Ge.formTextField,type:"text",name:"video_id",value:l.video_id,onChange:h})})]}),(0,t.jsxs)("div",{className:Ge.fieldContainer,children:[(0,t.jsx)("div",{className:Ge.formLabel,children:"Title"}),(0,t.jsx)("div",{className:Ge.formInput,children:(0,t.jsx)("input",{className:Ge.formTextField,type:"text",name:"title",value:l.title,onChange:h})})]}),(0,t.jsxs)("div",{className:Ge.fieldContainer,children:[(0,t.jsx)("div",{className:Ge.formLabel,children:"Slug"}),(0,t.jsx)("div",{className:Ge.formInput,children:(0,t.jsx)("input",{className:Ge.formTextField,type:"text",name:"slug",value:l.slug,onChange:h})})]}),(0,t.jsxs)("div",{className:Ge.fieldContainer,children:[(0,t.jsx)("div",{className:Ge.formLabel,children:"Description"}),(0,t.jsx)("div",{className:Ge.formInput,children:(0,t.jsx)("textarea",{className:Ge.formTextarea,name:"description",value:l.description,onChange:h})})]}),(0,t.jsxs)("div",{className:Ge.fieldContainer,children:[(0,t.jsx)("div",{className:Ge.formLabel,children:"Keywords"}),(0,t.jsxs)("div",{className:Ge.formDescription,children:["Place ",(0,t.jsx)("i",{children:"meme"})," here if you want the template to show up on the meme templates page."]}),(0,t.jsx)("div",{className:Ge.formInput,children:(0,t.jsx)("textarea",{className:Ge.formTextarea,name:"keywords",value:l.keywords??"",onChange:h})})]}),(0,t.jsx)("div",{className:Ge.fieldContainer,children:d?(0,t.jsxs)("button",{className:Ge.buttonLoading,disabled:!0,children:[(0,t.jsx)("span",{children:"Creating..."})," ",(0,t.jsx)("div",{className:Ge.loader})]}):(0,t.jsx)("button",{className:Ge.button,type:"submit",children:"Create template"})})]})}),s[8]=u,s[9]=d,s[10]=l.description,s[11]=l.keywords,s[12]=l.slug,s[13]=l.title,s[14]=l.video_id,s[15]=g):g=s[15];const _=g;let v;s[16]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{className:Ge.header,children:"Create a new template"}),s[16]=v):v=s[16];let b;s[17]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsxs)("div",{className:Ge.headerContainer,children:[v,(0,t.jsxs)("div",{className:Ge.description,children:["Use this form to create a new template. Templates will be created immediately but only released during the next Kapwing build. Need to edit an existing template? Visit the"," ",(0,t.jsx)(be,{to:"/admin/templates/edit",children:"edit template"})," page."]})]}),s[17]=b):b=s[17];let j;return s[18]!==_?(j=(0,t.jsxs)("div",{className:Ge.container,children:[b,(0,t.jsx)("div",{className:Ge.formContainer,children:_()})]}),s[18]=_,s[19]=j):j=s[19],j},Lx=Ex;function Bx(s){return s.exploreTemplates.adminAddingTemplate}const Dx="1001",Mx="1000",Fx="58px",Ox="TemplateAdmin-module_container_HgejS",qx="TemplateAdmin-module_formContainer_MmJzt",Vx="TemplateAdmin-module_form_u8xxO",Hx="TemplateAdmin-module_formLabel_Zqqri",Ux="TemplateAdmin-module_formTextField_mn0TN",Zx="TemplateAdmin-module_formButton_VqlGw",Wx="TemplateAdmin-module_formButtonSelected_tNb16",Kx="TemplateAdmin-module_formButtonsSelected_9h1-z",Gx="TemplateAdmin-module_formTextarea_AfFH-",Jx="TemplateAdmin-module_rows_QSkpF",zx="TemplateAdmin-module_rowsLink_Px6mz",Yx="TemplateAdmin-module_buttonContainer_LjVSW",Qx="TemplateAdmin-module_button_QvU9A",Xx="TemplateAdmin-module_cancel_QxAdC",eg="TemplateAdmin-module_loadingContainer_6P-Rh",tg="TemplateAdmin-module_nextPageContainer_-8aq-",sg="TemplateAdmin-module_nextPageLink_O0x6-",ng="TemplateAdmin-module_templatesWrapper_U9BGd",ag="TemplateAdmin-module_headerContainer_qTnSD",og="TemplateAdmin-module_header_-P8rm",ig="TemplateAdmin-module_description_zyVWU";
1var Mt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Dx,paywallBgZIndex:Mx,collapsedMediaSidebarWidth:Fx,container:Ox,formContainer:qx,form:Vx,formLabel:Hx,formTextField:Ux,formButton:Zx,formButtonSelected:Wx,formButtonsSelected:Kx,formTextarea:Gx,rows:Jx,rowsLink:zx,buttonContainer:Yx,button:Qx,cancel:Xx,loadingContainer:eg,nextPageContainer:tg,nextPageLink:sg,templatesWrapper:ng,headerContainer:ag,header:og,description:ig};const lg="1001",rg="1000",dg="58px",cg="TemplateElement-module_element_hFc2m",ug="TemplateElement-module_imagePreview_CBM61",mg="TemplateElement-module_info_2ZhbI",pg="TemplateElement-module_titleLink_qYRjT";var vn={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:lg,paywallBgZIndex:rg,collapsedMediaSidebarWidth:dg,element:cg,imagePreview:ug,info:mg,titleLink:pg},hg=Q(ie()),fg=s=>{const e=(0,hg.c)(11),{template:n}=s,{title:a,preview:o}=n,i=o?.thumbnailPath||"",l=`/explore/${n.slug}`;let r;e[0]!==i||e[1]!==a?(r=(0,t.jsx)("img",{src:i,className:vn.imagePreview,alt:a,loading:"lazy"}),e[0]=i,e[1]=a,e[2]=r):r=e[2];let d;e[3]!==n.title?(d=(0,t.jsx)("span",{className:vn.info,children:(0,t.jsx)("div",{className:vn.titleLink,children:n.title})}),e[3]=n.title,e[4]=d):d=e[4];let c;e[5]!==r||e[6]!==d?(c=(0,t.jsxs)("div",{className:vn.element,children:[r,d]}),e[5]=r,e[6]=d,e[7]=c):c=e[7];let m;return e[8]!==l||e[9]!==c?(m=(0,t.jsx)(be,{to:l,target:"_blank",rel:"noopener noreferrer",className:vn.titleLink,children:c}),e[8]=l,e[9]=c,e[10]=m):m=e[10],m},xg=f.memo(fg),gg=class extends f.Component{constructor(s){super(s),this.state={loading:!0,templates:[]}}componentDidMount(){this.updateTemplates()}componentDidUpdate(s){const{match:e}=this.props,{params:n}=e,{pageNumber:a}=n;a!==s.match.params.pageNumber&&this.updateTemplates()}updateTemplates=()=>{const{match:s}=this.props,{params:e}=s,{pageNumber:n}=e;this.setState({loading:!0}),Nu(n).then(a=>{this.setState({templates:a,loading:!1})}).catch(a=>{Ue({description:"An error occurred while getting the templates.",error:a}),this.setState({loading:!1})})};renderTemplates(){const{templates:s}=this.state;return(0,t.jsx)("div",{className:Mt.templatesWrapper,children:s.map(e=>(0,t.jsx)(xg,{template:e},e._id))})}renderPaginationLinks(){const{match:s}=this.props,{params:e}=s,{pageNumber:n}=e;return(0,t.jsxs)("div",{className:Mt.nextPageContainer,children:[n>1?(0,t.jsx)(be,{to:`/admin/templates/${parseInt(n,10)-1}`,className:Mt.nextPageLink,children:"â Previous Page"}):(0,t.jsx)("div",{}),(0,t.jsx)(be,{to:`/admin/templates/${parseInt(n,10)+1}`,className:Mt.nextPageLink,children:"Next Page â"})]})}render(){const{loading:s}=this.state;return(0,t.jsxs)("div",{className:Mt.container,children:[(0,t.jsxs)("div",{className:Mt.headerContainer,children:[(0,t.jsx)("div",{className:Mt.header,children:"Welcome to the template admin page"}),(0,t.jsxs)("div",{className:Mt.description,children:["Newly created templates will appear here. Note that newly created templates will be shown on this page, but they will not appear on /explore until the next release. Visit"," ",(0,t.jsx)("a",{href:"https://github.com/kapwing/kapwing/actions/workflows/build-landing-pages-prod.yml",rel:"noopener noreferrer",target:"_blank",children:"this link in Github"})," ","to run the workflow to rebuild the pages."]})]}),(0,t.jsx)("div",{className:Mt.buttonContainer,children:(0,t.jsx)(be,{to:"/admin/templates/new",className:Mt.button,children:"Add Template"})}),s?(0,t.jsx)("div",{className:Mt.loadingContainer,children:(0,t.jsx)(it,{text:"Loading templates..."})}):this.renderTemplates(),this.renderPaginationLinks()]})}},vg=Qs(gg);const _g="1001",jg="1000",bg="58px",yg="File-module_copyLinkButton_o7TX3",Sg="File-module_changeLinkButton_Kpz5C",Cg="File-module_submitChangeLinkButton_pJ1e-",Ng="File-module_cancelChangeLinkButton_R2Inc",wg="File-module_listItem_J3MsN",Ag="File-module_imagePreview_WY8G2",Ig="File-module_image_6nPdr",Tg="File-module_info_MJUa4",kg="File-module_uploadName_t00ka",Rg="File-module_urlContainer_OVb-0",$g="File-module_cdnUrl_JMx4J",Pg="File-module_uploadAuthor_vP-au",Eg="File-module_authorButton_wVlH2",Lg="File-module_deleteText_-HRbk",Bg="File-module_changeLinkErrorMessage_D6euZ";var _t={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:_g,paywallBgZIndex:jg,collapsedMediaSidebarWidth:bg,copyLinkButton:yg,changeLinkButton:Sg,submitChangeLinkButton:Cg,cancelChangeLinkButton:Ng,listItem:wg,imagePreview:Ag,image:Ig,info:Tg,uploadName:kg,urlContainer:Rg,cdnUrl:$g,uploadAuthor:Pg,authorButton:Eg,deleteText:Lg,changeLinkErrorMessage:Bg};function Dg(s){return H.admin.upload.getRecentUploads.query(s)}function Mg(s){return H.admin.upload.moveUpload.mutate(s)}function Fg(s){return H.admin.upload.deleteUpload.mutate(s)}var Og=Q(ie()),Wo="static",qg=/^[a-zA-Z0-9_-]+$/,Vg=s=>{const e=(0,Og.c)(58),{upload:n,updateUploads:a,authorSearch:o,updateSelf:i}=s,{name:l,cdnUrl:r,uploader:d,mime:c}=n,m=tt();let h;e[0]!==r?(h=r.split(".").pop()||"",e[0]=r,e[1]=h):h=e[1];const p=h,[u,g]=(0,f.useState)("Copy Link"),[_,v]=(0,f.useState)("Delete"),[b,j]=(0,f.useState)("Update"),[x,S]=(0,f.useState)(!1),C=f.useRef(null),[y,N]=(0,f.useState)("");let w;e[2]!==r?(w=()=>{navigator.clipboard.writeText(r||"").then(()=>{g("Link copied!"),setTimeout(()=>{g("Copy Link")},1500)})},e[2]=r,e[3]=w):w=e[3];const A=w;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{S(!0)},e[4]=I):I=e[4];const D=I;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{S(!1),j("Update"),N("")},e[5]=L):L=e[5];const $=L;let R;e[6]!==r||e[7]!==m||e[8]!==p||e[9]!==i||e[10]!==n?(R=async()=>{const U=C.current?.value;if(!U){N("Please add new link file name");return}if(U===r.split("static/").pop()?.split(".")[0]){N("New link file name must be different from current link");return}if(!qg.test(U)){N("New link file name must only contain letters, numbers, underscores, and hyphens");return}j("Updating...");const B=`${Wo}/${U}.${p}`,oe=r.split(`${Ro}/`).pop();try{if(!oe){N("Unable to determine original blob name"),j("Update");return}const de=await Mg({newBlobName:B,originalBlobName:oe,_id:n._id});m(He({description:"Updated link",type:"success"})),$(),i({...n,...de})}catch(de){N(de?.message||"Error updating"),j("Update")}},e[6]=r,e[7]=m,e[8]=p,e[9]=i,e[10]=n,e[11]=R):R=e[11];const P=R;let k;e[12]!==m||e[13]!==a?(k=async U=>{v("Deleting...");try{const B=await Fg({gcsBlobName:U.gcsBlobName,_id:U._id});m(He({description:`${U.name} deleted`,type:"success"})),a(B)}catch(B){Ue({description:"Error deleting upload",error:B}),v("Delete")}},e[12]=m,e[13]=a,e[14]=k):k=e[14];const T=k,E=Ug;let O;e[15]!==r||e[16]!==c||e[17]!==l?(O=c&&c.includes("video")?(0,t.jsx)("video",{src:r,className:_t.image,muted:!0}
1):(0,t.jsx)("img",{src:r,alt:`${l} Preview`,className:_t.image}),e[15]=r,e[16]=c,e[17]=l,e[18]=O):O=e[18];let q;e[19]!==r||e[20]!==O?(q=(0,t.jsx)("div",{className:_t.imagePreview,children:(0,t.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:O})}),e[19]=r,e[20]=O,e[21]=q):q=e[21];let J;e[22]!==o||e[23]!==d?(J=()=>{o(E(d))},e[22]=o,e[23]=d,e[24]=J):J=e[24];let K;e[25]!==d?(K=E(d),e[25]=d,e[26]=K):K=e[26];let z;e[27]!==J||e[28]!==K?(z=(0,t.jsxs)("span",{className:_t.uploadAuthor,children:["Uploaded by"," ",(0,t.jsx)("span",{className:_t.authorButton,onClick:J,children:K})]}),e[27]=J,e[28]=K,e[29]=z):z=e[29];let Y;e[30]!==l||e[31]!==z?(Y=(0,t.jsxs)("div",{className:_t.uploadName,children:[l,z]}),e[30]=l,e[31]=z,e[32]=Y):Y=e[32];let me;e[33]!==r||e[34]!==x||e[35]!==p?(me=(0,t.jsx)("div",{className:_t.urlContainer,children:x?(0,t.jsxs)(t.Fragment,{children:[Ro,"/",Wo,"/",(0,t.jsx)("input",{ref:C}),".",p]}):(0,t.jsx)("span",{className:_t.cdnUrl,children:(0,t.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:r})})}),e[33]=r,e[34]=x,e[35]=p,e[36]=me):me=e[36];let X;e[37]!==y||e[38]!==x||e[39]!==A||e[40]!==u||e[41]!==P||e[42]!==b?(X=x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:_t.submitChangeLinkButton,onClick:P,children:b}),(0,t.jsx)("div",{className:_t.cancelChangeLinkButton,onClick:$,children:"Cancel"})]}),y&&(0,t.jsx)("div",{className:_t.changeLinkErrorMessage,children:y})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:_t.copyLinkButton,onClick:A,children:u}),(0,t.jsx)("div",{className:_t.changeLinkButton,onClick:D,children:"Update Link"})]}),e[37]=y,e[38]=x,e[39]=A,e[40]=u,e[41]=P,e[42]=b,e[43]=X):X=e[43];let te;e[44]!==Y||e[45]!==me||e[46]!==X?(te=(0,t.jsxs)("div",{className:_t.info,children:[Y,me,X]}),e[44]=Y,e[45]=me,e[46]=X,e[47]=te):te=e[47];let ae;e[48]!==T||e[49]!==n?(ae=()=>T(n),e[48]=T,e[49]=n,e[50]=ae):ae=e[50];let G;e[51]!==_||e[52]!==ae?(G=(0,t.jsx)("div",{children:(0,t.jsx)("span",{onClick:ae,className:_t.deleteText,children:_})}),e[51]=_,e[52]=ae,e[53]=G):G=e[53];let se;return e[54]!==te||e[55]!==G||e[56]!==q?(se=(0,t.jsxs)("div",{className:_t.listItem,children:[q,te,G]}),e[54]=te,e[55]=G,e[56]=q,e[57]=se):se=e[57],se},Hg=f.memo(Vg);function Ug(s){const{name:e,firstName:n,lastName:a}=s;return e||(n&&a?`${n} ${a}`:n||a||"")}const Zg="1001",Wg="1000",Kg="58px",Gg="UploadAdmin-module_container_WR7HD",Jg="UploadAdmin-module_header_GliBF",zg="UploadAdmin-module_headerText_AtC-U",Yg="UploadAdmin-module_description_n-nG9",Qg="UploadAdmin-module_content_ftRAi",Xg="UploadAdmin-module_uploader_VwiPR",ev="UploadAdmin-module_uploaderSettings_-69kh",tv="UploadAdmin-module_filePickerInput_yhqL5",sv="UploadAdmin-module_link_YXqRT",nv="UploadAdmin-module_listWrapper_zoYBK",av="UploadAdmin-module_listFlex_y4SF-",ov="UploadAdmin-module_listHeader_Y-sFq",iv="UploadAdmin-module_listButton_mGDJv",lv="UploadAdmin-module_loadButton_bLtLN";var bt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Zg,paywallBgZIndex:Wg,collapsedMediaSidebarWidth:Kg,container:Gg,header:Jg,headerText:zg,description:Yg,content:Qg,uploader:Xg,uploaderSettings:ev,filePickerInput:tv,link:sv,listWrapper:nv,listFlex:av,listHeader:ov,listButton:iv,loadButton:lv},rv=()=>{const s=tt(),e=(0,f.useRef)(null),[n,a]=(0,f.useState)(!0),[o,i]=(0,f.useState)(!1),[l,r]=(0,f.useState)(0),[d,c]=(0,f.useState)(0),[m,h]=(0,f.useState)("none"),[p,u]=(0,f.useState)([]),g=ys(C=>C.currentUser);(0,f.useEffect)(()=>{(async()=>{try{const y=await Dg({loadIndex:d,authorSearch:m});u(N=>{const w=N.reduce((I,D)=>I.add(D._id),new Set),A=y.filter(I=>!w.has(I._id));return[...N,...A]})}catch(y){console.error("Error fetching recent uploads:",y)}})()},[d,m]);const _=(0,f.useCallback)(async C=>{const y=new FormData;y.append("file",C),y.append("shouldConvertToWebp",JSON.stringify(n)),y.append("shouldUploadRemoveBg",JSON.stringify(o));const N=new XMLHttpRequest,w=await new Promise(A=>{N.upload.onprogress=I=>{I.lengthComputable&&r(Math.floor(I.loaded/I.total*100))},N.addEventListener("loadend",()=>{r(0),A(JSON.parse(N.responseText))}),o?N.open("POST","/api/v1/admin/uploadFileRemoveBg",!0):N.open("POST","/api/v1/admin/uploadStaticFile",!0),N.setRequestHeader("x-access-token",g.token),N.send(y)});if(w){const{cdnUrl:A}=w;navigator.clipboard.writeText(A),s(He({description:`Upload complete! ${A} copied to clipboard.`,type:"success"}))}return w},[s,n,o,g.token]),v=async C=>{const y=C.length,N=[];if(y>10){s(He({description:"Upload failed! Please do not upload more than 10 images at a time.",type:"error"}));return}for(let w=0;w<y;w+=1){const A=await _(C[w]);e&&e.current&&w===y-1&&(e.current.value=""),N.push(A)}u(w=>[...N,...w])};(0,f.useEffect)(()=>{const C=y=>{e.current.files=y.clipboardData.files;const N=y.clipboardData.files;N&&v(N)};return window.addEventListener("paste",C),()=>{window.removeEventListener("paste",C)}},[_]);const b=async C=>
1{if(C&&C.target&&C.target.files&&C.target.files.length){const y=C.target.files;await v(y)}},j=C=>{C!==m&&(u([]),h(C),c(0),window.scrollTo({top:0,left:0,behavior:"smooth"}))},x=C=>y=>{u(N=>{const w=[...N];return w[C]=y,w})},S=()=>p?(0,t.jsxs)("div",{className:bt.listWrapper,children:[(0,t.jsxs)("div",{className:bt.listFlex,children:[(0,t.jsxs)("div",{className:bt.listHeader,children:["Uploaded by"," ",(0,t.jsx)("span",{children:m==="none"?"Everyone":m})]}),(0,t.jsx)("button",{className:bt.listButton,onClick:()=>j("none"),type:"button",children:"Reset Uploader"})]}),(0,t.jsx)("div",{children:p.map((C,y)=>{const{_id:N}=C;return(0,t.jsx)(Hg,{upload:C,authorSearch:j,updateUploads:u,updateSelf:x(y)},N)})})]}):null;return(0,t.jsxs)("div",{className:bt.container,children:[(0,t.jsxs)("div",{className:bt.header,children:[(0,t.jsx)("div",{className:bt.headerText,children:"Welcome to the upload admin page!"}),(0,t.jsxs)("div",{className:bt.description,children:["Use this page to upload files to the"," ",(0,t.jsxs)("a",{href:"https://console.cloud.google.com/storage/browser/kapwing-useast1/static/?project=kapwing-prod",className:bt.link,target:"_blank",rel:"noreferrer",children:["static folder ",(0,t.jsx)(oo,{})]})," ","on Google Cloud. By default, images will be compressed and converted to webp. If you want to upload your original image, uncheck the checkbox. You can also press cmd+V and paste files into this window, they will be automatically uploaded."]})]}),(0,t.jsxs)("div",{className:bt.content,children:[(0,t.jsx)("div",{className:bt.uploader,children:(0,t.jsx)("input",{type:"file",multiple:!0,onChange:b,ref:e,className:bt.filePickerInput})}),(0,t.jsxs)("div",{className:bt.uploaderSettings,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{children:(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>{a(!n)}}),"Convert image uploads to webp"]})}),(0,t.jsx)("div",{children:(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:o,onChange:()=>{i(!o)}}),"Upload to remove background folder"]})})]}),(0,t.jsxs)("div",{children:["Progress: ",l,"%"]})]})]}),S(),(0,t.jsx)("div",{className:bt.uploader,children:(0,t.jsx)("button",{className:bt.loadButton,onClick:()=>c(C=>C+100),type:"button",children:"Load More"})})]})},dv=f.memo(rv);const cv="1001",uv="1000",mv="58px",pv="AdminView-module_warning_x68la";var hv={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:cv,paywallBgZIndex:uv,collapsedMediaSidebarWidth:mv,warning:pv},fv=Q(ie());const vo=f.memo(()=>{const s=(0,fv.c)(2);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("b",{children:"STOP! Are you sure you should be accessing this information?"}),s[0]=e):e=s[0];let n;return s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsxs)("div",{className:hv.warning,children:[e," This page should only be accessed for ",(0,t.jsx)("b",{children:"work-related"})," purposes, such as customer service and product improvements. Please treat the data of our users with caution and respect."]}),s[1]=n):n=s[1],n});const xv="1001",gv="1000",vv="58px",_v="RecentKaiChats-module_container_lk87F",jv="RecentKaiChats-module_header_WxEEj",bv="RecentKaiChats-module_teamFilterContainer_T-n7h",yv="RecentKaiChats-module_chatLink_Xc5oT",Sv="RecentKaiChats-module_chatTimestamp_bMDyn",Cv="RecentKaiChats-module_loadMoreButton_UPxo2";var an={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:xv,paywallBgZIndex:gv,collapsedMediaSidebarWidth:vv,container:_v,header:jv,teamFilterContainer:bv,chatLink:yv,chatTimestamp:Sv,loadMoreButton:Cv},Nv=Q(ie()),Zn=10,wv=s=>{const e=(0,Nv.c)(35),{userId:n}=s,[a,o]=(0,f.useState)(!0),[i,l]=(0,f.useState)(!1);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[0]=r):r=e[0];const[d,c]=(0,f.useState)(r),[m,h]=(0,f.useState)(!1),[p,u]=(0,f.useState)("");let g;e[1]!==n?(g=Ut.team.getUser.queryOptions({userId:n}),e[1]=n,e[2]=g):g=e[2];const{data:_,isLoading:v}=Gs(g),b=!!_?.length;let j,x;e[3]!==_?(j=function(){if(!_?.length){u("");return}const O=_[0];O&&u(O._id)},x=[_],e[3]=_,e[4]=j,e[5]=x):(j=e[4],x=e[5]),(0,f.useEffect)(j,x);let S;e:{if(!p){S=void 0;break e}S=p}const C=S;let y,N;e[6]!==C||e[7]!==n||e[8]!==_?(y=function(){(async function(){if(Array.isArray(_)&&!(_.length>0&&!C)){o(!0),h(!1);try{const{chats:q}
1=await Oo(n,0,C);c(q),q.length<Zn&&h(!0)}catch(q){console.error(q)}o(!1)}})()},N=[C,n,_],e[6]=C,e[7]=n,e[8]=_,e[9]=y,e[10]=N):(y=e[9],N=e[10]),(0,f.useEffect)(y,N);let w;e[11]!==d.length||e[12]!==C||e[13]!==n?(w=async()=>{l(!0);const E=Math.floor(d.length/Zn);try{const{chats:O}=await Oo(n,E,C);if(!O.length){h(!0),l(!1);return}c(q=>q.concat(O)),O.length<Zn&&h(!0)}catch(O){console.error(O)}l(!1)},e[11]=d.length,e[12]=C,e[13]=n,e[14]=w):w=e[14];const A=w;let I;e[15]!==m||e[16]!==A||e[17]!==i||e[18]!==d.length?(I=()=>m||d.length%Zn!==0?null:i?(0,t.jsx)(it,{}):(0,t.jsx)("button",{type:"button",onClick:A,className:an.loadMoreButton,children:"Load 10 more chats"}),e[15]=m,e[16]=A,e[17]=i,e[18]=d.length,e[19]=I):I=e[19];const D=I;let L;e[20]!==a||e[21]!==v||e[22]!==d||e[23]!==D?(L=()=>a||v?(0,t.jsx)(it,{text:"Fetching Kai chats..."}):d.length?(0,t.jsxs)(t.Fragment,{children:[d.map(Iv),D()]}):(0,t.jsx)("span",{children:"No Kai chats found."}),e[20]=a,e[21]=v,e[22]=d,e[23]=D,e[24]=L):L=e[24];const $=L;let R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=(0,t.jsx)("div",{className:an.header,children:"Recent Kai Chats"}),e[25]=R):R=e[25];let P;e[26]!==b||e[27]!==p||e[28]!==_?(P=b&&(0,t.jsxs)("div",{className:an.teamFilterContainer,children:[(0,t.jsx)("label",{htmlFor:"kai-team-filter",children:"Workspace:"}),(0,t.jsx)("select",{id:"kai-team-filter",value:p,onChange:E=>u(E.target.value),children:_?.map(Tv)})]}),e[26]=b,e[27]=p,e[28]=_,e[29]=P):P=e[29];let k;e[30]!==$?(k=$(),e[30]=$,e[31]=k):k=e[31];let T;return e[32]!==P||e[33]!==k?(T=(0,t.jsxs)("div",{className:an.container,children:[R,P,k]}),e[32]=P,e[33]=k,e[34]=T):T=e[34],T},Av=f.memo(wv);function Iv(s){return(0,t.jsxs)("a",{href:`/kai/chat/${s._id}`,target:"_blank",rel:"noopener noreferrer",className:an.chatLink,children:[(0,t.jsx)("span",{children:s.name||"Untitled chat"}),(0,t.jsx)("span",{className:an.chatTimestamp,children:new Date(s.updatedAt).toLocaleString()})]},s._id)}function Tv(s){return(0,t.jsx)("option",{value:s._id,children:s.name},s._id)}const kv="1001",Rv="1000",$v="58px",Pv="AccountDropdown-module_home_WLi5A",Ev="AccountDropdown-module_homeHowBackgroundWhite_TC4T9",Lv="AccountDropdown-module_largeButton_FpKSn",Bv="AccountDropdown-module_sectionContent_MX5qq",Dv="AccountDropdown-module_sectionHeader_JGjlQ",Mv="AccountDropdown-module_spacer_fB5wB",Fv="AccountDropdown-module_chevron_zx5qL",Ov="AccountDropdown-module_splashText_Pv-yD",qv="AccountDropdown-module_splashSubtext_ipF96",Vv="AccountDropdown-module_aboutSection_l0Q4y",Hv="AccountDropdown-module_mobile_QF975",Uv="AccountDropdown-module_desktop_l4Qwu",Zv="AccountDropdown-module_screenReaderOnlyLabel_FWJUS",Wv="AccountDropdown-module_disabled_ccBaV",Kv="AccountDropdown-module_disabledWithPointerEvents_-Lq5R",Gv="AccountDropdown-module_noScrollBar_n3VvC",Jv="AccountDropdown-module_textOverflowEllipsis_KPzdW",zv="AccountDropdown-module_disableTextHighlight_HrdGT",Yv="AccountDropdown-module_genericButtonBlue_4du3b",Qv="AccountDropdown-module_rmButtonUserAgentStyles_i6PNd",Xv="AccountDropdown-module_dropdownContainer_rKL23",e_="AccountDropdown-module_item_xTiqu";var _n={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:kv,paywallBgZIndex:Rv,collapsedMediaSidebarWidth:$v,home:Pv,homeHowBackgroundWhite:Ev,largeButton:Lv,sectionContent:Bv,sectionHeader:Dv,spacer:Mv,chevron:Fv,splashText:Ov,splashSubtext:qv,aboutSection:Vv,mobile:Hv,desktop:Uv,screenReaderOnlyLabel:Zv,disabled:Wv,disabledWithPointerEvents:Kv,noScrollBar:Gv,textOverflowEllipsis:Jv,disableTextHighlight:zv,genericButtonBlue:Yv,rmButtonUserAgentStyles:Qv,dropdownContainer:Xv,item:e_},t_=Q(ie()),s_=s=>{const e=(0,t_.c)(37),{hideDropdown:n,navigate:a,selectName:o,video:i}=s,l=(0,f.useRef)(null);let r;e[0]!==n||e[1]!==i?(r=D=>{const{target:L}=D,{id:$,parentElement:R}=L||{},{id:P}=R||{},{_id:k}=i;l.current&&l.current.contains(L)||[$,P].includes(`dropdown-button-${k}`)||n()},e[0]=n,e[1]=i,e[2]=r):r=e[2];const d=r;let c,m;e[3]!==d?(c=()=>(document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}),m=[d],e[3]=d,e[4]=c,e[5]=m):(c=e[4],m=e[5]),(0,f.useEffect)(c,m);let h;if(e[6]!==a||e[7]!==i){h=()=>{const{_id:L}=i;D(L)};const D=L=>{a(`/${L}/studio/editor`)};e[6]=a,e[7]=i,e[8]=h}else h=e[8];let p;e[9]!==n||e[10]!==o?(p=D=>{n(),o(D)},e[9]=n,e[10]=o,e[11]=p):p=e[11];const u=p;let g;e[12]!==i._id||e[13]!==i.workspaceId?(g=()=>{Oc({videoIdsWithFolderId:[{videoId:i._id,folderId:i.workspaceId}],workflowIds:[]})},e[12]=i._id,e[13]=i.workspaceId,e[14]=g):g=e[14];const _=g;let v;e[15]!==i?(v=Lo(i,"fullPath"),e[15]=i,e[16]=v):v=e[16];let b;e[17]!==i?(b=Lo(i,"fullPath"),e[17]=i,e[18]=b):b=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(br,{}),e[19]=j):j=e[19];let x;e[20]!==v||e[21]!==b?(x=(0,t.jsxs)("a",{className:_n.item,href:v,download:b,children:[j," Download"]}),e[20]=v,e[21]=b,e[22]=x):x=e[22];let S;e[23]===Symbol.for("react.memo_cache_sentinel")?(S=(0,t.jsx)(yr,{}),e[23]=S):S=e[23];let C;e[24]!==u?(C=(0,t.jsxs)("div",{className:_n.item,onClick:u,children:[S," Rename"]}),e[24]=u,e[25]=C):C=e[25];let y;e[26]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsx)($r,{}),e[26]=y):y=e[26];let N;e[27]!==h?(N=(0,t.jsxs)("div",{className:_n.item,onClick:h,children:[y," Edit"]}),e[27]=h,e[28]=N):N=e[28];let w;e[29]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)(Ur,{}),e[29]=w):w=e[29];let A;e[30]!==_?(A=(0,t.jsxs)("div",{className:_n.item,onClick:_,children:[w," Delete"]}),e[30]=_,e[31]=A):A=e[31];let I;return e[32]!==C||e[33]!==N||e[34]!==A||e[35]!==x?(I=(0,t.jsxs)("div",{className:_n.dropdownContainer,ref:l,children:[x,C,N,A]}),e[32]=C,e[33]=N,e[34]=A,e[35]=x,e[36]=I):I=e[36],I},n_=f.memo(Qs(s_));const a_="1001",o_="1000",i_="58px",l_="AccountVideoElement-module_home_
1CGw9O",r_="AccountVideoElement-module_homeHowBackgroundWhite_SHVAn",d_="AccountVideoElement-module_largeButton_LXpG4",c_="AccountVideoElement-module_sectionContent_FiByv",u_="AccountVideoElement-module_sectionHeader_9tIjM",m_="AccountVideoElement-module_spacer_2z72E",p_="AccountVideoElement-module_chevron_EEbp5",h_="AccountVideoElement-module_splashText_havJm",f_="AccountVideoElement-module_splashSubtext_7fOyc",x_="AccountVideoElement-module_aboutSection_kBfH-",g_="AccountVideoElement-module_mobile_TDl42",v_="AccountVideoElement-module_desktop_ekn9L",__="AccountVideoElement-module_screenReaderOnlyLabel_nBKr2",j_="AccountVideoElement-module_disabled_-gUGT",b_="AccountVideoElement-module_disabledWithPointerEvents_HTxts",y_="AccountVideoElement-module_noScrollBar_lwNUD",S_="AccountVideoElement-module_textOverflowEllipsis_O1g3-",C_="AccountVideoElement-module_disableTextHighlight_KSwdx",N_="AccountVideoElement-module_genericButtonBlue_TKURU",w_="AccountVideoElement-module_rmButtonUserAgentStyles_aeg4z",A_="AccountVideoElement-module_imageContainer_MC4vO",I_="AccountVideoElement-module_image_wCOpZ",T_="AccountVideoElement-module_placeholder_f8Fgd",k_="AccountVideoElement-module_placeholderIcon_dL5sJ",R_="AccountVideoElement-module_date_gyWl9",$_="AccountVideoElement-module_container_214cz",P_="AccountVideoElement-module_type_LIJfk",E_="AccountVideoElement-module_draft_nz8BK",L_="AccountVideoElement-module_typeInput_z3cm0",B_="AccountVideoElement-module_draftInput_8TXD5",D_="AccountVideoElement-module_more_d7w0h";
1var It={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:a_,paywallBgZIndex:o_,collapsedMediaSidebarWidth:i_,home:l_,homeHowBackgroundWhite:r_,largeButton:d_,sectionContent:c_,sectionHeader:u_,spacer:m_,chevron:p_,splashText:h_,splashSubtext:f_,aboutSection:x_,mobile:g_,desktop:v_,screenReaderOnlyLabel:__,disabled:j_,disabledWithPointerEvents:b_,noScrollBar:y_,textOverflowEllipsis:S_,disableTextHighlight:C_,genericButtonBlue:N_,rmButtonUserAgentStyles:w_,imageContainer:A_,image:I_,placeholder:T_,placeholderIcon:k_,date:R_,container:$_,type:P_,draft:E_,typeInput:L_,draftInput:B_,more:D_},M_=Q(ie()),F_=s=>{const e=(0,M_.c)(65),{video:n}=s,[a,o]=(0,f.useState)(!1),[i,l]=(0,f.useState)(!1);let r;e[0]!==n?(r=()=>n.draft?n.name||"Untitled Project":n.name||jc(n),e[0]=n,e[1]=r):r=e[1];const d=r,[c,m]=(0,f.useState)(d);let h;e[2]!==d||e[3]!==c||e[4]!==i?(h=()=>c.trim()||i?c:d(),e[2]=d,e[3]=c,e[4]=i,e[5]=h):h=e[5];const p=h;let u,g,_,v,b;if(e[6]!==c||e[7]!==n._id||e[8]!==n.draft){_=G=>{G.keyCode===13&&b()};let X;e[14]!==n._id||e[15]!==n.draft?(X=()=>n.draft?`/${n._id}/studio/editor`:`/videos/${n._id}`,e[14]=n._id,e[15]=n.draft,e[16]=X):X=e[16],u=X;let te;e[17]===Symbol.for("react.memo_cache_sentinel")?(te=G=>{m(G.target.value)},e[17]=te):te=e[17],g=te;let ae;e[18]===Symbol.for("react.memo_cache_sentinel")?(ae=G=>{G.stopPropagation(),l(!0)},e[18]=ae):ae=e[18],v=ae,b=()=>{l(!1);const G=c.trim();G!==""&&(H.video.updateName.mutate({name:G,videoId:n._id}),m(G))},e[6]=c,e[7]=n._id,e[8]=n.draft,e[9]=u,e[10]=g,e[11]=_,e[12]=v,e[13]=b}else u=e[9],g=e[10],_=e[11],v=e[12],b=e[13];let j;e[19]!==b?(j=()=>{b()},e[19]=b,e[20]=j):j=e[20];const x=j;let S;e[21]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{o(!1)},e[21]=S):S=e[21];const C=S;let y;e[22]!==a?(y=()=>{o(!a)},e[22]=a,e[23]=y):y=e[23];const N=y;let w;e[24]!==n.fullPath||e[25]!==n.image_url?(w=()=>n.fullPath&&n.fullPath.length>4&&n.fullPath.endsWith(".mp3")?(0,t.jsx)("div",{className:It.placeholder,children:(0,t.jsx)(Lr,{className:It.placeholderIcon})}):n.image_url?(0,t.jsx)("img",{className:It.image,src:n.image_url,alt:"Content preview"}):(0,t.jsx)("div",{className:It.placeholder,children:(0,t.jsx)(Jr,{className:It.placeholderIcon})}),e[24]=n.fullPath,e[25]=n.image_url,e[26]=w):w=e[26];const A=w;let I;e[27]!==p||e[28]!==g||e[29]!==_||e[30]!==i||e[31]!==v||e[32]!==b||e[33]!==n.draft?(I=()=>{const X=n.draft?It.draft:It.type,te=n.draft?It.draftInput:It.typeInput,ae=p();return i?(0,t.jsx)("input",{type:"text",id:"nameInput",className:te,value:ae,onClick:v,onBlur:b,onChange:g,autoF
1ocus:!0,onKeyUp:_}):(0,t.jsx)("div",{className:X,onClick:v,children:ae})},e[27]=p,e[28]=g,e[29]=_,e[30]=i,e[31]=v,e[32]=b,e[33]=n.draft,e[34]=I):I=e[34];const D=I;let L;e[35]!==n.submittedAt?(L=il(n.submittedAt),e[35]=n.submittedAt,e[36]=L):L=e[36];const $=L,R=u();let P;e[37]!==A?(P=(0,t.jsx)("div",{className:It.imageContainer,children:A()}),e[37]=A,e[38]=P):P=e[38];let k;e[39]!==P||e[40]!==R?(k=(0,t.jsx)(be,{to:R,children:P}),e[39]=P,e[40]=R,e[41]=k):k=e[41];let T;e[42]!==D?(T=D(),e[42]=D,e[43]=T):T=e[43];const E=n.draft?"Saved":"Published";let O;e[44]!==E?(O=(0,t.jsx)("span",{children:E}),e[44]=E,e[45]=O):O=e[45];let q;e[46]!==O||e[47]!==$?(q=(0,t.jsxs)("div",{className:It.date,children:[O," ",$," ","ago"]}),e[46]=O,e[47]=$,e[48]=q):q=e[48];const J=`dropdown-button-${n._id}`;let K;e[49]!==J?(K=(0,t.jsx)(Pr,{id:J,size:22}),e[49]=J,e[50]=K):K=e[50];let z;e[51]!==K||e[52]!==N?(z=(0,t.jsx)("div",{className:It.more,onClick:N,children:K}),e[51]=K,e[52]=N,e[53]=z):z=e[53];let Y;e[54]!==v||e[55]!==a||e[56]!==n?(Y=a&&(0,t.jsx)(n_,{hideDropdown:C,selectName:v,video:n}),e[54]=v,e[55]=a,e[56]=n,e[57]=Y):Y=e[57];let me;return e[58]!==x||e[59]!==k||e[60]!==T||e[61]!==q||e[62]!==z||e[63]!==Y?(me=(0,t.jsxs)("div",{className:It.container,onClick:x,children:[k,T,q,z,Y]}),e[58]=x,e[59]=k,e[60]=T,e[61]=q,e[62]=z,e[63]=Y,e[64]=me):me=e[64],me},O_=f.memo(F_);const q_="UserContent-module_contentContainer_rGyEA",V_="UserContent-module_header_81xYm";var Ko={contentContainer:q_,header:V_},H_=Q(ie()),Go=50,U_=s=>{const e=(0,H_.c)(16),{user:n}=s,[a,o]=(0,f.useState)(!0),[i,l]=(0,f.useState)(!1);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[0]=r):r=e[0];const[d,c]=(0,f.useState)(r),[m,h]=(0,f.useState)(!1);let p,u;e[1]!==n.email?(p=()=>{(async()=>{o(!0);try{c(await Mo(n.email))}catch(x){console.error(x)}o(!1)})()},u=[n.email],e[1]=n.email,e[2]=p,e[3]=u):(p=e[2],u=e[3]),(0,f.useEffect)(p,u);let g;e[4]!==d||e[5]!==n.email?(g=async()=>{l(!0);const x=Math.floor(d.length/Go);try{const S=await Mo(n.email,x);if(!S.length)return h(!0);c(d.concat(S))}catch(S){console.error(S)}return l(!1)},e[4]=d,e[5]=n.email,e[6]=g):g=e[6];const _=g;let v;e[7]!==d.length||e[8]!==m||e[9]!==_||e[10]!==i?(v=()=>d.length%Go!==0||m?null:i?(0,t.jsx)(it,{}):(0,t.jsx)("div",{className:"primary-button account-load-more",onClick:_,children:"Load more videos"}),e[7]=d.length,e[8]=m,e[9]=_,e[10]=i,e[11]=v):v=e[11];const b=v;let j;return e[12]!==d||e[13]!==a||e[14]!==b?(j=a?(0,t.jsx)(it,{text:"Fetching content..."}):(0,t.jsxs)("div",{className:Ko.contentContainer,children:[(0,t.jsx)("div",{className:Ko.header,children:"Showing all media:"}),d&&d.length?(0,t.jsxs)(t.Fragment,{children:[d.map(W_),b()]}):(0,t.jsx)("span",{children:"No content found!"})]}),e[12]=d,e[13]=a,e[14]=b,e[15]=j):j=e[15],j},Z_=f.memo(U_);function W_(s){return(0,t.jsx)(O_,{video:s},s._id)}const K_="1001",G_="1000",J_="58px",z_="paywall-module_freePlanContainer_SAxEC",Y_="paywall-module_basicPlanContainer_NN9b7",Q_="paywall-module_proPlanContainer_wmchD",X_="paywall-module_teamPlanContainer_eB1Nd",e1="paywall-module_eduPlanContainer_73y47",t1="paywall-module_businessPlanContainer_7FZhd",s1="paywall-module_enterprisePlanContainer_ZE411",n1="paywall-module_freeBackgroun
1d_HP0Dv",a1="paywall-module_basicBackground_m6DuW",o1="paywall-module_proBackground_5MmL-",i1="paywall-module_teamBackground_Wrgpc",l1="paywall-module_eduBackground_r5-j5";var r1={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:K_,paywallBgZIndex:G_,collapsedMediaSidebarWidth:J_,freePlanContainer:z_,basicPlanContainer:Y_,proPlanContainer:Q_,teamPlanContainer:X_,eduPlanContainer:e1,businessPlanContainer:t1,enterprisePlanContainer:s1,freeBackground:n1,basicBackground:a1,proBackground:o1,teamBackground:i1,eduBackground:l1};const d1="1001",c1="1000",u1="58px",m1="PlanPill-module_pillWrapper_y5VQM",p1="PlanPill-module_planPillWrapper_hO-GE";var Jo={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:d1,paywallBgZIndex:c1,collapsedMediaSidebarWidth:u1,pillWrapper:m1,planPillWrapper:p1},h1=Q(ie()),f1=s=>{const e=(0,h1.c)(8),{overrideTeam:n,overridePlan:a}=s;let o=Hd();n&&(o=nl(n)),a&&(o=po(a));let i;e[0]!==o.isEdu||e[1]!==o.name?(i=()=>o.isEdu?"Edu Plan":`${o.name} Plan`,e[0]=o.isEdu,e[1]=o.name,e[2]=i):i=e[2];const l=i,r=r1[`${o.type}PlanContainer`];let d;e[3]!==r?(d=[Jo.planPillWrapper,r],e[3]=r,e[4]=d):d=e[4];const c=d.join(" "),m=l();let h;return e[5]!==c||e[6]!==m?(h=(0,t.jsx)("div",{className:Jo.pillWrapper,children:(0,t.jsx)("div",{className:c,children:m})}),e[5]=c,e[6]=m,e[7]=h):h=e[7],h},_o=f.memo(f1);const x1="1001",g1="1000",v1="58px",_1="ViewUser-module_container_D3kwj",j1="ViewUser-module_warning_qWn-C",b1="ViewUser-module_header_yc3OP",y1="ViewUser-module_subheader_B9tiH",S1="ViewUser-module_section_vTmIw",C1="ViewUser-module_sectionHeader_j9txp",N1="ViewUser-module_link_ahBA-",w1="ViewUser-module_userTeamContainer_fxT7-",A1="ViewUser-module_totalUsers_8S1kh",I1="ViewUser-module_teamPlans_T6t2K",T1="ViewUser-module_spacer_aV6zu",k1="ViewUser-module_planSide_NEggH";var ls={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:x1,paywallBgZIndex:g1,collapsedMediaSidebarWidth:v1,container:_1,warning:j1,header:b1,subheader:y1,section:S1,sectionHeader:C1,link:N1,userTeamContainer:w1,totalUsers:A1,teamPlans:I1,spacer:T1,planSide:k1},R1=Q(ie());const Cl=f.memo(s=>{const e=(0,R1.c)(17),{team:n,numberOfUsers:a,renderPill:o}=s,i=o===void 0?!0:o,l=`/admin/team/${n._id}`;let r;e[0]!==l||e[1]!==n.name?(r=(0,t.jsx)(be,{to:l,children:n.name}),e[0]=l,e[1]=n.name,e[2]=r):r=e[2];const d=a??n.users.length,c=a??n.users.length;let m;e[3]!==c?(m=Dd("User","Users",c),e[3]=c,e[4]=m):m=e[4];let h;e[5]!==d||e[6]!==m?(h=(0,t.jsxs)("span",{className:ls.totalUsers,children:[d," Total"," ",m]}),e[5]=d,e[6]=m,e[7]=h):h=e[7];let p;e[8]!==r||e[9]!==h?(p=(0,t.jsxs)("div",{children:[r,h]}),e[8]=r,e[9]=h,e[10]=p):p=e[10];let u;e[11]!==i||e[12]!==n?(u=i&&(0,t.jsxs)("div",{className:ls.planSide,children:[n.stripeId&&(0,t.jsx)("div",{className:ls.spacer,children:(0,t.jsx)("a",{href:`https://dashboard.stripe.com/customers/${n.stripeId}`,children:n.stripeId})}),(0,t.jsx)("div",{className:ls.spacer,children:(0,t.jsx)(_o,{overrideTeam:n})})]}),e[11]=i,e[12]=n,e[13]=u):u=e[13];let g;return e[14]!==p||e[15]!==u?(g=(0,t.jsxs)("div",{className:ls.userTeamContainer,children:[p,u]}),e[14]=p,e[15]=u,e[16]=g):g=e[16],g});const $1="1001",P1="1000",E1="58px",L1="MoreUserDetails-module_container_ZSJhk",B1="MoreUserDetails-module_itemContainer_WqUt-",D1="MoreUserDetails-module_header_LRoRE",M1="MoreUserDetails-module_red_nBOHg",F1="MoreUserDetails-module_teamsContainer_q6sR2",O1="MoreUserDetails-module_link_Qn1pq";var Aa={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:$1,paywallBgZIndex:P1,collapsedMediaSidebarWidth:E1,container:L1,itemContainer:B1,header:D1,red:M1,teamsContainer:F1,link:O1},q1=Q(ie()),V1=s=>{const e=(0,q1.c)(22),{user:n}=s,[a,o]=(0,f.useState)();let i;e[0]!==n._id?(i=Ut.team.getUser.queryOptions({userId:n._id}),e[0]=n._id,e[1]=i):i=e[1];const{data:l}=Gs(i);let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=function(){(async()=>{o(await H.team.suggested.query({emailDomain:void 0}))})()},e[2]=r):r=e[2];let d;e[3]!==n._id?(d=[n._id],e[3]=n._id,e[4]=d):d=e[4],(0,f.useEffect)(r,d);let c;e[5]!==l?(c=()=>l&&l.map(U1),e[5]=l,e[6]=c):c=e[6];const m=c;let h;e[7]!==a?(h=()=>!a||!a.teams||!a.teams.length?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:Aa.header,children:"Suggested Workspaces"}),a?.teams.map(Z1)]}),e[7]=a,e[8]=h):h=e[8];const p=h;let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)("span",{className:Aa.header,children:"Worksp
1aces"}),e[9]=u):u=e[9];let g;e[10]!==m?(g=m(),e[10]=m,e[11]=g):g=e[11];let _;e[12]!==g?(_=(0,t.jsx)("div",{children:g}),e[12]=g,e[13]=_):_=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("br",{}),e[14]=v):v=e[14];let b;e[15]!==p?(b=p(),e[15]=p,e[16]=b):b=e[16];let j;e[17]!==b?(j=(0,t.jsx)("div",{children:b}),e[17]=b,e[18]=j):j=e[18];let x;return e[19]!==j||e[20]!==_?(x=(0,t.jsxs)("div",{className:Aa.teamsContainer,children:[u,_,v,j]}),e[19]=j,e[20]=_,e[21]=x):x=e[21],x},H1=f.memo(V1);function U1(s){return(0,t.jsx)(Cl,{team:s},s._id)}function Z1(s){return(0,t.jsx)(Cl,{team:s,numberOfUsers:s.numberOfUsers,renderPill:!1},s._id)}const W1="1001",K1="1000",G1="58px",J1="UserDetails-module_picture_pDW-8",z1="UserDetails-module_container_GQHZf",Y1="UserDetails-module_infoContainer_jevjo",Q1="UserDetails-module_row_DYAxf",X1="UserDetails-module_header_wb7Il",ej="UserDetails-module_subscriber_0y4RI",tj="UserDetails-module_free_Nc5Ka",sj="UserDetails-module_dropdown_dqphY",nj="UserDetails-module_userTypeForm_Ul-Rj",aj="UserDetails-module_userTypeSubmit_PRPnR",oj="UserDetails-module_content_p-99r",ij="UserDetails-module_contentRow_dro5s",lj="UserDetails-module_userIdLink_UgIJq",rj="UserDetails-module_actionsContainer_h8x-W",dj="UserDetails-module_button_QF86f",cj="UserDetails-module_deleteButton_fHi-Q",uj="UserDetails-module_select_ieQw6",mj="UserDetails-module_planContainer_Fiurq",pj="UserDetails-module_pro_A3eWI",hj="UserDetails-module_team_dAlgF",fj="UserDetails-module_basic_hFqEr",xj="UserDetails-module_textInfo_MoTRp",gj="UserDetails-module_verifyEduContainer_-J-PR",vj="UserDetails-module_eduButton_Z71BV",_j="UserDetails-module_stripeWrapper_vXz7w",jj="UserDetails-module_stripeContainer_JLgja",bj="UserDetails-module_deleteStripe_zXgEK",yj="UserDetails-module_nameContainer_DhT1r",Sj="UserDetails-module_leftSection_HJvdq",Cj="UserDetails-module_rightSection_fRTYK";var Je={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:W1,paywallBgZIndex:K1,collapsedMediaSidebarWidth:G1,picture:J1,container:z1,infoContainer:Y1,row:Q1,header:X1,subscriber:ej,free:tj,dropdown:sj,userTypeForm:nj,userTypeSubmit:aj,content:oj,contentRow:ij,userIdLink:lj,actionsContainer:rj,button:dj,deleteButton:cj,select:uj,planContainer:mj,pro:pj,team:hj,basic:fj,textInfo:xj,verifyEduContainer:gj,eduButton:vj,stripeWrapper:_j,stripeContainer:jj,deleteStripe:bj,nameContainer:yj,leftSection:Sj,rightSection:Cj},Nj=Q(ie()),wj=s=>{const e=(0,Nj.c)(41),{refreshUser:n,user:a}=s,o=tt(),[i,l]=(0,f.useState)(!1);let r;e[0]!==a._id?(r=async()=>{await tu(a._id)},e[0]=a._id,e[1]=r):r=e[1];const d=r;let c;e[2]!==n||e[3]!==a._id||e[4]!==a.email||e[5]!==a.name?(c=()=>{oc({modalType:tc.ADMIN_DELETE_USER,userId:a._id,userEmail:a.email,userName:a.name,onDeleted:n})},e[2]=n,e[3]=a._id,e[4]=a.email,e[5]=a.name,e[6]=c):c=e[6];const m=c,h=async E=>{if(l(!0),E.preventDefault(),C===a.accountType){o(He({description:`The user accountType is already set to: ${C}`,type:"warning"})),l(!1);return}try{await yu(a._id,C),await n(),o(He({description:`User accountType changed successfully to ${C}`,type:"success"})),l(!1)}catch(O){const q=O;l(!1),Ue({description:"An error occurred while changing user accountType",error:q})}};let p;e[7]!==o||e[8]!==a.email?(p=async()=>{if(window.confirm(`This will send an EDU verification email to ${a.email}. Even if you've already sent one, a new one will be sent. Are you sure you want to continue?`))try{await H.admin.edu.sendVerificationEmail.mutate({email:a.email}),o(He({description:"Email successfully sent",type:"success"}))}catch(E){Ue({description:"An error occurred while trying to send email",error:E})}},e[7]=o,e[8]=a.email,e[9]=p):p=e[9];const u=p,{name:g,firstName:_,lastName:v,accountType:b}=a,j="https://app.amplitude.com/analytics/kapwing/users?search="+encodeURIComponent(a._id)+"&property=user_id&searchType=search",[x,S]=(0,f.useState)(b||ko.free),C=x;let y;e[10]!==a?(y=()=>(0,t.jsx)(jl,{user:a,className:Je.picture}),e[10]=a,e[11]=y):y=e[11];const N=y;let w;e[12]!==h||e[13]!==_||e[14]!==d||e[15]!==v||e[16]!==i||e[17]!==g||e[18]!==C||e[19]!==m||e[20]!==N||e[21]!==u||e[22]!==S?(w=()=>(0,t.jsxs)("div",{className:Je.row,children:[N(),(0,t.jsxs)("div",{className:Je.nameContainer,children:[(0,t.jsx)("div",{className:Je.header,children:g||`${_} ${v}`}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",onClick:d,className:Je.button,children:"Act As This User"})}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",onClick:m,className:`${Je.button} ${Je.deleteButton}`,children:"Delete Account"})}),(0,t.jsx)("div",{className:Je.verifyEduContainer,children:(0,t.jsx)("button",{type:"button",className:Je.eduButton,onClick:()=>
1u(),children:"Send EDU Verification Email"})})]}),(0,t.jsx)("div",{className:Je.actionsContainer,children:(0,t.jsx)("div",{className:Je.dropdown,children:(0,t.jsxs)("form",{onSubmit:E=>h(E),className:Je.userTypeForm,children:[(0,t.jsx)("label",{htmlFor:"type",children:"Set role to: Â "}),(0,t.jsx)("select",{id:"type",name:"type",defaultValue:C,onChange:E=>S(E.target.value),className:Je.select,children:Object.entries(ko).map(Ij)}),"Â Â ",i?(0,t.jsx)("input",{type:"submit",value:"Submitting...",disabled:!0,className:`${Je.userTypeSubmit} ${Je.button}`}):(0,t.jsx)("input",{type:"submit",className:`${Je.userTypeSubmit} ${Je.button}`})]})})})]}),e[12]=h,e[13]=_,e[14]=d,e[15]=v,e[16]=i,e[17]=g,e[18]=C,e[19]=m,e[20]=N,e[21]=u,e[22]=S,e[23]=w):w=e[23];const A=w;let I;e[24]!==a?(I=()=>{const{onboarding:E}=a;if(E&&E.survey){const{date:O,occupation:q,usage:J,projectUsage:K}=E.survey;return(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"Onboarding survey:"})," ",(0,t.jsxs)("div",{children:[O?new Date(O).toDateString():null," â ",J," â"," ",(0,t.jsx)("span",{children:q}),(0,t.jsx)("div",{children:K})]})]})}return null},e[24]=a,e[25]=I):I=e[25];const D=I;let L;e[26]!==j||e[27]!==D||e[28]!==a?(L=()=>{const{lastSignIn:E,onboarding:O}=a;return(0,t.jsxs)("div",{className:Je.infoContainer,children:[(0,t.jsx)("div",{className:Je.leftSection,children:(0,t.jsxs)("div",{className:Je.content,children:[(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"Email:"})," ",a.email," "]}),(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"User ID:"})," ",(0,t.jsx)("a",{href:j,target:"_blank",rel:"noopener noreferrer",className:Je.userIdLink,children:a._id})]}),(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"Name:"})," ",a.name," "]}),(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"Country:"})," ",a.country," "]}),!!a.createdAt&&(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"Created:"})," ",ot(a.createdAt).format("ddd, MMM DD, YYYY, h:mm a")]}),!!a.lastUpdated&&(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"Last updated:"})," ",ot(a.lastUpdated).format("ddd, MMM DD, YYYY, h:mm a")]})]})}),(0,t.jsx)("div",{className:Je.rightSection,children:(0,t.jsxs)("div",{className:Je.container,children:[(0,t.jsxs)("div",{className:Je.contentRow,children:[(0,t.jsx)("strong",{children:"Last signed in:"})," ",(0,t.jsx)("span",{children:new Date(E).toDateString()})]}),O?D():null]})})]})},e[26]=j,e[27]=D,e[28]=a,e[29]=L):L=e[29];const $=L;let R;e[30]!==A?(R=A(),e[30]=A,e[31]=R):R=e[31];let P;e[32]!==$?(P=$(),e[32]=$,e[33]=P):P=e[33];let k;e[34]!==n||e[35]!==a?(k=(0,t.jsx)(H1,{user:a,refetchUser:n}),e[34]=n,e[35]=a,e[36]=k):k=e[36];let T;return e[37]!==R||e[38]!==P||e[39]!==k?(T=(0,t.jsxs)("div",{className:Je.container,children:[R,P,k]}),e[37]=R,e[38]=P,e[39]=k,e[40]=T):T=e[40],T},Aj=f.memo(wj);function Ij(s){const[e,n]=s;return(0,t.jsxs)("option",{value:n,children:[tl(e)," (",n,")"]},n)}var Tj=({match:{params:{identifier:s}}})=>{const[e,n]=(0,f.useState)({loading:!0}),a=(0,f.useMemo)(()=>s.includes("@")?{type:"email",value:s}:{type:"id",value:s},[s]),o=(0,f.useCallback)(async()=>{try{n({loading:!1,user:await(a.type==="email"?Dc(a.value):Uc(a.value))})}catch(l){l instanceof Error?(console.error(l.message),n({loading:!1,error:l})):console.error(l)}},[a]);(0,f.useEffect)(()=>{o()},[o]);const i=()=>e.loading?(0,t.jsx)(it,{text:"Looking up user..."}):e.error?(0,t.jsx)("div",{className:ls.header,children:e.error.message}):e.user?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Aj,{user:e.user,refreshUser:o}),(0,t.jsx)(Av,{userId:e.user._id}),(0,t.jsx)(Z_,{user:e.user})]}):(0,t.jsxs)("div",{className:ls.header,children:["No user found matching ",a.type,": ",(0,t.jsx)("b",{children:a.value}),". Please try again!",(0,t.jsxs)("div",{children:["Did you mean to access a team?"," ",(0,t.jsx)("span",{className:ls.link,onClick:()=>Vd().push(`/admin/team/${a.value}`),children:"Visit Team Page."})]})]});return(0,t.jsxs)("div",{className:ls.container,children:[(0,t.jsx)(vo,{}),i()]})},kj=f.memo(Qs(Tj)),Rj=Q(ie());function $j(){const s=(0,Rj.c)(7);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[1,2,3],s[0]=e):e=s[0];const n=e,[a,o]=(0,f.useState)(0);let i,l;s[1]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const h=setInterval(()=>{o(Ej)},1e3);return()=>clearInterval(h)},l=[],s[1]=i,s[2]=l):(i=s[1],l=s[2]),(0,f.useEffect)(i,l);let r;s[3]===Symbol.for("react.memo_cache_sentinel")?(r=n.map(Pj),s[3]=r):r=s[3];const d=r;let c;s[4]===Symbol.for("react.memo_cache_sentinel")?(c={padding:"100px"},s[4]=c):c=s[4];let m;return s[5]!==a?(m=(0,t.jsxs)("div",{style:c,children:['If you are seeing "running expensiveValue" in the console once per second, then the react compiler has not been run on this component.',(0,t.jsxs)("div",{children:[d.length," ",a]})]}),s[5]=a,s[6]=m):m=s[6],m}function Pj(s){return console.info("running expensiveValue"),s*2}function Ej(s){return s+1}const Lj="1001",Bj="1000",Dj="58px",Mj="AdminTools-module_container_Rk0bL",Fj="AdminTools-module_header_PfhnB",Oj="AdminTools-module_eyebrow_IqdKC",qj="AdminTools-module_title_uhWds",Vj="AdminTools-module_subtitle_8Hzne",Hj="AdminTools-module_section_3Y8ja",Uj="AdminTools-module_sectionTitle_sz-rG",Zj="AdminTools-module_toolGrid_t8PAN",Wj="AdminTools-module_toolCard_yjReH",Kj="AdminTools-module_toolTitle_6-qSw",Gj="AdminTools-module_toolDescription_CMLNp",Jj="AdminTools-module_toolLink_7e2GS",zj="AdminTools-module_lookupForm_czr-y",Yj="AdminTools-module_lookupInput_U51RD",Qj="AdminTools-module_goButton_4p4vR";var ct={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Lj,paywallBgZIndex:Bj,collapsedMediaSidebarWidth:Dj,container:Mj,header:Fj,eyebrow:Oj,title:qj,subtitle:Vj,section:Hj,sectionTitle:Uj,toolGrid:Zj,toolCard:Wj,toolTitle:Kj,toolDescription:Gj,toolLink:Jj,lookupForm:zj,lookupInput:Yj,goButton:Qj},Nl=Q(ie()),Xj=[{title:"AI tools",description:"Open the collection of AI testing, comparison, evaluation, and debugging tools.",to:"/admin/ai/tools"},{title:"Monitor metrics",description:"Review production health and operational metrics.",to:"/admin/monitor"},{title:"Process video jobs",description:"Inspect processing jobs, stages, tasks, errors, and timing.",to:"/admin/process_video_jobs"},{title:"Job tasks",description:"Search and inspect individual background job tasks.",to:"/admin/tasks"},{title:"Video validation",description:"Review video test validation results and failures.",to:"/admin/validation"},{title:"Regression videos",description:"Review and manage the regression video collection.",to:"/admin/regression"},{title:"Export speed",description:"Compare export performance and investigate slow exports.",to:"/admin/export-speed"},{title:"Templates",description:"Create, edit, migrate, and delete templates.",to:"/admin/templates"},{title:"Static image uploader",description:"Upload and manage static image assets.",to:"/admin/upload"},{title:"Feature flags",description:"Manage feature flags, allowlists, and flag audit history.",to:"/admin/flags"},{title:"MCP feature flags",description:"Manage the MCP beta allowlist across every flag in the mcp_beta_tools config.",to:"/admin/flags/mcp"},{title:"Blocked accounts",description:"Review and manage blocked accounts.",to:"/admin/blocked-accounts"},{title:"Education admin",description:"Manage education accounts and Bytebot licenses.",to:"/admin/edu"},{title:"Qualified domains",description:"Explore qualified company and organization domains.",to:"/admin/qualified-domains"},{title:"Dev machines",description:"Review user development machine assignments.",to:"/admin/dev-machines"},{title:"Create team",description:"Create a new team for a Kapwing account.",to:"/admin/team/create"},{title:"Email scheduler",description:"Schedule administrative emails.",to:"/admin/emailScheduler"},{title:"NPS",description:"Review Net Promoter Score responses and feedback.",to:"/admin/nps"},{title:"K2 license keys",description:"Create and manage K2 license keys.",to:"/admin/k2-license-keys"},{title:"Translation pairs",description:"Manage supported translation language pairs.",to:"/admin/translation-pairs"},{title:"TTS voices",description:"Review and configure text-to-speech voices.",to:"/admin/tts-voices"},{title:"React Compiler",description:"Inspect React Compiler adoption and diagnostics.",to:"/admin/react-compiler"},{title:"Performance reports",description:"Generate and inspect application performance reports.",to:"/admin/performance-reports"}],eb=[{title:"User lookup",description:"Enter a user email address or Mongo user ID.",placeholder:"Email address or user ID",getPath:s=>`/admin/${encodeURIComponent(s)}`},{title:"Team lookup",description:"Enter the team's Mongo ID.",placeholder:"Team ID",getPath:s=>`/admin/team/${encodeURIComponent(s)}`},{title:"Video debugger",description:"Enter the video's Mongo ID.",placeholder:"Video ID",getPath:s=>`/videos/${encodeURIComponent(s)}/debug`},{title:"Process video job lookup",description:"Enter the process video job's Mongo ID.",placeholder:"Process video job ID",getPath:s=>`/admin/process_video_jobs/${encodeURIComponent(s)}`},{title:"Job task lookup",description:"Enter the background job task's ID.",placeholder:"Job task ID",getPath:s=>`/admin/tasks/${encodeURIComponent(s)}`}];function tb(s){const e=(0,Nl.c)(24),{tool:n}=s,a=Lt(),[o,i]=(0,f.useState)("");let l;e[0]!==a||e[1]!==n||e[2]!==o?(l=b=>{b.preventDefault();const j=o.trim();j&&a(n.getPath(j))},e[0]=a,e[1]=n,e[2]=o,e[3]=l):l=e[3];const r=l;let d;e[4]!==n.title?(d=(0,t.jsx)("h2",{className:ct.toolTitle,children:n.title}),e[4]=n.title,e[5]=d):d=e[5];let c;e[6]!==n.description?(c=(0,t.jsx)("p",{className:ct.toolDescription,children:n.description}),e[6]=n.description,e[7]=c):c=e[7];let m;e[8]!==d||e[9]!==c?(m=(0,t.jsxs)("div",{children:[d,c]}
1),e[8]=d,e[9]=c,e[10]=m):m=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=b=>i(b.target.value),e[11]=h):h=e[11];let p;e[12]!==n.placeholder||e[13]!==o?(p=(0,t.jsx)("input",{"aria-label":n.placeholder,className:ct.lookupInput,onChange:h,placeholder:n.placeholder,type:"text",value:o}),e[12]=n.placeholder,e[13]=o,e[14]=p):p=e[14];const u=!o.trim();let g;e[15]!==u?(g=(0,t.jsx)("button",{className:ct.goButton,disabled:u,type:"submit",children:"Go"}),e[15]=u,e[16]=g):g=e[16];let _;e[17]!==r||e[18]!==p||e[19]!==g?(_=(0,t.jsxs)("form",{className:ct.lookupForm,onSubmit:r,children:[p,g]}),e[17]=r,e[18]=p,e[19]=g,e[20]=_):_=e[20];let v;return e[21]!==m||e[22]!==_?(v=(0,t.jsxs)("div",{className:ct.toolCard,children:[m,_]}),e[21]=m,e[22]=_,e[23]=v):v=e[23],v}function sb(){const s=(0,Nl.c)(5);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("div",{className:ct.header,children:[(0,t.jsx)("p",{className:ct.eyebrow,children:"Admin"}),(0,t.jsx)("h1",{className:ct.title,children:"Internal tools"}),(0,t.jsx)("p",{className:ct.subtitle,children:"Find Kapwing's administrative, operational, and debugging tools."})]}),s[0]=e):e=s[0];let n;s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)("h2",{className:ct.sectionTitle,children:"Lookups and debuggers"}),s[1]=n):n=s[1];let a;s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)("section",{className:ct.section,children:[n,(0,t.jsx)("div",{className:ct.toolGrid,children:eb.map(ab)})]}),s[2]=a):a=s[2];let o;s[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("h2",{className:ct.sectionTitle,children:"All tools"}),s[3]=o):o=s[3];let i;return s[4]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxs)("main",{className:ct.container,children:[e,a,(0,t.jsxs)("section",{className:ct.section,children:[o,(0,t.jsx)("div",{className:ct.toolGrid,children:Xj.map(nb)})]})]}),s[4]=i):i=s[4],i}function nb(s){return(0,t.jsxs)(be,{className:ct.toolCard,to:s.to,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:ct.toolTitle,children:s.title}),(0,t.jsx)("p",{className:ct.toolDescription,children:s.description})]}),(0,t.jsxs)("span",{className:ct.toolLink,children:["Open tool ",(0,t.jsx)("span",{"aria-hidden":"true",children:"â"})]})]},s.title)}function ab(s){return(0,t.jsx)(tb,{tool:s},s.title)}var ob=Q(cn());const ib=`You are an AI customer relations representative at Kapwing. 2Provide answers concisely. 3Do not ask specific clarifying questions, like for a project name or details about a project.`;var lb=()=>{const[s,e]=(0,f.useState)(ib),[n,a]=(0,f.useState)("How do I upgrade to pro?"),[o,i]=(0,f.useState)(null),[l,r]=(0,f.useState)(!1),[d,c]=(0,f.useState)(!1);let m=o?o.allDocsInfo:[];return d||(m=(0,ob.uniqBy)(m,"title")),(0,t.jsxs)("div",{style:{width:650,margin:"auto"},children:[(0,t.jsx)("h1",{children:"Helpbot"}),(0,t.jsx)("h3",{children:"System Prompt"}),(0,t.jsx)("textarea",{value:s,onChange:h=>e(h.target.value),style:{width:"100%",height:"200px"}}),(0,t.jsx)("h3",{children:"User Question"}),(0,t.jsx)("textarea",{value:n,onChange:h=>a(h.target.value),style:{width:"100%",height:"50px"}}),(0,t.jsx)("button",{onClick:async()=>{try{r(!0),i(null),i(await H.ai.helpbot.query({question:n,systemPrompt:s}))}catch(h){Ue({error:h,description:"Failed to ask helpbot"})}finally{r(!1)}},type:"button",children:"Ask Question"}),(0,t.jsx)("h3",{children:"Response"}),l&&(0,t.jsx)("div",{children:"Loading..."}),o&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:o.message.content}),(0,t.jsx)("h3",{children:"Docs"}),(0,t.jsx)("button",{type:"button",onClick:()=>c(!d),style:{marginBottom:10,border:"none",outline:"none",background:"none",textDecoration:"underline",cursor:"pointer"},children:d?"Hide Duplicates":"Show Duplicates"}),(0,t.jsx)("div",{style:{width:"100%"},children:m.map(h=>(0,t.jsx)("div",{style:{background:h.questionUsed?"rgba(10, 200, 20, 0.15)":"",borderRadius:5,padding:"4px 8px",marginBottom:6,fontSize:14,width:"fit-content"},children:(0,t.jsxs)("a",{href:h.url,target:"_blank",rel:"noreferrer",style:{color:"black"},children:[(0,t.jsx)("span",{children:h.source==="canned-response"?"ð¥«":"ð°"}),"[",h.score.toFixed(3),"] ",h.question," (",h.title,")"]})},h._id))}),(0,t.jsxs)("div",{children:["Cost was ",o.costInCents," cents"]})]})]})},rb=f.memo(lb);const db="1001",cb="1000",ub="58px",mb="AdminAITools-module_container_gSvKf",pb="AdminAITools-module_header_8BUlx",hb="AdminAITools-module_eyebrow_7tFjc",fb="AdminAITools-module_title_wETgq",xb="AdminAITools-module_subtitle_CuT79",gb="AdminAITools-module_toolGrid_2Q1-D",vb="AdminAITools-module_toolCard_J9DRe",_b="AdminAITools-module_toolTitle_bKmIi",jb="AdminAITools-module_toolDescription_KGGT-",bb="AdminAITools-module_toolLink_bVSmF";var Ht={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:db,paywallBgZIndex:cb,collapsedMediaSidebarWidth:ub,container:mb,header:pb,eyebrow:hb,title:fb,subtitle:xb,toolGrid:gb,toolCard:vb,toolTitle:_b,toolDescription:jb,toolLink:bb},wl=Q(ie()),yb=[{title:"Objective test bank",description:"View and manage reusable test requests with expected tool calls, output assertions, assets, and conversation history.",linkLabel:"Open objective test bank",to:"/admin/ai/prompt-comparison-request-bank"},{title:"Run evaluation or view history",description:"Compare prompt and agent configurations across one or many requests, then review judged results and regressions.",linkLabel:"Open evaluations",to:"/admin/ai/prompt-comparison-runs"},{title:"HITL evaluations",description:"Run rubric-based evaluations and review human-in-the-loop scores for Kai conversations and generated results.",linkLabel:"Open HITL evaluations",to:"/admin/ai-evaluation"},{title:"Helpbot debugger",description:"Try Helpbot questions against an editable system prompt and inspect the documents used to produce each answer.",linkLabel:"Open Helpbot debugger",to:"/admin/ai/helpbot"},{title:"Langfuse",description:"Inspect Langfuse traces and spans for Kapwing's AI experiences.",linkLabel:"Open Langfuse",href:"https://us.cloud.langfuse.com/project/cmj0ap825008gad07tadtoy64/traces?page=1&limit=50&filter=type%3BstringOptions%3B%3Bany+of%3BSPAN&searchType=id&searchType=content"}];function Sb(s){const e=(0,wl.c)(19),{tool:n}=s;let a;e[0]!==n.title?(a=(0,t.jsx)("h2",{className:Ht.toolTitle,children:n.title}),e[0]=n.title,e[1]=a):a=e[1];let o;e[2]!==n.description?(o=(0,t.jsx)("p",{className:Ht.toolDescription,children:n.description}),e[2]=n.description,e[3]=o):o=e[3];let i;e[4]!==a||e[5]!==o?(i=(0,t.jsxs)("div",{children:[a,o]}),e[4]=a,e[5]=o,e[6]=i):i=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("span",{"aria-hidden":"true",children:"â"}),e[7]=l):l=e[7];let r;e[8]!==n.linkLabel?(r=(0,t.jsxs)("span",{className:Ht.toolLink,children:[n.linkLabel,l]}),e[8]=n.linkLabel,e[9]=r):r=e[9];let d;e[10]!==i||e[11]!==r?(d=(0,t.jsxs)(t.Fragment,{children:[i,r]}),e[10]=i,e[11]=r,e[12]=d):d=e[12];const c=d;if("href"in n){let h;return e[13]!==c||e[14]!==n.href?(h=(0,t.jsx)("a",{className:Ht.toolCard,href:n.href,rel:"noreferrer",target:"_blank",children:c}),e[13]=c,e[14]=n.href,e[15]=h):h=e[15],h}let m;return e[16]!==c||e[17]!==n.to?(m=(0,t.jsx)(be,{className:Ht.toolCard,to:n.to,children:c}),e[16]=c,e[17]=n.to,e[18]=m):m=e[18],m}function Cb(){const s=(0,wl.c)(2);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsxs)("div",{className:Ht.header,children:[(0,t.jsx)("p",{className:Ht.eyebrow,children:"Admin"}),(0,t.jsx)("h1",{className:Ht.title,children:"AI tools"}),(0,t.jsx)("p",{className:Ht.subtitle,children:"Test, compare, and evaluate Kapwing's AI experiences."})]}),s[0]=e):e=s[0];let n;return s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsxs)("main",{className:Ht.container,children:[e,(0,t.jsx)("div",{className:Ht.toolGrid,children:yb.map(Nb)})]}),s[1]=n):n=s[1],n}function Nb(s){return(0,t.jsx)(Sb,{tool:s},s.title)}var wb=Q(ie()),Al=(0,f.createContext)(null);function Ab(s){const e=(0,wb.c)(19),{children:n}=s,a=no();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ut.admin.aiEvaluation.getStartRunData.queryOptions(),e[0]=o):o=e[0];const i=Gs(o);let l;e[1]!==a?(l=()=>{a.invalidateQueries({queryKey:Ut.admin.aiEvaluation.getStartRunData.queryKey()})},e[1]=a,e[2]=l):l=e[2];const r=l;i.data?.recentRuns,i.data?.rubrics,i.data?.testSets;let d,c;e[3]!==i.data?.rubrics?(c=i.data?.rubrics??[],e[3]=i.data?.rubrics,e[4]=c):c=e[4];let m;e[5]!==i.data?.recentRuns?(m=i.data?.recentRuns??[],e[5]=i.data?.recentRuns,e[6]=m):m=e[6];let h;e[7]!==i.data?.testSets?(h=i.data?.testSets??[],e[7]=i.data?.testSets,e[8]=h):h=e[8];let p;e[9]!==r||e[10]!==i.isFetching||e[11]!==i.isLoading||e[12]!==c||e[13]!==m||e[14]!==h?(p={rubrics:c,runs:m,testSets:h,isLoading:i.isLoading,isFetching:i.isFetching,refresh:r},e[9]=r,e[10]=i.isFetching,e[11]=i.isLoading,e[12]=c,e[13]=m,e[14]=h,e[15]=p):p=e[15],d=p;const u=d;let g;return e[16]!==n||e[17]!==u?(g=(0,t.jsx)(Al.Provider,{value:u,children:n}),e[16]=n,e[17]=u,e[18]=g):g=e[18],g}function Il(){const s=(0,f.useContext)(Al);if(!s)throw new Error("useAdminEvaluationData must be used within an AdminEvaluationDataProvider");return s}const Ib="AdminEvaluationHome-module_container_BI2k9",Tb="AdminEvaluationHome-module_formCard_wBRsG",kb="AdminEvaluationHome-module_form_K5WTf",Rb="AdminEvaluationHome-module_formSection_BLKwn",$b="AdminEvaluationHome-module_fieldGroup_tWLZp",Pb="AdminEvaluationHome-module_field_8eLfS",Eb="AdminEvaluationHome-module_checkboxField_FGQoh",Lb="AdminEvaluationHome-module_helperText_aCqhH",Bb="AdminEvaluationHome-module_questionsCard_y2-Es",Db="AdminEvaluationHome-module_questionsCardHeader_cU-ag",Mb="AdminEvaluationHome-module_questionsList_oDMf2",Fb="AdminEvaluationHome-module_questionItem_wCYRd",Ob="AdminEvaluationHome-module_questionPrompt_QE-BL",qb="AdminEvaluationHome-module_questionMeta_tA4Cj",Vb="AdminEvaluationHome-module_testsSection_8smTa",Hb="AdminEvaluationHome-module_testSetManagementSection_9meMd",Ub="AdminEvaluationHome-module_testSetManagementRow_PGhbG",Zb="AdminEvaluationHome-module_testSetList_Vajw4",Wb="AdminEvaluationHome-module_testSetListRow_mrM69",Kb="AdminEvaluationHome-module_testSetListName_mHDpi",Gb="AdminEvaluationHome-module_testsToggle_YEVkB",Jb="AdminEvaluationHome-module_testsToggleLabel_EoisP",zb="AdminEvaluationHome-module_testsToggleMeta_Fhewg",Yb="AdminEvaluationHome-module_testsPanel_7n-JY",Qb="AdminEvaluationHome-module_testsList_cT-3M",Xb="AdminEvaluationHome-module_testRow_1S-aV",ey="AdminEvaluationHome-module_testInfo_qmXgG",ty="AdminEvaluationHome-module_testName_PzEjF",sy="AdminEvaluationHome-module_testSetCheckboxes_dVNsi",ny="AdminEvaluationHome-module_testSetCheckboxLabel_CRskq",ay="AdminEvaluationHome-module_testStatus_
3SMKLL",oy="AdminEvaluationHome-module_testArchiveToggle_doOdJ",iy="AdminEvaluationHome-module_testArchiveLabel_S1ZHn",ly="AdminEvaluationHome-module_testsLoading_-Oa1V",ry="AdminEvaluationHome-module_testsEmpty_cZee1",dy="AdminEvaluationHome-module_submitActions_6Hb2m",cy="AdminEvaluationHome-module_error_VayhC",uy="AdminEvaluationHome-module_success_04Q2s",my="AdminEvaluationHome-module_tableWrap_U6-q7",py="AdminEvaluationHome-module_table_WncY8",hy="AdminEvaluationHome-module_statusPill_ASb9x",fy="AdminEvaluationHome-module_agentModeCell_Rb1oR",xy="AdminEvaluationHome-module_statusQueued_UOk9d",gy="AdminEvaluationHome-module_statusRunning_kdazF",vy="AdminEvaluationHome-module_statusCompleted_zo-Ma",_y="AdminEvaluationHome-module_statusFailed_vuFdN",jy="AdminEvaluationHome-module_statusCancelled_gjCgL",by="AdminEvaluationHome-module_tableEmptyState_DbuZp",yy="AdminEvaluationHome-module_loadingState_A-Zxz";var fe={container:Ib,formCard:Tb,form:kb,formSection:Rb,fieldGroup:$b,field:Pb,checkboxField:Eb,helperText:Lb,questionsCard:Bb,questionsCardHeader:Db,questionsList:Mb,questionItem:Fb,questionPrompt:Ob,questionMeta:qb,testsSection:Vb,testSetManagementSection:Hb,testSetManagementRow:Ub,testSetList:Zb,testSetListRow:Wb,testSetListName:Kb,testsToggle:Gb,testsToggleLabel:Jb,testsToggleMeta:zb,testsPanel:Yb,testsList:Qb,testRow:Xb,testInfo:ey,testName:ty,testSetCheckboxes:sy,testSetCheckboxLabel:ny,testStatus:ay,testArchiveToggle:oy,testArchiveLabel:iy,testsLoading:ly,testsEmpty:ry,submitActions:dy,error:cy,success:uy,tableWrap:my,table:py,statusPill:hy,agentModeCell:fy,statusQueued:xy,statusRunning:gy,statusCompleted:vy,statusFailed:_y,statusCancelled:jy,tableEmptyState:by,loadingState:yy},Tl=Q(ie()),zo=s=>s?new Date(s).toLocaleString():"â",Sy=s=>s.agentExecutionMode==="planner"?"Planner":"Autonomous",Cy=s=>s.scoreMode==="pass_fail"?typeof s.passRate=="number"?`${s.passRate.toFixed(0)}%`:"â":typeof s.averageScore=="number"?s.averageScore.toFixed(2):"â",Ny=xl[0],wy=Ln,Ay=ic.options,Iy=Kd,yt="__default__",Ty={queued:fe.statusQueued,running:fe.statusRunning,completed:fe.statusCompleted,failed:fe.statusFailed,cancelled:fe.statusCancelled};function ky({rubrics:s,testSets:e,isLoading:n,onRunStarted:a}){const[o,i]=(0,f.useState)(Ny),[l,r]=(0,f.useState)(null),[d,c]=(0,f.useState)("default"),[m,h]=(0,f.useState)(sn),[p,u]=(0,f.useState)(""),[g,_]=(0,f.useState)(!1),[v,b]=(0,f.useState)(null),[j,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(()=>new Set),[y,N]=(0,f.useState)(!0),[w,A]=(0,f.useState)(yt),[I,D]=(0,f.useState)(yt),[L,$]=(0,f.useState)(yt),[R,P]=(0,f.useState)(yt),[k,T]=(0,f.useState)(yt),[E,O]=(0,f.useState)({name:window.location.origin,commitHash:Ud(),vendorName:"",notes:""}),[q,J]=(0,f.useState)(!1),[K,z]=(0,f.useState)(()=>new Set),[Y,me]=(0,f.useState)(null),[X,te]=(0,f.useState)(""),[ae,G]=(0,f.useState)(null),[se,U]=(0,f.useState)(null),[B,oe]=(0,f.useState)(!1),de=Lt(),ye=no(),Le=(0,f.useMemo)(()=>s.filter(V=>V.productArea===o),[s,o]);(0,f.useEffect)(function(){if(!Le.length){r(null);return}const Ie=Le[0];if(!Ie){r(null);return}(!l||!Le.some(ke=>ke.id===l))&&r(Ie.id)},[l,Le]),(0,f.useEffect)(function(){J(!1),me(null),z(new Set)},[o]),(0,f.useEffect)(function(){if(e.length===0){h(sn);return}if(!e.some(Ie=>Ie.id===m)){const Ie=e.find(De=>De.isDefault);if(Ie){h(Ie.id);return}const ke=e[0];ke&&h(ke.id)}},[m,e]);const Ne=(0,f.useMemo)(()=>Le.find(V=>V.id===l)??null,[Le,l]),Be=Gs({...Ut.admin.aiEvaluation.getTestsForProductArea.queryOptions({productArea:o}),enabled:q}),le=Be.data??[],he=le.filter(V=>!V.isArchived).length,ge=(0,f.useMemo)(()=>({[sn]:hl,...Object.fromEntries(e.map(V=>[V.id,V.name]))}),[e]),je=(0,f.useMemo)(()=>q?Be.isLoading?"Loadingâ¦":`${he} active / ${le.length} total`:"Expand to review",[q,Be.isLoading,he,le.length]),ue=async V=>{const Ie=String(V.id);if(!K.has(Ie)){me(null),z(ke=>new Set(ke).add(Ie));try{await H.admin.aiEvaluation.updateTestArchive.mutate({testId:V.id,isArchived:!V.isArchived}),ye.invalidateQueries({queryKey:Ut.admin.aiEvaluation.getTestsForProductArea.queryKey({productArea:o})})}catch(ke){me(ke instanceof Error?ke.message:"Failed to update test archive status.")}finally{z(ke=>{const De=new Set(ke);return De.delete(Ie),De})}}}
3,pe=async(V,Ie)=>{const ke=String(V.id);if(K.has(ke))return;const De=V.testSetIds.length?V.testSetIds:[sn],Xe=De.includes(Ie)?De.filter(jt=>jt!==Ie):[...De,Ie];me(null),z(jt=>new Set(jt).add(ke));try{await H.admin.aiEvaluation.updateTestSetAssignments.mutate({testId:V.id,testSetIds:Xe}),ye.invalidateQueries({queryKey:Ut.admin.aiEvaluation.getTestsForProductArea.queryKey({productArea:o})})}catch(jt){me(jt instanceof Error?jt.message:"Failed to update test set assignments.")}finally{z(jt=>{const Zt=new Set(jt);return Zt.delete(ke),Zt})}},ee=(V,Ie)=>{O(ke=>({...ke,[V]:Ie}))},xe=async()=>{const V=p.trim();if(!V){b("Enter a test set name.");return}try{x(!0),b(null),await H.admin.aiEvaluation.createTestSet.mutate({name:V}),u(""),a()}catch(Ie){b(Ie instanceof Error?Ie.message:"Failed to create test set.")}finally{x(!1)}},ve=async V=>{if(!S.has(V))try{b(null),C(Ie=>new Set(Ie).add(V)),await H.admin.aiEvaluation.deleteTestSet.mutate({testSetId:V}),a()}catch(Ie){b(Ie instanceof Error?Ie.message:"Failed to delete test set.")}finally{C(Ie=>{const ke=new Set(Ie);return ke.delete(V),ke})}},we=async V=>{if(V.preventDefault(),G(null),U(null),!Ne){G(`Add a rubric for ${o} before starting a run.`);return}let Ie;if(X.trim())try{Ie=JSON.parse(X)}catch{G("Metadata must be valid JSON.");return}try{oe(!0);const ke={},De={};w!==yt&&(De.planningLLM=w),I!==yt&&(ke.image=I),L!==yt&&(ke.video=L),R!==yt&&(ke.music=R),k!==yt&&(ke.soundEffect=k);const Xe={};Object.keys(De).length>0&&(Xe.llms=De),Object.keys(ke).length>0&&(Xe.generationModels=ke),y&&(Xe.autoConfirmResponses=!0),de(`/admin/ai-evaluation/runs/${(await H.admin.aiEvaluation.startTestRun.mutate({productArea:o,testSetId:m,rubricId:Ne.id,testType:d,environment:{name:E.name.trim(),commitHash:E.commitHash.trim()||void 0,vendorName:E.vendorName.trim()||void 0,notes:E.notes.trim()||void 0},agentModeEnabled:!0,kaiConfigOverrides:Object.keys(Xe).length>0?Xe:void 0,metadata:Ie})).run.id}`),U("Run queued successfully."),te(""),a()}catch(ke){G(ke instanceof Error?ke.message:"Failed to start run. Please try again.")}finally{oe(!1)}};function re(){return Be.error?(0,t.jsxs)("div",{className:fe.error,children:["Failed to load tests for ",o,"."]}):Be.isLoading?(0,t.jsxs)("div",{className:fe.testsLoading,children:["Loading tests for ",o,"â¦"]}):le.length?(0,t.jsx)("div",{className:fe.testsList,children:le.map(V=>{const Ie=String(V.id),ke=K.has(Ie);return(0,t.jsxs)("div",{className:fe.testRow,children:[(0,t.jsxs)("div",{className:fe.testInfo,children:[(0,t.jsx)("div",{className:fe.testName,children:V.name}),(0,t.jsx)("div",{className:fe.testSetCheckboxes,children:e.map(De=>{const Xe=V.testSetIds.length?V.testSetIds:[sn];return(0,t.jsxs)("label",{className:fe.testSetCheckboxLabel,children:[(0,t.jsx)("input",{type:"checkbox",checked:Xe.includes(De.id),disabled:ke||B,onChange:()=>pe(V,De.id)}),(0,t.jsx)("span",{children:ge[De.id]??De.id})]},`${Ie}-${De.id}`)})}),V.isArchived&&(0,t.jsx)("div",{className:fe.testStatus,children:"Archived"})]}),(0,t.jsxs)("label",{className:fe.testArchiveToggle,children:[(0,t.jsx)("input",{type:"checkbox",checked:V.isArchived,disabled:ke||B,onChange:()=>ue(V)}),(0,t.jsx)("span",{className:fe.testArchiveLabel,children:"Archived"})]})]},Ie)})}):(0,t.jsxs)("div",{className:fe.testsEmpty,children:["No tests found for ",o,"."]})}return(0,t.jsx)("div",{className:fe.formCard,children:(0,t.jsxs)("form",{className:fe.form,onSubmit:we,children:[(0,t.jsxs)("div",{className:fe.formSection,children:[(0,t.jsx)("h2",{children:"Run configuration"}),(0,t.jsxs)("div",{className:fe.fieldGroup,children:[(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"productArea",children:"Product area"}),(0,t.jsx)("select",{id:"productArea",value:o,disabled:n||B,onChange:V=>i(V.target.value),children:xl.map(V=>(0,t.jsx)("option",{value:V,children:V},V))}),(0,t.jsx)("p",{className:fe.helperText,children:"Determines which tests are eligible for sampling."})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"rubric",children:"Rubric"}),(0,t.jsx)("select",{id:"rubric",value:l??"",disabled:!Le.length||B,onChange:V=>r(V.target.value),children:Le.map(V=>
3(0,t.jsxs)("option",{value:V.id,children:[V.name," (v",V.version,")"]},V.id))}),(0,t.jsx)("p",{className:fe.helperText,children:"Every test in this run will be scored with these questions."})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"testSetId",children:"Test set"}),(0,t.jsx)("select",{id:"testSetId",value:m,disabled:B||e.length===0,onChange:V=>h(V.target.value),children:e.map(V=>(0,t.jsx)("option",{value:V.id,children:V.name},V.id))}),(0,t.jsx)("p",{className:fe.helperText,children:"Select which test set this run should execute."})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"testType",children:"Test type"}),(0,t.jsx)("select",{id:"testType",value:d,disabled:B,onChange:V=>c(V.target.value),children:Wc.map(V=>(0,t.jsx)("option",{value:V,children:V},V))}),(0,t.jsx)("p",{className:fe.helperText,children:"Helps compare runs with similar intent (default vs. vendor test)."})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"autoConfirmResponses",children:"Auto-confirm spend"}),(0,t.jsxs)("div",{className:fe.checkboxField,children:[(0,t.jsx)("input",{id:"autoConfirmResponses",type:"checkbox",checked:y,disabled:B,onChange:V=>N(V.target.checked)}),(0,t.jsx)("span",{children:"Spend credits automatically without extra-credit prompts"})]}),(0,t.jsx)("p",{className:fe.helperText,children:"Use this for unattended autonomous runs."})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"planningLLM",children:"Planning model"}),(0,t.jsxs)("select",{id:"planningLLM",value:w,disabled:B,onChange:V=>A(V.target.value),children:[(0,t.jsx)("option",{value:yt,children:"Use default"}),wy.map(V=>(0,t.jsx)("option",{value:V,children:Js(V)},V))]}),(0,t.jsx)("p",{className:fe.helperText,children:"Overrides Kai `planningLLM` for this run."})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"imageGenerationModel",children:"Image model"}),(0,t.jsxs)("select",{id:"imageGenerationModel",value:I,disabled:B,onChange:V=>D(V.target.value),children:[(0,t.jsx)("option",{value:yt,children:"Use default"}),Ay.map(V=>(0,t.jsx)("option",{value:V,children:V},V))]})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"videoGenerationModel",children:"Video model"}),(0,t.jsxs)("select",{id:"videoGenerationModel",value:L,disabled:B,onChange:V=>$(V.target.value),children:[(0,t.jsx)("option",{value:yt,children:"Use default"}),Iy.map(V=>(0,t.jsx)("option",{value:V,children:V},V))]})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"musicGenerationModel",children:"Music model"}),(0,t.jsxs)("select",{id:"musicGenerationModel",value:R,disabled:B,onChange:V=>P(V.target.value),children:[(0,t.jsx)("option",{value:yt,children:"Use default"}),(0,t.jsx)("option",{value:Wt.MINIMAX_MUSIC_3_0,children:Wt.MINIMAX_MUSIC_3_0}),(0,t.jsx)("option",{value:Wt.ELEVENLABS_MUSIC,children:Wt.ELEVENLABS_MUSIC}),(0,t.jsx)("option",{value:Wt.GOOGLE_LYRIA_3_5,children:Wt.GOOGLE_LYRIA_3_5}),(0,t.jsx)("option",{value:Wt.MINIMAX_MUSIC,children:Wt.MINIMAX_MUSIC})]})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"soundEffectGenerationModel",children:"Sound effect model"}),(0,t.jsxs)("select",{id:"soundEffectGenerationModel",value:k,disabled:B,onChange:V=>T(V.target.value),children:[(0,t.jsx)("option",{value:yt,children:"Use default"}),(0,t.jsx)("option",{value:Wt.ELEVEN_LABS_SOUND_EFFECT,children:Wt.ELEVEN_LABS_SOUND_EFFECT})]})]})]}),(0,t.jsxs)("div",{className:fe.testSetManagementSection,children:[(0,t.jsxs)("button",{type:"button",className:fe.testsToggle,onClick:()=>_(V=>!V),disabled:n||B,"aria-expanded":g,children:[(0,t.jsx)("span",{className:fe.testsToggleLabel,children:"Manage test sets"}),(0,t.jsx)("span",{className:fe.testsToggleMeta,children:g?"Minimize":"Expand"})]}),g&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:fe.testSetManagementRow,children:[(0,t.jsx)("input",{type:"text",value:p,placeholder:"Add a new test set name",disabled:j||B,onChange:V=>u(V.target.value)}),(0,t.jsx)("button",{type:"button",disabled:j||B,onClick:xe,children:j?"Adding...":"Add test set"})]}),(0,t.jsx)("div",{className:fe.testSetList,children:e.map(V=>{const Ie=S.has(V.id);return(0,t.jsxs)("div",{className:fe.testSetListRow,children:[(0,t.jsx)("span",{className:fe.testSetListName,children:V.name}),(0,t.jsx)("button",{type:"button",disabled:V.isDefault||Ie||B,onClick:()=>ve(V.id),children:Ie?"Removing...":"Remove"})]},V.id)})}),v&&(0,t.jsx)("div",{className:fe.error,children:v}),(0,t.jsx)("p",{className:fe.helperText,children:"Removing a test set also removes it from Kai admin dropdowns and AI evaluation selectors."})]})]}),(0,t.jsxs)("div",{className:fe.testsSection,children:[(0,t.jsxs)("button",{type:"button",className:fe.testsToggle,onClick:()=>J(V=>!V),disabled:n||B,"aria-expanded":q,children:[(0,t.jsxs)("span",{className:fe.testsToggleLabel,children:["Tests tagged to ",o]}),(0,t.jsx)("span",{className:fe.testsToggleMeta,children:je})]}),q&&(0,t.jsxs)("div",{className:fe.testsPanel,children:[re(),(0,t.jsx)("p",{className:fe.helperText,children:"Archived tests are skipped when the run is started."}),Y&&(0,t.jsx)("div",{className:fe.error,children:Y})]})]})]}),(0,t.jsxs)("div",{className:fe.formSection,children:[(0,t.jsx)("h2",{children:"Environment"}),(0,t.jsxs)("div",{className:fe.fieldGroup,children:[(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"environmentName",children:"Environment name"}),(0,t.jsx)("input",{id:"environmentName",type:"text",value:E.name,disabled:!0,onChange:V=>ee("name",V.target.value),required:!0}),(0,t.jsx)("p",{className:fe.helperText,children:"e.g. production, staging, vendor alph
3a."})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"commitHash",children:"Commit hash"}),(0,t.jsx)("input",{id:"commitHash",type:"text",value:E.commitHash,disabled:!0,placeholder:"Optional",onChange:V=>ee("commitHash",V.target.value)})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"vendorName",children:"Vendor name"}),(0,t.jsx)("input",{id:"vendorName",type:"text",value:E.vendorName,disabled:B,placeholder:"Optional",onChange:V=>ee("vendorName",V.target.value)})]}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"environmentNotes",children:"Notes"}),(0,t.jsx)("textarea",{id:"environmentNotes",value:E.notes,disabled:B,placeholder:"Optional",onChange:V=>ee("notes",V.target.value)})]})]})]}),(0,t.jsxs)("div",{className:fe.formSection,children:[(0,t.jsx)("h2",{children:"Metadata"}),(0,t.jsxs)("div",{className:fe.field,children:[(0,t.jsx)("label",{htmlFor:"metadata",children:"Metadata (JSON)"}),(0,t.jsx)("textarea",{id:"metadata",value:X,disabled:B,placeholder:'{"sampleCount": 20}',onChange:V=>te(V.target.value)}),(0,t.jsx)("p",{className:fe.helperText,children:"Optional. Include experiment flags, locales, or other context."})]})]}),(0,t.jsxs)("div",{className:fe.formSection,children:[(0,t.jsx)("h2",{children:"Rubric questions"}),(0,t.jsx)("div",{className:fe.questionsCard,children:Ne?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:fe.questionsCardHeader,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:Ne.name}),(0,t.jsxs)("p",{children:["Version ",Ne.version," â¢"," ",Ne.questions.length," questions"]})]}),Ne.description&&(0,t.jsx)("p",{className:fe.helperText,children:Ne.description})]}),(0,t.jsx)("ul",{className:fe.questionsList,children:Ne.questions.map(V=>(0,t.jsxs)("li",{className:fe.questionItem,children:[(0,t.jsx)("div",{className:fe.questionPrompt,children:V.prompt}),V.description&&(0,t.jsx)("div",{className:fe.questionMeta,children:V.description}),(0,t.jsxs)("div",{className:fe.questionMeta,children:["Score range ",V.minScore??1,"-",V.maxScore??5]})]},V.questionId))})]}):(0,t.jsxs)("p",{className:fe.helperText,children:["No rubrics available for ",o,". Add one to start runs."]})})]}),(0,t.jsxs)("div",{className:fe.submitActions,children:[ae&&(0,t.jsx)("div",{className:fe.error,children:ae}),se&&(0,t.jsx)("div",{className:fe.success,children:se}),(0,t.jsx)("button",{type:"submit",disabled:B||n||!Ne||e.length===0,children:B?"Starting run...":"Start test run"})]})]})})}function Ry(s){const e=(0,Tl.c)(14),{runs:n,testSets:a,isLoading:o}=s,i=Lt();let l,r;e[0]!==a?(r={[sn]:hl,...Object.fromEntries(a.map($y))},e[0]=a,e[1]=r):r=e[1],l=r;const d=l;if(o){let p;return e[2]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("div",{className:fe.loadingState,children:"Loading recent runsâ¦"}),e[2]=p):p=e[2],p}if(!n.length){let p;return e[3]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("div",{className:fe.tableEmptyState,children:"No evaluation runs yet. Start one above."}),e[3]=p):p=e[3],p}let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Product area"}),(0,t.jsx)("th",{children:"Test type"}),(0,t.jsx)("th",{children:"Test set"}),(0,t.jsx)("th",{children:"Agent"}),(0,t.jsx)("th",{children:"Planning model"}),(0,t.jsx)("th",{children:"Status"}),(0,t.jsx)("th",{children:"Created"}),(0,t.jsx)("th",{children:"Completed"}),(0,t.jsx)("th",{children:"Result"}),(0,t.jsx)("th",{children:"Tests"}),(0,t.jsx)("th",{children:"Environment"}),(0,t.jsx)("th",{children:"Notes"})]})}),e[4]=c):c=e[4];let m;if(e[5]!==i||e[6]!==n||e[7]!==d){let p;e[9]!==i||e[10]!==d?(p=u=>{const g=[u.environment.name,u.environment.commitHash,u.environment.vendorName].filter(Boolean);return(0,t.jsxs)("tr",{onClick:()=>{i(`/admin/ai-evaluation/runs/${u.id}`)},children:[(0,t.jsx)("td",{children:u.productArea}),(0,t.jsx)("td",{children:u.testType}),(0,t.jsx)("td",{children:d[u.testSetId]??u.testSetId}),(0,t.jsx)("td",{className:fe.agentModeCell,children:Sy(u)}),(0,t.jsx)("td",{children:u.kaiConfigOverrides?.llms?.planningLLM?Js(u.kaiConfigOverrides.llms.planningLLM):"â"}),(0,t.jsx)("td",{children:(0,t.jsx)("span",{className:`${fe.statusPill} ${Ty[u.status]??""}`,children:u.status})}),(0,t.jsx)("td",{children:zo(u.createdAt)}),(0,t.jsx)("td",{children:zo(u.completedAt)}),(0,t.jsx)("td",{children:Cy(u)}),(0,t.jsx)("td",{children:u.totalTests??"â"}),(0,t.jsx)("td",{children:g.join(" ⢠")||"â"}),(0,t.jsx)("td",{children:u.environment.notes||"â"})]},u.id)},e[9]=i,e[10]=d,e[11]=p):p=e[11],m=n.map(p),e[5]=i,e[6]=n,e[7]=d,e[8]=m}else m=e[8];let h;return e[12]!==m?(h=(0,t.jsx)("div",{className:fe.tableWrap,children:(0,t.jsxs)("table",{className:fe.table,children:[c,(0,t.jsx)("tbody",{children:m})]})}),e[12]=m,e[13]=h):h=e[13],h}function $y(s){return[s.id,s.name]}function Py(){const s=(0,Tl.c)(14),{rubrics:e,runs:n,testSets:a,isLoading:o,refresh:i}=Il();let l;s[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("h1",{children:"Start a test run"}),s[0]=l):l=s[0];let r;s[1]!==o||s[2]!==i||s[3]!==e||s[4]!==a?(r=(0,t.jsx)(ky,{rubrics:e,testSets:a,isLoading:o,onRunStarted:i}),s[1]=o,s[2]=i,s[3]=e,s[4]=a,s[5]=r):r=s[5];let d;s[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("h1",{children:"Recent test runs"}),s[6]=d):d=s[6];let c;s[7]!==o||s[8]!==n||s[9]!==a?(c=(0,t.jsx)(Ry,{runs:n,testSets:a,isLoading:o}),s[7]=o,s[8]=n,s[9]=a,s[10]=c):c=s[10];let m;return s[11]!==r||s[12]!==c?(m=(0,t.jsxs)("div",{className:fe.container,children:[l,r,d,c]}),s[11]=r,s[12]=c,s[13]=m):m=s[13],m}var Ya=Q(Ns());const Ey="1001",Ly="1000",By="58px",Dy="AdminEvaluationRun-module_home_QLQCH",My="AdminEvaluationRun-module_homeHowBackgroun
3dWhite_jpFfC",Fy="AdminEvaluationRun-module_largeButton_t0b-Y",Oy="AdminEvaluationRun-module_sectionContent_EeWRk",qy="AdminEvaluationRun-module_sectionHeader_TCEke",Vy="AdminEvaluationRun-module_spacer_GA9Es",Hy="AdminEvaluationRun-module_chevron_GPJSK",Uy="AdminEvaluationRun-module_splashText_e4haT",Zy="AdminEvaluationRun-module_splashSubtext_WidTB",Wy="AdminEvaluationRun-module_aboutSection_gF8Iu",Ky="AdminEvaluationRun-module_mobile_O4nA4",Gy="AdminEvaluationRun-module_desktop_QfRiK",Jy="AdminEvaluationRun-module_screenReaderOnlyLabel_DXTqC",zy="AdminEvaluationRun-module_disabled_HHgDd",Yy="AdminEvaluationRun-module_disabledWithPointerEvents_u-cYW",Qy="AdminEvaluationRun-module_noScrollBar_wCpLF",Xy="AdminEvaluationRun-module_textOverflowEllipsis_n5MoO",eS="AdminEvaluationRun-module_disableTextHighlight_LYLBb",tS="AdminEvaluationRun-module_genericButtonBlue_jYf1a",sS="AdminEvaluationRun-module_rmButtonUserAgentStyles_TBsr1",nS="AdminEvaluationRun-module_container_7Fjnt",aS="AdminEvaluationRun-module_topRow_-to4r",oS="AdminEvaluationRun-module_backLink_wqMsm",iS="AdminEvaluationRun-module_statusPill_bh4nG",lS="AdminEvaluationRun-module_header_n5Av9",rS="AdminEvaluationRun-module_runId_j5y2L",dS="AdminEvaluationRun-module_meta_MLwB9",cS="AdminEvaluationRun-module_summary_r7IUf",uS="AdminEvaluationRun-module_summaryItem_QEFY3",mS="AdminEvaluationRun-module_summaryLabel_5Yi31",pS="AdminEvaluationRun-module_summaryValue_lA3f7",hS="AdminEvaluationRun-module_comparisonControls_O4dOx",fS="AdminEvaluationRun-module_comparisonSelectGroup_iTEpU",xS="AdminEvaluationRun-module_comparisonSelectRow_pgwoj",gS="AdminEvaluationRun-module_clearButton_dpvbc",vS="AdminEvaluationRun-module_comparisonStatus_OsgAl",_S="AdminEvaluationRun-module_comparisonSummary_PeLID",jS="AdminEvaluationRun-module_comparisonCard_uBhbj",bS="AdminEvaluationRun-module_comparisonTitle_L0Z0R",yS="AdminEvaluationRun-module_questionSummary_FWCm1",SS="AdminEvaluationRun-module_questionGrid_CQxy4",CS="AdminEvaluationRun-module_questionCard_ODzCu",NS="AdminEvaluationRun-module_questionPrompt_6-cXe",wS="AdminEvaluationRun-module_questionAverage_M8tHo",AS="AdminEvaluationRun-module_questionAverageComparison_CMlbb",IS="AdminEvaluationRun-module_questionAverageBlock_kVftv",TS="AdminEvaluationRun-module_questionMeta_5dxJm",kS="AdminEvaluationRun-module_testsSection_9JcMV",RS="AdminEvaluationRun-module_sectionHeading_RYinO",$S="AdminEvaluationRun-module_sectionHint_lUISX",PS="AdminEvaluationRun-module_testList_SaqdY",ES="AdminEvaluationRun-module_comparisonGrid_FmL2r",LS="AdminEvaluationRun-module_comparisonColumnLabels_MkAwT",BS="AdminEvaluationRun-module_comparisonRow_ekeIF",DS="AdminEvaluationRun-module_comparisonCell_PonJk",MS="AdminEvaluationRun-module_missingTestCard_3VUqb",FS="AdminEvaluationRun-module_missingTestTitle_dW0QD",OS="AdminEvaluationRun-module_testRow_HEvJA",qS="AdminEvaluationRun-module_testMain_SfOyb",VS="AdminEvaluationRun-module_testName_oE2jc",HS="AdminEvaluationRun-module_testDescription_ln7hp",US="AdminEvaluationRun-module_empty_mw5Hx",ZS="AdminEvaluationRun-module_previewWrap_jcncq",WS="AdminEvaluationRun-module_previewToggle_ztSjS",KS="AdminEvaluationRun-module_errorBanner_Jd0IM",GS="AdminEvaluationRun-module_scoreOverview_rpaiA",JS="AdminEvaluationRun-module_scoreOverviewItem_bwMem",zS="AdminEvaluationRun-module_scoreOverviewPrompt_dIacC",YS="AdminEvaluationRun-module_scoreOverviewScores_I4lZA",QS="AdminEvaluationRun-module_mutedLabel_xO6UP",XS="AdminEvaluationRun-module_dotDivider_yueFL",eC="AdminEvaluationRun-module_questionList_d2rCo",tC="AdminEvaluationRun-module_questionDetailCard_pid7v",sC="AdminEvaluationRun-module_questionDetailHeader_yc2WF",nC="AdminEvaluationRun-module_questionDescription_Ulz82",aC="AdminEvaluationRun-module_scoreButtons_ZQbFc",oC="AdminEvaluationRun-module_scoreButton_3LQWb",iC="AdminEvaluationRun-module_scoreButtonSelected_z5KGC",lC="AdminEvaluationRun-module_scoreMetaRow_4yh5I",rC="AdminEvaluationRun-module_scoreMeta_hIZhR",dC="AdminEvaluationRun-module_peerScores_UqrGa",cC="AdminEvaluationRun-module_peerScoresLabel_U-MY2",uC="AdminEvaluationRun-module_peerScoreList_grEJc",mC="AdminEvaluationRun-module_peerScoreItem_FxiIH",pC="AdminEvaluationRun-module_peerScoresEmpty_y-KWO",hC="AdminEvaluationRun-module_iframeC
3ontainer_rxLgm",fC="AdminEvaluationRun-module_previewIframe_zpnDq";var ne={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Ey,paywallBgZIndex:Ly,collapsedMediaSidebarWidth:By,home:Dy,homeHowBackgroundWhite:My,largeButton:Fy,sectionContent:Oy,sectionHeader:qy,spacer:Vy,chevron:Hy,splashText:Uy,splashSubtext:Zy,aboutSection:Wy,mobile:Ky,desktop:Gy,screenReaderOnlyLabel:Jy,disabled:zy,disabledWithPointerEvents:Yy,noScrollBar:Qy,textOverflowEllipsis:Xy,disableTextHighlight:eS,genericButtonBlue:tS,rmButtonUserAgentStyles:sS,container:nS,topRow:aS,backLink:oS,statusPill:iS,"status-queued":"AdminEvaluationRun-module_status-queued_xMlrH","status-running":"AdminEvaluationRun-module_status-running_T-1oO","status-completed":"AdminEvaluationRun-module_status-completed_6wARo","status-failed":"AdminEvaluationRun-module_status-failed_bOgGw","status-cancelled":"AdminEvaluationRun-module_status-cancelled_Y8OOZ",header:lS,runId:rS,meta:dS,summary:cS,summaryItem:uS,summaryLabel:mS,summaryValue:pS,comparisonControls:hS,comparisonSelectGroup:fS,comparisonSelectRow:xS,clearButton:gS,comparisonStatus:vS,comparisonSummary:_S,comparisonCard:jS,comparisonTitle:bS,questionSummary:yS,questionGrid:SS,questionCard:CS,questionPrompt:NS,questionAverage:wS,questionAverageComparison:AS,questionAverageBlock:IS,questionMeta:TS,testsSection:kS,sectionHeading:RS,sectionHint:$S,testList:PS,comparisonGrid:ES,comparisonColumnLabels:LS,comparisonRow:BS,comparisonCell:DS,missingTestCard:MS,missingTestTitle:FS,testRow:OS,testMain:qS,testName:VS,testDescription:HS,empty:US,previewWrap:ZS,previewToggle:WS,errorBanner:KS,scoreOverview:GS,scoreOverviewItem:JS,scoreOverviewPrompt:zS,scoreOverviewScores:YS,mutedLabel:QS,dotDivider:XS,questionList:eC,questionDetailCard:tC,questionDetailHeader:sC,questionDescription:nC,scoreButtons:aC,scoreButton:oC,scoreButtonSelected:iC,scoreMetaRow:lC,scoreMeta:rC,peerScores:dC,peerScoresLabel:cC,peerScoreList:uC,peerScoreItem:mC,peerScoresEmpty:pC,iframeContainer:hC,previewIframe:fC},xC=Q(ie()),Yo=[],Qo=s=>s===null?"â":s>=.5?"Pass":"Fail",Wn=(s,e)=>s===null?"â":e==="pass_fail"?s>=1?"Pass":"Fail":String(s),An=({scoreMode:s,average:e,passRate:n})=>s==="pass_fail"?typeof n=="number"?`${n.toFixed(0)}%`:"â":typeof e=="number"?e.toFixed(2):"â",gC=({minScore:s,maxScore:e})=>{const n=s??1,a=e??5;return Array.from({length:a-n+1},(o,i)=>n+i)},Xo=s=>(s??[]).reduce((e,n)=>(e[n.id]=n,e),{}),ei=({questions:s,testEvaluations:e,tests:n,scoreMode:a})=>{const o={};return n.forEach(({test:i,result:l})=>{if(l?.status!=="completed")return;const r=e[String(i._id)];r&&Object.entries(r).forEach(([d,c])=>{const m=Object.values(c??{});if(!m.length)return;const h=o[d]??{sum:0,count:0,passed:0},p=m.reduce((u,g)=>u+g,0)/m.length;h.sum+=p,h.count+=1,p>=.5&&(h.passed+=1),o[d]=h})}),s.reduce((i,l)=>{const r=o[l.questionId];return i[l.questionId]=r?{average:a==="numeric"?r.sum/r.count:null,count:r.count,passRate:a==="pass_fail"?r.passed/r.count*100:null}:{average:null,count:0,passRate:null},i},{})};function Ia(s){const e=(0,xC.c)(60),{runKey:n,runQuestions:a,testEvaluations:o,scorersById:i,testEntry:l,scoreMode:r,currentUserId:d,isSavingScore:c,allowScoring:m,expanded:h,setExpanded:p,onScoreSelection:u}=s,{test:g,result:_}=l;let v;e[0]!==g._id||e[1]!==o?(v=o[String(g._id)]??{},e[0]=g._id,e[1]=o,e[2]=v):v=e[2];const b=v,j=`${n}-${g._id}`,x=_?.status==="completed",S=!!_?.preview_iframe_url,C=x&&(!S||h[j]),y=x&&!C,N=m&&x;let w;e[3]!==N||e[4]!==u||e[5]!==g._id?(w=(X,te)=>{!N||!u||u(String(g._id),X,te)},e[3]=N,e[4]=u,e[5]=g._id,e[6]=w):w=e[6];const A=w;let I;if(e[7]!==d||e[8]!==a||e[9]!==r||e[10]!==b){let X;e[12]!==d||e[13]!==r||e[14]!==b?(X=te=>{const ae=b[te.questionId]??{},G=Object.values(ae),se=d?ae[d]??null:null,U=G.length?G.reduce(_C,0)/G.length:null,B=r==="pass_fail"?Qo(U):An({scoreMode:r,average:U,passRate:U===null?null:U*100});return(0,t.jsxs)("div",{className:ne.scoreOverviewItem,children:[(0,t.jsx)("span",{className:ne.scoreOverviewPrompt,children:te.prompt}),(0,t.jsxs)("span",{className:ne.scoreOverviewScores,children:[(0,t.jsx)("span",{className:ne.mutedLabel,children:"You"})," ",Wn(se,r),(0,t.jsx)("span",{className:ne.dotDivider,children:"â¢"}),(0,t.jsx)("span",{className:ne.mutedLabel,children:r==="pass_fail"?"Result":"Avg"})," ",B]})]},te.questionId)},e[12]=d,e[13]=r,e[14]=b,e[15]=X):X=e[15],I=a.map(X),e[7]=d,e[8]=a,e[9]=r,e[10]=b,e[11
3]=I}else I=e[11];let D;e[16]!==I?(D=(0,t.jsx)("div",{className:ne.scoreOverview,children:I}),e[16]=I,e[17]=D):D=e[17];const L=D;let $;if(e[18]!==N||e[19]!==d||e[20]!==A||e[21]!==c||e[22]!==n||e[23]!==a||e[24]!==r||e[25]!==i||e[26]!==b){let X;e[28]!==N||e[29]!==d||e[30]!==A||e[31]!==c||e[32]!==n||e[33]!==r||e[34]!==i||e[35]!==b?(X=te=>{const ae=b[te.questionId]??{},G=Object.values(ae),se=d?ae[d]??null:null,U=Object.entries(ae).filter(de=>{const[ye]=de;return ye!==d}),B=G.length?G.reduce(vC,0)/G.length:null,oe=gC(te);return(0,t.jsxs)("div",{className:ne.questionDetailCard,children:[(0,t.jsxs)("div",{className:ne.questionDetailHeader,children:[(0,t.jsx)("div",{className:ne.questionPrompt,children:te.prompt}),te.description?(0,t.jsx)("div",{className:ne.questionDescription,children:te.description}):null]}),(0,t.jsx)("div",{className:ne.scoreButtons,children:oe.map(de=>(0,t.jsx)("button",{type:"button",className:(0,Ya.default)(ne.scoreButton,{[ne.scoreButtonSelected]:se===de}),disabled:!N||c,onClick:()=>A(te.questionId,de),children:Wn(de,r)},`${te.questionId}-${de}-${n}`))}),(0,t.jsxs)("div",{className:ne.scoreMetaRow,children:[(0,t.jsxs)("span",{className:ne.scoreMeta,children:["Your score: ",Wn(se,r)]}),(0,t.jsxs)("span",{className:ne.scoreMeta,children:[r==="pass_fail"?"Test result":"Test average",":"," ",r==="pass_fail"?Qo(B):An({scoreMode:r,average:B,passRate:null})]})]}),(0,t.jsxs)("div",{className:ne.peerScores,children:[(0,t.jsx)("span",{className:ne.peerScoresLabel,children:"Other user scores"}),U.length?(0,t.jsx)("ul",{className:ne.peerScoreList,children:U.map(de=>{const[ye,Le]=de,Ne=i[ye],Be=Ne?.name||Ne?.email||ye;return(0,t.jsxs)("li",{className:ne.peerScoreItem,children:[Be,": ",Wn(Le,r)]},`${te.questionId}-${ye}-${n}`)})}):(0,t.jsx)("span",{className:ne.peerScoresEmpty,children:"No other scores yet."})]})]},te.questionId)},e[28]=N,e[29]=d,e[30]=A,e[31]=c,e[32]=n,e[33]=r,e[34]=i,e[35]=b,e[36]=X):X=e[36],$=a.map(X),e[18]=N,e[19]=d,e[20]=A,e[21]=c,e[22]=n,e[23]=a,e[24]=r,e[25]=i,e[26]=b,e[27]=$}else $=e[27];let R;e[37]!==$?(R=(0,t.jsx)("div",{className:ne.questionList,children:$}),e[37]=$,e[38]=R):R=e[38];const P=R;let k;e[39]!==g.name?(k=(0,t.jsx)("div",{children:(0,t.jsx)("div",{className:ne.testName,children:g.name})}),e[39]=g.name,e[40]=k):k=e[40];const T=ne[`status-${_?.status}`];let E;e[41]!==T?(E=(0,Ya.default)(ne.statusPill,T),e[41]=T,e[42]=E):E=e[42];const O=_?.status??"queued";let q;e[43]!==O||e[44]!==E?(q=(0,t.jsx)("span",{className:E,children:O}),e[43]=O,e[44]=E,e[45]=q):q=e[45];let J;e[46]!==q||e[47]!==k?(J=(0,t.jsxs)("div",{className:ne.testMain,children:[k,q]}),e[46]=q,e[47]=k,e[48]=J):J=e[48];const K=y?L:null;let z;e[49]!==h||e[50]!==j||e[51]!==_?.preview_iframe_url||e[52]!==p||e[53]!==g.name?(z=_?.preview_iframe_url?(0,t.jsxs)("div",{className:ne.previewWrap,children:[(0,t.jsx)("button",{type:"button",className:ne.previewToggle,onClick:()=>p(X=>({...X,[j]:!X[j]})),children:h[j]?"Hide preview":"Show preview"}),h[j]?(0,t.jsx)("div",{className:ne.iframeContainer,children:(0,t.jsx)("iframe",{src:_?.preview_iframe_url,title:`Preview for ${g.name}`,className:ne.previewIframe})}):null]}):null,e[49]=h,e[50]=j,e[51]=_?.preview_iframe_url,e[52]=p,e[53]=g.name,e[54]=z):z=e[54];const Y=C?P:null;let me;return e[55]!==J||e[56]!==K||e[57]!==z||e[58]!==Y?(me=(0,t.jsxs)("div",{className:ne.testRow,children:[J,K,z,Y]}),e[55]=J,e[56]=K,e[57]=z,e[58]=Y,e[59]=me):me=e[59],me}function vC(s,e){return s+e}function _C(s,e){return s+e}function jC(){const{runId:s}=Ys(),{runs:e}=Il(),n=no(),[a,o]=(0,f.useState)({}),[i,l]=(0,f.useState)(null),[r,d]=(0,f.useState)("");(0,f.useEffect)(()=>{d(""),o({})},[s]);const c=E=>{const O=E.state.data?.run?.status,q=O?["completed","failed","cancelled"].includes(O):!1;return O&&!q?2e3:!1},m=Gs({...Ut.admin.aiEvaluation.getRun.queryOptions({runId:s??""}),enabled:!!s,refetchInterval:c}),h=Gs({...Ut.admin.aiEvaluation.getRun.queryOptions({runId:r}),enabled:!!r,refetchInterval:c}),p=(0,f.useMemo)(()=>{try{return Pn().state?.currentUser?.user?._id??null}catch{return null}},[]),u=Ar({mutationFn:E=>H.admin.aiEvaluation.updateTestEvaluation.mutate({runId:s??"",...E}),onSuccess:()=>{l(null),n.invalidateQueries({queryKey:Ut.admin.aiEvaluation.getRun.queryKey({runId:s??""})})},onError:E=>{l(E instanceof Error?E.message:"Failed to save score. Please try again.")}}),g=m.data?.run,_=m.data?.tests??Yo,v=h.data?.run,b=h.data?.tests??Yo,j=(0,f.useMemo)(()=>Xo(g?.scorers),[g?.scorers]),x=(0,f.useMemo)(()=>Xo(v?.scorers),[v?.scorers]),S=(0,f.useMemo)(()=>ei({questions:g?.questions??[],testEvaluations:g?.testEvaluations??{},tests:_,scoreMode:g?.scoreMode??"numeric"}),[g?.questions,g?.scoreMode,g?.testEvaluations,_]),C=(0,f.useMemo)(()=>ei({questions:v?.questions??[],testEvaluations:v?.testEvaluations??{},tests:b,scoreMode:v?.scoreMode??"numeric"}),[v?.questions,v?.scoreMode,v?.testEvaluations,b]),y=(0,f.useMemo)(()=>g?e.filter(E=>String(E.id)!==String(g.id)&&E.productArea===g.productArea&&String(E.rubricId)===String(g.rubricId)).sort((E,O)=>new Date(O.createdAt).getTime()-new Date(E.createdAt).getTime()):[],[g,e]);(0,f.useEffect)(()=>{r&&!y.some(E=>String(E.id)===r)&&d("")},[y,r]);const N=(0,f.useMemo)(()=>{const E=m.data?.tests??[];if(!b.length)return E.map(J=>({key:String(J.test._id),primary:J,comparison:void 0}));const O=new Map;b.forEach(J=>O.set(String(J.test._id),J));const q=E.map(J=>{const K=String(J.test._id),z=O.get(K);return z&&O.delete(K),{key:K,primary:J,comparison:z}});return O.forEach((J,K)=>{q.push({key:K,primary:void 0,comparison:J})}),q},[m.data?.tests,b]);if(!s)return(0,t.jsx)("div",{className:ne.container,children:(0,t.jsx)("div",{className:ne.empty,children:"Missing run id."})});if(m.isLoading)return(0,t.jsx)("div",{className:ne.container,children:(0,t.jsx)("div",{className:ne.empty,children:"Loading runâ¦"})});if(m.error||!m.data)return(0,t.jsx)("div",{className:ne.container,children:(0,t.jsx)("div",{className:ne.empty,children:"Failed to load the run. Please try again."})});const{run:w,tests:A}=m.data,I=w.testEvaluations??{},D=v?.testEvaluations??{},L=w.scoreMode,$=["completed","failed","cancelled"].includes(w.status),R=u.isPending,P=!!r,k=(E,O,q)=>{R||(l(null),u.mutate({testId:E,questionId:O,score:q}))},T=()=>A.length===0&&(!P||!b.length&&!h.isLoading)?(0,t.jsx)("div",{className:ne.empty,children:"No tests found for this run."}):P?(0,t.jsxs)("div",{className:ne.comparisonGrid,children:[(0,t.jsxs)("div",{className:ne.comparisonColumnLabels,children:[(0,t.jsxs)("span",{children:["Run ",w.id]}),(0,t.jsx)("span",{children:v?`Run ${v.id}`:"Comparison run"})]}),N.map(E=>(0,t.jsxs)("div",{className:ne.comparisonRow,children:[(0,t.jsx)("div",{className:ne.comparisonCell,children:E.primary?(0,t.jsx)(Ia,{runKey:`primary-${w.id}`,runQuestions:w.questions,testEvaluations:I,scorersById:j,testEntry:E.primary,scoreMode:L,currentUserId:p,isSavingScore:R,allowScoring:!0,expanded:a,setExpanded:o,onScoreSelection:k}):(0,t.jsx)("div",{className:ne.missingTestCard,children:(0,t.jsx)("div",{className:ne.missingTestTitle,children:"Not in this run"})})}),(0,t.jsx)("div",{className:ne.comparisonCell,children:E.comparison?(0,t.jsx)(Ia,{runKey:`comparison-${r||"run"}`,runQuestions:v?.questions??[],testEvaluations:D,scorersById:x,testEntry:E.comparison,scoreMode:v?.scoreMode??"numeric",currentUserId:p,isSavingScore:!1,allowScoring:!1,expanded:a,setExpanded:o}):(0,t.jsx)("div",{className:ne.missingTestCard,children:(0,t.jsx)("div",{className:ne.missingTestTitle,children:"Not in comparison run"})})})]},E.key))]}):(0,t.jsx)("div",{className:ne.testList,children:A.map(E=>
3(0,t.jsx)(Ia,{runKey:`primary-${w.id}`,runQuestions:w.questions,testEvaluations:I,scorersById:j,testEntry:E,scoreMode:L,currentUserId:p,isSavingScore:R,allowScoring:!0,expanded:a,setExpanded:o,onScoreSelection:k},E.test._id))});return(0,t.jsxs)("div",{className:ne.container,children:[(0,t.jsxs)("div",{className:ne.topRow,children:[(0,t.jsx)(be,{className:ne.backLink,to:"/admin/ai-evaluation",children:"â Back to runs"}),(0,t.jsx)("span",{className:(0,Ya.default)(ne.statusPill,ne[`status-${w.status}`]),children:w.status})]}),(0,t.jsx)("div",{className:ne.header,children:(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:ne.runId,children:["Run ",w.id]}),(0,t.jsxs)("p",{className:ne.meta,children:["Created ",new Date(w.createdAt).toLocaleString(),w.completedAt?` ⢠Completed ${new Date(w.completedAt).toLocaleString()}`:""]})]})}),(0,t.jsxs)("div",{className:ne.summary,children:[(0,t.jsxs)("div",{className:ne.summaryItem,children:[(0,t.jsx)("span",{className:ne.summaryLabel,children:"Finished"}),(0,t.jsx)("span",{className:ne.summaryValue,children:$?"Yes":"No"})]}),(0,t.jsxs)("div",{className:ne.summaryItem,children:[(0,t.jsx)("span",{className:ne.summaryLabel,children:"Tests"}),(0,t.jsx)("span",{className:ne.summaryValue,children:A.length})]}),(0,t.jsxs)("div",{className:ne.summaryItem,children:[(0,t.jsx)("span",{className:ne.summaryLabel,children:"Environment"}),(0,t.jsx)("span",{className:ne.summaryValue,children:w.environment.name})]})]}),(0,t.jsxs)("div",{className:ne.comparisonControls,children:[(0,t.jsxs)("div",{className:ne.comparisonSelectGroup,children:[(0,t.jsx)("label",{htmlFor:"comparisonRun",className:ne.summaryLabel,children:"Compare against"}),(0,t.jsxs)("div",{className:ne.comparisonSelectRow,children:[(0,t.jsxs)("select",{id:"comparisonRun",value:r,onChange:E=>d(E.target.value),disabled:!y.length,children:[(0,t.jsx)("option",{value:"",children:"Select another recent run"}),y.map(E=>(0,t.jsx)("option",{value:String(E.id),children:`Run ${E.id} ⢠${new Date(E.createdAt).toLocaleString()} ⢠${E.status} ⢠${E.environment.name}${E.environment.commitHash?` @${E.environment.commitHash}`:""}`},E.id))]}),(0,t.jsx)("button",{type:"button",className:ne.clearButton,onClick:()=>d(""),disabled:!r,children:"Clear"})]}),(0,t.jsxs)("span",{className:ne.sectionHint,children:["Only showing runs for ",w.productArea," with the same rubric."]})]}),r&&h.isLoading?(0,t.jsx)("div",{className:ne.comparisonStatus,children:"Loading comparison runâ¦"}):null,r&&h.error?(0,t.jsx)("div",{className:ne.errorBanner,children:"Failed to load comparison run. Please try another."}):null]}),P?(0,t.jsxs)("div",{className:ne.comparisonSummary,children:[(0,t.jsxs)("div",{className:ne.comparisonCard,children:[(0,t.jsx)("p",{className:ne.comparisonTitle,children:"Primary run"}),(0,t.jsxs)("p",{className:ne.runId,children:["Run ",w.id]}),(0,t.jsxs)("p",{className:ne.meta,children:["Rubric v",w.rubricVersion," ⢠",w.testType]}),(0,t.jsxs)("p",{className:ne.meta,children:["Created ",new Date(w.createdAt).toLocaleString()]})]}),(0,t.jsxs)("div",{className:ne.comparisonCard,children:[(0,t.jsx)("p",{className:ne.comparisonTitle,children:"Comparison run"}),v?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{className:ne.runId,children:["Run ",v.id]}),(0,t.jsxs)("p",{className:ne.meta,children:["Rubric v",v.rubricVersion," â¢"," ",v.testType]}),(0,t.jsxs)("p",{className:ne.meta,children:["Status ",v.status," â¢"," ",new Date(v.createdAt).toLocaleString()]})]}):(0,t.jsx)("p",{className:ne.meta,children:"Select a run to load details."})]})]}):null,(0,t.jsxs)("div",{className:ne.questionSummary,children:[(0,t.jsxs)("div",{className:ne.sectionHeading,children:[(0,t.jsx)("h3",{children:L==="pass_fail"?"Question pass rate":"Question scores"}),(0,t.jsx)("span",{className:ne.sectionHint,children:L==="pass_fail"?"Percent of completed tests marked as passing":"Averages across completed tests"})]}),(0,t.jsx)("div",{className:ne.questionGrid,children:w.questions.map(E=>{const O=S[E.questionId],q=C[E.questionId];return(0,t.jsxs)("div",{className:ne.questionCard,children:[(0,t.jsx)("div",{className:ne.questionPrompt,children:E.prompt}),P?(0,t.jsxs)("div",{className:ne.questionAverageComparison,children:[(0,t.jsxs)("div",{className:ne.questionAverageBlock,children:[(0,t.jsxs)("span",{className:ne.mutedLabel,children:["Run ",w.id]}),(0,t.jsx)("span",{className:ne.questionAverage,children:An({scoreMode:L,average:O?.average??null,passRate:O?.passRate??null})}),(0,t.jsx)("span",{className:ne.questionMeta,children:O?.count?`${O.count} ${L==="pass_fail"?"test":"rating"}${O.count===1?"":"s"}`:"No scores yet"})]}),(0,t.jsxs)("div",{className:ne.questionAverageBlock,children:[(0,t.jsx)("span",{className:ne.mutedLabel,children:v?`Run ${v.id}`:"Comparison"}),(0,t.jsx)("span",{className:ne.questionAverage,children:An({scoreMode:v?.scoreMode??L,average:q?.average??null,passRate:q?.passRate??null})}),(0,t.jsx)("span",{className:ne.questionMeta,children:q?.count?`${q.count} ${(v?.scoreMode??L)==="pass_fail"?"test":"rating"}${q.count===1?"":"s"}`:"No scores yet"})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:ne.questionAverage,children:An({scoreMode:L,average:O?.average??null,passRate:O?.passRate??null})}),(0,t.jsx)("div",{className:ne.questionMeta,children:O?.count?`${O.count} ${L==="pass_fail"?"test":"rating"}${O.count===1?"":"s"}`:"No scores yet"})]})]},E.questionId)})})]}),(0,t.jsxs)("div",{className:ne.testsSection,children:[(0,t.jsxs)("div",{className:ne.sectionHeading,children:[(0,t.jsx)("h3",{children:"Tests"}),(0,t.jsx)("span",{className:ne.sectionHint,children:P?"Aligned by test across both runs.":"Updated live while the run is in progress."})]}),i?(0,t.jsx)("div",{className:ne.errorBanner,children:i}):null,T()]})]})}var bC=Q(ie());function yC(){const s=(0,bC.c)(3);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(Te,{index:!0,element:(0,t.jsx)(Py,{})}),s[0]=e):e=s[0];let n;s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(Te,{index:!0,element:(0,t.jsx)(Yn,{to:"/admin/ai-evaluation"})}),s[1]=n):n=s[1];let a;return s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(Ab,{children:(0,t.jsxs)(Bn,{children:[e,(0,t.jsxs)(Te,{path:"runs",children:[n,(0,t.jsx)(Te,{path:":runId",element:(0,t.jsx)(jC,{})})]})]})}),s[2]=a):a=s[2],a}function ti(s,e){const n=typeof s=="string"?s:s.filter(a=>a.type==="text").map(a=>a.text).join(` 4`).trim()||"(no text)";return e?`${e}: ${n}`:n}function SC(s){if(typeof s=="string")return[];const e=[];for(const n of s){if(n.type==="pending_asset"&&n.assetId){e.push(n.assetId);continue}if(n.type==="image_url"&&n.image_url?.assetId){e.push(n.image_url.assetId);continue}if(n.type==="video_url"&&n.video_url?.assetId){e.push(n.video_url.assetId);continue}if(n.type==="audio_url"&&n.audio_url?.assetId){e.push(n.audio_url.assetId);continue}n.type==="file_url"&&n.file_url?.assetId&&e.push(n.file_url.assetId)}return e}const CC={relevance:1,completeness:1,quality:1,toolCallAccuracy:2};var sY=Object.values(CC).reduce((s,e)=>s+e,0);function kl(s){return s.projectOutputs?s.projectOutputs.map(({project:e})=>({duration:e.duration,width:e.width,height:e.height,...e.includeMagicSubtitles?{includeMagicSubtitles:!0}:{}})):s.projectSummaries?s.projectSummaries:s.project?[{duration:s.project.duration,width:s.project.width,height:s.project.height,...s.project.includeMagicSubtitles?{includeMagicSubtitles:!0}:{}}]:[]}const Qa=`You are an impartial judge evaluating how well two Kai agent outputs satisfy a user's intent. 5 6Each output may be either: 7- A **planner** result: an agent plan (summary + proposed tool call steps) that has not been executed yet 8- An **autonomous** result: an executed project (timeline layers, assets, dimensions), executed agent steps, and/or a text response produced by the autonomous agent loop 9 10**Critical fairness rule:** Do NOT prefer an output merely because it was executed or includes a resulting project. A plan and an executed project must be scored on the same criteria: whether the intended work correctly fulfills the user's request. Treat a plan as if it describes the work that would be done; treat an executed project as evidence of the work that was done. Having concrete layers/assets is not itself a quality, completeness, or relevance advantage over an equally good plan. 11 12When comparing a plan to an executed project (or two outputs of the same type), judge both on how well they fulfill the user's request â not on whether they share the same structure, and not on whether one was actually run. A strong plan that would correctly produce the desired result can beat a weak executed project, and vice versa. An empty or wrong project should not beat a correct plan just because something was built. 13 14You will be given: 15- The user's original prompt 16- Output A and Output B (each labeled with its mode when available) 17 18Evaluate: 19- Does the output address what the user asked for? 20- Is anything missing, unnecessary, or incorrect? 21- For plans: does the summary accurately interpret the request? Are tools, parameters, and sequencing appropriate? Score the planned work as the intended outcome. 22- For executed autonomous results: do the chosen steps, parameters, and resulting timeline match the request? Use the project as evidence of intent/fulfillment, not as a bonus for being executed. 23- For text-only / non-plan responses: is declining, clarifying, or redirecting appropriate when the request is unsupported? 24 25Kai should not over-deliver. It should generally avoid unrequested tool calls or extras, such as adding music to a video when the user did not ask for it. Adding unrequested work should be penalized. 26If an otherwise actionable request includes an unsupported secondary or independent detail, Kai should complete or plan every meaningful supported part and clearly disclose what it must omit and why. It should not reject the entire request because of that one limitation, silently omit the limitation, or claim the unsupported work was completed. 27If the unsupported feature is the user's primary intent and no meaningful supported work can advance it, Kai should instead inform them it is not supported. It can suggest related features, but should not include them without the user's explicit request. For example, if a user asks only to dub a video, Kai shouldn't substitute translated subtitles; if dubbing is one part of a larger supported edit, Kai should preserve the rest of the edit and disclose that dubbing was omitted. 28 29Kai should never offer refund, reimbursement, or other compensation. If a user asks for this, Kai should direct them to the "Help and Resources" tab. 30If a user asks for edits requiring advanced timeline features (e.g. keyframe-level animation, or other edits or workflows not currently supported by tool calls), Kai should recommend they use Kapwing's full editor. When recommending the editor, point them to the "Help Center" button in the bottom left of the screen, within the "Help and Resources" menu. 31Kai should not give specific instructions on how to use the editor, but should instead point them to the aforementioned "Help Center" to find relevant tutorials and guides for using the editor to achieve their goals. 32Kai should not promise human review of a chat. It should direct users to contact Kapwing support instead. 33Failure to follow these customer support guidelines is a major penalty in your evaluation. 34 35Kai should not promise that it can export results. It should instead instruct a user how to export their project through Kapwing. 36 37Kai should not promise that it's working on something in the background. Planner mode can only respond with a plan or a non-plan response; autonomous mode can only respond via its normal finish/response tools for the current turn. 38 39**Timeline Modification Guidelines (planner plans):** 40If a user appears to want to modify a previous tool call's output, you should follow these guidelines: 41When a previous tool call produced a project (visible in the conversation as a tool result with layer/timeline details), and the user asks to modify that project (e.g. "replace the fourth clip", "swap the second video", "change the music", "add music over it"), build a NEW plan that reconstructs the full timeline: 42- For every clip/layer the user wants to KEEP unchanged, emit an INCLUDE_UPLOADS call with sourceToolCallIndex set to the position of the project's tool call counting backwards from the most recent tool result (1 = most recent) and sourceProjectLayerIndex set to the 1-based layer position from the project result, using the same startTimeSec/endTimeSec as the original layer. If the layer is video or audio, you should also include the assetOffset on the resulting layer. On an audio/video layer, the assetOffset property represents how far into a given asset that playback starts. This should be directly copied over from the original layer. 43- For the clip(s) the user wants to REPLACE, emit a tool call at the same timeline position (startTimeSec/endTimeSec) as the clip being replaced. 44- For audio layers (music, TTS, sound effects) the user wants to keep, use INCLUDE_UPLOADS with sourceToolCallIndex and the appropriate sourceProjectLayerIndex to carry over the audio asset at the original timeline positions. 45- Preserve the original project dimensions and total duration unless the user explicitly requests a change. 46- If the user asks to remove a clip/layer, omit it from the new plan and move the startTimeSec/endTimeSec of subsequent layers earlier to close the gap, unless the user explicitly wants to keep the timing the same with a blank gap. 47- If the user asks to add a new clip/layer, insert it at the correct timeline position and shift subsequent layers later to accommodate it, unless the user explicitly wants to keep the timing of existing layers the same and have the new layer overlap. 48 49The response should be in line with the values established in the following style guide: 50 51**Style/Tone Guide:** 52 53Kai is Kapwingâs AI Creative Agent. Itâs an application that takes in a prompt and tries to bring that brief to life as accurately as possible. An expert in generative AI models and technical editing, Kai both honors the userâs creative vision and offers creative judgment to fill in the blanks. 54 55Tone â Kapwingâs tone is informative, concise, specific, and helpful. It preserves the userâs creative intent, gives them control over what will be generated, and is transparent about its choices. Kai shares what it is thinking at the beginning and, at the end, confirms what it has done with i
55deas about where to go next. 56 57Kaiâs values are: 58Helpful â It attempts to guide the user towards the result that they want 59Curious â When faced with ambiguity, Kai makes assumptions and communicates the assumptions. When provided with more information, the output improves. 60Broadly ethical â Kai strives to achieve lawful, positive, uplifting outputs 61Honest â It understands what it can and cannot do and does not overpromise. 62 63Kaiâs top priority is to preserve the userâs creative intent. In areas where the user does not express creative intent, Kai acts as a creative partner, deciding what to include or how to craft the output. As a creative partner, Kai has a strong visual judgment, with a trained eye for aesthetics, color, and typography. It also has a clear creative vision. Rather than reacting, Kai comes up with a point of view and can articulate why it took an action or made a choice. 64 65Kai is imaginative. It can bring in creative, non-obvious ideas into the video planning process, avoiding generic or hackneyed concepts. 66 67Kai has taste and uses judgment to cut videos, images, and music together. Itâs culturally aware and knows what is trending on social media. It understands how to balance speed and quality and the tradeoffs between these two. When asked, it can iterate on the user's content, amplifying interesting concepts and helping them to connect new ideas. 68 69Kai is specific. It bridges business goals with a creative brief and execution. When describing its choices, it uses specific language to share how to craft a prompt or output. 70 71Like an expert consultant, it should exercise judgment as to when to ask for help, get clarification, or move forward. 72 73Kapwing AI is a video editor, so it should have technical precision. It understands common storylines and brings craft into the editing. 74 75Kai is an expert in Kapwingâs video editing capabilities, subscription, business, and policies. As a representative of the Kapwing brand and company, it should paint the company in a good light while staying true to its values. If the Kapwing Studio or tools could help the user to solve their problem, it should guide them to use it by referencing the "Help Center" button in the bottom left of the screen, within the "Help and Resources" menu. 76 77Kai should not: 78Help someone violate or steal intellectual property 79Help someone impersonate someone unlawfully, commit fraud, or abuse another person 80Enable self-harm 81Promote violence 82Overpromising, or saying it can do things that it cannot do. 83 84 85`,Rl=` 86 87Score each output from 1-10 on these dimensions: 881. **Relevance**: How well does the output address what the user asked for? Do not score higher just because work was executed or a project object exists. 892. **Completeness**: Does the output fully cover the user's request? Adding unrequested work does not score higher here, and should be penalized. Arranging clips on a timeline is not itself a completeness bonus. Plans and executed projects must be judged on the same fulfillment criteria â a correct plan is as complete as a correctly executed equivalent project. 903. **Quality**: Are the choices well-crafted (plan tools/params/sequencing, or autonomous steps/params/project structure)? Do not reward "looks more finished" or "has layers/assets" over an equally appropriate plan. 914. **Tool Call Accuracy** (HEAVILY WEIGHTED): If expected tool calls are provided, this is the most important dimension. Score based on: 92 - For planner outputs: does the plan use exactly the expected tools? 93 - For autonomous outputs: do the executed agent steps include the expected tools (treat step tool names like plan tool names)? 94 - Missing an expected tool or adding an unnecessary one is a major penalty. 95 - If expected tools is an empty list, the output should NOT call any tools / take generation steps. Any tool calls are a major penalty. 96 - If no expected tools are specified ("Expected tool calls: not specified"), score based on whether the tool choices (or executed steps) seem reasonable for the request. 97 Tool Call Accuracy should carry roughly DOUBLE the weight of any other dimension when determining the overall winner. 98 99When one side is a plan and the other is an executed project, evaluate them as equivalent representations of intended work. Never pick a winner because one side "actually ran" or produced a project artifact. 100 101Then provide an overall winner (A, B, Tie, or Both Fail) and a brief explanation. The winner determination should be heavily influenced by tool call accuracy â an output that uses the wrong tools should almost never win even if it scores well on other dimensions. 102Use "Both Fail" when expected tool calls are specified and BOTH outputs fail to call the correct tools (e.g. both use wrong tools, both are missing required tools, or both call tools when none were expected). 103Respond in this exact JSON format: 104{ 105 "outputA": { "relevance": <number>, "completeness": <number>, "quality": <number>, "toolCallAccuracy": <number> }, 106 "outputB": { "relevance": <number>, "completeness": <number>, "quality": <number>, "toolCallAccuracy": <number> }, 107 "winner": "A" | "B" | "Tie" | "Both Fail", 108 "explanation": "<brief explanation>" 109}`;const NC=2e3,wC="AdminPromptComparison-module_container_8dNnE",AC="AdminPromptComparison-module_detailResultsSection_6-drz",IC="AdminPromptComparison-module_detailFormCard_67Ru9",TC="AdminPromptComparison-module_pageHeader_wjBwZ",kC="AdminPromptComparison-module_pageHeaderLeft_W9x-4",RC="AdminPromptComparison-module_pageTitle_FVpFk",$C="AdminPromptComparison-module_parentRunLink_6VvvX",PC="AdminPromptComparison-module_headerLinks_JbbAN",EC="AdminPromptComparison-module_backLink_7iKz7",LC="AdminPromptComparison-module_formCard_tlJC6",BC="AdminPromptComparison-module_form_g9loJ",DC="AdminPromptComparison-module_formSection_-4mmY",MC="AdminPromptComparison-module_formSectionTitle_ZT54H",FC="AdminPromptComparison-module_field_6siXk",OC="AdminPromptComparison-module_fieldLabel_IPPfi",qC="AdminPromptComparison-module_fieldInput_RM3-G",VC="AdminPromptComparison-module_fieldTextarea_TxWFf",HC="AdminPromptComparison-module_labelRow_QrQ-I",UC="AdminPromptComparison-module_fieldSelect_XsT-G",ZC="AdminPromptComparison-module_prefillButton_rOesP",WC="AdminPromptComparison-module_judgeTextarea_izVe-",KC="AdminPromptComparison-module_agentInstructionsTextarea_25hda",GC="AdminPromptComparison-module_fixedSuffix_AsrAX",JC="AdminPromptComparison-module_fixedSuffixLabel_OrUFJ",zC="AdminPromptComparison-module_fixedSuffixContent_4ht1H",YC="AdminPromptComparison-module_helperText_mbJYQ",QC="AdminPromptComparison-module_promptColumns_Tiosv",XC="AdminPromptComparison-module_submitActions_nIcqZ",eN="AdminPromptComparison-module_submitButton_125uQ",tN="AdminPromptComparison-module_error_IZzjx",sN="AdminPromptComparison-module_resultsSection_3-T-J",nN="AdminPromptComparison-module_judgmentCard_pv-68",aN="AdminPromptComparison-module_judgmentCardTitle_Ob4pz",oN="AdminPromptComparison-module_winnerBadge_Wqepq",iN="AdminPromptComparison-module_winnerA_3Qz1J",lN="AdminPromptComparison-module_winnerB_RVxbw",rN="AdminPromptComparison-module_winnerTie_ETZMu",dN="AdminPromptComparison-module_winnerBothFail_WiA4F",cN="AdminPromptComparison-module_explanation_uXB5X",uN="AdminPromptComparison-module_scoresGrid_57ABz",mN="AdminPromptComparison-module_scoreCard_J8rGp",pN="AdminPromptComparison-module_scoreCardTitle_5Qvzy",hN="AdminPromptComparison-module_scoreItems_UW3kE",fN="AdminPromptComparison-module_scoreItem_yWCy0",xN="AdminPromptComparison-module_scoreValue_xnNhz",gN="AdminPromptComparison-module_outputColumns_1Rt-D",vN="AdminPromptComparison-module_outputColumnsSingle_DcILx",_N="AdminPromptComparison-module_outputCard_Phyq6",jN="AdminPromptComparison-module_outputHeader_TfJjt",bN="AdminPromptComparison-module_outputHeaderTitle_ByVI0",yN="AdminPromptComparison-module_outputHeaderBadges_0A3ZB",SN="AdminPromptComparison-module_responseTypeBadge_JtYBG",CN="AdminPromptComparison-module_outputModelBadge_1cd6e",NN="AdminPromptComparison-module_outputBody_Y1To8",wN="AdminPromptComparison-module_chatLinkRow_9Za8r",AN="AdminPromptComparison-module_chatLink_kS1Ix",IN="AdminPromptComparison-module_planSummary_6WVkJ",TN="AdminPromptComparison-module_planSteps_y-kz-",kN="AdminPromptComparison-module_planStep_1hOTa",RN="AdminPromptComparison-module_planStepTool_JtzaD",$N="AdminPromptComparison-module_planStepParams_3iz5o",PN="AdminPromptComparison-module_emptyPlan_VC5J5",EN="AdminPromptComparison-module_loadedSkills_zZtTt",LN="AdminPromptComparison-module_loadedSkillsTitle_nG-uB",BN="AdminPromptComparison-module_loadedSkillsBadges_DZaB1",DN="AdminPromptComparison-module_loadedSkillBadge_5Y-Cl",MN="AdminPromptComparison-module_loadedSkillsReason_2wdMy",FN="AdminPromptComparison-module_loadingOverlay_1vzPp",ON="AdminPromptComparison-module_spinner_UOT9T",qN="AdminPromptComparison-module_spin_sWAww",VN="AdminPromptComparison-module_assetIdsRow_cl5AQ",HN="AdminPromptComparison-module_assetIdBadge_MbiG2",UN="AdminPromptComparison-module_removeAssetButton_EJ26h",ZN="AdminPromptComparison-module_nonPlanResponse_54EgP",WN="AdminPromptComparison-module_nonPlanResponseTitle_0Ph5m",KN="AdminPromptComparison-module_generationError_Y5aEZ",GN="AdminPromptComparison-module_toolCallSelector_Bk6Ey",JN="AdminPromptComparison-module_toolCallHeader_FhB-Q",zN="AdminPromptComparison-module_toolGrid_jp8C1",YN="AdminPromptComparison-module_toolOption_R8wCt",QN="AdminPromptComparison-module_toolName_v0Ov9",XN="AdminPromptComparison-module_attachMediaButton_Ze1xM",e2="AdminPromptComparison-module_assetThumbnailsRow_QrvB2";var W={container:wC,detailResultsSection:AC,detailFormCard:IC,pageHeader:TC,pageHeaderLeft:kC,pageTitle:RC,parentRunLink:$C,headerLinks:PC,backLink:EC,formCard:LC,form:BC,formSection:DC,formSectionTitle:MC,field:FC,fieldLabel:OC,fieldInput:qC,fieldTextarea:VC,labelRow:HC,fieldSelect:UC,prefillButton:ZC,judgeTextarea:WC,agentInstructionsTextarea:KC,fixedSuffix:GC,fixedSuffixLabel:JC,fixedSuffixContent:zC,helperText:YC,promptColumns:QC,submitActions:XC,submitButton:eN,error:tN,resultsSection:sN,judgmentCard:nN,judgmentCardTitle:aN,winnerBadge:oN,winnerA:iN,winnerB:lN,winnerTie:rN,winnerBothFail:dN,explanation:cN,scoresGrid:uN,scoreCard:mN,scoreCardTitle:pN,scoreItems:hN,scoreItem:fN,scoreValue:xN,outputColumns:gN,outputColumnsSingle:vN,outputCard:_N,outputHeader:jN,outputHeaderTitle:bN,outputHeaderBadges:yN,responseTypeBadge:SN,outputModelBadge:CN,outputBody:NN,chatLinkRow:wN,chatLink:AN,planSummary:IN,planSteps:TN,planStep:kN,planStepTool:RN,planStepParams:$N,emptyPlan:PN,loadedSkills:EN,loadedSkillsTitle:LN,loadedSkillsBadges:BN,loadedSkillBadge:DN,loadedSkillsReason:MN,loadingOverlay:FN,spinner:ON,spin:qN,assetIdsRow:VN,assetIdBadge:HN,removeAssetButton:UN,nonPlanResponse:ZN,nonPlanResponseTitle:WN,generationError:KN,toolCallSelector:GN,toolCallHeader:JN,toolGrid:zN,toolOption:YN,toolName:QN,attachMediaButton:XN,assetThumbnailsRow:e2};function t2(s){return!s||typeof s!="object"?!1:typeof s.userPrompt=="string"}const s2="ChatHistoryDisplay-module_field_kmw-6",n2="ChatHistoryDisplay-module_fieldLabel_Mpty-",a2="ChatHistoryDisplay-module_helperText_3ElxB",o2="ChatHistoryDisplay-module_chatHistoryContainer_jSicx",i2="ChatHistoryDisplay-module_chatHistoryEmpty_5rLDj",l2="ChatHistoryDisplay-module_chatHistoryEmptyInline_exmf3",r2="ChatHistoryDisplay-module_chatHistoryMessage_ee60q",d2="ChatHistoryDisplay-module_chatHistoryRoleUser_xNjAI",c2="ChatHistoryDisplay-module_chatHistoryRoleAssistant_5NMof",u2="ChatHistoryDisplay-module_chatHistoryRoleTool_i6FFQ",m2="ChatHistoryDisplay-module_chatHistoryRoleOther_0aUp6",p2="ChatHistoryDisplay-module_chatHistoryMessageHeader_s9w6K",h2="ChatHistoryDisplay-module_chatHistoryRoleLabel_531Yq",f2="ChatHistoryDisplay-module_chatHistoryRemoveButton_zcm0I",x2="ChatHistoryDisplay-module_chatHistoryBody_-Lpet",g2="ChatHistoryDisplay-module_chatHistoryToolCalls_wIy3k",v2="ChatHistoryDisplay-module_historyDetails_-7J6Y",_2="ChatHistoryDisplay-module_historySummary_tW9fI";var at={field:s2,fieldLabel:n2,helperText:a2,chatHistoryContainer:o2,chatHistoryEmpty:i2,chatHistoryEmptyInline:l2,chatHistoryMessage:r2,chatHistoryRoleUser:d2,chatHistoryRoleAssistant:c2,chatHistoryRoleTool:u2,chatHistoryRoleOther:m2,chatHistoryMessageHeader:p2,chatHistoryRoleLabel:h2,chatHistoryRemoveButton:f2,chatHistoryBody:x2,chatHistoryToolCalls:g2,historyDetails:v2,historySummary:_2},j2=Q(ie());function b2(s){switch(s.role){case"user":return"User";case"assistant":return s.type==="credits-warning"||s.type==="chat-limits-warning"?"Assistant (warning)":s.type==="card"?"Assistant (card)":"Assistant";case"tool":return`Tool: ${s.name}`;case"system":return"System";default:return"Message"}}function y2(s){switch(s.role){case"user":return at.chatHistoryRoleUser;case"assistant":return at.chatHistoryRoleAssistant;case"tool":return at.chatHistoryRoleTool;default:return at.chatHistoryRoleOther}}function S2(s){if(s.role==="tool")return s.content.trim()||"(no output)";if(s.role==="assistant"&&(s.type==="credits-warning"||s.type==="chat-limits-warning"))return s.content.trim()||null;if(s.role==="assistant"&&s.type==="card")return null;if(s.role==="system"||s.role==="user")return ti(s.content);if(s.role==="assistant"&&s.type==="llm-response"){const e=ti(s.content);return e==="(no text)"?null:e}return null}function jo(s){const e=(0,j2.c)(36),{history:n,totalMessages:a,isLoading:o,title:i,helperText:l,emptyMessage:r,loadingMessage:d,hideWhenEmpty:c,displayMode:m,collapsible:h,onRemoveMessage:p}=s,u=o===void 0?!1:o,g=i===void 0?"Chat history":i,_=r===void 0?"No history messages.":r,v=d===void 0?"Loading chat history...":d,b=c===void 0?!1:c,j=m===void 0?"section":m,x=h===void 0?!1:h,S=a??n?.length??0;if(b&&S===0)return null;let C;e[0]!==_||e[1]!==n||e[2]!==u||e[3]!==v||e[4]!==p?(C=function(){return u||n===void 0?(0,t.jsx)("p",{className:at.chatHistoryEmpty,children:v}):n.length===0?(0,t.jsx)("p",{className:at.chatHistoryEmpty,children:_}):n.map((R,P)=>{const k=y2(R),T=S2(R),E=R.role==="user"||R.role==="system"?SC(R.content):[],O=R.role==="assistant"&&R.type==="llm-response"?R.tool_calls??[]:[];return(0,t.jsxs)("div",{className:`${at.chatHistoryMessage} ${k}`,children:[(0,t.jsxs)("div",{className:at.chatHistoryMessageHeader,children:[(0,t.jsx)("span",{className:at.chatHistoryRoleLabel,children:b2(R)}),p&&(0,t.jsx)("button",{type:"button",className:at.chatHistoryRemoveButton,onClick:()=>p(P),"aria-label":"Remove message from history",children:"Remove"})]}),T!==null&&(0,t.jsx)("p",{className:at.chatHistoryBody,children:T}),E.length>0&&(0,t.jsxs)("span",{className:at.chatHistoryEmpty,children:[E.length," attached asset",E.length===1?"":"s"]}),O.length>0&&(0,t.jsx)("ul",{className:at.chatHistoryToolCalls,children:O.map(C2)})]},`${R.role}-${P}`)})},e[0]=_,e[1]=n,e[2]=u,e[3]=v,e[4]=p,e[5]=C):C=e[5];const y=C;if(j==="inline"){if(x){if(S===0){let q;
109return e[6]!==_?(q=(0,t.jsx)("span",{className:at.chatHistoryEmptyInline,children:_}),e[6]=_,e[7]=q):q=e[7],q}const P=S===1?"":"s";let k;e[8]!==S||e[9]!==P?(k=(0,t.jsxs)("summary",{className:at.historySummary,children:[S," message",P]}),e[8]=S,e[9]=P,e[10]=k):k=e[10];let T;e[11]!==y?(T=y(),e[11]=y,e[12]=T):T=e[12];let E;e[13]!==T?(E=(0,t.jsx)("div",{className:at.chatHistoryContainer,children:T}),e[13]=T,e[14]=E):E=e[14];let O;return e[15]!==k||e[16]!==E?(O=(0,t.jsxs)("details",{className:at.historyDetails,children:[k,E]}),e[15]=k,e[16]=E,e[17]=O):O=e[17],O}let $;e[18]!==y?($=y(),e[18]=y,e[19]=$):$=e[19];let R;return e[20]!==$?(R=(0,t.jsx)("div",{className:at.chatHistoryContainer,children:$}),e[20]=$,e[21]=R):R=e[21],R}const N=S===1?"":"s";let w;e[22]!==S||e[23]!==N||e[24]!==g?(w=(0,t.jsxs)("label",{className:at.fieldLabel,children:[g," (",S," message",N,")"]}),e[22]=S,e[23]=N,e[24]=g,e[25]=w):w=e[25];let A;e[26]!==l?(A=l&&(0,t.jsx)("p",{className:at.helperText,children:l}),e[26]=l,e[27]=A):A=e[27];let I;e[28]!==y?(I=y(),e[28]=y,e[29]=I):I=e[29];let D;e[30]!==I?(D=(0,t.jsx)("div",{className:at.chatHistoryContainer,children:I}),e[30]=I,e[31]=D):D=e[31];let L;return e[32]!==w||e[33]!==A||e[34]!==D?(L=(0,t.jsxs)("div",{className:at.field,children:[w,A,D]}),e[32]=w,e[33]=A,e[34]=D,e[35]=L):L=e[35],L}function C2(s){return(0,t.jsxs)("li",{children:[(0,t.jsx)("code",{children:s.function.name}),s.function.arguments?` (${s.function.arguments.length>120?`${s.function.arguments.slice(0,120)}...`:s.function.arguments})`:""]},s.id)}const N2="AdminAssetThumbnail-module_wrapper_nFEaT",w2="AdminAssetThumbnail-module_assetId_4uU1j";var si={wrapper:N2,assetId:w2},A2=Q(ie());function bo(s){const e=(0,A2.c)(20),{assetId:n,onRemove:a,size:o}=s,i=o===void 0?"medium":o,l=tt();let r;e[0]!==n?(r=b=>b.assets.byId[n],e[0]=n,e[1]=r):r=e[1];const d=ys(r);let c,m;e[2]!==d||e[3]!==n||e[4]!==l?(c=()=>{(async function(){!d&&n&&l(fo([await aa(n,Cs.admin)]))})()},m=[d,n,l],e[2]=d,e[3]=n,e[4]=l,e[5]=c,e[6]=m):(c=e[5],m=e[6]),(0,f.useEffect)(c,m);let h;e[7]!==n?(h=ll(n),e[7]=n,e[8]=h):h=e[8];const p=h;let u;e[9]!==a?(u=a?()=>{a()}:void 0,e[9]=a,e[10]=u):u=e[10];let g;e[11]!==p||e[12]!==i||e[13]!==u?(g=(0,t.jsx)(fl,{size:i,mediaCacheId:p,removeAttachment:u}),e[11]=p,e[12]=i,e[13]=u,e[14]=g):g=e[14];let _;e[15]!==n?(_=(0,t.jsxs)("span",{className:si.assetId,title:n,children:["Asset ID: ",n]}),e[15]=n,e[16]=_):_=e[16];let v;return e[17]!==g||e[18]!==_?(v=(0,t.jsxs)("div",{className:si.wrapper,children:[g,_]}),e[17]=g,e[18]=_,e[19]=v):v=e[19],v}var I2=Q(ie()),T2=6*1024*1024*1024;function k2({onAssetsSelected:s,onClose:e}){const n=tt(),[a,o]=(0,f.useState)([]),i=(0,f.useRef)(new Set),[l,r]=(0,f.useState)("myMedia"),d=v=>{o(b=>i.current.has(v)?b:(i.current.add(v),[...b,v]))},c=v=>{o(b=>i.current.has(v)?(i.current.delete(v),b.filter(j=>j!==v)):b)},m=(0,f.useCallback)(()=>{s(a),i.current=new Set,o([]),e()},[a,s,e]),h=(0,f.useCallback)((v,b)=>{b?._id&&d(b._id)},[]),{containerRef:p,containerDimensions:u}=pl(),g=async v=>{try{const b=ou(v);if(!b)return;const j=Pn().state.assets.byId[b];if(!j)throw new Error("Asset not found, please try a different file.");const{content_type:x}=j;if(!x)throw new Error("No content type found for the file.");if(x.includes("video")){const{file_size:S}=j;if(S&&S>T2)throw new Yd("Please use a video that is less than 6 GB.")}(!j.url||Ld(j.url))&&n(fo([await aa(j._id,Cs.admin)])),d(b)}catch(b){let j="An error occurred while adding the file. Try a different file.";b instanceof Error&&b.message&&(j=b.message),Ss({description:j})}},_=()=>(0,t.jsx)("div",{className:Kt.selectionContainer,children:a.map(v=>(0,t.jsx)(fl,{size:"large",mediaCacheId:ll(v),removeAttachment:()=>c(v)},v))});return(0,t.jsxs)("div",{className:Kt.container,children:[(0,t.jsxs)("div",{className:Kt.headerContainer,children:[(0,t.jsx)("div",{className:Kt.header,children:"Attach media to request"}),(0,t.jsx)("div",{className:Kt.description,children:"Upload or select from your media library. By uploading, you confirm you own or have permission to use this media."})]}),(0,t.jsxs)("div",{className:Kt.uploadConfigContainer,children:[(0,t.jsx)("div",{className:Kt.uploadContainer,children:(0,t.jsx)(Bc,{handleFinish:h,analyticsUploadSource:"Chat Media Attachment Upload",doDuplicateHandling:!1,addToStoreAfterUpload:!0,hideSample:!0,multiple:!0,suppressFileSizeWarnings:!0})}),(0,t.jsx)("div",{className:Kt.mediaLibraryContainer,ref:p,children:(0,t.jsx)(ru,{analyticsUploadSource:"Chat Media Attachment Upload",handlePreemptiveFinish:()=>{},filter:l,tileSize:"large",location:"overlay",parentContainerDimensions:u,hideTrim:!0,onAdd:g,hideBrandKit:!0,cmlTabsSlot:(0,t.jsx)(uu,{selectedTab:l,onTabChange:r,visibleTabs:["myMedia","uploads","generations"]})})})]}),(0,t.jsx)("div",{className:Kt.selectedUploadContainer,children:_()}),(0,t.jsx)("div",{className:Kt.attachButtonContainer,children:(0,t.jsx)(Xs,{label:"Attach media",onClick:m,dataTestId:"admin-attach-media-apply-button"})})]})}function $l(s){const e=(0,I2.c)(20),{onAssetsSelected:n,onClose:a,children:o}=s,[i,l]=(0,f.useState)(!1);let r;e[0]!==a?(r=()=>{l(!1),a()},e[0]=a,e[1]=r):r=e[1];const d=r;let c;e[2]!==n?(c=x=>{n(x),l(!1)},e[2]=n,e[3]=c):c=e[3];const m=c;let h;e[4]!==d?(h=x=>{x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),d())},e[4]=d,e[5]=h):h=e[5];const p=h;let u,g;e[6]!==p||e[7]!==i?(u=()=>{if(i)return document.addEventListener("keydown",p,!1),()=>{document.removeEventListener("keydown",p,!1)}},g=[p,i],e[6]=p,e[7]=i,e[8]=u,e[9]=g):(u=e[8],g=e[9]),(0,f.useEffect)(u,g);let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=()=>l(!0),e[10]=_):_=e[10];let v;e[11]!==o?(v=o({onClick:_}),e[11]=o,e[12]=v):v=e[12];let b;e[13]!==m||e[14]!==d||e[15]!==i?(b=i&&(0,t.jsx)(hc,{onClose:d,width:"90dvw",maxWidth:"1200px",noPadding:!0,children:(0,t.jsx)(k2,{onAssetsSelected:m,onClose:d})}),e[13]=m,e[14]=d,e[15]=i,e[16]=b):b=e[16];let j;return e[17]!==v||e[18]!==b?(j=(0,t.jsxs)(t.Fragment,{children:[v,b]}),e[17]=v,e[18]=b,e[19]=j):j=e[19],j}const Pl=["text","image","scene","audio","project"],R2={text:"Text",image:"Image",scene:"Video",audio:"Audio",project:"Project"},nY=[...Pl,"asset"],El=Pc,Ks=["16:9","9:16","1:1","4:5","5:4","4:3","3:4","2:3","21:9"],on=["video/mp4","video/webm","video/quicktime","image/png","image/jpeg","image/webp","image/gif","audio/mpeg","audio/mp4","audio/wav","audio/webm","application/pdf"],Ll=Iu,Bl=["blur","blurBackgroun
109d","opacity","contrast","brightness","saturate","blurPercent","temperature","tint","highlights","shadows","whites","blacks"],Dl=["intro","outro","both","none"],Ml=["blur","cutout","pixelate"],$2=["cross-dissolve","cross-blur"],Ta=["none","fade-in","fade-out","blur-in","blur-out","drop","focus-in","pop-in-bounce","reveal","slide-up","vibrate","wipe-rectangle","flicker-in-glow","hue-rotate","progress-bar","moving-zoom"],Fl=["brandkit","chat","stock"],Ve=ce.union([ce.number(),ce.object({eq:ce.number().optional(),neq:ce.number().optional(),lt:ce.number().optional(),lte:ce.number().optional(),gt:ce.number().optional(),gte:ce.number().optional()}).refine(s=>s.eq!==void 0||s.neq!==void 0||s.lt!==void 0||s.lte!==void 0||s.gt!==void 0||s.gte!==void 0,{message:"Number assertion must include at least one bound"})]),xt=ce.union([ce.string(),ce.object({eq:ce.string().optional(),neq:ce.string().optional(),includes:ce.union([ce.string(),ce.array(ce.string())]).optional()}).refine(s=>s.eq!==void 0||s.neq!==void 0||s.includes!==void 0,{message:"String assertion must include eq, neq, and/or includes"})]);function Yt(s){const e=ce.enum(s);return ce.union([e,ce.object({oneOf:ce.array(e).min(1)})])}var rn=Yt(Ks),Dn=Yt(on),P2=Yt(["audio","image","shape","text","video","placeholder","persona"]),pn={customAssertion:ce.string().min(1).optional()},E2=Object.fromEntries(Bl.map(s=>[s,Ve.optional()])),L2=ce.object({present:ce.boolean().optional(),...E2}),B2=ce.object({hasIntro:ce.boolean().optional(),hasOutro:ce.boolean().optional(),intro:xt.optional(),outro:xt.optional(),constant:xt.optional()}),D2=ce.object({position:Yt(Dl).optional(),introDurationSec:Ve.optional(),outroDurationSec:Ve.optional()}),M2=ce.object({enabled:ce.boolean().optional(),mode:Yt(Ml).optional(),invert:ce.boolean().optional(),assetId:xt.optional(),blurAmount:Ve.optional(),expandAmount:Ve.optional(),featherAmount:Ve.optional()});const F2=ce.object({type:P2.optional(),duration:Ve.optional(),startTime:Ve.optional(),endTime:Ve.optional(),videoDelay:Ve.optional(),playbackRate:Ve.optional(),timelineRow:Ve.optional(),timelineDurationSec:Ve.optional(),width:Ve.optional(),height:Ve.optional(),aspectRatio:rn.optional(),asset_id:xt.optional(),name:xt.optional(),mime:Dn.optional(),hasAudio:ce.boolean().optional(),volume:Ve.optional(),text:xt.optional(),fontFamily:xt.optional(),color:xt.optional(),fontSize:Ve.optional(),filters:L2.optional(),presetFilterId:Yt(Ll).optional(),animation:B2.optional(),audioFade:D2.optional(),mask:M2.optional(),personaId:xt.optional()});var O2=ce.object({name:xt.optional(),source:Yt(Fl).optional()}),hn={characters:ce.object({present:ce.boolean().optional(),usedInGeneration:ce.boolean().optional(),count:Ve.optional(),match:ce.array(O2).optional(),usage:ce.object({userCreated:Ve.optional(),chatCreated:Ve.optional(),stock:Ve.optional()}).optional()}).optional()},q2=ce.object({...hn,...pn,kind:ce.literal("text"),contentEquals:ce.string().optional(),contentIncludes:ce.array(ce.string().min(1)).optional()}),V2=ce.object({...hn,...pn,kind:ce.literal("image"),width:Ve.optional(),height:Ve.optional(),aspectRatio:rn.optional(),mimeType:Dn.optional()}),H2=ce.object({...hn,...pn,kind:ce.literal("scene"),width:Ve.optional(),height:Ve.optional(),duration:Ve.optional(),aspectRatio:rn.optional(),mimeType:Dn.optional(),hasAudio:ce.boolean().optional()}),U2=ce.object({...hn,...pn,kind:ce.literal("audio"),duration:Ve.optional(),mimeType:Dn.optional()}),Z2=ce.object({...hn,...pn,kind:ce.literal("asset"),duration:Ve.optional(),width:Ve.optional(),height:Ve.optional(),aspectRatio:rn.optional(),mimeType:Dn.optional(),hasAudio:ce.boolean().optional()}),W2=ce.object({fontColor:xt.optional(),fontFamily:xt.optional(),fontSize:Ve.optional(),fontWeight:xt.optional(),backgroundColor:xt.optional(),textAlign:xt.optional(),verticalAlign:Yt(["top","middle","bottom"]).optional(),italic:ce.boolean().optional(),underline:ce.boolean().optional()}),K2=ce.object({present:ce.boolean().optional(),contentEquals:ce.string().optional(),contentIncludes:ce.array(ce.string().min(1)).optional(),style:W2.optional(),placement:Yt(["top","bottom","keep-current"]).optional(),presetId:Yt(El).optional()}),G2=ce.object({transitionId:xt.optional(),durationSec:Ve.optional(),fromAssetId:xt.optional(),toAssetId:xt.optional()}),J2=ce.object({text:ce.string().min(1),occurrences:Ve,startsWith:ce.boolean().optional(),endsWith:ce.boolean().optional()}),z2=ce.object({contentEquals:ce.string().min(1).optional(),contentStartsWith:ce.string().min(1).optional(),phrases:ce.array(J2).optional(),speakerCount:Ve.optional(),maxSilenceSec:ce.number().nonnegative().optional(),minAudibleLayerDurationSec:ce.number().nonnegative().optional()}),Y2=ce.object({...hn,...pn,kind:ce.literal("project"),outputCount:Ve.optional(),eachOutputDuration:Ve.optional(),eachOutputAspectRatio:rn.optional(),duration:Ve.optional(),width:Ve.optional(),height:Ve.optional(),aspectRatio:rn.optional(),includeMagicSubtitles:ce.boolean().optional(),subtitles:K2.optional(),transcript:z2.optional(),assetSwitchCount:Ve.optional(),layers:ce.array(F2).optional(),layersStrict:ce.boolean().optional(),transitions:ce.array(G2).optional(),transitionCount:Ve.optional()});const Q2=ce.discriminatedUnion("kind",[q2,V2,H2,U2,Z2,Y2]);function X2(s){return(typeof s!="object"||s===null)&&typeof s!="function"?!1:"then"in s&&typeof s.then=="function"}function ew(s,e){const n={output:s,project:s.project,projects:kl(s),layers:s.project?.layers??[],transcript:s.resolvedTranscript,subtitles:s.resolvedSubtitles,helpers:{calculateLayerDuration:Ed,getLayerStartAndEndTimes:wd,rangesOverlap:(a,o)=>Math.max(a.start,o.start)<Math.min(a.end,o.end)}};
109try{const a=new Function("context",`"use strict"; 110const { output, project, projects, layers, transcript, subtitles, helpers } = context; 111${e}`)(n);return X2(a)?{passed:!1,error:"custom assertion returned a Promise; asynchronous assertions are not supported"}:{passed:!!a}}catch(a){return{passed:!1,error:`custom assertion threw: ${a instanceof Error?a.message:String(a)}`}}}function tw(s){if(typeof s=="number")return`== ${s}`;const e=[];return s.eq!==void 0&&e.push(`== ${s.eq}`),s.neq!==void 0&&e.push(`!= ${s.neq}`),s.gte!==void 0&&e.push(`>= ${s.gte}`),s.gt!==void 0&&e.push(`> ${s.gt}`),s.lte!==void 0&&e.push(`<= ${s.lte}`),s.lt!==void 0&&e.push(`< ${s.lt}`),e.join(" and ")}function sw(s){if(typeof s=="string")return`== ${JSON.stringify(s)}`;const e=[];if(s.eq!==void 0&&e.push(`== ${JSON.stringify(s.eq)}`),s.neq!==void 0&&e.push(`!= ${JSON.stringify(s.neq)}`),s.includes!==void 0){const n=Array.isArray(s.includes)?s.includes:[s.includes];for(const a of n)e.push(`includes ${JSON.stringify(a)}`)}return e.join(" and ")}function nw(s){return typeof s=="string"?`== ${s}`:`one of [${s.oneOf.join(", ")}]`}const aw="EditRequestModal-module_modalOverlay_RyYCK",ow="EditRequestModal-module_modalContent_BCja6",iw="EditRequestModal-module_sectionTitle_l4-P6",lw="EditRequestModal-module_field_iY3-R",rw="EditRequestModal-module_fieldLabel_33Cc0",dw="EditRequestModal-module_fieldTextarea_IuS6Y",cw="EditRequestModal-module_descriptionTextarea_vZ-Vu",uw="EditRequestModal-module_fieldInput_nteJh",mw="EditRequestModal-module_fieldSelect_H1FU7",pw="EditRequestModal-module_assertionField_1-PaI",hw="EditRequestModal-module_assertionFieldHeader_Cx3x0",fw="EditRequestModal-module_assertionFieldLabelGroup_UfP2u",xw="EditRequestModal-module_fieldSublabel_Y8zF9",gw="EditRequestModal-module_assertionFieldsGrid_HaOv5",vw="EditRequestModal-module_assertionFieldsGridWide_xVV4H",_w="EditRequestModal-module_kindSelectRow_U2xte",jw="EditRequestModal-module_rangeRows_h6BUU",bw="EditRequestModal-module_rangeRow_mQxoD",yw="EditRequestModal-module_layerAssertionCard_Gj78-",Sw="EditRequestModal-module_layerAssertionFields_uzki-",Cw="EditRequestModal-module_layerCardsGrid_mWDaK",Nw="EditRequestModal-module_attachMediaButton_s7Uzt",ww="EditRequestModal-module_assetThumbnailsRow_aqYcC",Aw="EditRequestModal-module_helperText_3pxW1",Iw="EditRequestModal-module_tagInputWrapper_UvUrL",Tw="EditRequestModal-module_tagInputContainer_zeKtg",kw="EditRequestModal-module_tagChip_UDI6l",Rw="EditRequestModal-module_tagChipRemove_bu17N",$w="EditRequestModal-module_tagInput_TwFpW",Pw="EditRequestModal-module_tagSuggestions_Ctwfd",Ew="EditRequestModal-module_tagSuggestion_y3bbf",Lw="EditRequestModal-module_modalActions_shO2e",Bw="EditRequestModal-module_smallButton_-BXg0",Dw="EditRequestModal-module_secondaryButton_gDwY4",Mw="EditRequestModal-module_toolCallSelector_iO0rE",Fw="EditRequestModal-module_programmableAssertionSection_sVcXX",Ow="EditRequestModal-module_programmableAssertionReference_yuM-y",qw="EditRequestModal-module_programmableAssertionSummary_K2i-n",Vw="EditRequestModal-module_codeReference_m6-L-",Hw="EditRequestModal-module_programmableAssertionTextarea_xz4F3",Uw="EditRequestModal-module_toolCallHeader_WzymY",Zw="EditRequestModal-module_prefillButton_E-l2M",Ww="EditRequestModal-module_toolGrid_VIPx4",Kw="EditRequestModal-module_toolOption_Q-CVP",Gw="EditRequestModal-module_toolName_OlkH4",Jw="EditRequestModal-module_assertionSubgroup_o88PQ",zw="EditRequestModal-module_assertionSubgroupHeader_aBEw4";var F={modalOverlay:aw,modalContent:ow,sectionTitle:iw,field:lw,fieldLabel:rw,fieldTextarea:dw,descriptionTextarea:cw,fieldInput:uw,fieldSelect:mw,assertionField:pw,assertionFieldHeader:hw,assertionFieldLabelGroup:fw,fieldSublabel:xw,assertionFieldsGrid:gw,assertionFieldsGridWide:vw,kindSelectRow:_w,rangeRows:jw,rangeRow:bw,layerAssertionCard:yw,layerAssertionFields:Sw,layerCardsGrid:Cw,attachMediaButton:Nw,assetThumbnailsRow:ww,helperText:Aw,tagInputWrapper:Iw,tagInputContainer:Tw,tagChip:kw,tagChipRemove:Rw,tagInput:$w,tagSuggestions:Pw,tagSuggestion:Ew,modalActions:Lw,smallButton:Bw,secondaryButton:Dw,toolCallSelector:Mw,programmableAssertionSection:Fw,programmableAssertionReference:Ow,programmableAssertionSummary:qw,codeReference:Vw,programmableAssertionTextarea:Hw,toolCallHeader:Uw,prefillButton:Zw,toolGrid:Ww,toolOption:Kw,toolName:Gw,assertionSubgroup:Jw,assertionSubgroupHeader:zw}
111,Ct=Q(ie()),Yw=Object.values(Yi),Qw={blur:"Blur",blurBackground:"Background blur",opacity:"Opacity",contrast:"Contrast",brightness:"Brightness",saturate:"Saturate",blurPercent:"Blur %",temperature:"Temperature",tint:"Tint",highlights:"Highlights",shadows:"Shadows",whites:"Whites",blacks:"Blacks"},Xw=`function assertion(context) { 112 const { 113 output, 114 project, 115 layers, 116 transcript, 117 subtitles, 118 helpers, 119 } = context; 120 121 // Your pasted body runs here and must return a truthy value. 122}`,eA=`type Context = { 123 output: { 124 executionMode?: "planner" | "autonomous"; 125 project?: Project; 126 directAsset?: { 127 assetIds: string[]; 128 assets?: Array<{ 129 assetId: string; 130 width?: number; 131 height?: number; 132 duration?: number; 133 mimeType?: string; 134 hasAudio?: boolean; 135 }>; 136 // Remaining fields are legacy single-asset metadata. 137 width?: number; 138 height?: number; 139 duration?: number; 140 mimeType?: string; 141 hasAudio?: boolean; 142 }; 143 // Also includes plan, responses, agent steps, and output metadata. 144 }; 145 projects: Array<{ 146 duration: number; 147 width: number; 148 height: number; 149 includeMagicSubtitles?: boolean; 150 }>; 151 project?: Project; 152 layers: Layer[]; // [] when output.project is absent 153 transcript?: { 154 fullText: string; 155 speakerCount: number; 156 audibleLayers: Array<{ 157 layerIndex: number; 158 assetDurationSec: number; 159 timelineDurationSec: number; 160 fullText: string; 161 maxSilenceSec?: number; 162 }>; 163 }; 164 subtitles?: { 165 present: boolean; 166 fullText: string; 167 style?: object; 168 placement?: "top" | "bottom" | "keep-current"; 169 presetId?: string; 170 }; 171 helpers: { 172 calculateLayerDuration(layer: Layer): number; 173 getLayerStartAndEndTimes(layer: Layer): { 174 start: number; 175 end: number; 176 }; 177 rangesOverlap( 178 left: { start: number; end: number }, 179 right: { start: number; end: number } 180 ): boolean; 181 }; 182}; 183 184type Project = { 185 duration: number; 186 width: number; 187 height: number; 188 layers: Layer[]; 189 includeMagicSubtitles?: boolean; 190}; 191 192type Layer = { 193 type: "video" | "audio" | "image" | "persona" | "text" | string; 194 asset_id?: string; 195 // Source trim range. For video/audio/persona, videoDelay is timeline start. 196 startTime?: number; 197 endTime?: number; 198 videoDelay?: number; 199 duration?: number; // Full source asset duration 200 playbackRate?: number; 201 timelineRow?: number; 202 volume?: number; 203 width?: number; 204 height?: number; 205 mime?: string; 206 name?: string; 207 text?: string; 208 kaiSourceText?: string; 209 hasAudio?: boolean; 210 // Additional ILayer fields remain available at runtime. 211};`;function tA(s){return s.passed?"Passed":s.error?`Failed: ${s.error}`:"Failed"}function sA(s){return s===void 0?"unset":typeof s=="number"?"exact":Object.keys(s).length===1&&s.neq!==void 0?"notEqual":"range"}function ni(s){return s.gte!==void 0?s.gte:s.gt!==void 0?s.gt:""}function ai(s){return s.lte!==void 0?s.lte:s.lt!==void 0?s.lt:""}function oi(s,e){const n={};return s!==""&&(n.gte=s),e!==""&&(n.lte=e),Object.keys(n).length>0?n:{gte:0}}function nA(s){return s===void 0?"unset":typeof s=="string"?"exact":s.neq!==void 0&&s.eq===void 0&&s.includes===void 0?"notEqual":s.eq!==void 0&&s.includes===void 0&&s.neq===void 0?"exact":"contains"}function aA(s){return s===void 0?"unset":typeof s=="string"?"exact":"oneOf"}function Xa(s){const e=(0,Ct.c)(23),{label:n,value:a,onChange:o,placeholder:i}=s;let l;e[0]!==a?(l=()=>(a??[]).join(` 212`),e[0]=a,e[1]=l):l=e[1];const[r,d]=(0,f.useState)(l),c=(0,f.useRef)(!1);let m,h;e[2]!==a?(m=function(){c.current||d((a??[]).join(` 213`))},h=[a],e[2]=a,e[3]=m,e[4]=h):(m=e[3],h=e[4]),(0,f.useEffect)(m,h);let p;e[5]!==o?(p=function(C){const y=C.split(`
214`).map(oA).filter(Boolean);return o(y.length>0?y:void 0),y},e[5]=o,e[6]=p):p=e[6];const u=p;let g;e[7]!==n?(g=n?(0,t.jsx)("span",{className:F.fieldLabel,children:n}):null,e[7]=n,e[8]=g):g=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{c.current=!0},e[9]=_):_=e[9];let v;e[10]!==u||e[11]!==r?(v=()=>{c.current=!1,d(u(r).join(` 215`))},e[10]=u,e[11]=r,e[12]=v):v=e[12];let b;e[13]!==u?(b=S=>{const C=S.target.value;d(C),u(C)},e[13]=u,e[14]=b):b=e[14];let j;e[15]!==r||e[16]!==i||e[17]!==v||e[18]!==b?(j=(0,t.jsx)("textarea",{className:F.fieldTextarea,value:r,placeholder:i,onFocus:_,onBlur:v,onChange:b}),e[15]=r,e[16]=i,e[17]=v,e[18]=b,e[19]=j):j=e[19];let x;return e[20]!==g||e[21]!==j?(x=(0,t.jsxs)("label",{className:F.field,children:[g,j]}),e[20]=g,e[21]=j,e[22]=x):x=e[22],x}function oA(s){return s.trim()}function iA(s){if(!(typeof s!="object"||s.includes===void 0))return Array.isArray(s.includes)?s.includes:[s.includes]}function lA(s){return s===void 0?"any":s?"true":"false"}function ii(s){if(typeof s=="number")return s;if(typeof s=="object"){if(s.neq!==void 0)return s.neq;if(s.eq!==void 0)return s.eq}return 0}function qe(s){const e=(0,Ct.c)(53),{label:n,sublabel:a,value:o,onChange:i}=s;let l;e[0]!==o?(l=sA(o),e[0]=o,e[1]=l):l=e[1];const r=l,d=typeof o=="object"?o:void 0;let c;e[2]!==d?(c=d?ni(d):"",e[2]=d,e[3]=c):c=e[3];const m=c;let h;e[4]!==d?(h=d?ai(d):"",e[4]=d,e[5]=h):h=e[5];const p=h;let u;e[6]!==i||e[7]!==o?(u=k=>{if(k==="unset"){i(void 0);return}if(k==="exact"){i(ii(o));return}if(k==="notEqual"){i({neq:ii(o)});return}if(typeof o=="number"){i({gte:o});return}if(typeof o=="object"&&o.neq!==void 0){i({gte:o.neq});return}if(typeof o=="object"){i(oi(ni(o),ai(o)));return}i({gte:0})},e[6]=i,e[7]=o,e[8]=u):u=e[8];const g=u;let _;e[9]!==i?(_=(k,T)=>{if(k===""&&T===""){i(void 0);return}i(oi(k,T))},e[9]=i,e[10]=_):_=e[10];const v=_;let b;e[11]!==n?(b=(0,t.jsx)("span",{className:F.fieldLabel,children:n}),e[11]=n,e[12]=b):b=e[12];let j;e[13]!==a?(j=a&&(0,t.jsx)("span",{className:F.fieldSublabel,children:a}),e[13]=a,e[14]=j):j=e[14];let x;e[15]!==b||e[16]!==j?(x=(0,t.jsxs)("div",{className:F.assertionFieldLabelGroup,children:[b,j]}),e[15]=b,e[16]=j,e[17]=x):x=e[17];let S;e[18]!==g?(S=k=>g(k.target.value),e[18]=g,e[19]=S):S=e[19];let C,y,N,w;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=(0,t.jsx)("option",{value:"unset",children:"Any"}),y=(0,t.jsx)("option",{value:"exact",children:"Exact"}),N=(0,t.jsx)("option",{value:"notEqual",children:"Not equal"}),w=(0,t.jsx)("option",{value:"range",children:"Range"}),e[20]=C,e[21]=y,e[22]=N,e[23]=w):(C=e[20],y=e[21],N=e[22],w=e[23]);let A;e[24]!==r||e[25]!==S?(A=(0,t.jsxs)("select",{className:F.fieldSelect,value:r,onChange:S,children:[C,y,N,w]}),e[24]=r,e[25]=S,e[26]=A):A=e[26];let I;e[27]!==A||e[28]!==x?(I=(0,t.jsxs)("div",{className:F.assertionFieldHeader,children:[x,A]}),e[27]=A,e[28]=x,e[29]=I):I=e[29];let D;e[30]!==r||e[31]!==i||e[32]!==o?(D=r==="exact"&&(0,t.jsx)("input",{type:"number",className:F.fieldInput,value:typeof o=="number"?o:"",onChange:k=>{const T=Number(k.target.value);i(Number.isFinite(T)?T:0)}}),e[30]=r,e[31]=i,e[32]=o,e[33]=D):D=e[33];let L;e[34]!==r||e[35]!==i||e[36]!==o?(L=r==="notEqual"&&(0,t.jsx)("input",{type:"number",className:F.fieldInput,value:typeof o=="object"&&o.neq!==void 0?o.neq:"",onChange:k=>{const T=Number(k.target.value);i({neq:Number.isFinite(T)?T:0})}}),e[34]=r,e[35]=i,e[36]=o,e[37]=L):L=e[37];let $;e[38]!==r||e[39]!==p||e[40]!==m||e[41]!==v?($=r==="range"&&(0,t.jsxs)("div",{className:F.rangeRows,children:[(0,t.jsxs)("label",{className:F.rangeRow,children:[(0,t.jsx)("span",{className:F.fieldSublabel,children:"Min (â¥)"}),(0,t.jsx)("input",{type:"number",className:F.fieldInput,value:m,placeholder:"Any",onChange:k=>{const T=k.target.value;if(T===""){v("",p);return}const E=Number(T);Number.isFinite(E)&&v(E,p)}})]}),(0,t.jsxs)("label",{className:F.rangeRow,children:[(0,t.jsx)("span",{className:F.fieldSublabel,children:"Max (â¤)"}),(0,t.jsx)("input",{type:"number",className:F.fieldInput,value:p,placeholder:"Any",onChange:k=>{const T=k.target.value;if(T===""){v(m,"");return}const E=Number(T);Number.isFinite(E)&&v(m,E)}})]})]}),e[38]=r,e[39]=p,e[40]=m,e[41]=v,e[42]=$):$=e[42];let R;e[43]!==n||e[44]!==r||e[45]!==o?(R=r!=="unset"&&o!==void 0&&(0,t.jsxs)("p",{className:F.helperText,children:["Assert ",n.toLowerCase()," ",tw(o)]}),e[43]=n,e[44]=r,e[45]=o,e[46]=R):R=e[46];let P;return e[47]!==I||e[48]!==D||e[49]!==L||e[50]!==$||e[51]!==R?(P=(0,t.jsxs)("div",{className:F.assertionField,children:[I,D,L,$,R]}),e[47]=I,e[48]=D,e[49]=L,e[50]=$,e[51]=R,e[52]=P):P=e[52],P}function rA(s){return typeof s=="string"?s:typeof s=="object"&&s.eq!==void 0?s.eq:typeof s=="object"&&s.neq!==void 0?s.neq:""}function dA(s){return typeof s!="object"||s.includes===void 0?"":Array.isArray(s.includes)?s.includes.join(` 216`):s.includes}function gt(s){const e=(0,Ct.c)(59),{label:n,sublabel:a,value:o,suggestions:i,onChange:l}=s,r=(0,f.useId)();let d;e[0]!==o?(d=nA(o),e[0]=o,e[1]=d):d=e[1];const c=d;let m;e[2]!==o?(m=rA(o),e[2]=o,e[3]=m):m=e[3];const h=m;let p;e[4]!==o?(p=dA(o),e[4]=o,e[5]=p):p=e[5];const u=p;let g;
216e[6]!==h||e[7]!==u||e[8]!==l?(g=k=>{if(k==="unset"){l(void 0);return}if(k==="exact"){l(h||"");return}if(k==="notEqual"){l({neq:h||""});return}l({includes:u?u.split(` 217`).filter(Boolean):[""]})},e[6]=h,e[7]=u,e[8]=l,e[9]=g):g=e[9];const _=g;let v;e[10]!==n?(v=(0,t.jsx)("span",{className:F.fieldLabel,children:n}),e[10]=n,e[11]=v):v=e[11];let b;e[12]!==a?(b=a&&(0,t.jsx)("span",{className:F.fieldSublabel,children:a}),e[12]=a,e[13]=b):b=e[13];let j;e[14]!==v||e[15]!==b?(j=(0,t.jsxs)("div",{className:F.assertionFieldLabelGroup,children:[v,b]}),e[14]=v,e[15]=b,e[16]=j):j=e[16];let x;e[17]!==_?(x=k=>_(k.target.value),e[17]=_,e[18]=x):x=e[18];let S,C,y,N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)("option",{value:"unset",children:"Any"}),S=(0,t.jsx)("option",{value:"exact",children:"Exact"}),C=(0,t.jsx)("option",{value:"notEqual",children:"Not equal"}),y=(0,t.jsx)("option",{value:"contains",children:"Contains"}),e[19]=S,e[20]=C,e[21]=y,e[22]=N):(S=e[19],C=e[20],y=e[21],N=e[22]);let w;e[23]!==c||e[24]!==x?(w=(0,t.jsxs)("select",{className:F.fieldSelect,value:c,onChange:x,children:[N,S,C,y]}),e[23]=c,e[24]=x,e[25]=w):w=e[25];let A;e[26]!==w||e[27]!==j?(A=(0,t.jsxs)("div",{className:F.assertionFieldHeader,children:[j,w]}),e[26]=w,e[27]=j,e[28]=A):A=e[28];let I;e[29]!==i||e[30]!==r?(I=i&&i.length>0&&(0,t.jsx)("datalist",{id:r,children:i.map(cA)}),e[29]=i,e[30]=r,e[31]=I):I=e[31];let D;e[32]!==h||e[33]!==c||e[34]!==l||e[35]!==i?.length||e[36]!==r?(D=c==="exact"&&(0,t.jsx)("input",{type:"text",className:F.fieldInput,list:i?.length?r:void 0,value:h,onChange:k=>l(k.target.value)}),e[32]=h,e[33]=c,e[34]=l,e[35]=i?.length,e[36]=r,e[37]=D):D=e[37];let L;e[38]!==c||e[39]!==l||e[40]!==i?.length||e[41]!==r||e[42]!==o?(L=c==="notEqual"&&(0,t.jsx)("input",{type:"text",className:F.fieldInput,list:i?.length?r:void 0,value:typeof o=="object"&&o.neq!==void 0?o.neq:"",onChange:k=>l({neq:k.target.value})}),e[38]=c,e[39]=l,e[40]=i?.length,e[41]=r,e[42]=o,e[43]=L):L=e[43];let $;e[44]!==c||e[45]!==l||e[46]!==o?($=c==="contains"&&(0,t.jsx)(Xa,{placeholder:"One substring per line",value:iA(o),onChange:k=>l({includes:k&&k.length>0?k:[""]})}),e[44]=c,e[45]=l,e[46]=o,e[47]=$):$=e[47];let R;e[48]!==n||e[49]!==c||e[50]!==o?(R=c!=="unset"&&o!==void 0&&(0,t.jsxs)("p",{className:F.helperText,children:["Assert ",n.toLowerCase()," ",sw(o)]}),e[48]=n,e[49]=c,e[50]=o,e[51]=R):R=e[51];let P;return e[52]!==A||e[53]!==I||e[54]!==D||e[55]!==L||e[56]!==$||e[57]!==R?(P=(0,t.jsxs)("div",{className:F.assertionField,children:[A,I,D,L,$,R]}),e[52]=A,e[53]=I,e[54]=D,e[55]=L,e[56]=$,e[57]=R,e[58]=P):P=e[58],P}function cA(s){return(0,t.jsx)("option",{value:s},s)}function ht(s){const e=(0,Ct.c)(45),{label:n,sublabel:a,value:o,options:i,onChange:l}=s;let r;e[0]!==o?(r=aA(o),e[0]=o,e[1]=r):r=e[1];const d=r,c=typeof o=="string"?o:"";let m;e[2]!==o?(m=typeof o=="object"&&o.oneOf?o.oneOf:[],e[2]=o,e[3]=m):m=e[3];const h=m,p=i[0]??"";let u;e[4]!==n?(u=(0,t.jsx)("span",{className:F.fieldLabel,children:n}),e[4]=n,e[5]=u):u=e[5];let g;e[6]!==a?(g=a&&(0,t.jsx)("span",{className:F.fieldSublabel,children:a}),e[6]=a,e[7]=g):g=e[7];let _;e[8]!==u||e[9]!==g?(_=(0,t.jsxs)("div",{className:F.assertionFieldLabelGroup,children:[u,g]}),e[8]=u,e[9]=g,e[10]=_):_=e[10];let v;e[11]!==c||e[12]!==p||e[13]!==l||e[14]!==h?(v=I=>{const D=I.target.value;l(D==="unset"?void 0:D==="exact"?c||p:{oneOf:h.length>0?h:[p]})},e[11]=c,e[12]=p,e[13]=l,e[14]=h,e[15]=v):v=e[15];let b,j,x;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("option",{value:"unset",children:"Any"}),j=(0,t.jsx)("option",{value:"exact",children:"Exact"}),x=(0,t.jsx)("option",{value:"oneOf",children:"One of"}),e[16]=b,e[17]=j,e[18]=x):(b=e[16],j=e[17],x=e[18]);let S;e[19]!==d||e[20]!==v?(S=(0,t.jsxs)("select",{className:F.fieldSelect,value:d,onChange:v,children:[b,j,x]}),e[19]=d,e[20]=v,e[21]=S):S=e[21];let C;e[22]!==S||e[23]!==_?(C=(0,t.jsxs)("div",{className:F.assertionFieldHeader,children:[_,S]}),e[22]=S,e[23]=_,e[24]=C):C=e[24];let y;e[25]!==c||e[26]!==d||e[27]!==l||e[28]!==i?(y=d==="exact"&&(0,t.jsx)("select",{className:F.fieldSelect,value:c,onChange:I=>l(I.target.value),children:i.map(uA)}),e[25]=c,e[26]=d,e[27]=l,e[28]=i,e[29]=y):y=e[29];let N;
217e[30]!==p||e[31]!==d||e[32]!==l||e[33]!==h||e[34]!==i?(N=d==="oneOf"&&(0,t.jsx)("div",{className:F.toolGrid,children:i.map(I=>(0,t.jsxs)("label",{className:F.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:h.includes(I),onChange:()=>{const D=h.includes(I)?h.filter(L=>L!==I):[...h,I];l(D.length>0?{oneOf:D}:{oneOf:[p]})}}),(0,t.jsx)("span",{className:F.toolName,children:I})]},I))}),e[30]=p,e[31]=d,e[32]=l,e[33]=h,e[34]=i,e[35]=N):N=e[35];let w;e[36]!==n||e[37]!==d||e[38]!==o?(w=d!=="unset"&&o!==void 0&&(0,t.jsxs)("p",{className:F.helperText,children:["Assert ",n.toLowerCase()," ",nw(o)]}),e[36]=n,e[37]=d,e[38]=o,e[39]=w):w=e[39];let A;return e[40]!==C||e[41]!==y||e[42]!==N||e[43]!==w?(A=(0,t.jsxs)("div",{className:F.assertionField,children:[C,y,N,w]}),e[40]=C,e[41]=y,e[42]=N,e[43]=w,e[44]=A):A=e[44],A}function uA(s){return(0,t.jsx)("option",{value:s,children:s},s)}function Tt(s){const e=(0,Ct.c)(20),{label:n,sublabel:a,value:o,onChange:i}=s;let l;e[0]!==o?(l=lA(o),e[0]=o,e[1]=l):l=e[1];const r=l;let d;e[2]!==n?(d=(0,t.jsx)("span",{className:F.fieldLabel,children:n}),e[2]=n,e[3]=d):d=e[3];let c;e[4]!==a?(c=a&&(0,t.jsx)("span",{className:F.fieldSublabel,children:a}),e[4]=a,e[5]=c):c=e[5];let m;e[6]!==d||e[7]!==c?(m=(0,t.jsxs)("div",{className:F.assertionFieldLabelGroup,children:[d,c]}),e[6]=d,e[7]=c,e[8]=m):m=e[8];let h;e[9]!==i?(h=b=>{const j=b.target.value;i(j==="any"?void 0:j==="true")},e[9]=i,e[10]=h):h=e[10];let p,u,g;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("option",{value:"any",children:"Any"}),u=(0,t.jsx)("option",{value:"true",children:"True"}),g=(0,t.jsx)("option",{value:"false",children:"False"}),e[11]=p,e[12]=u,e[13]=g):(p=e[11],u=e[12],g=e[13]);let _;e[14]!==r||e[15]!==h?(_=(0,t.jsxs)("select",{className:F.fieldSelect,value:r,onChange:h,children:[p,u,g]}),e[14]=r,e[15]=h,e[16]=_):_=e[16];let v;return e[17]!==m||e[18]!==_?(v=(0,t.jsxs)("label",{className:F.field,children:[m,_]}
217),e[17]=m,e[18]=_,e[19]=v):v=e[19],v}function Cn(s){const e=(0,Ct.c)(22),{label:n,sublabel:a,value:o,onChange:i,children:l}=s;let r;e[0]!==n?(r=(0,t.jsx)("span",{className:F.fieldLabel,children:n}),e[0]=n,e[1]=r):r=e[1];let d;e[2]!==a?(d=a&&(0,t.jsx)("span",{className:F.fieldSublabel,children:a}),e[2]=a,e[3]=d):d=e[3];let c;e[4]!==r||e[5]!==d?(c=(0,t.jsxs)("div",{className:F.assertionFieldLabelGroup,children:[r,d]}),e[4]=r,e[5]=d,e[6]=c):c=e[6];let m;e[7]!==i||e[8]!==o?(m=()=>i(o===void 0?{}:void 0),e[7]=i,e[8]=o,e[9]=m):m=e[9];const h=o===void 0?"Add":"Remove";let p;e[10]!==m||e[11]!==h?(p=(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:m,children:h}),e[10]=m,e[11]=h,e[12]=p):p=e[12];let u;e[13]!==c||e[14]!==p?(u=(0,t.jsxs)("div",{className:F.assertionSubgroupHeader,children:[c,p]}),e[13]=c,e[14]=p,e[15]=u):u=e[15];let g;e[16]!==l||e[17]!==o?(g=o!==void 0&&l(o),e[16]=l,e[17]=o,e[18]=g):g=e[18];let _;return e[19]!==u||e[20]!==g?(_=(0,t.jsxs)("div",{className:F.assertionSubgroup,children:[u,g]}),e[19]=u,e[20]=g,e[21]=_):_=e[21],_}function mA(s){const e=(0,Ct.c)(12),{value:n,onChange:a}=s;let o;e[0]!==a||e[1]!==n?(o=d=>a({...n,present:d}),e[0]=a,e[1]=n,e[2]=o):o=e[2];let i;e[3]!==o||e[4]!==n.present?(i=(0,t.jsx)(Tt,{label:"Any adjustment set",sublabel:"True asserts kai_set_filters wrote at least one value",value:n.present,onChange:o}),e[3]=o,e[4]=n.present,e[5]=i):i=e[5];let l;e[6]!==a||e[7]!==n?(l=Bl.map(d=>(0,t.jsx)(qe,{label:Qw[d],value:n[d],onChange:c=>a({...n,[d]:c})},d)),e[6]=a,e[7]=n,e[8]=l):l=e[8];let r;return e[9]!==i||e[10]!==l?(r=(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[i,l]}),e[9]=i,e[10]=l,e[11]=r):r=e[11],r}function pA(s){const e=(0,Ct.c)(37),{value:n,onChange:a}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("p",{className:F.helperText,children:"Animation names are resolved through the project animation table, so a layer on either side of a cross transition also reports the transition id here."}),e[0]=o):o=e[0];let i;e[1]!==a||e[2]!==n?(i=v=>a({...n,hasIntro:v}),e[1]=a,e[2]=n,e[3]=i):i=e[3];let l;e[4]!==i||e[5]!==n.hasIntro?(l=(0,t.jsx)(Tt,{label:"Has intro animation",value:n.hasIntro,onChange:i}),e[4]=i,e[5]=n.hasIntro,e[6]=l):l=e[6];let r;e[7]!==a||e[8]!==n?(r=v=>a({...n,hasOutro:v}),e[7]=a,e[8]=n,e[9]=r):r=e[9];let d;e[10]!==r||e[11]!==n.hasOutro?(d=(0,t.jsx)(Tt,{label:"Has outro animation",value:n.hasOutro,onChange:r}),e[10]=r,e[11]=n.hasOutro,e[12]=d):d=e[12];let c;e[13]!==a||e[14]!==n?(c=v=>a({...n,intro:v}),e[13]=a,e[14]=n,e[15]=c):c=e[15];let m;e[16]!==c||e[17]!==n.intro?(m=(0,t.jsx)(gt,{label:"Intro animation",suggestions:Ta,value:n.intro,onChange:c}),e[16]=c,e[17]=n.intro,e[18]=m):m=e[18];let h;e[19]!==a||e[20]!==n?(h=v=>a({...n,outro:v}),e[19]=a,e[20]=n,e[21]=h):h=e[21];let p;e[22]!==h||e[23]!==n.outro?(p=(0,t.jsx)(gt,{label:"Outro animation",suggestions:Ta,value:n.outro,onChange:h}),e[22]=h,e[23]=n.outro,e[24]=p):p=e[24];let u;e[25]!==a||e[26]!==n?(u=v=>a({...n,constant:v}),e[25]=a,e[26]=n,e[27]=u):u=e[27];let g;e[28]!==u||e[29]!==n.constant?(g=(0,t.jsx)(gt,{label:"Constant animation",suggestions:Ta,value:n.constant,onChange:u}),e[28]=u,e[29]=n.constant,e[30]=g):g=e[30];let _;return e[31]!==g||e[32]!==l||e[33]!==d||e[34]!==m||e[35]!==p?(_=(0,t.jsxs)(t.Fragment,{children:[o,(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[l,d,m,p,g]})]}),e[31]=g,e[32]=l,e[33]=d,e[34]=m,e[35]=p,e[36]=_):_=e[36],_}function hA(s){const e=(0,Ct.c)(22),{value:n,onChange:a}=s;let o;e[0]!==a||e[1]!==n?(o=h=>a({...n,position:h}),e[0]=a,e[1]=n,e[2]=o):o=e[2];let i;e[3]!==o||e[4]!==n.position?(i=(0,t.jsx)(ht,{label:"Fade position",sublabel:"none matches a layer with no audio fade",value:n.position,options:Dl,onChange:o}),e[3]=o,e[4]=n.position,e[5]=i):i=e[5];let l;e[6]!==a||e[7]!==n?(l=h=>a({...n,introDurationSec:h}),e[6]=a,e[7]=n,e[8]=l):l=e[8];let r;e[9]!==l||e[10]!==n.introDurationSec?(r=(0,t.jsx)(qe,{label:"Intro fade (s)",sublabel:"slow 3, default 1, fast 0.5",value:n.introDurationSec,onChange:l}),e[9]=l,e[10]=n.introDurationSec,e[11]=r):r=e[11];let d;e[12]!==a||e[13]!==n?(d=h=>a({...n,outroDurationSec:h}),e[12]=a,e[13]=n,e[14]=d):d=e[14];let c;e[15]!==d||e[16]!==n.outroDurationSec?(c=(0,t.jsx)(qe,{label:"Outro fade (s)",value:n.outroDurationSec,onChange:d}),e[15]=d,e[16]=n.outroDurationSec,e[17]=c):c=e[17];let m;return e[18]!==i||e[19]!==r||e[20]!==c?(m=(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[i,r,c]}),e[18]=i,e[19]=r,e[20]=c,e[21]=m):m=e[21],m}function fA(s){const e=(0,Ct.c)(50),{value:n,onChange:a}=s;let o;e[0]!==a||e[1]!==n?(o=x=>a({...n,enabled:x}),e[0]=a,e[1]=n,e[2]=o):o=e[2];let i;e[3]!==o||e[4]!==n.enabled?(i=(0,t.jsx)(Tt,{label:"Mask enabled",value:n.enabled,onChange:o}),e[3]=o,e[4]=n.enabled,e[5]=i):i=e[5];let l;e[6]!==a||e[7]!==n?(l=x=>a({...n,mode:x}),e[6]=a,e[7]=n,e[8]=l):l=e[8];let r;e[9]!==l||e[10]!==n.mode?(r=(0,t.jsx)(ht,{label:"Mask mode",value:n.mode,options:Ml,onCh
217ange:l}),e[9]=l,e[10]=n.mode,e[11]=r):r=e[11];let d;e[12]!==a||e[13]!==n?(d=x=>a({...n,invert:x}),e[12]=a,e[13]=n,e[14]=d):d=e[14];let c;e[15]!==d||e[16]!==n.invert?(c=(0,t.jsx)(Tt,{label:"Inverted",value:n.invert,onChange:d}),e[15]=d,e[16]=n.invert,e[17]=c):c=e[17];let m;e[18]!==a||e[19]!==n?(m=x=>a({...n,assetId:x}),e[18]=a,e[19]=n,e[20]=m):m=e[20];let h;e[21]!==m||e[22]!==n.assetId?(h=(0,t.jsx)(gt,{label:"Mask asset id",value:n.assetId,onChange:m}),e[21]=m,e[22]=n.assetId,e[23]=h):h=e[23];let p;e[24]!==a||e[25]!==n?(p=x=>a({...n,blurAmount:x}),e[24]=a,e[25]=n,e[26]=p):p=e[26];let u;e[27]!==p||e[28]!==n.blurAmount?(u=(0,t.jsx)(qe,{label:"Blur amount",value:n.blurAmount,onChange:p}),e[27]=p,e[28]=n.blurAmount,e[29]=u):u=e[29];let g;e[30]!==a||e[31]!==n?(g=x=>a({...n,expandAmount:x}),e[30]=a,e[31]=n,e[32]=g):g=e[32];let _;e[33]!==g||e[34]!==n.expandAmount?(_=(0,t.jsx)(qe,{label:"Expand amount",value:n.expandAmount,onChange:g}),e[33]=g,e[34]=n.expandAmount,e[35]=_):_=e[35];let v;e[36]!==a||e[37]!==n?(v=x=>a({...n,featherAmount:x}),e[36]=a,e[37]=n,e[38]=v):v=e[38];let b;e[39]!==v||e[40]!==n.featherAmount?(b=(0,t.jsx)(qe,{label:"Feather amount",value:n.featherAmount,onChange:v}),e[39]=v,e[40]=n.featherAmount,e[41]=b):b=e[41];let j;return e[42]!==u||e[43]!==_||e[44]!==b||e[45]!==i||e[46]!==r||e[47]!==c||e[48]!==h?(j=(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[i,r,c,h,u,_,b]}),e[42]=u,e[43]=_,e[44]=b,e[45]=i,e[46]=r,e[47]=c,e[48]=h,e[49]=j):j=e[49],j}function xA(s){const e=(0,Ct.c)(53),{value:n,onChange:a}=s;let o;e[0]!==n.phrases?(o=n.phrases??[],e[0]=n.phrases,e[1]=o):o=e[1];const i=o;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("p",{className:F.helperText,children:"Phrase matching ignores case, punctuation, and repeated whitespace."}),e[2]=l):l=e[2];let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("span",{className:F.fieldLabel,children:"Exact transcript (optional)"}),e[3]=r):r=e[3];const d=n.contentEquals??"";let c;e[4]!==a||e[5]!==n?(c=L=>a({...n,contentEquals:L.target.value||void 0}),e[4]=a,e[5]=n,e[6]=c):c=e[6];let m;e[7]!==d||e[8]!==c?(m=(0,t.jsxs)("label",{className:F.field,children:[r,(0,t.jsx)("textarea",{className:F.fieldTextarea,value:d,onChange:c})]}),e[7]=d,e[8]=c,e[9]=m):m=e[9];let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("span",{className:F.fieldLabel,children:"Transcript starts with"}),e[10]=h):h=e[10];const p=n.contentStartsWith??"";let u;e[11]!==a||e[12]!==n?(u=L=>a({...n,contentStartsWith:L.target.value||void 0}),e[11]=a,e[12]=n,e[13]=u):u=e[13];let g;e[14]!==p||e[15]!==u?(g=(0,t.jsxs)("label",{className:F.field,children:[h,(0,t.jsx)("input",{className:F.fieldInput,value:p,onChange:u})]}),e[14]=p,e[15]=u,e[16]=g):g=e[16];let _;e[17]!==a||e[18]!==i||e[19]!==n?(_=i.map((L,$)=>(0,t.jsxs)("div",{className:F.assertionField,children:[(0,t.jsxs)("label",{className:F.field,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Transcript phrase"}),(0,t.jsx)("input",{className:F.fieldInput,value:L.text,onChange:R=>{const P=[...i];P[$]={...L,text:R.target.value},a({...n,phrases:P})}})]}),(0,t.jsx)(qe,{label:"Occurrences",value:L.occurrences,onChange:R=>{if(R===void 0)return;const P=[...i];P[$]={...L,occurrences:R},a({...n,phrases:P})}}),(0,t.jsxs)("label",{className:F.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:L.startsWith===!0,onChange:R=>{const P=[...i];P[$]={...L,startsWith:R.target.checked?!0:void 0},a({...n,phrases:P})}}),(0,t.jsx)("span",{className:F.toolName,children:"Starts with"})]}),(0,t.jsxs)("label",{className:F.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:L.endsWith===!0,onChange:R=>{const P=[...i];P[$]={...L,endsWith:R.target.checked?!0:void 0},a({...n,phrases:P})}}),(0,t.jsx)("span",{className:F.toolName,children:"Ends with"})]}),(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,phrases:i.filter((R,P)=>P!==$)}),children:"Remove phrase"})]},$)),e[17]=a,e[18]=i,e[19]=n,e[20]=_):_=e[20];let v;e[21]!==a||e[22]!==i||e[23]!==n?(v=(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,phrases:[...i,{text:"",occurrences:1}]}),children:"Add transcript phrase"}),e[21]=a,e[22]=i,e[23]=n,e[24]=v):v=e[24];let b;e[25]!==a||e[26]!==n?(b=L=>a({...n,speakerCount:L}),e[25]=a,e[26]=n,e[27]=b):b=e[27];let j;e[28]!==b||e[29]!==n.speakerCount?(j=(0,t.jsx)(qe,{label:"Speaker count",sublabel:"Distinct speaker labels represented by retained words",value:n.speakerCount,onChange:b}),e[28]=b,e[29]=n.speakerCount,e[30]=j):j=e[30];let x;e[31]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)("span",{className:F.fieldLabel,children:"Maximum silence (seconds)"}),e[31]=x):x=e[31];const S=n.maxSilenceSec??"";let C;e[32]!==a||e[33]!==n?(C=L=>{const $=L.target.value;a({...n,maxSilenceSec:$===""?void 0:Number($)})},e[32]=a,e[33]=n,e[34]=C):C=e[34];let y;e[35]!==S||e[36]!==C?(y=(0,t.jsxs)("label",{className:F.field,children:[x,(0,t.jsx)("input",{type:"number",min:"0",step:"0.1",className:F.fieldInput,value:S,placeholder:"Any",onChange:C})]}),e[35]=S,e[36]=C,e[37]=y):y=e[37];let N;e[38]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)("span",{className:F.fieldLabel,children:"Minimum source asset duration (seconds)"}),e[38]=N):N=e[38];const w=n.minAudibleLayerDurationSec??"";let A;e[39]!==a||e[40]!==n?(A=L=>{const $=L.target.value;a({...n,minAudibleLayerDurationSec:$===""?void 0:Number($)})},e[39]=a,e[40]=n,e[41]=A):A=e[41];let I;e[42]!==w||e[43]!==A?(I=(0,t.jsxs)("label",{className:F.field,children:[N,(0,t.jsx)("input",{type:"number",min:"0",step:"0.1",className:F.fieldInput,value:w,placeholder:"0",onChange:A})]}),e[42]=w,e[43]=A,e[44]=I):I=e[44];let D;return e[45]!==g||e[46]!==_||e[47]!==v||e[48]!==j||e[49]!==y||e[50]!==I||e[51]!==m?(D=(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[l,m,g,_,v,j,y,I]}),e[45]=g,e[46]=_,e[47]=v,e[48]=j,e[49]=y,e[50]=I,e[51]=m,e[52]=D):D=e[52],D}function gA(s){const e=(0,Ct.c)(197),{value:n,onChange:a,onRemove:o}=s;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("span",{className:F.fieldLabel,children:"Layer expectation"}),e[0]=i):i=e[0];let l;e[1]!==o?(l=(0,t.jsxs)("div",{className:F.assertionFieldHeader,children:[i,(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:o,children:"Remove"})]}),e[1]=o,e[2]=l):l=e[2];let r;e[3]!==a||e[4]!==n?(r=re=>a({...n,type:re}),e[3]=a,e[4]=n,e[5]=r):r=e[5];let d;e[6]!==r||e[7]!==n.type?(d=(0,t.jsx)(ht,{label:"Type",value:n.type,options:Yw,onChange:r}),e[6]=r,e[7]=n.type,e[8]=d):d=e[8];let c;e[9]!==a||e[10]!==n?(c=re=>a({...n,timelineDurationSec:re}),e[9]=a,e[10]=n,e[11]=c):c=e[11];let m;e[12]!==c||e[13]!==n.timelineDurationSec?(m=(0,t.jsx)(qe,{label:"Timeline duration",sublabel:"How much time the layer takes on the project timeline (seconds)",value:n.timelineDurationSec,onChange:c}),e[12]=c,e[13]=n.timelineDurationSec,e[14]=m):m=e[14];let h;e[15]!==a||e[16]!==n?(h=re=>a({...n,videoDelay:re}),e[15]=a,e[16]=n,e[17]=h):h=e[17];let p;e[18]!==h||e[19]!==n.videoDelay?(p=(0,t.jsx)(qe,{label:"Video delay",sublabel:"Where the trimmed clip starts on the project timeline (seconds). NOTE: only applicable to video/audio layers.",value:n.videoDelay,onChange:h}),e[18]=h,e[19]=n.videoDelay,e[20]=p):p=e[20];let u;e[21]!==a||e[22]!==n?(u=re=>a({...n,startTime:re}),e[21]=a,e[22]=n,e[23]=u):u=e[23];let g;e[24]!==u||e[25]!==n.startTime?(g=(0,t.jsx)(qe,{label:"Start time",sublabel:"Trim start inside the source asset (seconds)",value:n.startTime,onChange:u}),e[24]=u,e[25]=n.startTime,e[26]=g):g=e[26];let _;e[27]!==a||e[28]!==n?(_=re=>a({...n,endTime:re}),e[27]=a,e[28]=n,e[29]=_):_=e[29];let v;e[30]!==_||e[31]!==n.endTime?(v=(0,t.jsx)(qe,{label:"End time",sublabel:"Trim end inside the source asset (seconds)",value:n.endTime,onChange:_}),e[30]=_,e[31]=n.endTime,e[32]=v):v=e[32];let b;e[33]!==a||e[34]!==n?(b=re=>a({...n,duration:re}),e[33]=a,e[34]=n,e[35]=b):b=e[35];let j;e[36]!==b||e[37]!==n.duration?(j=(0,t.jsx)(qe,{label:"Full Asset Duration",sublabel:"Source asset length (layer.duration), not the trimmed timeline span",value:n.duration,onChange:b}),e[36]=b,e[37]=n.duration,e[38]=j):j=e[38];let x;e[39]!==a||e[40]!==n?(x=re=>a({...n,playbackRate:re}),e[39]=a,e[40]=n,e[41]=x):x=e[41];let S;e[42]!==x||e[43]!==n.playbackRate?(S=(0,t.jsx)(qe,{label:"Playback rate",value:n.playbackRate,onChange:x}),e[42]=x,e[43]=n.playbackRate,e[44]=S):S=e[44];let C;e[45]!==a||e[46]!==n?(C=re=>a({...n,timelineRow:re}),e[45]=a,e[46]=n,e[47]=C):C=e[47];let y;e[48]!==C||e[49]!==n.timelineRow?(y=(0,t.jsx)(qe,{label:"Timeline row",value:n.timelineRow,onChange:C}),e[48]=C,e[49]=n.timelineRow,e[50]=y):y=e[50];let N;e[51]!==a||e[52]!==n?(N=re=>a({...n,width:re}),e[51]=a,e[52]=n,e[53]=N):N=e[53];let w;e[54]!==N||e[55]!==n.width?(w=(0,t.jsx)(qe,{label:"Width",value:n.width,onChange:N}),e[54]=N,e[55]=n.width,e[56]=w):w=e[56];let A;e[57]!==a||e[58]!==n?(A=re=>a({...n,height:re}),e[57]=a,e[58]=n,e[59]=A):A=e[59];let I;e[60]!==A||e[61]!==n.height?(I=(0,t.jsx)(qe,{label:"Height",value:n.height,onChange:A}),e[60]=A,e[61]=n.height,e[62]=I):I=e[62];let D;e[63]!==a||e[64]!==n?(D=re=>a({...n,aspectRatio:re}),e[63]=a,e[64]=n,e[65]=D):D=e[65];let L;e[66]!==D||e[67]!==n.aspectRatio?(L=(0,t.jsx)(ht,{label:"Aspect ratio",sublabel:"Matches computed width÷height to a named ratio",value:n.aspectRatio,options:Ks,onChange:D}),e[66]=D,e[67]=n.aspectRatio,e[68]=L):L=e[68];let $;e[69]!==a||e[70]!==n?($=re=>a({...n,asset_id:re}),e[69]=a,e[70]=n,e[71]=$):$=e[71];let R;e[72]!==$||e[73]!==n.asset_id?(R=(0,t.jsx)(gt,{label:"Asset id",value:n.asset_id,onChange:$}),e[72]=$,e[73]=n.asset_id,e[74]=R):R=e[74];let P;e[75]!==a||e[76]!==n?(P=re=>a({...n,name:re}),e[75]=a,e[76]=n,e[77]=P):P=e[77];let k;e[78]!==P||e[79]!==n.name?(k=(0,t.jsx)(gt,{label:"Name",value:n.name,onChange:P}),e[78]=P,e[79]=n.name,e[80]=k):k=e[80];let T;e[81]!==a||e[82]!==n?(T=re=>a({...n,mime:re}),e[81]=a,e[82]=n,e[83]=T):T=e[83];let E;e[84]!==T||e[85]!==n.mime?(E=(0,t.jsx)(ht,{label:"Mime",value:n.mime,options:on,onChange:T}),e[84]=T,e[85]=n.mime,e[86]=E):E=e[86];let O;e[87]!==a||e[88]!==n?(O=re=>a({...n,hasAudio:re}),e[87]=a,e[88]=n,e[89]=O):O=e[89];let q;e[90]!==O||e[91]!==n.hasAudio?(q=(0,t.jsx)(Tt,{label:"Has audio",value:n.hasAudio,onChange:O}),e[90]=O,e[91]=n.hasAudio,e[92]=q):q=e[92];let J;e[93]!==a||e[94]!==n?(J=re=>a({...n,volume:re}),e[93]=a,e[94]=n,e[95]=J):J=e[95];let K;e[96]!==J||e[97]!==n.volume?(K=(0,t.jsx)(qe,{label:"Volume",value:n.volume,onChange:J}),e[96]=J,e[97]=n.volume,e[98]=K):K=e[98];let z;e[99]!==a||e[100]!==n?(z=re=>a({...n,text:re}),e[99]=a,e[100]=n,e[101]=z):z=e[101];let Y;e[102]!==z||e[103]!==n.text?(Y=(0,t.jsx)(gt,{label:"Text",sublabel:"Source text on a text layer (kaiSourceText, falling back to text)",value:n.text,onChange:z}),e[102]=z,e[103]=n.text,e[104]=Y):Y=e[104];let me;e[105]!==a||e[106]!==n?(me=re=>a({...n,fontFamily:re}),e[105]=a,e[106]=n,e[107]=me):me=e[107];let X;e[108]!==me||e[109]!==n.fontFamily?(X=(0,t.jsx)(gt,{label:"Font family",sublabel:"Font family of the text layer",value:n.fontFamily,onChange:me}),e[108]=me,e[109]=n.fontFamily,e[110]=X):X=e[110];let te;e[111]!==a||e[112]!==n?(te=re=>a({...n,color:re}),e[111]=a,e[112]=n,e[113]=te):te=e[113];let ae;e[114]!==te||e[115]!==n.color?(ae=(0,t.jsx)(gt,{label:"Color",sublabel:"Color of the text layer",value:n.color,onChange:te}),e[114]=te,e[115]=n.color,e[116]=ae):ae=e[116];let G;e[117]!==a||e[118]!==n?(G=re=>a({...n,fontSize:re}),e[117]=a,e[118]=n,e[119]=G):G=e[119];let se;e[120]!==G||e[121]!==n.fontSize?(se=(0,t.jsx)(qe,{label:"Font size",sublabel:"Font size of the text layer",value:n.fontSize,onChange:G}),e[120]=G,e[121]=n.fontSize,e[122]=se):se=e[122];let U;e[123]!==a||e[124]!==n?(U=re=>a({...n,presetFilterId:re}),e[123]=a,e[124]=n,e[125]=U):U=e[125];let B;e[126]!==U||e[127]!==n.presetFilterId?(B=(0,t.jsx)(ht,{label:"Preset filter",sublabel:"Named Studio look from kai_set_preset_filter",value:n.presetFilterId,options:Ll,onChange:U}),e[126]=U,e[127]=n.presetFilterId,e[128]=B):B=e[128];let oe;e[129]!==a||e[130]!==n?(oe=re=>a({...n,personaId:re}),e[129]=a,e[130]=n,e[131]=oe):oe=e[131];let de;e[132]!==oe||e[133]!==n.personaId?(de=(0,t.jsx)(gt,{label:"Persona id",sublabel:"Persona backing a talking-head layer",value:n.personaId,onChange:oe}),e[132]=oe,e[133]=n.personaId,e[134]=de):de=e[134];let ye;e[135]!==g||e[136]!==v||e[137]!==j||e[138]!==S||e[139]!==y||e[140]!==w||e[141]!==I||e[142]!==L||e[143]!==R||e[144]!==k||e[145]!==E||e[146]!==q||e[147]!==K||e[148]!==Y||e[149]!==X||e[150]!==d||e[151]!==ae||e[152]!==se||e[153]!==B||e[154]!==de||e[155]!==m||e[156]!==p?(ye=(0,t.jsxs)("div",{className:F.layerAssertionFields,children:[d,m,p,g,v,j,S,y,w,I,L,R,k,E,q,K,Y,X,ae,se,B,de]}),e[135]=g,e[136]=v,e[137]=j,e[138]=S,e[139]=y,e[140]=w,e[141]=I,e[142]=L,e[143]=R,e[144]=k,e[145]=E,e[146]=q,e[147]=K,e[148]=Y,e[149]=X,e[150]=d,e[151]=ae,e[152]=se,e[153]=B,e[154]=de,e[155]=m,e[156]=p,e[157]=ye):ye=e[157];let Le,Ne;e[158]!==a||e[159]!==n?(Le=re=>a({...n,filters:re}),Ne=re=>(0,t.jsx)(mA,{value:re,onChange:V=>a({...n,filters:V})}),e[158]=a,e[159]=n,e[160]=Le,e[161]=Ne):(Le=e[160],Ne=e[161]);let Be;e[162]!==Le||e[163]!==Ne||e[164]!==n.filters?(Be=(0,t.jsx)(Cn,{label:"Colour filters",sublabel:"Adjustments written by kai_set_filters",value:n.filters,onChange:Le,children:Ne}),e[162]=Le,e[163]=Ne,e[164]=n.filters,e[165]=Be):Be=e[165];let le,he;e[166]!==a||e[167]!==n?(le=re=>a({...n,animation:re}),he=re=>(0,t.jsx)(pA,{value:re,onChange:V=>a({...n,animation:V})}),e[166]=a,e[167]=n,e[168]=le,e[169]=he):(le=e[168],he=e[169]);let ge;e[170]!==le||e[171]!==he||e[172]!==n.animation?(ge=(0,t.jsx)(Cn,{label:"Animations & transitions",sublabel:"Intro / outro / constant animations on this layer",value:n.animation,onChange:le,children:he}),e[170]=le,e[171]=he,e[172]=n.animation,e[173]=ge):ge=e[173];let je,ue;e[174]!==a||e[175]!==n?(je=re=>a({...n,audioFade:re}),ue=re=>(0,t.jsx)(hA,{value:re,onChange:V=>a({...n,audioFade:V})}),e[174]=a,e[175]=n,e[176]=je,e[177]=ue):(je=e[176],ue=e[177]);let pe;e[178]!==je||e[179]!==ue||e[180]!==n.audioFade?(pe=(0,t.jsx)(Cn,{label:"Audio fade",sublabel:"Written by kai_set_audio_fade",value:n.audioFade,onChange:je,children:ue}),e[178]=je,e[179]=ue,e[180]=n.audioFade,e[181]=pe):pe=e[181];let ee,xe;e[182]!==a||e[183]!==n?(ee=re=>a({...n,mask:re}),xe=re=>(0,t.jsx)(fA,{value:re,onChange:V=>a({...n,mask:V})}),e[182]=a,e[183]=n,e[184]=ee,e[185]=xe):(ee=e[184],xe=e[185]);let ve;e[186]!==ee||e[187]!==xe||e[188]!==n.mask?(ve=(0,t.jsx)(Cn,{label:"Mask",sublabel:"Written by kai_mask_video",value:n.mask,onChange:ee,children:xe}),e[186]=ee,e[187]=xe,e[188]=n.mask,e[189]=ve):ve=e[189];let we;return e[190]!==l||e[191]!==ye||e[192]!==Be||e[193]!==ge||e[194]!==pe||e[195]!==ve?(we=(0,t.jsxs)("div",{className:F.layerAssertionCard,children:[l,ye,Be,ge,pe,ve]}),e[190]=l,e[191]=ye,e[192]=Be,e[193]=ge,e[194]=pe,e[195]=ve,e[196]=we):we=e[196],we}function vA(s){const e=(0,Ct.c)(35),{value:n,onChange:a,onRemove:o}=s;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("span",{className:F.fieldLabel,children:"Transition expectation"}),e[0]=i):i=e[0];let l;e[1]!==o?(l=(0,t.jsxs)("div",{className:F.assertionFieldHeader,children:[i,(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:o,children:"Remove"})]}),e[1]=o,e[2]=l):l=e[2];let r;e[3]!==a||e[4]!==n?(r=b=>a({...n,transitionId:b}),e[3]=a,e[4]=n,e[5]=r):r=e[5];let d;e[6]!==r||e[7]!==n.transitionId?(d=(0,t.jsx)(gt,{label:"Transition id",suggestions:$2,value:n.transitionId,onChange:r}),e[6]=r,e[7]=n.transitionId,e[8]=d):d=e[8];let c;e[9]!==a||e[10]!==n?(c=b=>a({...n,durationSec:b}),e[9]=a,e[10]=n,e[11]=c):c=e[11];let m;e[12]!==c||e[13]!==n.durationSec?(m=(0,t.jsx)(qe,{label:"Duration (s)",value:n.durationSec,onChange:c}),e[12]=c,e[13]=n.durationSec,e[14]=m):m=e[14];let h;e[15]!==a||e[16]!==n?(h=b=>a({...n,fromAssetId:b}),e[15]=a,e[16]=n,e[17]=h):h=e[17];let p;e[18]!==h||e[19]!==n.fromAssetId?(p=(0,t.jsx)(gt,{label:"From asset id",sublabel:"asset_id of the outgoing layer",value:n.fromAssetId,onChange:h}),e[18]=h,e[19]=n.fromAssetId,e[20]=p):p=e[20];let u;e[21]!==a||e[22]!==n?(u=b=>a({...n,toAssetId:b}),e[21]=a,e[22]=n,e[23]=u):u=e[23];let g;e[24]!==u||e[25]!==n.toAssetId?(g=(0,t.jsx)(gt,{label:"To asset id",sublabel:"asset_id of the incoming layer",value:n.toAssetId,
217onChange:u}),e[24]=u,e[25]=n.toAssetId,e[26]=g):g=e[26];let _;e[27]!==g||e[28]!==d||e[29]!==m||e[30]!==p?(_=(0,t.jsxs)("div",{className:F.layerAssertionFields,children:[d,m,p,g]}),e[27]=g,e[28]=d,e[29]=m,e[30]=p,e[31]=_):_=e[31];let v;return e[32]!==_||e[33]!==l?(v=(0,t.jsxs)("div",{className:F.layerAssertionCard,children:[l,_]}),e[32]=_,e[33]=l,e[34]=v):v=e[34],v}function _A(s){const e=(0,Ct.c)(49),{value:n,onChange:a}=s;let o;e[0]!==n.match?(o=n.match??[],e[0]=n.match,e[1]=o):o=e[1];const i=o;let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("p",{className:F.helperText,children:"Name and count read the characters this run attached to the chat. Brandkit and stock characters are picked rather than created, so they only appear under mention usage. To check that an existing character was used, set Used in generation instead of attachment or count checks."}),e[2]=l):l=e[2];let r;e[3]!==a||e[4]!==n?(r=y=>a({...n,present:y}),e[3]=a,e[4]=n,e[5]=r):r=e[5];let d;e[6]!==r||e[7]!==n.present?(d=(0,t.jsx)(Tt,{label:"Any character attached",value:n.present,onChange:r}),e[6]=r,e[7]=n.present,e[8]=d):d=e[8];let c;e[9]!==a||e[10]!==n?(c=y=>a({...n,usedInGeneration:y}),e[9]=a,e[10]=n,e[11]=c):c=e[11];let m;e[12]!==c||e[13]!==n.usedInGeneration?(m=(0,t.jsx)(Tt,{label:"Used in generation",sublabel:"A generation job resolved character mentions",value:n.usedInGeneration,onChange:c}),e[12]=c,e[13]=n.usedInGeneration,e[14]=m):m=e[14];let h;e[15]!==a||e[16]!==n?(h=y=>a({...n,count:y}),e[15]=a,e[16]=n,e[17]=h):h=e[17];let p;e[18]!==h||e[19]!==n.count?(p=(0,t.jsx)(qe,{label:"Chat-attached character count",value:n.count,onChange:h}),e[18]=h,e[19]=n.count,e[20]=p):p=e[20];let u;e[21]!==d||e[22]!==m||e[23]!==p?(u=(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[d,m,p]}),e[21]=d,e[22]=m,e[23]=p,e[24]=u):u=e[24];let g,_;e[25]!==a||e[26]!==n?(g=y=>a({...n,usage:y}),_=y=>(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[(0,t.jsx)(qe,{label:"Brandkit / user created",value:y.userCreated,onChange:N=>a({...n,usage:{...y,userCreated:N}})}),(0,t.jsx)(qe,{label:"Chat created",value:y.chatCreated,onChange:N=>a({...n,usage:{...y,chatCreated:N}})}),(0,t.jsx)(qe,{label:"Stock",value:y.stock,onChange:N=>a({...n,usage:{...y,stock:N}})})]}),e[25]=a,e[26]=n,e[27]=g,e[28]=_):(g=e[27],_=e[28]);let v;e[29]!==g||e[30]!==_||e[31]!==n.usage?(v=(0,t.jsx)(Cn,{label:"Mention usage",sublabel:"Summed per job â one character used by three generations counts three times",value:n.usage,onChange:g,children:_}),e[29]=g,e[30]=_,e[31]=n.usage,e[32]=v):v=e[32];let b;e[33]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("span",{className:F.fieldLabel,children:"Named characters"}),e[33]=b):b=e[33];let j;e[34]!==i||e[35]!==a||e[36]!==n?(j=(0,t.jsxs)("div",{className:F.toolCallHeader,children:[b,(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,match:[...i,{}]}),children:"Add character expectation"})]}),e[34]=i,e[35]=a,e[36]=n,e[37]=j):j=e[37];let x;e[38]!==i||e[39]!==a||e[40]!==n?(x=i.map((y,N)=>(0,t.jsxs)("div",{className:F.layerAssertionCard,children:[(0,t.jsxs)("div",{className:F.assertionFieldHeader,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Character expectation"}),(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>{const w=i.filter((A,I)=>I!==N);a({...n,match:w.length>0?w:void 0})},children:"Remove"})]}),(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[(0,t.jsx)(gt,{label:"Name",value:y.name,onChange:w=>{const A=[...i];A[N]={...y,name:w},a({...n,match:A})}}),(0,t.jsx)(ht,{label:"Source",value:y.source,options:Fl,onChange:w=>{const A=[...i];A[N]={...y,source:w},a({...n,match:A})}})]})]},N)),e[38]=i,e[39]=a,e[40]=n,e[41]=x):x=e[41];let S;e[42]!==x?(S=(0,t.jsx)("div",{className:F.layerCardsGrid,children:x}),e[42]=x,e[43]=S):S=e[43];let C;return e[44]!==v||e[45]!==j||e[46]!==S||e[47]!==u?(C=(0,t.jsxs)(t.Fragment,{children:[l,u,v,j,S]}),e[44]=v,e[45]=j,e[46]=S,e[47]=u,e[48]=C):C=e[48],C}function jA(s){return s==="text"?{kind:"text"}:s==="project"?{kind:"project",layers:[]}:s==="image"?{kind:"image"}:s==="audio"?{kind:"audio"}:{kind:"scene"}}function Ol(s){const e=(0,Ct.c)(24),{value:n,onChange:a,testOutputs:o}=s;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];const[l,r]=(0,f.useState)(i),d=n!==void 0,c=n?.kind==="asset"?"scene":n?.kind??"project";let m;e[1]!==a?(m=function(S){a(jA(S))},e[1]=a,e[2]=m):m=e[2];const h=m;let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("label",{className:F.fieldLabel,children:"Expected result assertions"}),e[3]=p):p=e[3];let u;e[4]!==d||e[5]!==a?(u=()=>{a(d?void 0:{kind:"project",layers:[]})},e[4]=d,e[5]=a,e[6]=u):u=e[6];const g=d?"Disable result asserts":"Enable result asserts";let _;e[7]!==u||e[8]!==g?(_=(0,t.jsxs)("div",{className:F.toolCallHeader,children:[p,(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:u,children:g})]}),e[7]=u,e[8]=g,e[9]=_):_=e[9];let v;e[10]!==d?(v=!d&&(0,t.jsx)("p",{className:F.helperText,children:"Optional. When enabled, autonomous variants are checked against the expected output kind and field assertions (e.g. duration >= 2 and < 5). Video maps to Kai's scene output type under the hood."}),e[10]=d,e[11]=v):v=e[11];let b;e[12]!==l||e[13]!==h||e[14]!==d||e[15]!==c||e[16]!==a||e[17]!==o||e[18]!==n?(b=d&&n&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:F.kindSelectRow,children:(0,t.jsxs)("label",{className:F.field,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Expected output kind"}),(0,t.jsx)("select",{className:F.fieldSelect,value:c,onChange:x=>h(x.target.value),children:Pl.map(bA)})]})}),(0,t.jsxs)("div",{className:F.toolCallHeader,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Kai character expectations"}),(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,characters:n.characters===void 0?{}:void 0}),children:n.characters===void 0?"Add":"Remove"})]}),n.characters!==void 0&&(0,t.jsx)(_A,{value:n.characters,onChange:x=>a({...n,characters:x})}),n.kind==="text"&&(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[(0,t.jsxs)("label",{className:F.field,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Exact text match (optional)"}),(0,t.jsx)("textarea",{className:F.fieldTextarea,value:n.contentEquals??"",onChange:x=>a({...n,contentEquals:x.target.value||void 0})})]}),(0,t.jsx)(Xa,{label:"Content must include (one phrase per line)",value:n.contentIncludes,onChange:x=>a({...n,contentIncludes:x})})]}),n.kind!=="text"&&n.kind!=="project"&&(0,t.jsx)("p",{className:F.helperText,children:"Media assertions apply to every returned asset. Video, image, and audio kinds require all returned assets to have that media type."}),n.kind==="image"&&(0,t.jsxs)("div",{className:F.assertionFieldsGrid,children:[(0,t.jsx)(qe,{label:"Width",value:n.width,onChange:x=>a({...n,width:x})}),(0,t.jsx)(qe,{label:"Height",value:n.height,onChange:x=>a({...n,height:x})}),(0,t.jsx)(ht,{label:"Aspect ratio",sublabel:"Matches computed width÷height to a named ratio",value:n.aspectRatio,options:Ks,onChange:x=>a({...n,aspectRatio:x})}),(0,t.jsx)(ht,{label:"Mime type",value:n.mimeType,options:on,onChange:x=>a({...n,mimeType:x})})]}),n.kind==="scene"&&(0,t.jsxs)("div",{className:F.assertionFieldsGrid,children:[(0,t.jsx)(qe,{label:"Width",value:n.width,onChange:x=>a({...n,width:x})}),(0,t.jsx)(qe,{label:"Height",value:n.height,onChange:x=>a({...n,height:x})}),(0,t.jsx)(qe,{label:"Duration",sublabel:"(seconds)",value:n.duration,onChange:x=>a({...n,duration:x})}),(0,t.jsx)(ht,{label:"Aspect ratio",sublabel:"Matches computed width÷height to a named ratio",value:n.aspectRatio,options:Ks,onChange:x=>a({...n,aspectRatio:x})}),(0,t.jsx)(ht,{label:"Mime type",value:n.mimeType,options:on,onChange:x=>a({...n,mimeType:x})}),(0,t.jsx)(Tt,{label:"Has audio",value:n.hasAudio,onChange:x=>a({...n,hasAudio:x})})]}),n.kind==="audio"&&(0,t.jsxs)("div",{className:F.assertionFieldsGrid,children:[(0,t.jsx)(qe,{label:"Duration",sublabel:"(seconds)",value:n.duration,onChange:x=>a({...n,duration:x})}),(0,t.jsx)(ht,{label:"Mime type",value:n.mimeType,options:on,onChange:x=>a({...n,mimeType:x})})]}),n.kind==="asset"&&(0,t.jsxs)("div",{className:F.assertionFieldsGrid,children:[(0,t.jsx)(qe,{label:"Duration",sublabel:"(seconds)",value:n.duration,onChange:x=>a({...n,duration:x})}),(0,t.jsx)(qe,{label:"Width",value:n.width,onChange:x=>a({...n,width:x})}),(0,t.jsx)(qe,{label:"Height",value:n.height,onChange:x=>a({...n,height:x})}),(0,t.jsx)(ht,{label:"Aspect ratio",sublabel:"Matches computed width÷height to a named ratio",value:n.aspectRatio,options:Ks,onChange:x=>a({...n,aspectRatio:x})}),(0,t.jsx)(ht,{label:"Mime type",value:n.mimeType,options:on,onChange:x=>a({...n,mimeType:x})}),(0,t.jsx)(Tt,{label:"Has audio",value:n.hasAudio,onChange:x=>a({...n,hasAudio:x})})]}),n.kind==="project"&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:F.toolCallHeader,children:(0,t.jsx)("span",{className:F.fieldLabel,children:"Multi-output expectations"})}),(0,t.jsx)("p",{className:F.helperText,children:"Assert the number of separate projects and constraints that every output must satisfy. Project fields below continue to inspect the first output in detail."}),(0,t.jsxs)("div",{className:F.assertionFieldsGrid,children:[(0,t.jsx)(qe,{label:"Output count",value:n.outputCount,onChange:x=>a({...n,outputCount:x})}),(0,t.jsx)(qe,{label:"Each output duration",sublabel:"(seconds)",value:n.eachOutputDuration,onChange:x=>a({...n,eachOutputDuration:x})}),(0,t.jsx)(ht,{label:"Each output aspect ratio",value:n.eachOutputAspectRatio,options:Ks,onChange:x=>a({...n,eachOutputAspectRatio:x})})]}),(0,t.jsxs)("div",{className:F.assertionFieldsGrid,children:[(0,t.jsx)(qe,{label:"Project duration",sublabel:"(seconds)",value:n.duration,onChange:x=>a({...n,duration:x})}),(0,t.jsx)(qe,{label:"Project width",value:n.width,onChange:x=>a({...n,width:x})}),(0,t.jsx)(qe,{label:"Project height",value:n.height,onChange:x=>a({...n,height:x})}),(0,t.jsx)(ht,{label:"Aspect ratio",sublabel:"Matches computed width÷height to a named ratio",value:n.aspectRatio,options:Ks,onChange:x=>a({...n,aspectRatio:x})})]}),(0,t.jsxs)("div",{className:F.toolCallHeader,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Transcript expectations (primary output)"}),n.transcript===void 0?(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,transcript:{}}),children:"Add transcript expectation"}):(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,transcript:void 0}),children:"Remove"})]}),n.transcript!==void 0&&(0,t.jsx)(xA,{value:n.transcript,onChange:x=>a({...n,transcript:x})}),(0,t.jsxs)("div",{className:F.toolCallHeader,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Subtitle expectations (primary output)"}),n.subtitles===void 0?(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,subtitles:{}}
217),children:"Add subtitle expectation"}):(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,subtitles:void 0}),children:"Remove"})]}),n.subtitles!==void 0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:F.helperText,children:"Content is checked against the full Magic Subtitle transcript resolved from asset transcriptions."}),(0,t.jsxs)("div",{className:F.assertionFieldsGridWide,children:[(0,t.jsx)(Tt,{label:"Subtitles present",sublabel:"True/False do subtitles exist in the output",value:n.subtitles.present,onChange:x=>a({...n,subtitles:{...n.subtitles,present:x}})}),(0,t.jsx)(ht,{label:"Placement",value:n.subtitles.placement,options:["top","bottom","keep-current"],onChange:x=>a({...n,subtitles:{...n.subtitles,placement:x}})}),(0,t.jsx)(ht,{label:"Preset id",value:n.subtitles.presetId,options:El,onChange:x=>a({...n,subtitles:{...n.subtitles,presetId:x}})}),(0,t.jsxs)("label",{className:F.field,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Exact subtitle text match (optional)"}),(0,t.jsx)("textarea",{className:F.fieldTextarea,value:n.subtitles.contentEquals??"",onChange:x=>a({...n,subtitles:{...n.subtitles,contentEquals:x.target.value||void 0}})})]}),(0,t.jsx)(Xa,{label:"Subtitle text must include (one phrase per line)",value:n.subtitles.contentIncludes,onChange:x=>a({...n,subtitles:{...n.subtitles,contentIncludes:x}})})]}),(0,t.jsxs)("div",{className:F.assertionFieldsGrid,children:[(0,t.jsx)(gt,{label:"Font color",value:n.subtitles.style?.fontColor,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,fontColor:x}}})}),(0,t.jsx)(gt,{label:"Font family",value:n.subtitles.style?.fontFamily,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,fontFamily:x}}})}),(0,t.jsx)(qe,{label:"Font size",value:n.subtitles.style?.fontSize,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,fontSize:x}}})}),(0,t.jsx)(gt,{label:"Font weight",value:n.subtitles.style?.fontWeight,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,fontWeight:x}}})}),(0,t.jsx)(gt,{label:"Background color",value:n.subtitles.style?.backgroundColor,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,backgroundColor:x}}})}),(0,t.jsx)(gt,{label:"Text align",value:n.subtitles.style?.textAlign,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,textAlign:x}}})}),(0,t.jsx)(ht,{label:"Vertical align",value:n.subtitles.style?.verticalAlign,options:["top","middle","bottom"],onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,verticalAlign:x}}})}),(0,t.jsx)(Tt,{label:"Italic",value:n.subtitles.style?.italic,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,italic:x}}})}),(0,t.jsx)(Tt,{label:"Underline",value:n.subtitles.style?.underline,onChange:x=>a({...n,subtitles:{...n.subtitles,style:{...n.subtitles?.style,underline:x}}})})]})]}),(0,t.jsxs)("div",{className:F.toolCallHeader,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Transition expectations"}),(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,transitions:[...n.transitions??[],{}]}),children:"Add transition expectation"})]}),(0,t.jsx)("p",{className:F.helperText,children:"Cross transitions between adjacent layers, read from the project animation table. Set the count to 0 to assert a run added none."}),(0,t.jsx)("div",{className:F.assertionFieldsGridWide,children:(0,t.jsx)(qe,{label:"Transition count",sublabel:"How many cross transitions the project has",value:n.transitionCount,onChange:x=>a({...n,transitionCount:x})})}),(0,t.jsx)("div",{className:F.layerCardsGrid,children:(n.transitions??[]).map((x,S)=>(0,t.jsx)(vA,{value:x,onChange:C=>{const y=[...n.transitions??[]];y[S]=C,a({...n,transitions:y})},onRemove:()=>{const C=[...n.transitions??[]];C.splice(S,1),a({...n,transitions:C.length>0?C:void 0})}},S))}),(0,t.jsxs)("div",{className:F.toolCallHeader,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Layer expectations"}),(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:()=>a({...n,layers:[...n.layers??[],{}]}),children:"Add layer expectation"})]}),(0,t.jsx)("div",{className:F.assertionFieldsGrid,children:(0,t.jsx)(qe,{label:"Asset switches",sublabel:"Transitions between video/persona asset IDs in timeline order. AâB is 1; AâBâA is 2.",value:n.assetSwitchCount,onChange:x=>a({...n,assetSwitchCount:x})})}),(0,t.jsxs)("label",{className:F.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:n.layersStrict===!0,onChange:x=>a({...n,layersStrict:x.target.checked?!0:void 0})}),(0,t.jsx)("span",{className:F.toolName,children:"Strict mode (exact 1:1 layer match)"})]}),(0,t.jsx)("p",{className:F.helperText,children:n.layersStrict?"Strict: project must have the same number of layers as expectations, and each expectation must uniquely match one project layer.":"Default: each expectation must match at least one layer (existential)."}
217),(0,t.jsx)("div",{className:F.layerCardsGrid,children:(n.layers??[]).map((x,S)=>(0,t.jsx)(gA,{value:x,onChange:C=>{const y=[...n.layers??[]];y[S]=C,a({...n,layers:y})},onRemove:()=>{const C=[...n.layers??[]];C.splice(S,1),a({...n,layers:C.length>0?C:void 0,...C.length===0?{layersStrict:void 0}:{}})}},S))})]}),(0,t.jsxs)("section",{className:F.programmableAssertionSection,children:[(0,t.jsx)("div",{className:F.toolCallHeader,children:(0,t.jsx)("span",{className:F.fieldLabel,children:"Programmable assertion"})}),(0,t.jsx)("p",{className:F.helperText,children:"Trusted synchronous JavaScript. Return a truthy value to pass. Falsey returns, missing returns, promises, syntax errors, and thrown errors fail the assertion."}),(0,t.jsxs)("div",{className:F.programmableAssertionReference,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"Function signature"}),(0,t.jsx)("pre",{className:F.codeReference,children:(0,t.jsx)("code",{children:Xw})})]}),(0,t.jsxs)("label",{className:F.field,children:[(0,t.jsx)("span",{className:F.fieldLabel,children:"JavaScript assertion body"}),(0,t.jsx)("textarea",{className:`${F.fieldTextarea} ${F.programmableAssertionTextarea}`,placeholder:`const videos = layers.filter((layer) => layer.type === "video"); 218return videos.length > 1;`,rows:12,spellCheck:!1,value:n.customAssertion??"",onChange:x=>{r({}),a({...n,customAssertion:x.target.value||void 0})}})]}),(0,t.jsxs)("details",{className:F.programmableAssertionReference,open:!0,children:[(0,t.jsx)("summary",{className:F.programmableAssertionSummary,children:"Context schema and timeline fields"}),(0,t.jsx)("pre",{className:F.codeReference,children:(0,t.jsx)("code",{children:eA})})]})]}),n.customAssertion&&o&&o.length>0&&(0,t.jsx)("div",{className:F.toolGrid,children:o.map(x=>{const{label:S,output:C}=x,y=l[S];return(0,t.jsxs)("div",{className:F.field,children:[(0,t.jsxs)("button",{type:"button",className:F.prefillButton,onClick:()=>r(N=>({...N,[S]:ew(C,n.customAssertion??"")})),children:["Run against ",S]}),y&&(0,t.jsx)("span",{className:F.helperText,children:tA(y)})]},S)})})]}),e[12]=l,e[13]=h,e[14]=d,e[15]=c,e[16]=a,e[17]=o,e[18]=n,e[19]=b):b=e[19];let j;return e[20]!==_||e[21]!==v||e[22]!==b?(j=(0,t.jsxs)("div",{className:F.toolCallSelector,children:[_,v,b]}),e[20]=_,e[21]=v,e[22]=b,e[23]=j):j=e[23],j}function bA(s){return(0,t.jsx)("option",{value:s,children:R2[s]},s)}const yA="PromptComparisonSkillEditors-module_field_gUKJP",SA="PromptComparisonSkillEditors-module_fieldLabel_TapIt",CA="PromptComparisonSkillEditors-module_labelRow_R7JKb",NA="PromptComparisonSkillEditors-module_fieldTextarea_Fsj2s",wA="PromptComparisonSkillEditors-module_agentInstructionsTextarea_sTGLL";var jn={field:yA,fieldLabel:SA,labelRow:CA,fieldTextarea:NA,agentInstructionsTextarea:wA},AA=Q(ie()),IA=Q(Ns());function sa(s){const e=(0,AA.c)(14),{id:n,label:a,value:o,disabled:i,onChange:l}=s;let r;e[0]!==n||e[1]!==a?(r=(0,t.jsx)("div",{className:jn.labelRow,children:(0,t.jsx)("label",{className:jn.fieldLabel,htmlFor:n,children:a})}),e[0]=n,e[1]=a,e[2]=r):r=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=(0,IA.default)(jn.fieldTextarea,jn.agentInstructionsTextarea),e[3]=d):d=e[3];let c;e[4]!==l?(c=p=>l(p.target.value),e[4]=l,e[5]=c):c=e[5];let m;e[6]!==i||e[7]!==n||e[8]!==c||e[9]!==o?(m=(0,t.jsx)("textarea",{id:n,className:d,value:o,disabled:i,placeholder:"Additional autonomous planning guidance. Leave empty to use production Skills V2 guidance.",onChange:c}),e[6]=i,e[7]=n,e[8]=c,e[9]=o,e[10]=m):m=e[10];let h;return e[11]!==r||e[12]!==m?(h=(0,t.jsxs)("div",{className:jn.field,children:[r,m]}),e[11]=r,e[12]=m,e[13]=h):h=e[13],h}var la=Q(ie());function TA(s){if(!s)return[];const e=[];return s.outputA&&e.push({label:s.runMode==="validation"?"output":"output A",output:s.outputA}),s.outputB&&e.push({label:"output B",output:s.outputB}),e}function Kn(s){return Js(s??Vt)}var kA={A:"Output A wins",B:"Output B wins",Tie:"It's a tie","Both Fail":"Both fail"},RA={A:W.winnerA,B:W.winnerB,Tie:W.winnerTie,"Both Fail":W.winnerBothFail},$A={passed:"Passed",failed:"Failed",skipped:"Skipped",error:"Error"};function PA(s,e){return s?e?"Running validation...":"Running comparison...":e?"Run validation":"Run comparison"}var EA=Object.values(oa);function LA(s){const e=(0,la.c)(27),{value:n,onChange:a,doNonStrictToolCheck:o,onDoNonStrictToolCheckChange:i,label:l,disabled:r}=s,d=n!==void 0;let c;e[0]!==d||e[1]!==a||e[2]!==i?(c=function(){d?(a(void 0),i(!1)):a([])},e[0]=d,e[1]=a,e[2]=i,e[3]=c):c=e[3];const m=c;let h;e[4]!==d||e[5]!==a||e[6]!==n?(h=function(S){d&&(n.includes(S)?a(n.filter(C=>C!==S)):a([...n,S]))},e[4]=d,e[5]=a,e[6]=n,e[7]=h):h=e[7];const p=h;let u;
218e[8]!==l?(u=(0,t.jsx)("label",{className:W.fieldLabel,children:l}),e[8]=l,e[9]=u):u=e[9];const g=d?"Disable tool check":"Enable tool check";let _;e[10]!==r||e[11]!==m||e[12]!==g?(_=(0,t.jsx)("button",{type:"button",className:W.prefillButton,disabled:r,onClick:m,children:g}),e[10]=r,e[11]=m,e[12]=g,e[13]=_):_=e[13];let v;e[14]!==u||e[15]!==_?(v=(0,t.jsxs)("div",{className:W.toolCallHeader,children:[u,_]}),e[14]=u,e[15]=_,e[16]=v):v=e[16];let b;e[17]!==r||e[18]!==o||e[19]!==p||e[20]!==d||e[21]!==i||e[22]!==n?(b=d&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:W.helperText,children:n.length===0?"Currently set to expect no tool calls.":`${n.length} tool(s) selected.`}),(0,t.jsxs)("label",{className:W.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:o,disabled:r,onChange:x=>i(x.target.checked)}),(0,t.jsx)("span",{className:W.toolName,children:"Non-strict tool check (allow extras)"})]}),(0,t.jsx)("div",{className:W.toolGrid,children:EA.map(x=>(0,t.jsxs)("label",{className:W.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:n.includes(x),disabled:r,onChange:()=>p(x)}),(0,t.jsx)("span",{className:W.toolName,children:x})]},x))})]}),e[17]=r,e[18]=o,e[19]=p,e[20]=d,e[21]=i,e[22]=n,e[23]=b):b=e[23];let j;return e[24]!==v||e[25]!==b?(j=(0,t.jsxs)("div",{className:W.toolCallSelector,children:[v,b]}),e[24]=v,e[25]=b,e[26]=j):j=e[26],j}function BA(s){const e=s?.plannerOnlyToolCalls?.find(o=>o.toolName===oa.LOAD_SKILLS);if(!e)return null;const n=e.params,a=n.skillIds??[];return a.length===0?null:{skillIds:a,reason:n.reason}}function ka(s){const e=(0,la.c)(13),{label:n,result:a}=s;if(!a||a.skipped){let d;e[0]!==n?(d=(0,t.jsx)("h3",{className:W.scoreCardTitle,children:n}),e[0]=n,e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("p",{className:W.explanation,children:"Skipped (no asserts)"}),e[2]=c):c=e[2];let m;return e[3]!==d?(m=(0,t.jsxs)("div",{className:W.scoreCard,children:[d,c]}),e[3]=d,e[4]=m):m=e[4],m}const o=a.passed?"Passed":"Failed";let i;e[5]!==n||e[6]!==o?(i=(0,t.jsxs)("h3",{className:W.scoreCardTitle,children:[n,": ",o]}),e[5]=n,e[6]=o,e[7]=i):i=e[7];let l;e[8]!==a.failures?(l=a.failures.length>0?(0,t.jsx)("ul",{className:W.scoreItems,children:a.failures.map(DA)}):(0,t.jsx)("p",{className:W.explanation,children:"All expected-result assertions matched."}),e[8]=a.failures,e[9]=l):l=e[9];let r;return e[10]!==i||e[11]!==l?(r=(0,t.jsxs)("div",{className:W.scoreCard,children:[i,l]}),e[10]=i,e[11]=l,e[12]=r):r=e[12],r}function DA(s){return(0,t.jsx)("li",{className:W.scoreItem,children:(0,t.jsxs)("span",{children:[s.path,": ",s.message]})},`${s.path}:${s.message}`)}function li(s){const e=(0,la.c)(90),{label:n,output:a,generationError:o,modelLabel:i}=s,l=a?.executionMode??"planner",r=a?.plan;let d,c,m,h,p,u,g,_,v,b,j;if(e[0]!==l||e[1]!==o||e[2]!==n||e[3]!==i||e[4]!==a||e[5]!==r){const L=BA(r);c=!!(a?.directAsset||a?.autonomousOutputType),d=a?.directAsset,m=a?.autonomousOutputType??"asset",b=W.outputCard;let $;e[17]!==n?($=(0,t.jsx)("h3",{className:W.outputHeaderTitle,children:n}),e[17]=n,e[18]=$):$=e[18];let R;e[19]!==i?(R=i&&(0,t.jsx)("span",{className:W.outputModelBadge,children:i}),e[19]=i,e[20]=R):R=e[20];const P=l==="autonomous"?"Autonomous":"Planner";let k;e[21]!==P?(k=(0,t.jsx)("span",{className:W.outputModelBadge,children:P}),e[21]=P,e[22]=k):k=e[22];let T;e[23]!==c||e[24]!==m?(T=c&&(0,t.jsx)("span",{className:W.responseTypeBadge,children:m}),e[23]=c,e[24]=m,e[25]=T):T=e[25];let E;e[26]!==R||e[27]!==k||e[28]!==T?(E=(0,t.jsxs)("div",{className:W.outputHeaderBadges,children:[R,k,T]}),e[26]=R,e[27]=k,e[28]=T,e[29]=E):E=e[29],e[30]!==$||e[31]!==E?(j=(0,t.jsxs)("div",{className:W.outputHeader,children:[$,E]}),e[30]=$,e[31]=E,e[32]=j):j=e[32],h=W.outputBody,e[33]!==a?(p=a?.chatId&&(0,t.jsx)("p",{className:W.chatLinkRow,children:(0,t.jsx)("a",{className:W.chatLink,href:`/kai/chat/${a.chatId}`,target:"_blank",rel:"noopener noreferrer",children:"Open generated chat"})}),e[33]=a,e[34]=p):p=e[34],e[35]!==o?(u=o&&(0,t.jsxs)("div",{className:W.generationError,children:["Generation error: ",o]}),e[35]=o,e[36]=u):u=e[36],e[37]!==l||e[38]!==a?(g=a?.nonPlanResponse&&(0,t.jsxs)("div",{className:W.nonPlanResponse,children:[(0,t.jsx)("h4",{className:W.nonPlanResponseTitle,children:l==="autonomous"?"Narration / response":"LLM Non-plan Response"}),(0,t.jsx)(No,{className:W.planSummary,components:{a:HA},children:a.nonPlanResponse})]}),e[37]=l,e[38]=a,e[39]=g):g=e[39],e[40]!==a?(_=a?.plan?.summary&&(0,t.jsx)(No,{className:W.planSummary,components:{a:VA},children:a.plan?.summary}),e[40]=a,e[41]=_):_=e[41],v=L&&(0,t.jsxs)("div",{className:W.loadedSkills,children:[(0,t.jsx)("h4",{className:W.loadedSkillsTitle,children:"Selected skills"}),(0,t.jsx)("div",{className:W.loadedSkillsBadges,children:L.skillIds.map(qA)}),L.reason&&(0,t.jsx)("p",{className:W.loadedSkillsReason,children:L.reason})]}),e[0]=l,e[1]=o,e[2]=n,e[3]=i,e[4]=a,e[5]=r,e[6]=d,e[7]=c,e[8]=m,e[9]=h,e[10]=p,e[11]=u,e[12]=g,e[13]=_,e[14]=v,e[15]=b,e[16]=j}else d=e[6],c=e[7],m=e[8],h=e[9],p=e[10],u=e[11],g=e[12],_=e[13],v=e[14],b=e[15],j=e[16];let x;e[42]!==a?(x=a?.plan?.steps.length?(0,t.jsx)("ol",{className:W.planSteps,children:a.plan?.steps.map(OA)}):null,e[42]=a,e[43]=x):x=e[43];let S;e[44]!==l||e[45]!==a?(S=l==="autonomous"&&a?.agentSteps?.length?(0,t.jsx)("ol",{className:W.planSteps,children:a.agentSteps.map(FA)}):null,e[44]=l,e[45]=a,e[46]=S):S=e[46];let C;e[47]!==d||e[48]!==c||e[49]!==a||e[50]!==m?(C=c&&d&&(0,t.jsxs)("div",{className:W.nonPlanResponse,children:[(0,t.jsxs)("h4",{className:W.nonPlanResponseTitle,children:["Direct ",m," output",a.stopReason?` (${a.stopReason})`:""]}),d.assetIds.length>0&&(0,t.jsx)("div",{className:W.assetThumbnailsRow,children:d.assetIds.map(MA)}
218),(0,t.jsx)("pre",{className:W.planStepParams,children:JSON.stringify({type:m,...d},null,2)})]}),e[47]=d,e[48]=c,e[49]=a,e[50]=m,e[51]=C):C=e[51];let y;e[52]!==d||e[53]!==c||e[54]!==a||e[55]!==m?(y=c&&!d&&(0,t.jsxs)("div",{className:W.nonPlanResponse,children:[(0,t.jsxs)("h4",{className:W.nonPlanResponseTitle,children:["Direct ",m," output",a?.stopReason?` (${a.stopReason})`:""]}),(0,t.jsx)("p",{className:W.emptyPlan,children:"(no asset snapshot available for this run)"})]}),e[52]=d,e[53]=c,e[54]=a,e[55]=m,e[56]=y):y=e[56];let N;e[57]!==c||e[58]!==a?(N=!c&&a?.project&&(0,t.jsxs)("div",{className:W.nonPlanResponse,children:[(0,t.jsxs)("h4",{className:W.nonPlanResponseTitle,children:["Executed primary project",` (1 of ${kl(a).length})`,a.stopReason?` (${a.stopReason})`:""]}),(0,t.jsx)("pre",{className:W.planStepParams,children:JSON.stringify(a.project,null,2)})]}),e[57]=c,e[58]=a,e[59]=N):N=e[59];let w;e[60]!==l||e[61]!==o||e[62]!==a?.nonPlanResponse||e[63]!==a?.plan?.steps?(w=l==="planner"&&!o&&!a?.plan?.steps.length&&!a?.nonPlanResponse&&(0,t.jsx)("p",{className:W.emptyPlan,children:"(no steps)"}),e[60]=l,e[61]=o,e[62]=a?.nonPlanResponse,e[63]=a?.plan?.steps,e[64]=w):w=e[64];let A;e[65]!==d||e[66]!==l||e[67]!==o||e[68]!==a?.agentSteps?.length||e[69]!==a?.nonPlanResponse||e[70]!==a?.project?(A=l==="autonomous"&&!o&&!a?.project&&!d&&!a?.agentSteps?.length&&!a?.nonPlanResponse&&(0,t.jsx)("p",{className:W.emptyPlan,children:"(no autonomous output)"}),e[65]=d,e[66]=l,e[67]=o,e[68]=a?.agentSteps?.length,e[69]=a?.nonPlanResponse,e[70]=a?.project,e[71]=A):A=e[71];let I;e[72]!==x||e[73]!==S||e[74]!==C||e[75]!==y||e[76]!==N||e[77]!==w||e[78]!==A||e[79]!==h||e[80]!==p||e[81]!==u||e[82]!==g||e[83]!==_||e[84]!==v?(I=(0,t.jsxs)("div",{className:h,children:[p,u,g,_,v,x,S,C,y,N,w,A]}),e[72]=x,e[73]=S,e[74]=C,e[75]=y,e[76]=N,e[77]=w,e[78]=A,e[79]=h,e[80]=p,e[81]=u,e[82]=g,e[83]=_,e[84]=v,e[85]=I):I=e[85];let D;return e[86]!==I||e[87]!==b||e[88]!==j?(D=(0,t.jsxs)("div",{className:b,children:[j,I]}),e[86]=I,e[87]=b,e[88]=j,e[89]=D):D=e[89],D}function MA(s){return(0,t.jsx)(bo,{assetId:s,size:"medium"},s)}function FA(s,e){return(0,t.jsx)("li",{className:W.planStep,children:(0,t.jsxs)("span",{className:W.planStepTool,children:[s.toolName," [",s.status,"]"]})},e)}function OA(s,e){return(0,t.jsxs)("li",{className:W.planStep,children:[(0,t.jsx)("span",{className:W.planStepTool,children:s.toolName}),(0,t.jsx)("pre",{className:W.planStepParams,children:JSON.stringify(s.params,null,2)})]},e)}function qA(s){return(0,t.jsx)("span",{className:W.loadedSkillBadge,children:s},s)}function VA(s){const{node:e,...n}=s;return(0,t.jsx)("a",{...n,target:"_blank",rel:"noopener noreferrer"})}function HA(s){const{node:e,...n}=s;return(0,t.jsx)("a",{...n,target:"_blank",rel:"noopener noreferrer"})}function ri(s){const e=(0,la.c)(22),{label:n,scores:a}=s;let o;e[0]!==n?(o=(0,t.jsx)("h3",{className:W.scoreCardTitle,children:n}),e[0]=n,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("span",{children:"Relevance"}),e[2]=i):i=e[2];let l;e[3]!==a.relevance?(l=(0,t.jsxs)("div",{className:W.scoreItem,children:[i,(0,t.jsxs)("span",{className:W.scoreValue,children:[a.relevance,"/10"]})]}),e[3]=a.relevance,e[4]=l):l=e[4];let r;e[5]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("span",{children:"Completeness"}),e[5]=r):r=e[5];let d;e[6]!==a.completeness?(d=(0,t.jsxs)("div",{className:W.scoreItem,children:[r,(0,t.jsxs)("span",{className:W.scoreValue,children:[a.completeness,"/10"]})]}),e[6]=a.completeness,e[7]=d):d=e[7];let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("span",{children:"Quality"}),e[8]=c):c=e[8];let m;e[9]!==a.quality?(m=(0,t.jsxs)("div",{className:W.scoreItem,children:[c,(0,t.jsxs)("span",{className:W.scoreValue,children:[a.quality,"/10"]})]}),e[9]=a.quality,e[10]=m):m=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("span",{children:"Tool Call Accuracy"}),e[11]=h):h=e[11];let p;e[12]!==a.toolCallAccuracy?(p=(0,t.jsxs)("div",{className:W.scoreItem,children:[h,(0,t.jsxs)("span",{className:W.scoreValue,children:[a.toolCallAccuracy,"/10"]})]}),e[12]=a.toolCallAccuracy,e[13]=p):p=e[13];let u;e[14]!==l||e[15]!==d||e[16]!==m||e[17]!==p?(u=(0,t.jsxs)("div",{className:W.scoreItems,children:[l,d,m,p]}),e[14]=l,e[15]=d,e[16]=m,e[17]=p,e[18]=u):u=e[18];let g;return e[19]!==o||e[20]!==u?(g=(0,t.jsxs)("div",{className:W.scoreCard,children:[o,u]}),e[19]=o,e[20]=u,e[21]=g):g=e[21],g}function UA(){const{jobId:s}=Ys(),e=Lt(),n=zs(),a=n.state,[o,i]=(0,f.useState)(""),[l,r]=(0,f.useState)([]),[d,c]=(0,f.useState)([]),[m,h]=(0,f.useState)(void 0),[p,u]=(0,f.useState)(!1),[g,_]=(0,f.useState)(void 0),[v,b]=(0,f.useState)("comparison"),[j,x]=(0,f.useState)(""),[S,C]=(0,f.useState)(""),[y,N]=(0,f.useState)(Qa),[w,A]=(0,f.useState)(""),[I,D]=(0,f.useState)(""),[L,$]=(0,f.useState)(Vt),[R,P]=(0,f.useState)(Vt),[k,T]=(0,f.useState)(null),[E,O]=(0,f.useState)(a?.parentRunId??null),[q,J]=(0,f.useState)(!1),[K,z]=(0,f.useState)(null),[Y,me]=(0,f.useState)(null),X=k!==null;function te(U){i(U.userPrompt),c(U.inputAssetIds??[]),h(U.correctToolCalls),u(U.doNonStrictToolCheck===!0),_(U.expectedResult),r(U.messageHistory??[])}(0,f.useEffect)(function(){if(s)return;const B=n.state?.prefill;t2(B)&&(te(B),e(n.pathname,{replace:!0,state:null}))},[s,n.state,n.pathname,e]),(0,f.useEffect)(function(){s&&(J(!0),z(null),H.admin.promptComparison.getComparison.query({jobId:s}).then(B=>
218{if(!B){z("Job not found.");return}if(i(B.input.userPrompt),r(B.input.messageHistory??[]),c(B.input.inputAssetIds??[]),h(B.input.correctToolCalls??void 0),u(B.input.doNonStrictToolCheck),_(B.input.expectedResult??void 0),b(B.input.runMode??"comparison"),O(B.parentRunId??null),x(B.input.systemPromptA),C(B.input.systemPromptB),N(B.input.judgeSystemPrompt),A(B.input.agentInstructionsA??""),D(B.input.agentInstructionsB??""),$(B.input.planningLLMA??Vt),P(B.input.planningLLMB??Vt),B.status==="running"||B.status==="judging")T(s);else if(B.status==="completed"){const oe=B.input.runMode??"comparison";(oe==="validation"||B.judgment)&&me({runMode:oe,outputA:B.outputA??void 0,outputB:B.outputB??void 0,outputAError:B.outputAError,outputBError:B.outputBError,assertionResultA:B.assertionResultA??void 0,assertionResultB:B.assertionResultB??void 0,validationOutcome:B.validationOutcome,modelALabel:Kn(B.input.planningLLMA),modelBLabel:Kn(B.input.planningLLMB),judgment:B.judgment??void 0})}else B.status==="failed"&&z(B.error??"Comparison failed.")}).catch(B=>{z(B instanceof Error?B.message:"Failed to load job.")}).finally(()=>{J(!1)}))},[s]),xo({callback:(0,f.useCallback)(async()=>{if(k)try{const U=await H.admin.promptComparison.getComparison.query({jobId:k});if(!U){z("Job not found."),T(null);return}if(U.status==="running"||U.status==="judging")return;if(U.status==="completed"){const B=U.input.runMode??"comparison";(B==="validation"||U.judgment)&&me({runMode:B,outputA:U.outputA??void 0,outputB:U.outputB??void 0,outputAError:U.outputAError,outputBError:U.outputBError,assertionResultA:U.assertionResultA??void 0,assertionResultB:U.assertionResultB??void 0,validationOutcome:U.validationOutcome,modelALabel:Kn(U.input.planningLLMA),modelBLabel:Kn(U.input.planningLLMB),judgment:U.judgment??void 0}),T(null)}U.status==="failed"&&(z(U.error??"Comparison failed."),T(null))}catch(U){z(U instanceof Error?U.message:"Failed to poll job status."),T(null)}},[k]),intervalMs:3e3,shouldPoll:X});const ae=async U=>{U.preventDefault(),z(null),me(null),O(null);try{const B=await H.admin.promptComparison.startComparison.mutate({userPrompt:o.trim(),inputAssetIds:d.length>0?d:void 0,messageHistory:l.length>0?l:void 0,correctToolCalls:m,doNonStrictToolCheck:m!==void 0?p:void 0,expectedResult:g,runMode:v,systemPromptA:j.trim(),systemPromptB:v==="validation"?void 0:S.trim()||void 0,judgeSystemPrompt:v==="validation"?void 0:y.trim()||void 0,agentInstructionsA:w.trim()||void 0,agentInstructionsB:v==="validation"?void 0:I.trim()||void 0,planningLLMA:L,planningLLMB:v==="validation"?void 0:R});T(B.jobId),e(`/admin/ai/prompt-comparison/${B.jobId}`,{replace:!0})}catch(B){z(B instanceof Error?B.message:"Something went wrong. Please try again.")}},G=v==="validation",se=!X&&!q&&o.trim().length>0&&j.trim().length>0&&(G||S.trim().length>0&&y.trim().length>0);return(0,t.jsxs)("div",{className:W.container,children:[(0,t.jsxs)("div",{className:W.pageHeader,children:[(0,t.jsxs)("div",{className:W.pageHeaderLeft,children:[E&&(0,t.jsx)(be,{to:`/admin/ai/prompt-comparison-runs/${E}`,className:W.parentRunLink,children:"â View parent eval"}),(0,t.jsx)("h1",{className:W.pageTitle,children:G?"Viewing objective test":"Prompt A/B comparison"})]}),(0,t.jsxs)("div",{className:W.headerLinks,children:[(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison-runs",className:W.backLink,children:"All evals"}),"·",(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison-request-bank",className:W.backLink,children:"Manage tests"})]})]}),(0,t.jsx)("div",{className:`${W.formCard} ${s?W.detailFormCard:""}`,children:(0,t.jsxs)("form",{className:W.form,onSubmit:ae,children:[(0,t.jsxs)("div",{className:W.formSection,children:[(0,t.jsx)("h2",{className:W.formSectionTitle,children:"Run mode"}),(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsxs)("label",{className:W.toolOption,children:[(0,t.jsx)("input",{type:"radio",name:"runMode",checked:v==="comparison",disabled:X||q,onChange:()=>b("comparison")}),(0,t.jsx)("span",{className:W.toolName,children:"Comparison (A/B + judge)"})]}),(0,t.jsxs)("label",{className:W.toolOption,children:[(0,t.jsx)("input",{type:"radio",name:"runMode",checked:v==="validation",disabled:X||q,onChange:()=>b("validation")}),(0,t.jsx)("span",{className:W.toolName,children:"Validation (single prompt + assertion/tool checks)"})]}),(0,t.jsx)("p",{className:W.helperText,children:"Validation runs only variant A, skips the judge LLM, and reports whether expected-result assertions (and optional tool checks) passed."})]})]}),(0,t.jsxs)("div",{className:W.formSection,children:[(0,t.jsx)("h2",{className:W.formSectionTitle,children:"User prompt"}),(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsx)("label",{className:W.fieldLabel,htmlFor:"userPrompt",children:"Message to send to both runs"}),(0,t.jsx)("textarea",{id:"userPrompt",className:`${W.fieldInput} ${W.fieldTextarea}`,value:o,disabled:X||q,placeholder:"e.g. Make me a 30-second promo video for a coffee shop",onChange:U=>i(U.target.value)}),(0,t.jsx)("p",{className:W.helperText,children:"This will be sent as the user message to both LLM calls."})]}),(0,t.jsx)("div",{className:W.field,children:(0,t.jsx)(jo,{history:l,title:"Chat history context",helperText:"Messages replayed before the prompt above for both variants.",emptyMessage:"No prior chat history."})}),(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsx)("label",{className:W.fieldLabel,children:"Attached assets (optional)"}),(0,t.jsx)($l,{onAssetsSelected:U=>c(B=>[...B,...U]),onClose:()=>{},children:({onClick:U})=>(0,t.jsx)("button",{type:"button",className:W.attachMediaButton,disabled:X||q,onClick:U,children:"Attach media"})}),d.length>0&&(0,t.jsx)("div",{className:W.assetThumbnailsRow,children:d.map(U=>(0,t.jsx)(bo,{assetId:U,onRemove:()=>c(B=>B.filter(oe=>oe!==U)),size:"medium"},U))})]}),(0,t.jsx)(LA,{value:m,onChange:h,doNonStrictToolCheck:p,onDoNonStrictToolCheckChange:u,label:"Expected tool calls (optional)",disabled:X||q}),(0,t.jsx)(Ol,{value:g,onChange:_,testOutputs:TA(Y)})]}),(0,t.jsxs)("div",{className:W.formSection,children:[(0,t.jsx)("h2",{className:W.formSectionTitle,children:G?"System prompt":"System prompts"}),(0,t.jsxs)("div",{className:G?void 0:W.promptColumns,children:[(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsxs)("div",{className:W.labelRow,children:[(0,t.jsx)("label",{className:W.fieldLabel,htmlFor:"systemPromptA",children:G?"System prompt":"System prompt A"}),(0,t.jsx)("button",{type:"button",className:W.prefillButton,disabled:X||q,onClick:()=>x(Xn),children:"Use current agent prompt"})]}),(0,t.jsx)("textarea",{id:"systemPromptA",className:`${W.fieldInput} ${W.fieldTextarea}`,value:j,disabled:X||q,placeholder:"Enter the system prompt...",onChange:U=>x(U.target.value)})]}),!G&&(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsxs)("div",{className:W.labelRow,children:[(0,t.jsx)("label",{className:W.fieldLabel,htmlFor:"systemPromptB",children:"System prompt B"}),(0,t.jsx)("button",{type:"button",className:W.prefillButton,disabled:X||q,onClick:()=>C(Xn),children:"Use current agent prompt"})]}),(0,t.jsx)("textarea",{id:"systemPromptB",className:`${W.fieldInput} ${W.fieldTextarea}`,value:S,disabled:X||q,placeholder:"Enter the second system prompt...",onChange:U=>C(U.target.value)})]})]}),(0,t.jsx)("p",{className:W.helperText,children:G?"This system prompt is used for the single validation run.":"Each system prompt is prepended to the message history for its respective run."})]}),(0,t.jsxs)("div",{className:W.formSection,children:[(0,t.jsx)("h2",{className:W.formSectionTitle,children:"Planning LLM"}),(0,t.jsxs)("div",{className:W.promptColumns,children:[(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsx)("label",{className:W.fieldLabel,htmlFor:"planningLLMA",children:G?"Planning LLM":"Planning LLM A"}),(0,t.jsx)("select",{id:"planningLLMA",className:W.fieldSelect,value:L,disabled:X||q,onChange:U=>{ea(U.target.value)&&$(U.target.value)},children:Ln.map(U=>(0,t.jsx)("option",{value:U,children:Js(U)},U))})]}),!G&&(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsx)("label",{className:W.fieldLabel,htmlFor:"planningLLMB",children:"Planning LLM B"}),(0,t.jsx)("select",{id:"planningLLMB",className:W.fieldSelect,value:R,disabled:X||q,onChange:U=>{ea(U.target.value)&&P(U.target.value)},children:Ln.map(U=>(0,t.jsx)("option",{value:U,children:Js(U)},U))})]})]}),(0,t.jsxs)("p",{className:W.helperText,children:["Overrides the Kai planning model",G?"":" for each variant",". Default matches the current production delegator."]})]}),(0,t.jsxs)("div",{className:W.formSection,children:[(0,t.jsx)("h2",{className:W.formSectionTitle,children:"Agent instructions"}),(0,t.jsxs)("div",{className:G?void 0:W.promptColumns,children:[(0,t.jsx)(sa,{id:"agentInstructionsA",label:G?"Agent instructions":"Agent instructions A",value:w,disabled:X||q,onChange:A}),!G&&(0,t.jsx)(sa,{id:"agentInstructionsB",label:"Agent instructions B",value:I,disabled:X||q,onChange:D})]}),(0,t.jsx)("p",{className:W.helperText,children:"Applied as additional autonomous planning context. Leave empty to use production Skills V2 guidance."})]}),!G&&(0,t.jsxs)("div",{className:W.formSection,children:[(0,t.jsx)("h2",{className:W.formSectionTitle,children:"Judge system prompt"}),(0,t.jsxs)("div",{className:W.field,children:[(0,t.jsx)("label",{className:W.fieldLabel,htmlFor:"judgeSystemPrompt",children:"Customizable instructions for the judge LLM"}),(0,t.jsx)("textarea",{id:"judgeSystemPrompt",className:`${W.fieldInput} ${W.fieldTextarea} ${W.judgeTextarea}`,value:y,disabled:X||q,onChange:U=>N(U.target.value)})]}),(0,t.jsxs)("div",{className:W.fixedSuffix,children:[(0,t.jsx)("span",{className:W.fixedSuffixLabel,children:"Always appended (not editable):"}),(0,t.jsx)("pre",{className:W.fixedSuffixContent,children:Rl.trim()})]})]}),(0,t.jsxs)("div",{className:W.submitActions,children:[K&&(0,t.jsx)("div",{className:W.error,children:K}),(0,t.jsx)("button",{type:"submit",className:W.submitButton,disabled:!se,children:PA(X,G)})]})]})}),X&&(0,t.jsxs)("div",{className:W.loadingOverlay,children:[(0,t.jsx)("div",{className:W.spinner}),(0,t.jsx)("span",{children:G?"Running prompt and checking assertions...":"Running both prompts and judging results..."})]}),Y&&(0,t.jsxs)("div",{className:`${W.resultsSection} ${s?W.detailResultsSection:""}`,children:[(0,t.jsx)("div",{className:W.judgmentCard,children:Y.runMode==="validation"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h2",{className:W.judgmentCardTitle,children:"Validation summary"}),(0,t.jsx)("span",{className:W.winnerBadge,children:$A[Y.validationOutcome??"skipped"]}),(0,t.jsx)("p",{className:W.explanation,children:"Single-prompt validation (no A/B judge). Outcome is based on expected-result assertions and optional expected tool checks."}),(0,t.jsx)(ka,{label:"Assertions",result:Y.assertionResultA})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h2",{className:W.judgmentCardTitle,children:"Judgment"}),Y.judgment&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:`${W.winnerBadge} ${RA[Y.judgment.winner]}`,children:kA[Y.judgment.winner]}),(0,t.jsx)("p",{className:W.explanation,children:Y.judgment.explanation}),(Y.assertionResultA||Y.assertionResultB)&&(0,t.jsxs)("div",{className:W.scoresGrid,children:[(0,t.jsx)(ka,{label:"Assertions A",result:Y.assertionResultA}),(0,t.jsx)(ka,{label:"Assertions B",result:Y.assertionResultB})]}),(0,t.jsxs)("div",{className:W.scoresGrid,children:[(0,t.jsx)(ri,{label:"Output A",scores:Y.judgment.outputA}),(0,t.jsx)(ri,{label:"Output B",scores:Y.judgment.outputB})]})]})]})}),(0,t.jsx)("h2",{children:Y.runMode==="validation"?"Agent output":"Agent plans"}),(0,t.jsxs)("div",{className:Y.runMode==="validation"?`${W.outputColumns} ${W.outputColumnsSingle}`:W.outputColumns,children:[(0,t.jsx)(li,{label:Y.runMode==="validation"?"Output":"Output A",output:Y.outputA,generationError:Y.outputAError,modelLabel:Y.modelALabel}),Y.runMode!=="validation"&&(0,t.jsx)(li,{label:"Output B",output:Y.outputB,generationError:Y.outputBError,modelLabel:Y.modelBLabel})]})]})]})}const ZA="AdminPromptComparisonRequestBank-module_container_hifCF",WA="AdminPromptComparisonRequestBank-module_pageHeader_C4lQ-",KA="AdminPromptComparisonRequestBank-module_pageHeaderLeft_wieEx",GA="AdminPromptComparisonRequestBank-module_startNewRunButton_vdlfr",JA="AdminPromptComparisonRequestBank-module_headerLinks_2vdhQ",zA="AdminPromptComparisonRequestBank-module_pageTitle_W8LKl",YA="AdminPromptComparisonRequestBank-module_pageTitleDisplay_-P2tR",QA="AdminPromptComparisonRequestBank-module_pageTitleEditor_sxSVJ",XA="AdminPromptComparisonRequestBank-module_pageTitleInput_02Yz8",eI="AdminPromptComparisonRequestBank-module_pageTitleEditButton_AIEr8",tI="AdminPromptComparisonRequestBank-module_runMetadataCard_jlrqH",sI="AdminPromptComparisonRequestBank-module_runMetadataGrid_Z0szx",nI="AdminPromptComparisonRequestBank-module_metadataItem_Fp4bB",aI="AdminPromptComparisonRequestBank-module_metadataLabel_CEY-z",oI="AdminPromptComparisonRequestBank-module_runId_tsHzO",iI="AdminPromptComparisonRequestBank-module_backLink_kX9SS",lI="AdminPromptComparisonRequestBank-module_card_Xufcz",rI="AdminPromptComparisonRequestBank-module_sectionTitle_X6daS",dI="AdminPromptComparisonRequestBank-module_testHistoryHeader_OqxH1",cI="AdminPromptComparisonRequestBank-module_addRequestRow_oom0y",uI="AdminPromptComparisonRequestBank-module_addRequestInput_dLeQh",mI="AdminPromptComparisonRequestBank-module_smallButton_asznA",pI="AdminPromptComparisonRequestBank-module_dangerButton_NwOYi",hI="AdminPromptComparisonRequestBank-module_requestList_Ni59V",fI="AdminPromptComparisonRequestBank-module_requestItem_YmRnr",xI="AdminPromptComparisonRequestBank-module_requestCheckbox_66VUw",gI="AdminPromptComparisonRequestBank-module_requestContent_4fVlK",vI="AdminPromptComparisonRequestBank-module_requestBadges_Fet1V",_I="AdminPromptComparisonRequestBank-module_requestTagBadge_hVOWo",jI="AdminPromptComparisonRequestBank-module_requestPrompt_lZyKI",bI="AdminPromptComparisonRequestBank-module_requestDescription_pO42W",yI="AdminPromptComparisonRequestBank-module_requestToolBadge_gxjST",SI="AdminPromptComparisonRequestBank-module_editButton_ntWfY",CI="AdminPromptComparisonRequestBank-module_runButton_Mjsyw",NI="AdminPromptComparisonRequestBank-module_deleteButton_rj1zm",wI="AdminPromptComparisonRequestBank-module_emptyState_qH6C7",AI="AdminPromptComparisonRequestBank-module_deleteModalText_q-n45",II="AdminPromptComparisonRequestBank-module_deleteModalPrompt_X5Sg-",TI="AdminPromptComparisonRequestBank-module_field_-CQSY",kI="AdminPromptComparisonRequestBank-module_fieldLabel_xu5Qr",RI="AdminPromptComparisonRequestBank-module_fieldTextarea_29j3T",$I="AdminPromptComparisonRequestBank-module_descriptionTextarea_-g-zu",PI="AdminPromptComparisonRequestBank-module_fieldSelect_oKsBS",EI="AdminPromptComparisonRequestBank-module_labelRow_jM0Ip",LI="AdminPromptComparisonRequestBank-module_prefillButton_1lVtb",BI="AdminPromptComparisonRequestBank-module_promptColumns_L3YLA",DI="AdminPromptComparisonRequestBank-module_judgeTextarea_hzZL1",MI="AdminPromptComparisonRequestBank-module_agentInstructionsTextarea_k1wW0",FI="AdminPromptComparisonRequestBank-module_fixedSuffix_N2x3t",OI="AdminPromptComparisonRequestBank-module_fixedSuffixLabel_Id47O",qI="AdminPromptComparisonRequestBank-module_fixedSuffixContent_Gb65U",VI="AdminPromptComparisonRequestBank-module_helperText_AJuBa",HI="AdminPromptComparisonRequestBank-module_submitActions_l3WWL",UI="AdminPromptComparisonRequestBank-module_error_Idn1r",ZI="AdminPromptComparisonRequestBank-module_loadingOverlay_3BR3M",WI="AdminPromptComparisonRequestBank-module_fullScreenLoadingOverlay_aKiOk",KI="AdminPromptComparisonRequestBank-module_spinner_EE4MB",GI="AdminPromptComparisonRequestBank-module_spin_txnYd",JI="AdminPromptComparisonRequestBank-module_resultsSection_bgeud",zI="AdminPromptComparisonRequestBank-module_summaryCard_zbTMB",YI="AdminPromptComparisonRequestBank-module_synthesisCard_Sx8YH",QI="AdminPromptComparisonRequestBank-module_synthesisTitle_U5Qq8",XI="AdminPromptComparisonRequestBank-module_synthesisTargetNote_VaBDw",eT="AdminPromptComparisonRequestBank-module_synthesisSection_jEwPB",tT="AdminPromptComparisonRequestBank-module_synthesisHeading_InMkc",sT="AdminPromptComparisonRequestBank-module_synthesisBody_4WROe",nT="AdminPromptComparisonRequestBan
218k-module_synthesisPre_exNv0",aT="AdminPromptComparisonRequestBank-module_reportTypeOption_4TaAN",oT="AdminPromptComparisonRequestBank-module_regressionScoreRow_6j22M",iT="AdminPromptComparisonRequestBank-module_regressionScoreValue_RJYuf",lT="AdminPromptComparisonRequestBank-module_regressionScoreMax_Tvvka",rT="AdminPromptComparisonRequestBank-module_regressionStatsRow_dSDDz",dT="AdminPromptComparisonRequestBank-module_regressionSeverityBadge_dXVEB",cT="AdminPromptComparisonRequestBank-module_regressionSeverityNone_lXfxV",uT="AdminPromptComparisonRequestBank-module_regressionSeverityMinor_WiYs7",mT="AdminPromptComparisonRequestBank-module_regressionSeverityModerate_4lxg4",pT="AdminPromptComparisonRequestBank-module_regressionSeveritySevere_pONUq",hT="AdminPromptComparisonRequestBank-module_regressionList_JtSsH",fT="AdminPromptComparisonRequestBank-module_regressionItem_X0Crm",xT="AdminPromptComparisonRequestBank-module_regressionItemHeader_XqPW0",gT="AdminPromptComparisonRequestBank-module_regressionItemDelta_Q95FQ",vT="AdminPromptComparisonRequestBank-module_regressionItemScores_eKLFs",_T="AdminPromptComparisonRequestBank-module_regressionItemPrompt_kpa-v",jT="AdminPromptComparisonRequestBank-module_summaryTitle_BvSUr",bT="AdminPromptComparisonRequestBank-module_summaryHeader_-Hfgr",yT="AdminPromptComparisonRequestBank-module_progressRow_CN61N",ST="AdminPromptComparisonRequestBank-module_progressStat_BiGJ0",CT="AdminPromptComparisonRequestBank-module_winBar_TWxaN",NT="AdminPromptComparisonRequestBank-module_winBarA_qyIOQ",wT="AdminPromptComparisonRequestBank-module_winBarTie_8AojP",AT="AdminPromptComparisonRequestBank-module_winBarBothFail_dIO2D",IT="AdminPromptComparisonRequestBank-module_winBarB_-CBNZ",TT="AdminPromptComparisonRequestBank-module_winLegend_AmZJU",kT="AdminPromptComparisonRequestBank-module_legendDot_q0gff",RT="AdminPromptComparisonRequestBank-module_legendDotA_yybO5",$T="AdminPromptComparisonRequestBank-module_legendDotTie_bMSd4",PT="AdminPromptComparisonRequestBank-module_legendDotB_U6qUm",ET="AdminPromptComparisonRequestBank-module_legendDotBothFail_3CmfG",LT="AdminPromptComparisonRequestBank-module_subJobsTable_PyTF8",BT="AdminPromptComparisonRequestBank-module_sortableHeader_6dM9v",DT="AdminPromptComparisonRequestBank-module_sortIndicator_JVoXl",MT="AdminPromptComparisonRequestBank-module_subJobErrorCell_7N3mO",FT="AdminPromptComparisonRequestBank-module_statusIndicator_cYPyn",OT="AdminPromptComparisonRequestBank-module_statusDot_s-J0G",qT="AdminPromptComparisonRequestBank-module_statusRunning_O0Mxg",VT="AdminPromptComparisonRequestBank-module_statusJudging_ZgBLc",HT="AdminPromptComparisonRequestBank-module_statusCompleted_uLLFk",UT="AdminPromptComparisonRequestBank-module_statusFailed_vmgX7",ZT="AdminPromptComparisonRequestBank-module_statusCancelled_1BlXa",WT="AdminPromptComparisonRequestBank-module_validationOutcome_ruNuu",KT="AdminPromptComparisonRequestBank-module_validationOutcomePassed_V3u50",GT="AdminPromptComparisonRequestBank-module_validationOutcomeFailed_jPr6a",JT="AdminPromptComparisonRequestBank-module_validationOutcomeError_v-77j",zT="AdminPromptComparisonRequestBank-module_validationOutcomeSkipped_Ezb1e",YT="AdminPromptComparisonRequestBank-module_winnerCell_OoS7S",QT="AdminPromptComparisonRequestBank-module_winnerCellA_seOiW",XT="AdminPromptComparisonRequestBank-module_winnerCellB_po9QC",ek="AdminPromptComparisonRequestBank-module_winnerCellTie_BoZR0",tk="AdminPromptComparisonRequestBank-module_winnerCellBothFail_Dicjn",sk="AdminPromptComparisonRequestBank-module_jobLink_ZcvOQ",nk="AdminPromptComparisonRequestBank-module_pastRunsList_g7jOH",ak="AdminPromptComparisonRequestBank-module_pastRunsLoading_cX9RB",ok="AdminPromptComparisonRequestBank-module_pastRunItem_HZqPB",ik="AdminPromptComparisonRequestBank-module_pastRunDetails_JeMb8",lk="AdminPromptComparisonRequestBank-module_pastRunMeta_l5dnX",rk="AdminPromptComparisonRequestBank-module_passRate_Bnf9z",dk="AdminPromptComparisonRequestBank-module_passRateLabel_ek9YU",ck="AdminPromptComparisonRequestBank-module_passRateBar_qrDfB",uk="AdminPromptComparisonRequestBank-module_passRatePassed_
218LKqMb",mk="AdminPromptComparisonRequestBank-module_passRateFailed_Xwcbl",pk="AdminPromptComparisonRequestBank-module_selectAllRow_PwbEF",hk="AdminPromptComparisonRequestBank-module_tagFilterControl_ZZSIC",fk="AdminPromptComparisonRequestBank-module_tagCheckbox_4hFN8",xk="AdminPromptComparisonRequestBank-module_modalOverlay_1kHlt",gk="AdminPromptComparisonRequestBank-module_modalContent_KSmLz",vk="AdminPromptComparisonRequestBank-module_modalActions_-VWty",_k="AdminPromptComparisonRequestBank-module_secondaryButton_uJ379",jk="AdminPromptComparisonRequestBank-module_toolCallSelector_iHSdZ",bk="AdminPromptComparisonRequestBank-module_toolCallHeader_4a4V5",yk="AdminPromptComparisonRequestBank-module_toolGrid_8tfl3",Sk="AdminPromptComparisonRequestBank-module_toolOption_bKdzD",Ck="AdminPromptComparisonRequestBank-module_toolName_U9KUT",Nk="AdminPromptComparisonRequestBank-module_attachMediaButton_C-lKY",wk="AdminPromptComparisonRequestBank-module_assetThumbnailsRow_s5lRo",Ak="AdminPromptComparisonRequestBank-module_assetIdsRow_JsuVU",Ik="AdminPromptComparisonRequestBank-module_assetIdBadge_ixWHf",Tk="AdminPromptComparisonRequestBank-module_removeAssetButton_5UW8v",kk="AdminPromptComparisonRequestBank-module_statsGrid_lmRRg",Rk="AdminPromptComparisonRequestBank-module_statsSection_4u3DM",$k="AdminPromptComparisonRequestBank-module_statsSubtitle_gJtFh",Pk="AdminPromptComparisonRequestBank-module_statsList_yjXlv",Ek="AdminPromptComparisonRequestBank-module_statsItem_E5m53",Lk="AdminPromptComparisonRequestBank-module_statsLabel_JPnxO",Bk="AdminPromptComparisonRequestBank-module_statsCount_MgnH7",Dk="AdminPromptComparisonRequestBank-module_statsToggle_OVunr",Mk="AdminPromptComparisonRequestBank-module_statsToggleLabel_iJoNE",Fk="AdminPromptComparisonRequestBank-module_statsToggleChevron_ufukC",Ok="AdminPromptComparisonRequestBank-module_addFormSection_pfY5d",qk="AdminPromptComparisonRequestBank-module_addRequestTextarea_-jvsl",Vk="AdminPromptComparisonRequestBank-module_addRequestActions_E3ktB",Hk="AdminPromptComparisonRequestBank-module_importButtonWrapper_JSpy-",Uk="AdminPromptComparisonRequestBank-module_importButtonHelp_owU45",Zk="AdminPromptComparisonRequestBank-module_searchRow_Po17V",Wk="AdminPromptComparisonRequestBank-module_searchInput_Gbkx1",Kk="AdminPromptComparisonRequestBank-module_searchCount_jDwdM",Gk="AdminPromptComparisonRequestBank-module_requestItemFocused_nzJfk",Jk="AdminPromptComparisonRequestBank-module_requestMetadataBadge_LnBxX";var Pe={container:ZA,pageHeader:WA,pageHeaderLeft:KA,startNewRunButton:GA,headerLinks:JA,pageTitle:zA,pageTitleDisplay:YA,pageTitleEditor:QA,pageTitleInput:XA,pageTitleEditButton:eI,runMetadataCard:tI,runMetadataGrid:sI,metadataItem:nI,metadataLabel:aI,runId:oI,backLink:iI,card:lI,sectionTitle:rI,testHistoryHeader:dI,addRequestRow:cI,addRequestInput:uI,smallButton:mI,dangerButton:pI,requestList:hI,requestItem:fI,requestCheckbox:xI,requestContent:gI,requestBadges:vI,requestTagBadge:_I,requestPrompt:jI,requestDescription:bI,requestToolBadge:yI,editButton:SI,runButton:CI,deleteButton:NI,emptyState:wI,deleteModalText:AI,deleteModalPrompt:II,field:TI,fieldLabel:kI,fieldTextarea:RI,descriptionTextarea:$I,fieldSelect:PI,labelRow:EI,prefillButton:LI,promptColumns:BI,judgeTextarea:DI,agentInstructionsTextarea:MI,fixedSuffix:FI,fixedSuffixLabel:OI,fixedSuffixContent:qI,helperText:VI,submitActions:HI,error:UI,loadingOverlay:ZI,fullScreenLoadingOverlay:WI,spinner:KI,spin:GI,resultsSection:JI,summaryCard:zI,synthesisCard:YI,synthesisTitle:QI,synthesisTargetNote:XI,synthesisSection:eT,synthesisHeading:tT,synthesisBody:sT,synthesisPre:nT,reportTypeOption:aT,regressionScoreRow:oT,regressionScoreValue:iT,regressionScoreMax:lT,regressionStatsRow:rT,regressionSeverityBadge:dT,regressionSeverityNone:cT,regressionSeverityMinor:uT,regressionSeverityModerate:mT,regressionSeveritySevere:pT,regressionList:hT,regressionItem:fT,regressionItemHeader:xT,regressionItemDelta:gT,regressionItemScores:vT,regressionItemPrompt:_T,summaryTitle:jT,summaryHeader:bT,progressRow:yT,progressStat:ST,winBar:CT,winBarA:NT,winBarTie:wT,winBarBothFail:AT,winBarB:IT,winLegend:TT,legendDot:kT,legendDotA:RT,legendDotTie:$T,legendDotB:PT,legendDotBothFail:ET,subJobsTable:LT,sortableHeader:BT,sortIndicator:DT,subJobErrorCell:MT,statusIndicator:FT,statusDot:OT,statusRunning:qT,statusJudging:VT,statusCompleted:HT,statusFailed:UT,statusCancelled:ZT,validationOutcome:WT,validationOutcomePassed:KT,validationOutcomeFailed:GT,validationOutcomeError:JT,validationOutcomeSkipped:zT,winnerCell:YT,winnerCellA:QT,winnerCellB:XT,winnerCellTie:ek,winnerCellBothFail:tk,jobLink:sk,pastRunsList:nk,pastRunsLoading:ak,pastRunItem:ok,pastRunDetails:ik,pastRunMeta:lk,passRate:rk,passRateLabel:dk,passRateBar:ck,passRatePassed:uk,passRateFailed:mk,selectAllRow:pk,tagFilterControl:hk,tagCheckbox:fk,modalOverlay:xk,modalContent:gk,modalActions:vk,secondaryButton:_k,toolCallSelector:jk,toolCallHeader:bk,toolGrid:yk,toolOption:Sk,toolName:Ck,attachMediaButton:Nk,assetThumbnailsRow:wk,assetIdsRow:Ak,assetIdBadge:Ik,removeAssetButton:Tk,statsGrid:kk,statsSection:Rk,statsSubtitle:$k,statsList:Pk,statsItem:Ek,statsLabel:Lk,statsCount:Bk,statsToggle:Dk,statsToggleLabel:Mk,statsToggleChevron:Fk,addFormSection:Ok,addRequestTextarea:qk,addRequestActions:Vk,importButtonWrapper:Hk,importButtonHelp:Uk,searchRow:Zk,searchInput:Wk,searchCount:Kk,requestItemFocused:Gk,requestMetadataBadge:Jk},ql=Q(ie()),zk=Object.values(oa);function Yk(s){const e=(0,ql.c)(24),{value:n,onChange:a,label:o,doNonStrictToolCheck:i,onDoNonStrictToolCheckChange:l}=s,r=n!==void 0;let d;e[0]!==r||e[1]!==a?(d=function(){a(r?void 0:[])},e[0]=r,e[1]=a,e[2]=d):d=e[2];const c=d;let m;e[3]!==r||e[4]!==a||e[5]!==n?(m=function(x){r&&(n.includes(x)?a(n.filter(S=>S!==x)):a([...n,x]))},e[3]=r,e[4]=a,e[5]=n,e[6]=m):m=e[6];const h=m;let p;e[7]!==o?(p=(0,t.jsx)("label",{className:F.fieldLabel,children:o}),e[7]=o,e[8]=p):p=e[8];const u=r?"Disable tool check":"Enable tool check";let g;
218e[9]!==c||e[10]!==u?(g=(0,t.jsx)("button",{type:"button",className:F.prefillButton,onClick:c,children:u}),e[9]=c,e[10]=u,e[11]=g):g=e[11];let _;e[12]!==p||e[13]!==g?(_=(0,t.jsxs)("div",{className:F.toolCallHeader,children:[p,g]}),e[12]=p,e[13]=g,e[14]=_):_=e[14];let v;e[15]!==i||e[16]!==h||e[17]!==r||e[18]!==l||e[19]!==n?(v=r&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("label",{className:F.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:i,onChange:j=>l(j.target.checked)}),(0,t.jsx)("span",{className:F.toolName,children:"Non-strict match (allow extra tool calls beyond expected)"})]}),(0,t.jsx)("p",{className:F.helperText,children:n.length===0?"Currently set to expect no tool calls.":`${n.length} tool(s) selected.`}),(0,t.jsx)("div",{className:F.toolGrid,children:zk.map(j=>(0,t.jsxs)("label",{className:F.toolOption,children:[(0,t.jsx)("input",{type:"checkbox",checked:n.includes(j),onChange:()=>h(j)}),(0,t.jsx)("span",{className:F.toolName,children:j})]},j))})]}),e[15]=i,e[16]=h,e[17]=r,e[18]=l,e[19]=n,e[20]=v):v=e[20];let b;return e[21]!==_||e[22]!==v?(b=(0,t.jsxs)("div",{className:F.toolCallSelector,children:[_,v]}),e[21]=_,e[22]=v,e[23]=b):b=e[23],b}function Qk(s){const e=(0,ql.c)(37),{value:n,onChange:a,existingTags:o}=s,[i,l]=(0,f.useState)(""),[r,d]=(0,f.useState)(!1),c=(0,f.useRef)(null),m=(0,f.useRef)(null),h=n.length>=20;let p="Add another tag";h?p="Tag limit reached":n.length===0&&(p="Add a tag");let u,g;if(e[0]!==o||e[1]!==i||e[2]!==n){const $=i.trim().toLowerCase();g=o.filter(R=>!n.some(P=>P.toLowerCase()===R.toLowerCase())&&(!$||R.toLowerCase().includes($))),e[0]=o,e[1]=i,e[2]=n,e[3]=g}else g=e[3];u=g;const _=u;let v;e[4]!==o||e[5]!==h||e[6]!==a||e[7]!==n?(v=$=>{const R=$.trim();if(!R||h)return;const P=o.find(k=>k.toLowerCase()===R.toLowerCase())??R;n.some(k=>k.toLowerCase()===P.toLowerCase())||a([...n,P]),l(""),d(!1),c.current?.focus()},e[4]=o,e[5]=h,e[6]=a,e[7]=n,e[8]=v):v=e[8];const b=v;let j;e[9]!==b||e[10]!==i||e[11]!==a||e[12]!==_||e[13]!==n?(j=function(R){if(R.key==="Enter"||R.key===","){R.preventDefault(),b(_.find(P=>P.toLowerCase()===i.trim().toLowerCase())??i);return}R.key==="Backspace"&&!i&&n.length>0&&a(n.slice(0,-1))},e[9]=b,e[10]=i,e[11]=a,e[12]=_,e[13]=n,e[14]=j):j=e[14];const x=j;let S,C;e[15]===Symbol.for("react.memo_cache_sentinel")?(S=function(){const R=function(k){const T=k.target;T instanceof Node&&(m.current?.contains(T)||d(!1))};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},C=[],e[15]=S,e[16]=C):(S=e[15],C=e[16]),(0,f.useEffect)(S,C);let y;e[17]!==a||e[18]!==n?(y=n.map($=>(0,t.jsxs)("span",{className:F.tagChip,children:[$,(0,t.jsx)("button",{type:"button",className:F.tagChipRemove,onClick:()=>a(n.filter(R=>R!==$)),"aria-label":`Remove ${$} tag`,children:"Ã"})]},$)),e[17]=a,e[18]=n,e[19]=y):y=e[19];let N,w;e[20]===Symbol.for("react.memo_cache_sentinel")?(N=$=>{l($.target.value),d(!0)},w=()=>d(!0),e[20]=N,e[21]=w):(N=e[20],w=e[21]);let A;e[22]!==x||e[23]!==i||e[24]!==h||e[25]!==p?(A=(0,t.jsx)("input",{ref:c,type:"text",className:F.tagInput,value:i,maxLength:80,disabled:h,placeholder:p,onChange:N,onFocus:w,onKeyDown:x}),e[22]=x,e[23]=i,e[24]=h,e[25]=p,e[26]=A):A=e[26];let I;e[27]!==A||e[28]!==y?(I=(0,t.jsxs)("div",{className:F.tagInputContainer,children:[y,A]}),e[27]=A,e[28]=y,e[29]=I):I=e[29];let D;e[30]!==b||e[31]!==r||e[32]!==_?(D=r&&_.length>0&&(0,t.jsx)("div",{className:F.tagSuggestions,children:_.slice(0,8).map($=>(0,t.jsx)("button",{type:"button",className:F.tagSuggestion,onClick:()=>b($),children:$},$))}),e[30]=b,e[31]=r,e[32]=_,e[33]=D):D=e[33];let L;return e[34]!==I||e[35]!==D?(L=(0,t.jsxs)("div",{className:F.tagInputWrapper,ref:m,children:[I,D]}),e[34]=I,e[35]=D,e[36]=L):L=e[36],L}function Vl({request:s,description:e,prompt:n,assetIds:a,toolCalls:o,doNonStrictToolCheck:i,expectedResult:l,tags:r,existingTags:d,chatHistoryKeptIndices:c,onPromptChange:m,onDescriptionChange:h,onAssetIdsChange:p,onToolCallsChange:u,onDoNonStrictToolCheckChange:g,onExpectedResultChange:_,onTagsChange:v,onChatHistoryKeptIndicesChange:b,onSave:j,onCancel:x,updateRequest:S,createRequest:C,mode:y="edit",onStartRun:N}){const[w,A]=(0,f.useState)(!1),I=y==="create",D=s.chatHistory??[],L=c.map(T=>D[T]).filter(T=>T!==void 0);function $(T){const E=c[T];E!==void 0&&b(c.filter(O=>O!==E))}function R(){return{description:e.trim(),userPrompt:n.trim(),assetIds:a.length>0?a:void 0,correctToolCalls:o,doNonStrictToolCheck:o!==void 0&&i,tags:r,expectedResult:l??null,chatHistoryKeptIndices:I?void 0:c}}async function P(){const T=R();if(I){if(!C)return;j(await C(T));return}await S({id:s.id,...T}),j()}async function k(){if(N){A(!0);try{await P(),N(s.id)}finally{A(!1)}}}return(0,t.jsx)("div",{className:F.modalOverlay,onClick:x,role:"presentation",children:(0,t.jsxs)("div",{className:F.modalContent,onClick:T=>T.stopPropagation(),role:"dialog","aria-labelledby":"edit-request-title",children:[(0,t.jsx)("h2",{id:"edit-request-title",className:F.sectionTitle,children:I?"Add request":"Edit request"}),(0,t.jsx)(jo,{history:L,totalMessages:L.length,hideWhenEmpty:!0,emptyMessage:"No history messages on this request.",helperText:"Context replayed before the prompt above when this request is run. Remove messages to trim the replayed context.",onRemoveMessage:I?void 0:$}),(0,t.jsxs)("div",{className:F.field,children:[(0,t.jsx)("label",{className:F.fieldLabel,children:"Description (optional)"}),(0,t.jsx)("textarea",{className:F.descriptionTextarea,value:e,maxLength:NC,placeholder:"Explain the intent of this test and what behavior it protects.",onCh
218ange:T=>h(T.target.value)}),(0,t.jsx)("p",{className:F.helperText,children:"Helps future readers understand why this test exists."})]}),(0,t.jsxs)("div",{className:F.field,children:[(0,t.jsx)("label",{className:F.fieldLabel,children:"User prompt"}),(0,t.jsx)("textarea",{className:F.fieldTextarea,value:n,onChange:T=>m(T.target.value)})]}),(0,t.jsxs)("div",{className:F.field,children:[(0,t.jsx)("label",{className:F.fieldLabel,children:"Attached assets (optional)"}),(0,t.jsx)($l,{onAssetsSelected:T=>p([...a,...T]),onClose:()=>{},children:({onClick:T})=>(0,t.jsx)("button",{type:"button",className:F.attachMediaButton,onClick:T,children:"Attach media"})}),a.length>0&&(0,t.jsx)("div",{className:F.assetThumbnailsRow,children:a.map(T=>(0,t.jsx)(bo,{assetId:T,onRemove:()=>p(a.filter(E=>E!==T)),size:"medium"},T))})]}),(0,t.jsx)(Yk,{value:o,onChange:u,label:"Expected tool calls (only non-autonomous runs)",doNonStrictToolCheck:i,onDoNonStrictToolCheckChange:g}),(0,t.jsx)(Ol,{value:l,onChange:_}),(0,t.jsxs)("div",{className:F.field,children:[(0,t.jsx)("label",{className:F.fieldLabel,children:"Tags"}),(0,t.jsx)(Qk,{value:r,onChange:v,existingTags:d}),(0,t.jsxs)("p",{className:F.helperText,children:["Use existing tags where possible. Press Enter or comma to add a new tag. Up to ",20," tags, with at most"," ",80," characters each."]})]}),(0,t.jsxs)("div",{className:F.modalActions,children:[!I&&N&&(0,t.jsx)("button",{type:"button",className:`${F.smallButton} ${F.secondaryButton}`,disabled:!n.trim()||w,onClick:k,title:"Saves the request, then opens the runs page pre-selected for this request.",children:w?"Saving...":"Run this request..."}),(0,t.jsx)("button",{type:"button",className:F.smallButton,disabled:!n.trim()||w,onClick:P,children:I?"Add":"Save"}),(0,t.jsx)("button",{type:"button",className:`${F.smallButton} ${F.secondaryButton}`,disabled:w,onClick:x,children:"Cancel"})]})]})})}var di="focus",Xk=Object.values(oa);function e3(){const s=Lt(),[e,n]=Ji(),a=e.get(di),o=(0,f.useRef)(new Map),i=(0,f.useRef)(null),[l,r]=(0,f.useState)([]),[d,c]=(0,f.useState)(null),[m,h]=(0,f.useState)(!1),[p,u]=(0,f.useState)(""),[g,_]=(0,f.useState)(""),[v,b]=(0,f.useState)([]),[j,x]=(0,f.useState)(void 0),[S,C]=(0,f.useState)(!1),[y,N]=(0,f.useState)(void 0),[w,A]=(0,f.useState)([]),[I,D]=(0,f.useState)([]),[L,$]=(0,f.useState)(null),[R,P]=(0,f.useState)(!1),[k,T]=(0,f.useState)(!1),[E,O]=(0,f.useState)(""),[q,J]=(0,f.useState)(null),K=f.useMemo(()=>{const B=new Set;for(const oe of l)for(const de of oe.tags??[])B.add(de);return Array.from(B).sort((oe,de)=>oe.localeCompare(de))},[l]),z=f.useMemo(()=>{const B=E.trim().toLowerCase();return B?l.filter(oe=>!!(oe.userPrompt.toLowerCase().includes(B)||oe.description?.toLowerCase().includes(B)||oe.correctToolCalls?.some(de=>de.toLowerCase().includes(B))||oe.expectedResult?.kind.toLowerCase().includes(B)||oe.tags?.some(de=>de.toLowerCase().includes(B)))):l},[l,E]),Y=f.useMemo(()=>{const B={},oe={};for(const de of l){if(!de.correctToolCalls)B["Not specified"]=(B["Not specified"]??0)+1;else if(de.correctToolCalls.length===0)B["No tools expected"]=(B["No tools expected"]??0)+1;else for(const ye of de.correctToolCalls)B[ye]=(B[ye]??0)+1;for(const ye of de.tags??[])oe[ye]=(oe[ye]??0)+1}return{tagCounts:oe,toolCallCounts:B}},[l]);(0,f.useEffect)(function(){H.admin.promptComparison.listRequests.query().then(r)},[]),(0,f.useEffect)(function(){if(!a||i.current===a)return;const oe=o.current.get(a);oe&&(i.current=a,oe.scrollIntoView({behavior:"smooth",block:"center"}))},[a,l]);function me(){if(!a)return;const B=new URLSearchParams(e);B.delete(di),n(B,{replace:!0})}function X(){c(null),h(!1)}function te(){h(!0),c({id:"",userPrompt:"",chatHistory:[]}),u(""),_(""),b([]),x(void 0),C(!1),N(void 0),A([]),D([])}async function ae(){const B=q;if(B)try{await H.admin.promptComparison.deleteRequest.mutate({id:B.id}),r(oe=>oe.filter(de=>de.id!==B.id)),a===B.id&&me()}catch(oe){Ue({error:oe,description:"Failed to delete request."})}finally{J(null)}}async function G(){P(!0);try{const B=await H.admin.promptComparison.importEvaluationTests.mutate();r(await H.admin.promptComparison.listRequests.query()),$(null),B.imported===0&&$(`No new tests to import (${B.skipped} already exist or had no prompt).`)}catch(B){$(B instanceof Error?B.message:"Failed to import evaluation tests.")}finally{P(!1)}}function se(B){h(!1),c({...B,chatHistory:B.chatHistory??[]}),u(B.description??""),_(B.userPrompt),b(B.assetIds??[]),x(B.correctToolCalls),C(B.doNonStrictToolCheck??!1),N(B.expectedResult),A(B.tags??[]),D((B.chatHistory??[]).map((oe,de)=>de))}function U(){return l.length>0?(0,t.jsx)("div",{className:Pe.requestList,children:z.map(B=>{const oe=B.id===a?`${Pe.requestItem} ${Pe.requestItemFocused}`:Pe.requestItem,de=B.chatHistory?.length??0;return(0,t.jsxs)("div",{ref:ye=>{ye?o.current.set(B.id,ye):o.current.delete(B.id)},className:oe,children:[(0,t.jsxs)("div",{className:Pe.requestContent,children:[(0,t.jsx)("span",{className:Pe.requestPrompt,children:B.userPrompt}),B.description&&(0,t.jsx)("span",{className:Pe.requestDescription,children:B.description}),(0,t.jsxs)("div",{className:Pe.requestBadges,children:[B.tags?.map(ye=>(0,t.jsxs)("span",{className:Pe.requestTagBadge,children:["#",ye]},ye)),B.assetIds&&B.assetIds.length>0&&(0,t.jsxs)("span",{className:Pe.requestMetadataBadge,children:[B.assetIds.length," asset(s)"]}),de>0&&(0,t.jsxs)("span",{className:Pe.requestMetadataBadge,children:["chat history: ",de," msg",de===1?"":"s"]}),B.correctToolCalls!==void 0&&(0,t.jsx)("span",{className:Pe.requestToolBadge,children:B.correctToolCalls?.length===0?"N
218o tools expected":B.correctToolCalls?.join(", ")}),B.expectedResult&&(0,t.jsxs)("span",{className:Pe.requestMetadataBadge,children:["expect:"," ",B.expectedResult.kind==="scene"?"video":B.expectedResult.kind]})]})]}),(0,t.jsx)("button",{type:"button",className:Pe.runButton,onClick:()=>{s("/admin/ai/prompt-comparison",{state:{prefill:{userPrompt:B.userPrompt,inputAssetIds:B.assetIds,correctToolCalls:B.correctToolCalls,doNonStrictToolCheck:B.doNonStrictToolCheck,expectedResult:B.expectedResult,messageHistory:B.chatHistory}}})},children:"Run"}),(0,t.jsx)("button",{type:"button",className:Pe.editButton,onClick:()=>se(B),children:"Edit"}),(0,t.jsx)("button",{type:"button",className:Pe.deleteButton,onClick:()=>J(B),children:"Delete"})]},B.id)})}):E.trim()?(0,t.jsxs)("p",{className:Pe.emptyState,children:['No requests match "',E,'".']}):(0,t.jsx)("p",{className:Pe.emptyState,children:"No test requests yet. Add one above."})}return(0,t.jsxs)("div",{className:Pe.container,children:[(0,t.jsxs)("div",{className:Pe.pageHeader,children:[(0,t.jsx)("h1",{className:Pe.pageTitle,children:"Test request bank"}),(0,t.jsxs)("div",{className:Pe.headerLinks,children:[(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison-runs",className:Pe.backLink,children:"Run comparisons"}),(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison",className:Pe.backLink,children:"Single comparison"})]})]}),l.length>0&&(0,t.jsxs)("div",{className:Pe.card,children:[(0,t.jsx)("button",{type:"button",className:Pe.statsToggle,onClick:()=>T(B=>!B),"aria-expanded":k,children:(0,t.jsxs)("span",{className:Pe.statsToggleLabel,children:[(0,t.jsx)("span",{className:Pe.statsToggleChevron,children:k?"â¼":"â¶"}),"Stats"]})}),k&&(0,t.jsxs)("div",{className:Pe.statsGrid,children:[(0,t.jsxs)("div",{className:Pe.statsSection,children:[(0,t.jsx)("h3",{className:Pe.statsSubtitle,children:"By tool call"}),(0,t.jsx)("ul",{className:Pe.statsList,children:["Not specified","No tools expected",...Xk.filter(B=>(Y.toolCallCounts[B]??0)>0)].filter(B=>(Y.toolCallCounts[B]??0)>0).map(B=>(0,t.jsxs)("li",{className:Pe.statsItem,children:[(0,t.jsx)("span",{className:Pe.statsLabel,children:B}),(0,t.jsx)("span",{className:Pe.statsCount,children:Y.toolCallCounts[B]})]},B))})]}),(0,t.jsxs)("div",{className:Pe.statsSection,children:[(0,t.jsx)("h3",{className:Pe.statsSubtitle,children:"By tag"}),(0,t.jsx)("ul",{className:Pe.statsList,children:K.length>0?K.map(B=>(0,t.jsxs)("li",{className:Pe.statsItem,children:[(0,t.jsx)("span",{className:Pe.statsLabel,children:B}),(0,t.jsx)("span",{className:Pe.statsCount,children:Y.tagCounts[B]})]},B)):(0,t.jsxs)("li",{className:Pe.statsItem,children:[(0,t.jsx)("span",{className:Pe.statsLabel,children:"No tags"}),(0,t.jsx)("span",{className:Pe.statsCount,children:"0"})]})})]})]})]}),(0,t.jsxs)("div",{className:Pe.card,children:[(0,t.jsxs)("div",{className:Pe.addRequestActions,children:[(0,t.jsx)("button",{type:"button",className:Pe.smallButton,onClick:te,children:"Add new request"}),(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison-request-import",className:Pe.smallButton,children:"Import Notion test"}),(0,t.jsxs)("div",{className:Pe.importButtonWrapper,children:[(0,t.jsx)("button",{type:"button",className:Pe.smallButton,disabled:R,onClick:G,children:R?"Importing...":"Import from evaluation tests (do not use if you are AI)"}),(0,t.jsx)(Vc,{content:"Copies non-archived AI evaluation tests into this request bank, using each test name as its description and including attached assets. Skips tests whose prompt already exists here or has no prompt.",children:(0,t.jsx)("span",{className:Pe.importButtonHelp,"aria-label":"About importing from evaluation tests",role:"img",children:"?"})})]})]}),(0,t.jsx)("h2",{className:Pe.sectionTitle,children:"Requests"}),l.length>0&&(0,t.jsxs)("div",{className:Pe.searchRow,children:[(0,t.jsx)("input",{type:"search",className:Pe.searchInput,placeholder:"Search prompts, descriptions, tool calls, tags...",value:E,onChange:B=>O(B.target.value)}),(0,t.jsxs)("span",{className:Pe.searchCount,children:[z.length," of ",l.length]})]}),L&&(0,t.jsx)("div",{className:Pe.error,children:L}),U()]}),d&&(0,t.jsx)(Vl,{mode:m?"create":"edit",request:d,description:p,prompt:g,assetIds:v,toolCalls:j,doNonStrictToolCheck:S,expectedResult:y,tags:w,existingTags:K,chatHistoryKeptIndices:I,onPromptChange:_,onDescriptionChange:u,onAssetIdsChange:b,onToolCallsChange:x,onDoNonStrictToolCheckChange:C,onExpectedResultChange:N,onTagsChange:A,onChatHistoryKeptIndicesChange:D,onSave:B=>{B?r(oe=>[{id:B.id,description:B.description,userPrompt:B.userPrompt,assetIds:B.assetIds,
218correctToolCalls:B.correctToolCalls,doNonStrictToolCheck:B.doNonStrictToolCheck,expectedResult:B.expectedResult,tags:B.tags,createdAt:new Date().toISOString()},...oe]):d&&r(oe=>oe.map(de=>de.id===d.id?{...de,description:p.trim()||void 0,userPrompt:g.trim(),assetIds:v.length>0?v:void 0,correctToolCalls:j,doNonStrictToolCheck:j!==void 0&&S,expectedResult:y,tags:w,chatHistory:(de.chatHistory??[]).filter((ye,Le)=>I.includes(Le))}:de)),X()},onCancel:X,createRequest:async B=>{const oe=await H.admin.promptComparison.createRequest.mutate({description:B.description,userPrompt:B.userPrompt,assetIds:B.assetIds,correctToolCalls:B.correctToolCalls,doNonStrictToolCheck:B.doNonStrictToolCheck,expectedResult:B.expectedResult??void 0,tags:B.tags});return{id:oe.id,description:oe.description,userPrompt:oe.userPrompt,assetIds:B.assetIds,correctToolCalls:oe.correctToolCalls??void 0,doNonStrictToolCheck:oe.doNonStrictToolCheck,expectedResult:oe.expectedResult??void 0,tags:oe.tags}},updateRequest:async B=>{await H.admin.promptComparison.updateRequest.mutate({id:B.id,description:B.description,userPrompt:B.userPrompt,assetIds:B.assetIds,correctToolCalls:B.correctToolCalls,doNonStrictToolCheck:B.doNonStrictToolCheck,expectedResult:B.expectedResult,tags:B.tags,chatHistoryKeptIndices:B.chatHistoryKeptIndices})},onStartRun:B=>{window.open(`/admin/ai/prompt-comparison-runs?preselectRequestId=${encodeURIComponent(B)}`,"_blank","noopener,noreferrer")}}),(0,t.jsxs)(go,{isOpen:q!==null,onClose:()=>J(null),onConfirm:ae,title:"Delete request?",confirmText:"Delete",cancelText:"Cancel",dataTestId:"delete-request-confirm-modal",children:[(0,t.jsx)("p",{className:Pe.deleteModalText,children:"Are you sure you want to delete this request? This action cannot be undone."}),q&&(0,t.jsxs)("p",{className:Pe.deleteModalPrompt,children:['"',q.userPrompt,'"']})]})]})}const Hl="https://app.notion.com/p/kapwing/3c1b51a3250a80b59535d983397dcd6a?v=3c1b51a3250a8042ab7a000ce6ddc4a6",aY=ce.object({chatUrl:ce.url(),title:ce.string().trim().min(1).max(300),assertions:ce.string().trim().min(1).max(2e4),rationale:ce.string().trim().max(4e3),whoAdded:ce.string().trim().min(1).max(300),functionalityTargets:ce.array(ce.string().trim().min(1).max(80)).max(19),exampleOutputUrl:ce.url().optional(),sourceTableUrl:ce.url().default(Hl)}),oY=ce.object({expectedResult:Q2,unresolvedAssertions:ce.array(ce.string().trim().min(1)).default([]),placeholders:ce.array(ce.string().trim().min(1)).default([])}),t3="AdminPromptComparisonRequestImport-module_container_t5wIN",s3="AdminPromptComparisonRequestImport-module_pageHeader_BDzLp",n3="AdminPromptComparisonRequestImport-module_pageHeaderLeft_XDFTv",a3="AdminPromptComparisonRequestImport-module_startNewRunButton_dzC1k",o3="AdminPromptComparisonRequestImport-module_headerLinks_ThQrL",i3="AdminPromptComparisonRequestImport-module_pageTitle_VcWXH",l3="AdminPromptComparisonRequestImport-module_pageTitleDisplay_RxPwA",r3="AdminPromptComparisonRequestImport-module_pageTitleEditor_M-hlS",d3="AdminPromptComparisonRequestImport-module_pageTitleInput_zU590",c3="AdminPromptComparisonRequestImport-module_pageTitleEditButton_Y6TI5",u3="AdminPromptComparisonRequestImport-module_runMetadataCard_v4NV8",m3="AdminPromptComparisonRequestImport-module_runMetadataGrid_aH3xK",p3="AdminPromptComparisonRequestImport-module_metadataItem_v-f6Q",h3="AdminPromptComparisonRequestImport-module_metadataLabel_erKdL",f3="AdminPromptComparisonRequestImport-module_runId_sWUA9",x3="AdminPromptComparisonRequestImport-module_backLink_Yd6du",g3="AdminPromptComparisonRequestImport-module_card_at358",v3="AdminPromptComparisonRequestImport-module_sectionTitle_EIXJR",_3="AdminPromptComparisonRequestImport-module_testHistoryHeader_6qvh3",j3="AdminPromptComparisonRequestImport-module_addRequestRow_Or4Zm",b3="AdminPromptComparisonRequestImport-module_addRequestInput_xSwJm",y3="AdminPromptComparisonRequestImport-module_smallButton_i6xQl",S3="AdminPromptComparisonRequestImport-module_dangerButton_WRQFo",C3="AdminPromptComparisonRequestImport-module_requestList_E5-JJ",N3="AdminPromptComparisonRequestImport-module_requestItem_mxxTK",w3="AdminPromptComparisonRequestImport-module_requestCheckbox_kHPPX",A3="AdminPromptComparisonRequestImport-module_requestContent_WAjSu",I3="AdminPromptComparisonRequestImport-module_requestBadges_KNopN",T3="AdminPromptComparisonRequestImport-module_requestTagBadge_ZfckG",k3="AdminPromptComparisonRequestImport-module_requestPrompt_FAv2H",R3="AdminPromptComparisonRequestImport-module_requestDescription_TyccP",$3="AdminPromptComparisonRequestImport-module_requestToolBadge_34B4U",P3="AdminPromptComparisonRequestImport-module_editButton_-xhSa",E3="AdminPromptComparisonRequestImport-module_runButton_Duy-6",L3="AdminPromptComparisonRequestImport-module_deleteButton_IHYgG",B3="AdminPromptComparisonRequestImport-module_emptyState_kiY8r",D3="AdminPromptComparisonRequestImport-module_deleteModalText_InNjx",M3="AdminPromptComparisonRequestImport-module_deleteModalPrompt_rwS0B",F3="AdminPromptComparisonRequestImport-module_field_82ehG",O3="AdminPromptComparisonRequestImport-module_fieldLabel_5WhyE",q3="AdminPromptComparisonRequestImport-module_fieldTextarea_BE0r5",V3="AdminPromptComparisonRequestImport-module_descriptionTextarea_A4Ubd",H3="AdminPromptComparisonRequestImport-module_fieldSelect_G-m1a",U3="AdminPromptComparisonRequestImport-module_labelRow_bd-Th",Z3="AdminPromptComparisonRequestImport-module_prefillButton_t6xK1",W3="AdminPromptComparisonRequestImport-module_promptColumns_CVCWM",K3="AdminPromptComparisonRequestImport-module_judgeTextarea_hKhi-",G3="AdminPromptComparisonRequestImport-module_agentInstructionsTextarea_eYNDk",J3="AdminPromptComparisonRequestImport-module_fixedSuffix_TtUr1",z3="AdminPromptComparisonRequestImport-module_fixedSuffixLabel_DteF0",Y3="AdminPromptComparisonRequestImport-module_fixedSuffixContent_qt0yE",Q3="AdminPromptComparisonRequestImport-module_helperText_8A2Ac",X3="AdminPromptComparisonRequestImport-module_submitActions_n2lMN",eR="AdminPromptComparisonRequestImport-module_error_v81bY",tR="AdminPromptComparisonRequestImport-module_loadingOverlay_iCYzf",sR="AdminPromptComparisonRequestImport-module_fullScreenLoadingOverlay_bqC3I",nR="AdminPromptComparisonRequestImport-module_spinner_djw2k",aR="AdminPromptComparisonRequestImport-module_spin_S9ho-",oR="AdminPromptComparisonRequestImport-module_resultsSection_3OM3U",iR="AdminPromptComparisonRequestImport-module_summaryCard_24qAR",lR="AdminPromptComparisonRequestImport-module_synthesisCard_47bM-",rR="AdminPromptComparisonRequestImport-module_synthesisTitle_KT28e",dR="AdminPromptComparisonRequestImport-module_synthesisTargetNote_i8uYm",cR="AdminPromptComparisonRequestImport-module_synthesisSection_d4G3t",uR="AdminPromptComparisonRequestImport-module_synthesisHeading_wGQPz",mR="AdminPromptComparisonRequestImport-module_synthesisBody_sXD2h",pR="AdminPromptComparisonRequestImport-module_synthesisPre_tYcZ-",hR="AdminPromptComparisonRequestImport-module_reportTypeOption_SvzNL",fR="AdminPromptComparisonRequestImport-module_regressionScoreRow_-1p5q",xR="AdminPromptComparisonRequestImport-module_regressionScoreValue_9Vysg",gR="AdminPromptComparisonRequestImport-module_regressionScoreMax_K0mGr",vR="AdminPromptComparisonRequestImport-module_regressionStatsRow_KkvXd",_R="AdminPromptComparisonRequestImport-module_regressionSeverityBadge_ttnfx",jR="AdminPromptComparisonRequestImport-module_regressionSeverityNone_wfQby",bR="AdminPromptComparisonRequestImport-module_regressionSeverityMinor_ghHsk",yR="AdminPromptComparisonRequestImport-module_regressionSeverityModerate_Tq5HB",SR="AdminPromptComparisonRequestImport-module_regressionSeveritySevere_H-LQt",CR="AdminPromptComparisonRequestImport-module_regressionList_NFLpD",NR="AdminPromptComparisonRequestImport-module_regressionItem_-ZBpn",w
218R="AdminPromptComparisonRequestImport-module_regressionItemHeader_AF8sq",AR="AdminPromptComparisonRequestImport-module_regressionItemDelta_tq41K",IR="AdminPromptComparisonRequestImport-module_regressionItemScores_Qvv3V",TR="AdminPromptComparisonRequestImport-module_regressionItemPrompt_3WGNv",kR="AdminPromptComparisonRequestImport-module_summaryTitle_18PlB",RR="AdminPromptComparisonRequestImport-module_summaryHeader_OqKZH",$R="AdminPromptComparisonRequestImport-module_progressRow_CC9Nf",PR="AdminPromptComparisonRequestImport-module_progressStat_uegzc",ER="AdminPromptComparisonRequestImport-module_winBar_i1RLn",LR="AdminPromptComparisonRequestImport-module_winBarA_oFgkt",BR="AdminPromptComparisonRequestImport-module_winBarTie_jdhwW",DR="AdminPromptComparisonRequestImport-module_winBarBothFail_DCXqs",MR="AdminPromptComparisonRequestImport-module_winBarB_567CH",FR="AdminPromptComparisonRequestImport-module_winLegend_SiBEp",OR="AdminPromptComparisonRequestImport-module_legendDot_vBNms",qR="AdminPromptComparisonRequestImport-module_legendDotA_lBMp3",VR="AdminPromptComparisonRequestImport-module_legendDotTie_ODdig",HR="AdminPromptComparisonRequestImport-module_legendDotB_2KSpY",UR="AdminPromptComparisonRequestImport-module_legendDotBothFail_Y5qmG",ZR="AdminPromptComparisonRequestImport-module_subJobsTable_1DXtL",WR="AdminPromptComparisonRequestImport-module_sortableHeader_Q1e86",KR="AdminPromptComparisonRequestImport-module_sortIndicator_R27om",GR="AdminPromptComparisonRequestImport-module_subJobErrorCell_2GMh5",JR="AdminPromptComparisonRequestImport-module_statusIndicator_u43gS",zR="AdminPromptComparisonRequestImport-module_statusDot_e06yN",YR="AdminPromptComparisonRequestImport-module_statusRunning_SenCV",QR="AdminPromptComparisonRequestImport-module_statusJudging_Yykc-",XR="AdminPromptComparisonRequestImport-module_statusCompleted_7sYrD",e$="AdminPromptComparisonRequestImport-module_statusFailed_dbipB",t$="AdminPromptComparisonRequestImport-module_statusCancelled_KnGe6",s$="AdminPromptComparisonRequestImport-module_validationOutcome_jbPyP",n$="AdminPromptComparisonRequestImport-module_validationOutcomePassed_1W-d-",a$="AdminPromptComparisonRequestImport-module_validationOutcomeFailed_wzpaA",o$="AdminPromptComparisonRequestImport-module_validationOutcomeError_8Tu2J",i$="AdminPromptComparisonRequestImport-module_validationOutcomeSkipped_NsgI4",l$="AdminPromptComparisonRequestImport-module_winnerCell_Nc1hk",r$="AdminPromptComparisonRequestImport-module_winnerCellA_AfiKE",d$="AdminPromptComparisonRequestImport-module_winnerCellB_ZUKg0",c$="AdminPromptComparisonRequestImport-module_winnerCellTie_QGdrQ",u$="AdminPromptComparisonRequestImport-module_winnerCellBothFail_XMDYb",m$="AdminPromptComparisonRequestImport-module_jobLink_VfNNI",p$="AdminPromptComparisonRequestImport-module_pastRunsList_nJ9XV",h$="AdminPromptComparisonRequestImport-module_pastRunsLoading_4HH94",f$="AdminPromptComparisonRequestImport-module_pastRunItem_CkHEG",x$="AdminPromptComparisonRequestImport-module_pastRunDetails_RvQnY",g$="AdminPromptComparisonRequestImport-module_pastRunMeta_4-XCb",v$="AdminPromptComparisonRequestImport-module_passRate_wLzx6",_$="AdminPromptComparisonRequestImport-module_passRateLabel_9ys-W",j$="AdminPromptComparisonRequestImport-module_passRateBar_8-4OK",b$="AdminPromptComparisonRequestImport-module_passRatePassed_1ZK2v",y$="AdminPromptComparisonRequestImport-module_passRateFailed_a1ERD",S$="AdminPromptComparisonRequestImport-module_selectAllRow_-BcQx",C$="AdminPromptComparisonRequestImport-module_tagFilterControl_Rn7T3",N$="AdminPromptComparisonRequestImport-module_tagCheckbox_mthTa",w$="AdminPromptComparisonRequestImport-module_modalOverlay_gxL-U",A$="AdminPromptComparisonRequestImport-module_modalContent_4OvAH",I$="AdminPromptComparisonRequestImport-module_modalActions_bKjLG",T$="AdminPromptComparisonRequestImport-module_secondaryButton_kZm5Y",k$="AdminPromptComparisonRequestImport-module_toolCallSelector_yEKRh",R$="AdminPromptComparisonRequestImport-module_toolCallHeader_AM-eK",$$="AdminPromptComparisonRequestImport-module_toolGrid_W5clO",P$="AdminPromptComparisonRequestImport-module_toolOption_wqJyN",E$="AdminPromptComparisonRequestImport-module_toolName_xR090",L$="AdminPromptComparisonRequestImport-module_attachMediaButton_qrot4",B$="AdminPromptComparisonRequestImport-module_assetThumbnailsRow_VgOP3",D$="AdminPromptComparisonRequestImport-module_assetIdsRow_ZVapZ",M$="AdminPromptComparisonRequestImport-module_assetIdBadge_qaHod",F$="AdminPromptComparisonRequestImport-module_removeAssetButton_pD8-K",O$="AdminPromptComparisonRequestImport-module_pageDescription_2PEeQ",q$="AdminPromptComparisonRequestImport-module_resultCard_Jlfaa",V$="AdminPromptComparisonRequestImport-module_label_UabmD",H$="AdminPromptComparisonRequestImport-module_input_PE1iE",U$="AdminPromptComparisonRequestImport-module_textarea_zm5XH",Z$="AdminPromptComparisonRequestImport-module_textareaSmall_xWXkz",W$="AdminPromptComparisonRequestImport-module_tagList_pS-xp",K$="AdminPromptComparisonRequestImport-module_tag_QTlKQ",G$="AdminPromptComparisonRequestImport-module_removeTag_Nm1AR",J$="AdminPromptComparisonRequestImport-module_tagInputRow_-0Fik",z$="AdminPromptComparisonRequestImport-module_primaryButton_SSCX4",Y$="AdminPromptComparisonRequestImport-module_primaryLink_8kai4",Q$="AdminPromptComparisonRequestImport-module_resultTitle_o9v-j",X$="AdminPromptComparisonRequestImport-module_resultSubtitle_PbX83",e4="AdminPromptComparisonRequestImport-module_resultList_WdBrB";var Me={container:t3,pageHeader:s3,pageHeaderLeft:n3,startNewRunButton:a3,headerLinks:o3,pageTitle:i3,pageTitleDisplay:l3,pageTitleEditor:r3,pageTitleInput:d3,pageTitleEditButton:c3,runMetadataCard:u3,runMetadataGrid:m3,metadataItem:p3,metadataLabel:h3,runId:f3,backLink:x3,card:g3,sectionTitle:v3,testHistoryHeader:_3,addRequestRow:j3,addRequestInput:b3,smallButton:y3,dangerButton:S3,requestList:C3,requestItem:N3,requestCheckbox:w3,requestContent:A3,requestBadges:I3,requestTagBadge:T3,requestPrompt:k3,requestDescription:R3,requestToolBadge:$3,editButton:P3,runButton:E3,deleteButton:L3,emptyState:B3,deleteModalText:D3,deleteModalPrompt:M3,field:F3,fieldLabel:O3,fieldTextarea:q3,descriptionTextarea:V3,fieldSelect:H3,labelRow:U3,prefillButton:Z3,promptColumns:W3,judgeTextarea:K3,agentInstructionsTextarea:G3,fixedSuffix:J3,fixedSuffixLabel:z3,fixedSuffixContent:Y3,helperText:Q3,submitActions:X3,error:eR,loadingOverlay:tR,fullScreenLoadingOverlay:sR,spinner:nR,spin:aR,resultsSection:oR,summaryCard:iR,synthesisCard:lR,synthesisTitle:rR,synthesisTargetNote:dR,synthesisSection:cR,synthesisHeading:uR,synthesisBody:mR,synthesisPre:pR,reportTypeOption:hR,regressionScoreRow:fR,regressionScoreValue:xR,regressionScoreMax:gR,regressionStatsRow:vR,regressionSeverityBadge:_R,regressionSeverityNone:jR,regressionSeverityMinor:bR,regressionSeverityModerate:yR,regressionSeveritySevere:SR,regressionList:CR,regressionItem:NR,regressionItemHeader:wR,regressionItemDelta:AR,regressionItemScores:IR,regressionItemPrompt:TR,summaryTitle:kR,summaryHeader:RR,progressRow:$R,progressStat:PR,winBar:ER,winBarA:LR,winBarTie:BR,winBarBothFail:DR,winBarB:MR,winLegend:FR,legendDot:OR,legendDotA:qR,legendDotTie:VR,legendDotB:HR,legendDotBothFail:UR,subJobsTable:ZR,sortableHeader:WR,sortIndicator:KR,subJobErrorCell:GR,statusIndicator:JR,statusDot:zR,statusRunning:YR,statusJudging:QR,statusCompleted:XR,statusFailed:e$,statusCancelled:t$,validationOutcome:s$,validationOutcomePassed:n$,validationOutcomeFailed:a$,validationOutcomeError:o$,validationOutcomeSkipped:i$,winnerCell:l$,winnerCellA:r$,winnerCellB:d$,winnerCellTie:c$,winnerCellBothFail:u$,jobLink:m$,pastRunsList:p$,pastRunsLoading:h$,pastRunItem:f$,pastRunDetails:x$,pastRunMeta:g$,passRate:v$,passRateLabel:_$,passRateBar:j$,passRatePassed:b$,passRateFailed:y$,selectAllRow:S$,tagFilterControl:C$,tagCheckbox:N$,modalOverlay:w$,modalContent:A$,modalActions:I$,secondaryButton:T$,toolCallSelector:k$,toolCallHeader:R$,toolGrid:$$,toolOption:P$,toolName:E$,attachMediaButton:L$,assetThumbnailsRow:B$,assetIdsRow:D$,assetIdBadge:M$,removeAssetButton:F$,pageDescription:O$,resultCard:q$,label:V$,input:H$,textarea:U$,textareaSmall:Z$,tagList:W$,tag:K$,removeTag:G$,tagInputRow:J$,primaryButton:z$,primaryLink:Y$,resultTitle:Q$,resultSubtitle:X$,resultList:e4};function t4(){const[s,e]=(0,f.useState)(""),[n,a]=(0,f.useState)(""),[o,i]=(0,f.useState)(""),[l,r]=(0,f.useState)(""),[d,c]=(0,f.useState)(""),[m,h]=(0,f.useState)(""),[p,u]=(0,f.useState)(Hl),[g,_]=(0,f.useState)([]),[v,b]=(0,f.useState)(""),[j,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(null),[y,N]=(0,f.useState)(null);function w(){const I=v.trim();I&&(g.some(D=>D.toLowerCase()===I.toLowerCase())||_(D=>[...D,I]),b(""))}async function A(I){I.preventDefault(),x(!0),C(null),N(null);try{const D=v.trim(),L=[...g];D&&!L.some($=>$.toLowerCase()===D.toLowerCase())&&(L.push(D),_(L),b("")),N(await H.admin.promptComparison.importRequestFromNotionRow.mutate({chatUrl:s,title:n,assertions:o,rationale:l,whoAdded:d,functionalityTargets:L,exampleOutputUrl:m.trim()||void 0,sourceTableUrl:p}))}catch(D){C(D instanceof Error?D.message:"Failed to import the test.")}finally{x(!1)}}return(0,t.jsxs)("div",{className:Me.container,children:[(0,t.jsxs)("div",{className:Me.pageHeader,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:Me.pageTitle,children:"Import Notion test"}),(0,t.jsx)("p",{className:Me.pageDescription,children:"Convert one row from the 26Q3 editing test table into a configured request-bank test."})]}),(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison-request-bank",className:Me.backLink,children:"Request bank"})]}),(0,t.jsxs)("form",{className:Me.card,onSubmit:A,children:[(0,t.jsxs)("label",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Chat Link"}),(0,t.jsx)("input",{className:Me.input,type:"url",required:!0,value:s,placeholder:"https://www.kapwing.com/kai/chat/...",onChange:I=>e(I.target.value)})]}),(0,t.jsxs)("label",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Title"}),(0,t.jsx)("input",{className:Me.input,required:!0,maxLength:300,value:n,onChange:I=>a(I.target.value)})]}),(0,t.jsxs)("label",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Assertions"}),(0,t.jsx)("textarea",{className:Me.textarea,required:!0,value:o,placeholder:"Paste all assertions from the Notion row.",onChange:I=>i(I.target.value)})]}),(0,t.jsxs)("label",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Rationale"}
218),(0,t.jsx)("textarea",{className:Me.textareaSmall,value:l,onChange:I=>r(I.target.value)})]}),(0,t.jsxs)("label",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Who Added"}),(0,t.jsx)("input",{className:Me.input,required:!0,maxLength:300,value:d,onChange:I=>c(I.target.value)})]}),(0,t.jsxs)("div",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Functionality Targeted"}),(0,t.jsx)("div",{className:Me.tagList,children:g.map(I=>(0,t.jsxs)("span",{className:Me.tag,children:[I,(0,t.jsx)("button",{className:Me.removeTag,type:"button","aria-label":`Remove ${I}`,onClick:()=>_(D=>D.filter(L=>L!==I)),children:"Ã"})]},I))}),(0,t.jsxs)("div",{className:Me.tagInputRow,children:[(0,t.jsx)("input",{className:Me.input,value:v,placeholder:"Take Selection",onChange:I=>b(I.target.value),onKeyDown:I=>{I.key!=="Enter"&&I.key!==","||(I.preventDefault(),w())}}),(0,t.jsx)("button",{className:Me.secondaryButton,type:"button",onClick:w,children:"Add tag"})]}),(0,t.jsx)("span",{className:Me.helperText,children:"Tags preserve capitalization. The 26q3-editing tag is added automatically."})]}),(0,t.jsxs)("label",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Example output URL (optional)"}),(0,t.jsx)("input",{className:Me.input,type:"url",value:m,onChange:I=>h(I.target.value)})]}),(0,t.jsxs)("label",{className:Me.field,children:[(0,t.jsx)("span",{className:Me.label,children:"Source table URL"}),(0,t.jsx)("input",{className:Me.input,type:"url",required:!0,value:p,onChange:I=>u(I.target.value)})]}),S&&(0,t.jsx)("div",{className:Me.error,children:S}),(0,t.jsx)("button",{className:Me.primaryButton,type:"submit",disabled:j,children:j?"Generating and creating test...":"Create test"})]}),y&&(0,t.jsxs)("div",{className:Me.resultCard,children:[(0,t.jsx)("h2",{className:Me.resultTitle,children:y.created?"Test created":"Test already imported"}),y.placeholders.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:Me.resultSubtitle,children:"Placeholders to replace"}),(0,t.jsx)("ul",{className:Me.resultList,children:y.placeholders.map(I=>(0,t.jsx)("li",{children:I},I))})]}),y.unresolvedAssertions.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:Me.resultSubtitle,children:"Needs refinement"}),(0,t.jsx)("ul",{className:Me.resultList,children:y.unresolvedAssertions.map(I=>(0,t.jsx)("li",{children:I},I))})]}),(0,t.jsx)(be,{className:Me.primaryLink,to:y.requestBankUrl,children:"Review test in request bank"})]})]})}const s4="AdminPromptComparisonRuns-module_container_1MW-h",n4="AdminPromptComparisonRuns-module_pageHeader_IccNK",a4="AdminPromptComparisonRuns-module_pageHeaderLeft_AoBpt",o4="AdminPromptComparisonRuns-module_startNewRunButton_6fTHx",i4="AdminPromptComparisonRuns-module_headerLinks_pOwhX",l4="AdminPromptComparisonRuns-module_pageTitle_jQ2mZ",r4="AdminPromptComparisonRuns-module_pageTitleDisplay_kh3Et",d4="AdminPromptComparisonRuns-module_pageTitleEditor_0-vgI",c4="AdminPromptComparisonRuns-module_pageTitleInput_sN3Qy",u4="AdminPromptComparisonRuns-module_pageTitleEditButton_6Kup-",m4="AdminPromptComparisonRuns-module_runMetadataCard_RYOeq",p4="AdminPromptComparisonRuns-module_runMetadataGrid_xJbDs",h4="AdminPromptComparisonRuns-module_metadataItem_cWZi1",f4="AdminPromptComparisonRuns-module_metadataLabel_PLfaC",x4="AdminPromptComparisonRuns-module_runId_L-PrO",g4="AdminPromptComparisonRuns-module_backLink_hjgtp",v4="AdminPromptComparisonRuns-module_card_2WbtR",_4="AdminPromptComparisonRuns-module_sectionTitle_2s-L1",j4="AdminPromptComparisonRuns-module_testHistoryHeader_dYbFm",b4="AdminPromptComparisonRuns-module_addRequestRow_8RBdC",y4="AdminPromptComparisonRuns-module_addRequestInput_heH3n",S4="AdminPromptComparisonRuns-module_smallButton_3gR1S",C4="AdminPromptComparisonRuns-module_dangerButton_Ti5zg",N4="AdminPromptComparisonRuns-module_requestList_ajNUn",w4="AdminPromptComparisonRuns-module_requestItem_-jbKq",A4="AdminPromptComparisonRuns-module_requestCheckbox_3pQ0c",I4="AdminPromptComparisonRuns-module_requestContent_TPXFx",T4="AdminPromptComparisonRuns-module_requestBadges_2XtCw",k4="AdminPromptComparisonRuns-module_requestTagBadge_B5DP0",R4="AdminPromptComparisonRuns-module_requestPrompt_Xw-QT",$4="AdminPromptComparisonRuns-module_requestDescription_wApFS",P4="AdminPromptComparisonRuns-module_requestToolBadge_MSFUl",E4="AdminPromptComparisonRuns-module_editButton_UuZ-B",L4="AdminPromptComparisonRuns-module_runButton_LgyD-",B4="AdminPromptComparisonRuns-module_deleteButton_-AbzF",D4="AdminPromptComparisonRuns-module_emptyState_1jLPg",M4="AdminPromptComparisonRuns-module_deleteModalText_ZYJ00",F4="AdminPromptComparisonRuns-module_deleteModalPrompt_v64rC",O4="AdminPromptComparisonRuns-module_field_2-OsT",q4="AdminPromptComparisonRuns-module_fieldLabel_spNLM",V4="AdminPromptComparisonRuns-module_fieldTextarea_1NX-K",H4="AdminPromptComparisonRuns-module_descriptionTextarea_Z-rLn",U4="AdminPromptComparisonRuns-module_fieldSelect_ibaig",Z4="AdminPromptComparisonRuns-module_labelRow_G2iG1",W4="AdminPromptComparisonRuns-module_prefillButton_kbsoV",K4="AdminPromptComparisonRuns-module_promptColumns_SdDrA",G4="AdminPromptComparisonRuns-module_judgeTextarea_nMCw0",J4="AdminPromptComparisonRuns-module_agentInstructionsTextarea_kMK49",z4="AdminPromptComparisonRuns-module_fixedSuffix_0VFtm",Y4="AdminPromptComparisonRuns-module_fixedSuffixLabel_lNFDU",Q4="AdminPromptComparisonRuns-module_fixedSuffixContent_t6PO5",X4="AdminPromptComparisonRuns-module_helperText_3NGQA",eP="AdminPromptComparisonRuns-module_submitActions_QyZF8",tP="AdminPromptComparisonRuns-module_error_uGbJO",sP="AdminPromptComparisonRuns-module_loadingOverlay_2U-oK",nP="AdminPromptComparisonRuns-module_fullScreenLoadingOverlay_vNSQY",aP="AdminPromptComparisonRuns-module_spinner_qxlv4",oP="AdminPromptComparisonRuns-module_spin_xv9VD",iP="AdminPromptComparisonRuns-module_resultsSection_GjEsJ",lP="AdminPromptComparisonRuns-module_summaryCard_ONVza",rP="AdminPromptComparisonRuns-module_synthesisCard_gQRQL",dP="AdminPromptComparisonRuns-module_synthesisTitle_irVGU",cP="AdminPromptComparisonRuns-module_synthesisTargetNote_CQgPt",uP="AdminPromptComparisonRuns-module_synthesisSection_Hkv8u",mP="AdminPromptComparisonRuns-module_synthesisHeading_G5hJT",pP="AdminPromptComparisonRuns-module_synthesisBody_IZEUA",hP="AdminPromptComparisonRuns-module_synthesisPre_mL7cw",fP="AdminPromptComparisonRuns-module_reportTypeOption_Jgybi",xP="AdminPromptComparisonRuns-module_regressionScoreRow_fx6SB",gP="AdminPromptComparisonRuns-module_regressionScoreValue_KemTf",vP="AdminPromptComparisonRuns-module_regressionScoreMax_V5Dfr",_P="AdminPromptComparisonRuns-module_regressionStatsRow_HGxzL",jP="AdminPromptComparisonRuns-module_regressionSeverityBadge_MMbSZ",bP="AdminPromptComparisonRuns-module_regressionSeverityNone_opPXn",yP="AdminPromptComparisonRuns-module_regressionSeverityMinor_aLFGh",SP="AdminPromptComparisonRuns-module_regressionSeverityModerate_uq4PD",CP="AdminPromptComparisonRuns-module_regressionSeveritySevere_scKwv",NP="AdminPromptComparisonRuns-module_regressionList_fQYdI",wP="AdminPromptComparisonRuns-module_regressionItem_ytQfG",AP="AdminPromptComparisonRuns-module_regressionItemHeader_gjRQJ",IP="AdminPromptComparisonRuns-module_regressionItemDelta_gzRJR",TP="AdminPromptComparisonRuns-module_regressionItemScores_sN0wp",kP="AdminPromptComparisonRuns-module_regressionItemPrompt_vi-uk",RP="AdminPromptComparisonRuns-module_summaryTitle_FIL8f",$P="AdminPromptComparisonRuns-module_summaryHeader_7JtkS",PP="AdminPromptComparisonRuns-module_progressRow_hiomL",EP="AdminPromptComparisonRuns-module_progressStat_dxQUe",LP="AdminPromptComparisonRuns-module_winBar_s7WW2",BP="AdminPromptComparisonRuns-module_winBarA_QKIRv",DP="AdminPromptComparisonRuns-module_winBarTie_qEU-K",MP="AdminPromptComparisonRuns-module_winBarBothFail_t9uLF",FP="AdminPromptComparisonRuns-module_winBarB_3GlwP",OP="AdminPromptComparisonRuns-module_winLegend_3JoFC",qP="AdminPromptComparisonRuns-module_legendDot_QTLhl",VP="AdminPromptComparisonRuns-module_legendDotA_9Uq4n",HP="AdminPromptComparisonRuns-module_legendDotTie_w9w8V",UP="AdminPromptComparisonRuns-module_legendDotB_HlkPi",ZP="AdminPromptComparisonRuns-module_legendDotBothFail_pbLz-",WP="AdminPromptComparisonRuns-module_subJobsTable_ODuUw",KP="AdminPromptComparisonRuns-module_sortableHeader_PNjxb",GP="AdminPromptComparisonRuns-module_sortIndicator_TuFPI",JP="AdminPromptComparisonRuns-module_subJobErrorCell_aYdV2",zP="AdminPromptComparisonRuns-module_statusIndicator_IFNi9",YP="AdminPromptComparisonRuns-module_statusDot_mayvQ",QP="AdminPromptComparisonRuns-module_statusRunning_2uIMG",XP="AdminPromptComparisonRuns-module_statusJudging_Oc3EV",eE="AdminPromptComparisonRuns-module_statusCompleted_MG-5E",tE="AdminPromptComparisonRuns-module_statusFailed_xqSkU",sE="AdminPromptComparisonRuns-module_statusCancelled_jfXXG",nE="AdminPromptComparisonRuns-module_validationOutcome_DUfpr",aE="AdminPromptComparisonRuns-module_validationOutcomePassed_eJWZD",oE="AdminPromptComparisonRuns-module_validationOutcomeFailed_ypsz6",iE="AdminPromptComparisonRuns-module_validationOutcomeError_CnA-8",lE="AdminPromptComparisonRuns-module_validationOutcomeSkipped_lG1G1",rE="AdminPromptComparisonRuns-module_winnerCell_G-SLz",dE="AdminPromptComparisonRuns-module_winnerCellA_om0FU",cE="AdminPromptComparisonRuns-module_winnerCellB_hZ0gS",uE="AdminPromptComparisonRuns-module_winnerCellTie_G-wyj",mE="AdminPromptComparisonRuns-module_winnerCellBothFail_EirF2",pE="AdminPromptComparisonRuns-module_jobLink_JEr0P",hE="AdminPromptComparisonRuns-module_pastRu
218nsList_1--me",fE="AdminPromptComparisonRuns-module_pastRunsLoading_6UyWs",xE="AdminPromptComparisonRuns-module_pastRunItem_2owvg",gE="AdminPromptComparisonRuns-module_pastRunDetails_PaIlw",vE="AdminPromptComparisonRuns-module_pastRunMeta_lMFd4",_E="AdminPromptComparisonRuns-module_passRate_HxD3r",jE="AdminPromptComparisonRuns-module_passRateLabel_oKzy8",bE="AdminPromptComparisonRuns-module_passRateBar_0OPYO",yE="AdminPromptComparisonRuns-module_passRatePassed_orsW8",SE="AdminPromptComparisonRuns-module_passRateFailed_56jzY",CE="AdminPromptComparisonRuns-module_selectAllRow_-rjN-",NE="AdminPromptComparisonRuns-module_tagFilterControl_yyP-K",wE="AdminPromptComparisonRuns-module_tagCheckbox_196Wx",AE="AdminPromptComparisonRuns-module_modalOverlay_MoxeC",IE="AdminPromptComparisonRuns-module_modalContent_sZPaq",TE="AdminPromptComparisonRuns-module_modalActions_hdqlI",kE="AdminPromptComparisonRuns-module_secondaryButton_A9jZd",RE="AdminPromptComparisonRuns-module_toolCallSelector_IKPLy",$E="AdminPromptComparisonRuns-module_toolCallHeader_c1LbC",PE="AdminPromptComparisonRuns-module_toolGrid_TUmTd",EE="AdminPromptComparisonRuns-module_toolOption_Kt-co",LE="AdminPromptComparisonRuns-module_toolName_o3-G6",BE="AdminPromptComparisonRuns-module_attachMediaButton_fY-Wg",DE="AdminPromptComparisonRuns-module_assetThumbnailsRow_pRjLf",ME="AdminPromptComparisonRuns-module_assetIdsRow_EiQp6",FE="AdminPromptComparisonRuns-module_assetIdBadge_9RrYd",OE="AdminPromptComparisonRuns-module_removeAssetButton_MxKkb";var M={container:s4,pageHeader:n4,pageHeaderLeft:a4,startNewRunButton:o4,headerLinks:i4,pageTitle:l4,pageTitleDisplay:r4,pageTitleEditor:d4,pageTitleInput:c4,pageTitleEditButton:u4,runMetadataCard:m4,runMetadataGrid:p4,metadataItem:h4,metadataLabel:f4,runId:x4,backLink:g4,card:v4,sectionTitle:_4,testHistoryHeader:j4,addRequestRow:b4,addRequestInput:y4,smallButton:S4,dangerButton:C4,requestList:N4,requestItem:w4,requestCheckbox:A4,requestContent:I4,requestBadges:T4,requestTagBadge:k4,requestPrompt:R4,requestDescription:$4,requestToolBadge:P4,editButton:E4,runButton:L4,deleteButton:B4,emptyState:D4,deleteModalText:M4,deleteModalPrompt:F4,field:O4,fieldLabel:q4,fieldTextarea:V4,descriptionTextarea:H4,fieldSelect:U4,labelRow:Z4,prefillButton:W4,promptColumns:K4,judgeTextarea:G4,agentInstructionsTextarea:J4,fixedSuffix:z4,fixedSuffixLabel:Y4,fixedSuffixContent:Q4,helperText:X4,submitActions:eP,error:tP,loadingOverlay:sP,fullScreenLoadingOverlay:nP,spinner:aP,spin:oP,resultsSection:iP,summaryCard:lP,synthesisCard:rP,synthesisTitle:dP,synthesisTargetNote:cP,synthesisSection:uP,synthesisHeading:mP,synthesisBody:pP,synthesisPre:hP,reportTypeOption:fP,regressionScoreRow:xP,regressionScoreValue:gP,regressionScoreMax:vP,regressionStatsRow:_P,regressionSeverityBadge:jP,regressionSeverityNone:bP,regressionSeverityMinor:yP,regressionSeverityModerate:SP,regressionSeveritySevere:CP,regressionList:NP,regressionItem:wP,regressionItemHeader:AP,regressionItemDelta:IP,regressionItemScores:TP,regressionItemPrompt:kP,summaryTitle:RP,summaryHeader:$P,progressRow:PP,progressStat:EP,winBar:LP,winBarA:BP,winBarTie:DP,winBarBothFail:MP,winBarB:FP,winLegend:OP,legendDot:qP,legendDotA:VP,legendDotTie:HP,legendDotB:UP,legendDotBothFail:ZP,subJobsTable:WP,sortableHeader:KP,sortIndicator:GP,subJobErrorCell:JP,statusIndicator:zP,statusDot:YP,statusRunning:QP,statusJudging:XP,statusCompleted:eE,statusFailed:tE,statusCancelled:sE,validationOutcome:nE,validationOutcomePassed:aE,validationOutcomeFailed:oE,validationOutcomeError:iE,validationOutcomeSkipped:lE,winnerCell:rE,winnerCellA:dE,winnerCellB:cE,winnerCellTie:uE,winnerCellBothFail:mE,jobLink:pE,pastRunsList:hE,pastRunsLoading:fE,pastRunItem:xE,pastRunDetails:gE,pastRunMeta:vE,passRate:_E,passRateLabel:jE,passRateBar:bE,passRatePassed:yE,passRateFailed:SE,selectAllRow:CE,tagFilterControl:NE,tagCheckbox:wE,modalOverlay:AE,modalContent:IE,modalActions:TE,secondaryButton:kE,toolCallSelector:RE,toolCallHeader:$E,toolGrid:PE,toolOption:EE,toolName:LE,attachMediaButton:BE,assetThumbnailsRow:DE,assetIdsRow:ME,assetIdBadge:FE,removeAssetButton:OE},Mn=Q(ie()),qE={running:M.statusRunning,judging:M.statusJudging,completed:M.statusCompleted,failed:M.statusFailed,cancelled:M.statusCancelled},VE={A:M.winnerCellA,B:M.winnerCellB,Tie:M.winnerCellTie,"Both Fail":M.winnerCellBothFail},HE={passed:M.validationOutcomePassed,failed:M.validationOutcomeFailed,skipped:M.validationOutcomeSkipped,error:M.validationOutcomeError},UE={passed:"Passed",failed:"Failed",skipped:"Skipped",error:"Error"};function eo(s){const e=(0,Mn.c)(7),{status:n}=s,a=`${M.statusDot} ${qE[n]??""}`;let o;e[0]!==a?(o=(0,t.jsx)("span",{"aria-hidden":"true",className:a}),e[0]=a,e[1]=o):o=e[1];let i;e[2]!==n?(i=(0,t.jsx)("span",{children:n}),e[2]=n,e[3]=i):i=e[3];let l;return e[4]!==o||e[5]!==i?(l=(0,t.jsxs)("span",{className:M.statusIndicator,children:[o,i]}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function ZE({isRunning:s,isValidationMode:e,completed:n,total:a,judging:o,selectedCount:i}){return s?`Running (${n}/${a}${!e&&o>0?`, ${o} judging`:""})`:e?`Run validation suite (${i} requests)`:`Run comparison suite (${i} requests)`}
218var ci="preselectRequestId",Ra="validation";function WE(){const{runId:s}=Ys(),e=Lt(),[n,a]=Ji(),[o,i]=(0,f.useState)([]),[l,r]=(0,f.useState)(new Set),[d,c]=(0,f.useState)(""),[m,h]=(0,f.useState)(null),[p,u]=(0,f.useState)(!1),[g,_]=(0,f.useState)(""),[v,b]=(0,f.useState)(""),[j,x]=(0,f.useState)([]),[S,C]=(0,f.useState)(void 0),[y,N]=(0,f.useState)(!1),[w,A]=(0,f.useState)(void 0),[I,D]=(0,f.useState)([]),[L,$]=(0,f.useState)([]),[R,P]=(0,f.useState)(""),[k,T]=(0,f.useState)(""),[E,O]=(0,f.useState)(Ra),[q,J]=(0,f.useState)("synthesis"),[K,z]=(0,f.useState)(Qa),[Y,me]=(0,f.useState)(""),[X,te]=(0,f.useState)(""),[ae,G]=(0,f.useState)(Vt),[se,U]=(0,f.useState)(Vt),[B,oe]=(0,f.useState)(""),[de,ye]=(0,f.useState)(""),[Le,Ne]=(0,f.useState)(!1),[Be,le]=(0,f.useState)(!1),he=(0,f.useRef)(null),[ge,je]=(0,f.useState)(null),[ue,pe]=(0,f.useState)(null),[ee,xe]=(0,f.useState)([]),[ve,we]=(0,f.useState)(!0),[re,V]=(0,f.useState)(null),[Ie,ke]=(0,f.useState)(!!s),[De,Xe]=(0,f.useState)(!s),[jt,Zt]=(0,f.useState)(!1),[ws,es]=(0,f.useState)(!1),[ts,cs]=(0,f.useState)(!1),[ss,As]=(0,f.useState)(null),et=ge!==null||jt,ns=!!s&&ue===null,Bt=(0,f.useMemo)(()=>{const Z=new Set;for(const Ae of o)for(const Ee of Ae.tags??[])Z.add(Ee);return Array.from(Z).sort((Ae,Ee)=>Ae.localeCompare(Ee))},[o]),At=(0,f.useMemo)(()=>d?o.filter(Z=>Z.tags?.includes(d)):o,[o,d]),as=At.filter(Z=>l.has(Z.id)).length,os=At.length>0&&as===At.length,ut=At.filter(Z=>l.has(Z.id)).map(Z=>Z.id);(0,f.useEffect)(function(){!De||ns||H.admin.promptComparison.listRequests.query().then(i)},[De,ns]),(0,f.useEffect)(function(){if(!De||ns)return;let Ae=!1;return H.admin.promptComparison.listRuns.query().then(Ee=>{Ae||xe(Ee)}).catch(Ee=>{Ae||V(Ee instanceof Error?Ee.message:"Failed to load past runs.")}).finally(()=>{Ae||we(!1)}),()=>{Ae=!0}},[De,ns]),(0,f.useEffect)(function(){d&&!Bt.includes(d)&&c("")},[Bt,d]),(0,f.useEffect)(function(){const Ae=n.get(ci);if(!Ae||o.length===0||!o.some(ps=>ps.id===Ae))return;r(new Set([Ae]));const Ee=new URLSearchParams(n);Ee.delete(ci),a(Ee,{replace:!0})},[o,n,a]),(0,f.useEffect)(function(){if(!s){je(null),pe(null),ke(!1),Xe(!0),O(Ra);return}let Ae=!1;return ke(!0),pe(null),V(null),H.admin.promptComparison.getRun.query({runId:s}).then(Ee=>{if(!Ae){if(!Ee){V("Run not found.");return}P(Ee.input.systemPromptA),T(Ee.input.systemPromptB),O(Ee.runMode??Ee.input.runMode??"comparison"),J(Ee.reportType??"synthesis"),z(Ee.input.judgeSystemPrompt),me(Ee.input.agentInstructionsA??""),te(Ee.input.agentInstructionsB??""),G(Ee.input.planningLLMA??Vt),U(Ee.input.planningLLMB??Vt),oe(Ee.title??`Evaluation ${Ee.runId}`),ye(Ee.description??""),pe(Ee),je(Ee.status==="running"?s:null)}}).catch(Ee=>{Ae||V(Ee instanceof Error?Ee.message:"Failed to load run.")}).finally(()=>{Ae||(ke(!1),Xe(!0))}),()=>{Ae=!0}},[s]),(0,f.useEffect)(function(){Be&&(he.current?.focus(),he.current?.select())},[Be]),xo({callback:(0,f.useCallback)(async()=>{if(ge)try{const Z=await H.admin.promptComparison.getRun.query({runId:ge});if(!Z){V("Run not found."),je(null);return}pe(Z),(Z.status==="completed"||Z.status==="failed"||Z.status==="cancelled")&&je(null)}catch(Z){V(Z instanceof Error?Z.message:"Failed to poll run status."),je(null)}},[ge]),intervalMs:3e3,shouldPoll:et});function Nt(){h(null),u(!1)}function wt(){u(!0),h({id:"",userPrompt:"",chatHistory:[]}),_(""),b(""),x([]),C(void 0),N(!1),A(void 0),D([]),$([])}async function us(){const Z=ss;if(Z)try{await H.admin.promptComparison.deleteRequest.mutate({id:Z.id}),i(Ae=>Ae.filter(Ee=>Ee.id!==Z.id)),r(Ae=>{const Ee=new Set(Ae);return Ee.delete(Z.id),Ee})}catch(Ae){Ue({error:Ae,description:"Failed to delete request."})}finally{As(null)}}function ms(Z){u(!1),h({...Z,chatHistory:Z.chatHistory??[]}),_(Z.description??""),b(Z.userPrompt),x(Z.assetIds??[]),C(Z.correctToolCalls),N(Z.doNonStrictToolCheck??!1),A(Z.expectedResult),D(Z.tags??[]),$((Z.chatHistory??[]).map((Ae,Ee)=>Ee))}function Is(Z){r(Ae=>{const Ee=new Set(Ae);return Ee.has(Z)?Ee.delete(Z):Ee.add(Z),Ee})}function Fn(){r(Z=>{const Ae=new Set(Z);for(const Ee of At)os?Ae.delete(Ee.id):Ae.add(Ee.id);return Ae})}function On(){r(new Set(pa.map(Z=>Z.id)))}async function qn(Z){Z.preventDefault(),V(null),pe(null),Zt(!0);try{const Ae=await H.admin.promptComparison.startRun.mutate({description:de.trim()||void 0,systemPromptA:R.trim(),systemPromptB:E==="validation"?void 0:k.trim()||void 0,judgeSystemPrompt:E==="validation"?void 0:K.trim()||void 0,agentInstructionsA:Y.trim()||void 0,agentInstructionsB:E==="validation"?void 0:X.trim()||void 0,planningLLMA:ae,planningLLMB:E==="validation"?void 0:se,requestIds:ut,reportType:E==="validation"?void 0:q,runMode:E});je(Ae.runId),e(`/admin/ai/prompt-comparison-runs/${Ae.runId}`,{replace:!0})}catch(Ae){V(Ae instanceof Error?Ae.message:"Failed to start run.")}finally{Zt(!1)}}async function ca(){if(!ge||ws)return;const Z=ge;V(null),es(!0);try{await H.admin.promptComparison.cancelRun.mutate({runId:Z});const Ae=await H.admin.promptComparison.getRun.query({runId:Z});Ae&&(pe(Ae),Ae.status!=="running"&&je(null),xe(Ee=>Ee.map(ps=>ps.runId===Z?{...ps,status:Ae.status}:ps)))}catch(Ae){V(Ae instanceof Error?Ae.message:"Failed to stop run.")}finally{es(!1)}}async function fn({finishTitleEdit:Z=!1}={}){if(!(!ue||!B.trim()||Le)){V(null),Ne(!0);try{await H.admin.promptComparison.updateRunMetadata.mutate({runId:ue.runId,title:B.trim(),description:de.trim()||void 0}),pe(Ae=>Ae&&{...Ae,title:B.trim(),description:de.trim()||void 0}),Z&&le(!1)}catch(Ae){V(Ae instanceof Error?Ae.message:"Failed to save run details.")}finally{Ne(!1)}}}async function ua(Z){Z.preventDefault(),await fn({finishTitleEdit:!0})}function Ts(){if(!B.trim()){oe(ue?.title??""),le(!1);return}fn({finishTitleEdit:!0})}function ma(){de.trim()!==(ue?.description??"")&&fn()}function xr(){je(null),pe(null),V(null),r(new Set),P(""),T(""),O(Ra),J("synthesis"),z(Qa),me(""),te(""),G(Vt),U(Vt),oe(""),ye(""),e("/admin/ai/prompt-comparison-runs")}const vt=E==="validation",pa=At.filter(Z=>Z.expectedResult!==void 0),gr=!et&&!Ie&&ut.length>0&&R.trim().length>0&&(vt||k.trim().length>0&&K.trim().length>0),vr=()=>
218ve?(0,t.jsxs)("div",{className:M.pastRunsLoading,role:"status","aria-live":"polite","aria-busy":"true",children:[(0,t.jsx)("div",{className:M.spinner}),(0,t.jsx)("span",{children:"Loading past runs..."})]}):ee.length>0?(0,t.jsx)("div",{className:M.pastRunsList,children:ee.map(Z=>(0,t.jsxs)(be,{to:`/admin/ai/prompt-comparison-runs/${Z.runId}`,className:M.pastRunItem,children:[(0,t.jsxs)("div",{className:M.pastRunDetails,children:[(0,t.jsx)("strong",{children:Z.title||`Evaluation ${Z.runId}`}),(0,t.jsxs)("div",{className:M.pastRunMeta,children:[(0,t.jsx)(eo,{status:Z.status}),(0,t.jsxs)("span",{children:[Z.subJobCount," requests"]}),(0,t.jsx)("span",{children:new Date(Z.createdAt).toLocaleString()}),(0,t.jsxs)("span",{children:["Developer: ",Z.developer]}),(0,t.jsxs)("span",{children:["Where: ",Z.runLocation??"Not recorded"]})]})]}),Z.validationSummary&&Z.validationSummary.totalTests>0&&(0,t.jsx)(_r,{passedCount:Z.validationSummary.passedCount,totalTests:Z.validationSummary.totalTests})]},Z.runId))}):(0,t.jsx)("p",{className:M.emptyState,children:"No past runs yet."});function _r({passedCount:Z,totalTests:Ae}){const Ee=Math.round(Z/Ae*100),ps=100-Ee,Vn=`${Ee}% passing (${Z}/${Ae})`;return(0,t.jsxs)("div",{className:M.passRate,children:[(0,t.jsx)("span",{className:M.passRateLabel,children:Vn}),(0,t.jsxs)("div",{"aria-label":Vn,className:M.passRateBar,role:"img",children:[(0,t.jsx)("span",{className:M.passRatePassed,style:{width:`${Ee}%`}}),(0,t.jsx)("span",{className:M.passRateFailed,style:{width:`${ps}%`}})]})]})}return(0,t.jsxs)("div",{className:M.container,children:[Ie&&s&&(0,t.jsxs)("div",{className:M.fullScreenLoadingOverlay,role:"status","aria-live":"polite","aria-busy":"true",children:[(0,t.jsx)("div",{className:M.spinner}),(0,t.jsx)("span",{children:"Loading run..."})]}),(0,t.jsxs)("div",{className:M.pageHeader,children:[(0,t.jsxs)("div",{className:M.pageHeaderLeft,children:[ue&&(0,t.jsx)("button",{type:"button",className:M.startNewRunButton,onClick:xr,children:"â All evals"}),ue&&Be?(0,t.jsxs)("form",{className:M.pageTitleEditor,onSubmit:ua,children:[(0,t.jsx)("input",{ref:he,"aria-label":"Evaluation title",className:M.pageTitleInput,maxLength:120,value:B,onBlur:Ts,onChange:Z=>oe(Z.target.value)}),(0,t.jsx)("button",{"aria-label":"Save evaluation title",className:M.pageTitleEditButton,disabled:!B.trim()||Le,type:"submit",onMouseDown:Z=>Z.preventDefault(),children:(0,t.jsx)(Cr,{"aria-hidden":"true"})})]}):(0,t.jsxs)("div",{className:M.pageTitleDisplay,children:[(0,t.jsx)("h1",{className:M.pageTitle,children:s?ue?.title||`Evaluation ${s}`:"Manage Evaluations"}),ue&&(0,t.jsx)("button",{"aria-label":"Edit evaluation title",className:M.pageTitleEditButton,type:"button",onClick:()=>le(!0),children:(0,t.jsx)(Rr,{"aria-hidden":"true"})})]})]}),(0,t.jsxs)("div",{className:M.headerLinks,children:[ge&&(0,t.jsx)("button",{type:"button",className:`${M.smallButton} ${M.dangerButton}`,disabled:ws,onClick:ca,title:"Cancels queued work and prevents another variant from starting. An active operation may finish.",children:ws?"Cancelling...":"Cancel remaining work"}),(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison-request-bank",className:M.backLink,children:"Manage test bank"}),"·",(0,t.jsx)(be,{to:"/admin/ai/prompt-comparison",className:M.backLink,children:"Run single comparison"})]})]}),ue&&(0,t.jsxs)("section",{className:`${M.card} ${M.runMetadataCard}`,children:[(0,t.jsxs)("div",{className:M.runMetadataGrid,children:[(0,t.jsxs)("div",{className:M.metadataItem,children:[(0,t.jsx)("span",{className:M.metadataLabel,children:"Date"}),(0,t.jsx)("span",{children:new Date(ue.createdAt).toLocaleString()})]}),(0,t.jsxs)("div",{className:M.metadataItem,children:[(0,t.jsx)("span",{className:M.metadataLabel,children:"Developer"}),(0,t.jsx)("span",{children:ue.developer})]}),(0,t.jsxs)("div",{className:M.metadataItem,children:[(0,t.jsx)("span",{className:M.metadataLabel,children:"Where"}),(0,t.jsx)("span",{children:ue.runLocation??"Not recorded"})]}),(0,t.jsxs)("div",{className:M.metadataItem,children:[(0,t.jsx)("span",{className:M.metadataLabel,children:"Run ID"}
218),(0,t.jsx)("span",{className:M.runId,children:ue.runId})]})]}),(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsx)("label",{className:M.fieldLabel,htmlFor:"historicalRunDescription",children:"Description"}),(0,t.jsx)("textarea",{id:"historicalRunDescription",className:`${M.fieldTextarea} ${M.descriptionTextarea}`,maxLength:2e3,placeholder:"What was being tested in this run?",value:de,onBlur:ma,onChange:Z=>ye(Z.target.value)})]})]}),(0,t.jsxs)("div",{className:M.card,hidden:!ts||!!s,children:[(0,t.jsx)("h2",{className:M.sectionTitle,children:"Test requests"}),(0,t.jsx)("div",{className:M.addRequestRow,children:(0,t.jsx)("button",{type:"button",className:M.smallButton,onClick:wt,children:"Add new request"})}),o.length>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:M.selectAllRow,children:[(0,t.jsxs)("label",{className:M.tagFilterControl,children:[(0,t.jsx)("span",{children:"Filter by tag"}),(0,t.jsxs)("select",{className:M.fieldSelect,value:d,disabled:et,onChange:Z=>c(Z.target.value),children:[(0,t.jsx)("option",{value:"",children:"All tags"}),Bt.map(Z=>(0,t.jsx)("option",{value:Z,children:Z},Z))]})]}),(0,t.jsx)("input",{type:"checkbox",className:M.requestCheckbox,checked:os,onChange:Fn}),(0,t.jsxs)("span",{children:["Select all shown (",as,"/",At.length," shown;"," ",ut.length," will run)"]}),(0,t.jsxs)("button",{type:"button",className:M.smallButton,disabled:pa.length===0,onClick:On,children:["Select shown with result assertions (",pa.length,")"]})]}),(0,t.jsx)("div",{className:M.requestList,children:At.map(Z=>(0,t.jsxs)("div",{className:M.requestItem,children:[(0,t.jsx)("input",{type:"checkbox",className:M.requestCheckbox,checked:l.has(Z.id),onChange:()=>Is(Z.id)}),(0,t.jsxs)("div",{className:M.requestContent,children:[(0,t.jsx)("span",{className:M.requestPrompt,children:Z.userPrompt}),Z.description&&(0,t.jsx)("span",{className:M.requestDescription,children:Z.description}),(0,t.jsxs)("div",{className:M.requestBadges,children:[Z.tags?.map(Ae=>(0,t.jsx)("span",{className:M.requestTagBadge,children:Ae},Ae)),Z.assetIds&&Z.assetIds.length>0&&(0,t.jsxs)("span",{className:M.requestTagBadge,children:[Z.assetIds.length," asset(s)"]}),Z.correctToolCalls!==void 0&&(0,t.jsx)("span",{className:M.requestToolBadge,children:Z.correctToolCalls.length===0?"No tools expected":Z.correctToolCalls.join(", ")}),Z.expectedResult&&(0,t.jsxs)("span",{className:M.requestTagBadge,children:["expect:"," ",Z.expectedResult.kind==="scene"?"video":Z.expectedResult.kind]})]})]}),(0,t.jsx)("button",{type:"button",className:M.editButton,onClick:()=>ms(Z),children:"Edit"}),(0,t.jsx)("button",{type:"button",className:M.deleteButton,onClick:()=>As(Z),children:"Delete"})]},Z.id))})]}):(0,t.jsx)("p",{className:M.emptyState,children:"No test requests yet. Add one above."})]}),(0,t.jsx)("div",{className:M.card,hidden:!ts||!!s,children:(0,t.jsx)("form",{onSubmit:qn,children:(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,t.jsx)("h2",{className:M.sectionTitle,children:"Run details"}),(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsx)("label",{className:M.fieldLabel,htmlFor:"runDescription",children:"Description (optional)"}),(0,t.jsx)("textarea",{id:"runDescription",className:`${M.fieldTextarea} ${M.descriptionTextarea}`,maxLength:2e3,placeholder:"Describe the hypothesis, changes, or behavior being tested.",value:de,disabled:et,onChange:Z=>ye(Z.target.value)})]}),(0,t.jsx)("h2",{className:M.sectionTitle,children:"Evaluation mode"}),(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsxs)("label",{className:M.reportTypeOption,children:[(0,t.jsx)("input",{type:"radio",name:"runMode",checked:E==="comparison",disabled:et,onChange:()=>O("comparison")}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"Comparison"})," â A/B dual run with judge LLM."]})]}),(0,t.jsxs)("label",{className:M.reportTypeOption,children:[(0,t.jsx)("input",{type:"radio",name:"runMode",checked:E==="validation",disabled:et,onChange:()=>O("validation")}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"Validation"})," â single prompt combo; skips the judge and checks expected-result assertions / expected tools."]})]})]}),(0,t.jsx)("h2",{className:M.sectionTitle,children:vt?"System prompt":"System prompts"}),(0,t.jsxs)("div",{className:vt?void 0:M.promptColumns,children:[(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsxs)("div",{className:M.labelRow,children:[(0,t.jsx)("label",{className:M.fieldLabel,htmlFor:"runSystemPromptA",children:vt?"System prompt":"System prompt A"}),(0,t.jsx)("button",{type:"button",className:M.prefillButton,disabled:et,onClick:()=>P(Xn),children:"Use current agent prompt"})]}),(0,t.jsx)("textarea",{id:"runSystemPromptA",className:`${M.fieldTextarea}`,value:R,disabled:et,placeholder:vt?"Enter system prompt...":"Enter system prompt A...",onChange:Z=>P(Z.target.value)})]}),!vt&&(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsxs)("div",{className:M.labelRow,children:[(0,t.jsx)("label",{className:M.fieldLabel,htmlFor:"runSystemPromptB",children:"System prompt B"}),(0,t.jsx)("button",{type:"button",className:M.prefillButton,disabled:et,onClick:()=>T(Xn),children:"Use current agent prompt"})]}),(0,t.jsx)("textarea",{id:"runSystemPromptB",className:`${M.fieldTextarea}`,value:k,disabled:et,placeholder:"Enter system prompt B...",onChange:Z=>T(Z.target.value)})]})]}),(0,t.jsx)("p",{className:M.helperText,children:vt?"The prompt is tested against all selected requests. Use assertions and/or expected tools on each request for pass/fail checks.":"Each prompt is tested against all selected requests."}),(0,t.jsx)("h2",{className:M.sectionTitle,children:"Planning LLM"}),(0,t.jsxs)("div",{className:vt?void 0:M.promptColumns,children:[(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsx)("label",{className:M.fieldLabel,htmlFor:"runPlanningLLMA",children:vt?"Planning LLM":"Planning LLM A"}),(0,t.jsx)("select",{id:"runPlanningLLMA",className:M.fieldSelect,value:ae,disabled:et,onChange:Z=>{ea(Z.target.value)&&G(Z.target.value)},children:Ln.map(Z=>(0,t.jsx)("option",{value:Z,children:Js(Z)},Z))})]}),!vt&&(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsx)("label",{className:M.fieldLabel,htmlFor:"runPlanningLLMB",children:"Planning LLM B"}),(0,t.jsx)("select",{id:"runPlanningLLMB",className:M.fieldSelect,value:se,disabled:et,onChange:Z=>{ea(Z.target.value)&&U(Z.target.value)},children:Ln.map(Z=>(0,t.jsx)("option",{value:Z,children:Js(Z)},Z))})]})]}),(0,t.jsxs)("p",{className:M.helperText,children:["Overrides the Kai planning model",vt?"":" for each variant",". Default matches the current production delegator."]}),(0,t.jsx)("h2",{className:M.sectionTitle,children:"Agent instructions"}),(0,t.jsxs)("div",{className:vt?void 0:M.promptColumns,children:[(0,t.jsx)(sa,{id:"runAgentInstructionsA",label:vt?"Agent instructions":"Agent instructions A",value:Y,disabled:et,onChange:me}),!vt&&(0,t.jsx)(sa,{id:"runAgentInstructionsB",label:"Agent instructions B",value:X,disabled:et,onChange:te})]}),(0,t.jsx)("p",{className:M.helperText,children:"Applied as additional autonomous planning context. Leave empty to use production Skills V2 guidance."}),!vt&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("h2",{className:M.sectionTitle,children:"Judge system prompt"}),(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsx)("label",{className:M.fieldLabel,htmlFor:"runJudgePrompt",children:"Customizable instructions for the judge LLM"}),(0,t.jsx)("textarea",{id:"runJudgePrompt",className:`${M.fieldTextarea} ${M.judgeTextarea}`,value:K,disabled:et,onChange:Z=>z(Z.target.value)})]}),(0,t.jsxs)("div",{className:M.fixedSuffix,children:[(0,t.jsx)("span",{className:M.fixedSuffixLabel,children:"Always appended (not editable):"}),(0,t.jsx)("pre",{className:M.fixedSuffixContent,children:Rl.trim()})]}),(0,t.jsx)("h2",{className:M.sectionTitle,children:"Post-run report"}),(0,t.jsxs)("div",{className:M.field,children:[(0,t.jsxs)("label",{className:M.reportTypeOption,children:[(0,t.jsx)("input",{type:"radio",name:"reportType",value:"synthesis",checked:q==="synthesis",disabled:et,onChange:()=>J("synthesis")}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"Synthesis"})," â LLM-authored summary and prompt improvement suggestions."]})]}),(0,t.jsxs)("label",{className:M.reportTypeOption,children:[(0,t.jsx)("input",{type:"radio",name:"reportType",value:"regression",checked:q==="regression",disabled:et,onChange:()=>J("regression")}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"Regression Report"})," â treats A as control and B as experimental, scoring how much B regressed from A. Use for ensuring smaller prompt changes don't regress performance."]})]})]})]}),(0,t.jsxs)("div",{className:M.submitActions,children:[re&&(0,t.jsx)("div",{className:M.error,children:re}),(0,t.jsx)("button",{type:"submit",className:M.smallButton,disabled:!gr,children:ZE({isRunning:et,isValidationMode:vt,completed:ue?.summary.completed??0,total:ue?.summary.total??"?",judging:ue?.summary.judging??0,selectedCount:ut.length})})]})]})})}
218),!s&&(0,t.jsxs)("div",{className:M.card,children:[(0,t.jsxs)("div",{className:M.testHistoryHeader,children:[(0,t.jsx)("h2",{className:M.sectionTitle,children:"Evaluation history"}),(0,t.jsx)("button",{type:"button",className:M.smallButton,"aria-expanded":ts,onClick:()=>cs(Z=>!Z),children:ts?"Hide evaluation setup":"Start an evaluation"})]}),vr()]}),et&&!ue&&(0,t.jsxs)("div",{className:M.loadingOverlay,children:[(0,t.jsx)("div",{className:M.spinner}),(0,t.jsx)("span",{children:vt?"Starting validation run...":"Starting comparison run..."})]}),ue&&(0,t.jsx)(QE,{result:ue}),m&&(0,t.jsx)(Vl,{mode:p?"create":"edit",request:m,description:g,prompt:v,assetIds:j,toolCalls:S,doNonStrictToolCheck:y,expectedResult:w,tags:I,existingTags:Bt,chatHistoryKeptIndices:L,onPromptChange:b,onDescriptionChange:_,onAssetIdsChange:x,onToolCallsChange:C,onDoNonStrictToolCheckChange:N,onExpectedResultChange:A,onTagsChange:D,onChatHistoryKeptIndicesChange:$,onSave:Z=>{Z?i(Ae=>[{id:Z.id,description:Z.description,userPrompt:Z.userPrompt,assetIds:Z.assetIds,correctToolCalls:Z.correctToolCalls,doNonStrictToolCheck:Z.doNonStrictToolCheck,expectedResult:Z.expectedResult,tags:Z.tags,createdAt:new Date().toISOString()},...Ae]):m&&i(Ae=>Ae.map(Ee=>Ee.id===m.id?{...Ee,description:g.trim()||void 0,userPrompt:v.trim(),assetIds:j.length>0?j:void 0,correctToolCalls:S,doNonStrictToolCheck:S!==void 0&&y,expectedResult:w,tags:I,chatHistory:(Ee.chatHistory??[]).filter((ps,Vn)=>L.includes(Vn))}:Ee)),Nt()},onCancel:Nt,createRequest:async Z=>{const Ae=await H.admin.promptComparison.createRequest.mutate({description:Z.description,userPrompt:Z.userPrompt,assetIds:Z.assetIds,correctToolCalls:Z.correctToolCalls,doNonStrictToolCheck:Z.doNonStrictToolCheck,expectedResult:Z.expectedResult??void 0,tags:Z.tags});return{id:Ae.id,description:Ae.description,userPrompt:Ae.userPrompt,assetIds:Z.assetIds,correctToolCalls:Ae.correctToolCalls??void 0,doNonStrictToolCheck:Ae.doNonStrictToolCheck,expectedResult:Ae.expectedResult??void 0,tags:Ae.tags}},updateRequest:async Z=>{await H.admin.promptComparison.updateRequest.mutate({id:Z.id,description:Z.description,userPrompt:Z.userPrompt,assetIds:Z.assetIds,correctToolCalls:Z.correctToolCalls,doNonStrictToolCheck:Z.doNonStrictToolCheck,expectedResult:Z.expectedResult,tags:Z.tags,chatHistoryKeptIndices:Z.chatHistoryKeptIndices})}}),(0,t.jsxs)(go,{isOpen:ss!==null,onClose:()=>As(null),onConfirm:us,title:"Delete request?",confirmText:"Delete",cancelText:"Cancel",dataTestId:"delete-request-confirm-modal",children:[(0,t.jsx)("p",{className:M.deleteModalText,children:"Are you sure you want to delete this request? This action cannot be undone."}),ss&&(0,t.jsxs)("p",{className:M.deleteModalPrompt,children:['"',ss.userPrompt,'"']})]})]})}function KE(s){return s==="A"?"Suggestions apply only to variant A (more judge wins in A vs B head-to-head).":s==="B"?"Suggestions apply only to variant B (more judge wins in A vs B head-to-head).":s==="tie"?"Head-to-head wins were tied; targeted improvement suggestions are omitted.":null}function GE(s){const e=(0,Mn.c)(25),{synthesis:n}=s;let a;e[0]!==n.improvementTarget?(a=KE(n.improvementTarget),e[0]=n.improvementTarget,e[1]=a):a=e[1];const o=a;let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("h3",{className:M.synthesisTitle,children:"Synthesis (GPT 5.1)"}),e[2]=i):i=e[2];let l;e[3]!==o?(l=o&&(0,t.jsx)("p",{className:M.synthesisTargetNote,children:o}),e[3]=o,e[4]=l):l=e[4];let r;e[5]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("h4",{className:M.synthesisHeading,children:"Summary"}),e[5]=r):r=e[5];let d;e[6]!==n.summary?(d=(0,t.jsxs)("div",{className:M.synthesisSection,children:[r,(0,t.jsx)("p",{className:M.synthesisBody,children:n.summary})]}),e[6]=n.summary,e[7]=d):d=e[7];let c;e[8]!==n.suggestedSystemPromptChanges?(c=n.suggestedSystemPromptChanges.trim().length>0&&(0,t.jsxs)("div",{className:M.synthesisSection,children:[(0,t.jsx)("h4",{className:M.synthesisHeading,children:"Suggested system prompt changes"}),(0,t.jsx)("p",{className:M.synthesisBody,children:n.suggestedSystemPromptChanges})]}),e[8]=n.suggestedSystemPromptChanges,e[9]=c):c=e[9];let m;e[10]!==n.suggestedAgentInstructionsChanges?(m=n.suggestedAgentInstructionsChanges.trim().length>0&&(0,t.jsxs)("div",{className:M.synthesisSection,children:[(0,t.jsx)("h4",{className:M.synthesisHeading,children:"Suggested agent instructions changes"}),(0,t.jsx)("p",{className:M.synthesisBody,children:n.suggestedAgentInstructionsChanges})]}),e[10]=n.suggestedAgentInstructionsChanges,e[11]=m):m=e[11];let h;e[12]!==n.editedWinningSystemPrompt||e[13]!==n.improvementTarget?(h=n.improvementTarget&&n.improvementTarget!=="tie"&&n.editedWinningSystemPrompt&&n.editedWinningSystemPrompt.length>0&&(0,t.jsxs)("div",{className:M.synthesisSection,children:[(0,t.jsxs)("h4",{className:M.synthesisHeading,children:["Edited system prompt (variant ",n.improvementTarget,")"]}),(0,t.jsx)("pre",{className:M.synthesisPre,children:n.editedWinningSystemPrompt})]}),e[12]=n.editedWinningSystemPrompt,e[13]=n.improvementTarget,e[14]=h):h=e[14];let p;e[15]!==n.editedWinningAgentInstructions||e[16]!==n.improvementTarget?(p=n.improvementTarget&&n.improvementTarget!=="tie"&&n.editedWinningAgentInstructions&&n.editedWinningAgentInstructions.length>0&&(0,t.jsxs)("div",{className:M.synthesisSection,children:[(0,t.jsxs)("h4",{className:M.synthesisHeading,children:["Edited agent instructions (variant ",n.improvementTarget,")"]}),(0,t.jsx)("pre",{className:M.synthesisPre,children:n.editedWinningAgentInstructions})]}),e[15]=n.editedWinningAgentInstructions,e[16]=n.improvementTarget,e[17]=p):p=e[17];let u;return e[18]!==l||e[19]!==d||e[20]!==c||e[21]!==m||e[22]!==h||e[23]!==p?(u=(0,t.jsxs)("div",{className:M.synthesisCard,
218children:[i,l,d,c,m,h,p]}),e[18]=l,e[19]=d,e[20]=c,e[21]=m,e[22]=h,e[23]=p,e[24]=u):u=e[24],u}var JE={none:"No regression",minor:"Minor regression",moderate:"Moderate regression",severe:"Severe regression"},ui={none:M.regressionSeverityNone,minor:M.regressionSeverityMinor,moderate:M.regressionSeverityModerate,severe:M.regressionSeveritySevere};function bn(s){return`${s>0?"+":""}${s}`}function zE(s){const e=(0,Mn.c)(63),{report:n,runId:a}=s,o=n.averageDimensionDeltas;let i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("h3",{className:M.synthesisTitle,children:"Regression Report"}),l=(0,t.jsx)("p",{className:M.synthesisTargetNote,children:"Variant A is treated as the control and variant B as the experimental group. Positive deltas mean B scored below A."}),e[0]=i,e[1]=l):(i=e[0],l=e[1]);let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("span",{className:M.regressionScoreMax,children:"/100"}),e[2]=r):r=e[2];let d;e[3]!==n.overallRegressionScore?(d=(0,t.jsxs)("div",{className:M.regressionScoreValue,children:[n.overallRegressionScore,r]}),e[3]=n.overallRegressionScore,e[4]=d):d=e[4];const c=`${M.regressionSeverityBadge} ${ui[n.overallSeverity]}`,m=JE[n.overallSeverity];let h;e[5]!==c||e[6]!==m?(h=(0,t.jsx)("span",{className:c,children:m}),e[5]=c,e[6]=m,e[7]=h):h=e[7];let p;e[8]!==d||e[9]!==h?(p=(0,t.jsxs)("div",{className:M.regressionScoreRow,children:[d,h]}),e[8]=d,e[9]=h,e[10]=p):p=e[10];let u;e[11]!==n.regressedTestCount?(u=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.regressedTestCount})," regressed"]}),e[11]=n.regressedTestCount,e[12]=u):u=e[12];let g;e[13]!==n.improvedTestCount?(g=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.improvedTestCount})," improved"]}),e[13]=n.improvedTestCount,e[14]=g):g=e[14];let _;e[15]!==n.unchangedTestCount?(_=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.unchangedTestCount})," unchanged"]}),e[15]=n.unchangedTestCount,e[16]=_):_=e[16];let v;e[17]!==n.totalJudgedTests?(v=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.totalJudgedTests})," judged"]}),e[17]=n.totalJudgedTests,e[18]=v):v=e[18];let b;e[19]!==g||e[20]!==_||e[21]!==v||e[22]!==u?(b=(0,t.jsxs)("div",{className:M.regressionStatsRow,children:[u,g,_,v]}),e[19]=g,e[20]=_,e[21]=v,e[22]=u,e[23]=b):b=e[23];let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)("h4",{className:M.synthesisHeading,children:"Mean weighted score"}),e[24]=j):j=e[24];let x;e[25]!==n.meanWeightedScoreA?(x=(0,t.jsx)("strong",{children:n.meanWeightedScoreA}),e[25]=n.meanWeightedScoreA,e[26]=x):x=e[26];let S;e[27]!==n.meanWeightedScoreB?(S=(0,t.jsx)("strong",{children:n.meanWeightedScoreB}),e[27]=n.meanWeightedScoreB,e[28]=S):S=e[28];let C;e[29]!==x||e[30]!==S?(C=(0,t.jsxs)("div",{className:M.synthesisSection,children:[j,(0,t.jsxs)("p",{className:M.synthesisBody,children:["Control A: ",x," · Experimental B: ",S," (weighted 1-10, tool call accuracy double-weighted)"]})]}),e[29]=x,e[30]=S,e[31]=C):C=e[31];let y;e[32]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsx)("h4",{className:M.synthesisHeading,children:"Average dimension delta (A â B)"}),e[32]=y):y=e[32];let N;e[33]!==o.relevance?(N=bn(o.relevance),e[33]=o.relevance,e[34]=N):N=e[34];let w;e[35]!==N?(w=(0,t.jsx)("strong",{children:N}),e[35]=N,e[36]=w):w=e[36];let A;e[37]!==o.completeness?(A=bn(o.completeness),e[37]=o.completeness,e[38]=A):A=e[38];let I;e[39]!==A?(I=(0,t.jsx)("strong",{children:A}),e[39]=A,e[40]=I):I=e[40];let D;e[41]!==o.quality?(D=bn(o.quality),e[41]=o.quality,e[42]=D):D=e[42];let L;e[43]!==D?(L=(0,t.jsx)("strong",{children:D}),e[43]=D,e[44]=L):L=e[44];let $;e[45]!==o.toolCallAccuracy?($=bn(o.toolCallAccuracy),e[45]=o.toolCallAccuracy,e[46]=$):$=e[46];let R;e[47]!==$?(R=(0,t.jsx)("strong",{children:$}),e[47]=$,e[48]=R):R=e[48];let P;e[49]!==w||e[50]!==I||e[51]!==L||e[52]!==R?(P=(0,t.jsxs)("div",{className:M.synthesisSection,children:[y,(0,t.jsxs)("p",{className:M.synthesisBody,children:["Relevance: ",w," · Completeness: ",I," · Quality: ",L," · Tool call accuracy: ",R]})]}),e[49]=w,e[50]=I,e[51]=L,e[52]=R,e[53]=P):P=e[53];let k;e[54]!==n.regressions||e[55]!==a?(k=n.regressions.length>0&&(0,t.jsxs)("div",{className:M.synthesisSection,children:[(0,t.jsxs)("h4",{className:M.synthesisHeading,children:["Regressed tests (",n.regressions.length,")"]}),(0,t.jsx)("div",{className:M.regressionList,children:n.regressions.map(E=>(0,t.jsxs)(be,{to:`/admin/ai/prompt-comparison/${E.jobId}`,state:{parentRunId:a},className:M.regressionItem,children:[(0,t.jsxs)("div",{className:M.regressionItemHeader,children:[(0,t.jsx)("span",{className:`${M.regressionSeverityBadge} ${ui[E.severity]}`,children:E.severity}),(0,t.jsx)("span",{className:M.regressionItemDelta,children:bn(E.delta)}),(0,t.jsxs)("span",{className:M.regressionItemScores,children:["A ",E.weightedScoreA," â B ",E.weightedScoreB]})]}),(0,t.jsx)("span",{className:M.regressionItemPrompt,children:E.userPrompt})]},E.jobId))})]}),e[54]=n.regressions,e[55]=a,e[56]=k):k=e[56];let T;return e[57]!==b||e[58]!==C||e[59]!==P||e[60]!==k||e[61]!==p?(T=(0,t.jsxs)("div",{className:M.synthesisCard,
218children:[i,l,p,b,C,P,k]}),e[57]=b,e[58]=C,e[59]=P,e[60]=k,e[61]=p,e[62]=T):T=e[62],T}function YE(s){const e=(0,Mn.c)(22),{report:n}=s;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("h3",{className:M.synthesisTitle,children:"Validation summary"}),e[0]=a):a=e[0];let o;e[1]!==n.summary?(o=(0,t.jsx)("p",{className:M.synthesisBody,children:n.summary}),e[1]=n.summary,e[2]=o):o=e[2];let i;e[3]!==n.passedCount?(i=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.passedCount})," passed"]}),e[3]=n.passedCount,e[4]=i):i=e[4];let l;e[5]!==n.failedCount?(l=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.failedCount})," failed"]}),e[5]=n.failedCount,e[6]=l):l=e[6];let r;e[7]!==n.skippedCount?(r=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.skippedCount})," skipped"]}),e[7]=n.skippedCount,e[8]=r):r=e[8];let d;e[9]!==n.erroredCount?(d=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.erroredCount})," errored"]}),e[9]=n.erroredCount,e[10]=d):d=e[10];let c;e[11]!==n.totalTests?(c=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:n.totalTests})," total"]}),e[11]=n.totalTests,e[12]=c):c=e[12];let m;e[13]!==i||e[14]!==l||e[15]!==r||e[16]!==d||e[17]!==c?(m=(0,t.jsxs)("div",{className:M.regressionStatsRow,children:[i,l,r,d,c]}),e[13]=i,e[14]=l,e[15]=r,e[16]=d,e[17]=c,e[18]=m):m=e[18];let h;return e[19]!==o||e[20]!==m?(h=(0,t.jsxs)("div",{className:M.synthesisCard,children:[a,o,m]}),e[19]=o,e[20]=m,e[21]=h):h=e[21],h}function mi(s){return!s||s.skipped?"â":s.passed?"pass":s.failures.length===0?"fail":`fail (${s.failures.length})`}function pi(s,e){return e==="chatHistory"?s.messageHistory.length:e==="userPrompt"?s.userPrompt.toLowerCase():e==="status"?s.status:e==="winner"?s.winner??"":e==="validationOutcome"?s.validationOutcome??"":e==="outputAError"?s.outputAError??"":e==="outputBError"?s.outputBError??"":s.error??""}function QE(s){const e=(0,Mn.c)(124),{result:n}=s,{summary:a,subJobs:o}=n,i=n.runMode==="validation"||n.input.runMode==="validation";let l;e[0]!==i||e[1]!==o||e[2]!==a.bothFail||e[3]!==a.ties||e[4]!==a.winsA||e[5]!==a.winsB?(l=i?o.filter(a5).length:a.winsA+a.winsB+a.ties+a.bothFail,e[0]=i,e[1]=o,e[2]=a.bothFail,e[3]=a.ties,e[4]=a.winsA,e[5]=a.winsB,e[6]=l):l=e[6];const r=l,d=o.filter(n5).length,c=o.filter(s5).length,m=o.filter(t5).length,h=o.filter(e5).length,[p,u]=(0,f.useState)(null),[g,_]=(0,f.useState)("asc");let v;e:{if(!p){v=o;break e}const ve=g==="asc"?1:-1;let we;if(e[7]!==ve||e[8]!==p||e[9]!==o){let re;e[11]!==ve||e[12]!==p?(re=(V,Ie)=>{const ke=pi(V,p),De=pi(Ie,p);return typeof ke=="number"&&typeof De=="number"?(ke-De)*ve:String(ke).localeCompare(String(De))*ve},e[11]=ve,e[12]=p,e[13]=re):re=e[13],we=[...o].sort(re),e[7]=ve,e[8]=p,e[9]=o,e[10]=we}else we=e[10];v=we}const b=v;let j;e[14]!==p?(j=function(we){p===we?_(XE):(u(we),_("asc"))},e[14]=p,e[15]=j):j=e[15];const x=j;let S;e[16]!==g||e[17]!==p?(S=function(we){return p!==we?"â":g==="asc"?"â²":"â¼"},e[16]=g,e[17]=p,e[18]=S):S=e[18];const C=S;let y;e[19]!==x||e[20]!==C?(y=function(we,re){return(0,t.jsx)("th",{children:(0,t.jsxs)("button",{type:"button",className:M.sortableHeader,onClick:()=>x(re),children:[we,(0,t.jsx)("span",{className:M.sortIndicator,children:C(re)})]})})},e[19]=x,e[20]=C,e[21]=y):y=e[21];const N=y;let w;e[22]!==r?(w=function(we){return r===0?0:Math.round(we/r*100)},e[22]=r,e[23]=w):w=e[23];const A=w,I=M,D=M;let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=(0,t.jsx)("h2",{className:M.summaryTitle,children:"Results"}),e[24]=L):L=e[24];let $;e[25]!==n.status?($=(0,t.jsxs)("div",{className:M.summaryHeader,children:[L,(0,t.jsx)(eo,{status:n.status})]}),e[25]=n.status,e[26]=$):$=e[26];let R;e[27]!==a.completed?(R=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:a.completed})," completed"]}),e[27]=a.completed,e[28]=R):R=e[28];let P;e[29]!==a.running?(P=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:a.running})," running"]}),e[29]=a.running,e[30]=P):P=e[30];let k;e[31]!==i||e[32]!==a.judging?(k=!i&&(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:a.judging??0})," judging"]}),e[31]=i,e[32]=a.judging,e[33]=k):k=e[33];let T;e[34]!==a.failed?(T=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:a.failed})," failed"]}),e[34]=a.failed,e[35]=T):T=e[35];let E;e[36]!==a.cancelled?(E=a.cancelled>0&&(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:a.cancelled})," cancelled"]}),e[36]=a.cancelled,e[37]=E):E=e[37];let O;e[38]!==a.total?(O=(0,t.jsxs)("span",{className:M.progressStat,children:[(0,t.jsx)("strong",{children:a.total})," total"]}),e[38]=a.total,e[39]=O):O=e[39];let q;e[40]!==R||e[41]!==P||e[42]!==k||e[43]!==T||e[44]!==E||e[45]!==O?(q=(0,t.jsxs)("div",{className:M.progressRow,children:[R,P,k,T,E,O]}),e[40]=R,e[41]=P,e[42]=k,e[43]=T,e[44]=E,e[45]=O,e[46]=q):q=e[46];let J;e[47]!==n.judgeBatchId||e[48]!==n.judgeBatchResultsApplied||e[49]!==n.judgeBatchStatus?(J=n.judgeBatchId&&(0,t.jsxs)("p",{className:M.helperText,children:["Judge batch: ",(0,t.jsx)("code",{children:n.judgeBatchId}),n.judgeBatchStatus?` â status: ${n.judgeBatchStatus}`:"",n.judgeBatchResultsApplied?" (results applied)":""]}),e[47]=n.judgeBatchId,e[48]=n.judgeBatchResultsApplied,e[49]=n.judgeBatchStatus,e[50]=J):J=e[50];let K;e[51]!==n.validationReport?(K=n.validationReport&&(0,t.jsx)(YE,{report:n.validationReport}),e[51]=n.validationReport,e[52]=K):K=e[52];let z;e[53]!==n.synthesis?(z=n.synthesis&&(0,t.jsx)(GE,{synthesis:n.synthesis}),e[53]=n.synthesis,e[54]=z):z=e[54];let Y;e[55]!==n.regressionReport||e[56]!==n.runId?(Y=n.regressionReport&&(0,t.jsx)(zE,{report:n.regressionReport,runId:n.runId}),e[55]=n.regressionReport,e[56]=n.runId,e[57]=Y):Y=e[57];const me=i&&r>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:M.winBar,children:[A(d)>0&&(0,t.jsxs)("div",{className:M.winBarA,style:{width:`${A(d)}%`}
218,children:["Pass: ",A(d),"%"]}),A(c)>0&&(0,t.jsxs)("div",{className:M.winBarBothFail,style:{width:`${A(c)}%`},children:["Fail: ",A(c),"%"]}),A(m)>0&&(0,t.jsxs)("div",{className:M.winBarTie,style:{width:`${A(m)}%`},children:["Skip: ",A(m),"%"]}),A(h)>0&&(0,t.jsxs)("div",{className:M.winBarB,style:{width:`${A(h)}%`},children:["Error: ",A(h),"%"]})]}),(0,t.jsxs)("div",{className:M.winLegend,children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotA}`}),"Passed: ",d," (",A(d),"%)"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotBothFail}`}),"Failed: ",c," (",A(c),"%)"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotTie}`}),"Skipped: ",m," (",A(m),"%)"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotB}`}),"Errored: ",h," (",A(h),"%)"]})]})]});let X;e[58]!==r||e[59]!==i||e[60]!==A||e[61]!==a.bothFail||e[62]!==a.ties||e[63]!==a.winsA||e[64]!==a.winsB?(X=!i&&r>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:M.winBar,children:[A(a.winsA)>0&&(0,t.jsxs)("div",{className:M.winBarA,style:{width:`${A(a.winsA)}%`},children:["A: ",A(a.winsA),"%"]}),A(a.ties)>0&&(0,t.jsxs)("div",{className:M.winBarTie,style:{width:`${A(a.ties)}%`},children:["Tie: ",A(a.ties),"%"]}),A(a.winsB)>0&&(0,t.jsxs)("div",{className:M.winBarB,style:{width:`${A(a.winsB)}%`},children:["B: ",A(a.winsB),"%"]}),A(a.bothFail)>0&&(0,t.jsxs)("div",{className:M.winBarBothFail,style:{width:`${A(a.bothFail)}%`},children:["Both Fail: ",A(a.bothFail),"%"]})]}),(0,t.jsxs)("div",{className:M.winLegend,children:[(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotA}`}),"Prompt A: ",a.winsA," wins (",A(a.winsA),"%)"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotTie}`}),"Tie: ",a.ties," (",A(a.ties),"%)"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotB}`}),"Prompt B: ",a.winsB," wins (",A(a.winsB),"%)"]}),(0,t.jsxs)("span",{children:[(0,t.jsx)("span",{className:`${M.legendDot} ${M.legendDotBothFail}`}),"Both Fail: ",a.bothFail," (",A(a.bothFail),"%)"]})]})]}),e[58]=r,e[59]=i,e[60]=A,e[61]=a.bothFail,e[62]=a.ties,e[63]=a.winsA,e[64]=a.winsB,e[65]=X):X=e[65];let te;e[66]!==$||e[67]!==q||e[68]!==J||e[69]!==K||e[70]!==z||e[71]!==Y||e[72]!==me||e[73]!==X||e[74]!==D.summaryCard?(te=(0,t.jsxs)("div",{className:D.summaryCard,children:[$,q,J,K,z,Y,me,X]}),e[66]=$,e[67]=q,e[68]=J,e[69]=K,e[70]=z,e[71]=Y,e[72]=me,e[73]=X,e[74]=D.summaryCard,e[75]=te):te=e[75];let ae;e[76]===Symbol.for("react.memo_cache_sentinel")?(ae=(0,t.jsx)("h2",{className:M.sectionTitle,children:"Individual results"}),e[76]=ae):ae=e[76];let G,se,U;e[77]!==N?(G=N("User prompt","userPrompt"),se=N("Chat history","chatHistory"),U=N("Status","status"),e[77]=N,e[78]=G,e[79]=se,e[80]=U):(G=e[78],se=e[79],U=e[80]);let B;e[81]!==i||e[82]!==N?(B=i?N("Outcome","validationOutcome"):N("Winner","winner"),e[81]=i,e[82]=N,e[83]=B):B=e[83];const oe=i?"Assert":"Assert A";let de;e[84]!==oe?(de=(0,t.jsx)("th",{children:oe}),e[84]=oe,e[85]=de):de=e[85];let ye;e[86]!==i?(ye=!i&&(0,t.jsx)("th",{children:"Assert B"}),e[86]=i,e[87]=ye):ye=e[87];const Le=i?"Output error":"Output A error";let Ne;e[88]!==N||e[89]!==Le?(Ne=N(Le,"outputAError"),e[88]=N,e[89]=Le,e[90]=Ne):Ne=e[90];let Be;e[91]!==i||e[92]!==N?(Be=!i&&N("Output B error","outputBError"),e[91]=i,e[92]=N,e[93]=Be):Be=e[93];const le=i?"Error":"Comparison error";let he;e[94]!==N||e[95]!==le?(he=N(le,"error"),e[94]=N,e[95]=le,e[96]=he):he=e[96];let ge;e[97]===Symbol.for("react.memo_cache_sentinel")?(ge=(0,t.jsx)("th",{children:"Details"}),e[97]=ge):ge=e[97];let je;e[98]!==G||e[99]!==se||e[100]!==U||e[101]!==B||e[102]!==de||e[103]!==ye||e[104]!==Ne||e[105]!==Be||e[106]!==he?(je=(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[G,se,U,B,de,ye,Ne,Be,he,ge]})}),e[98]=G,e[99]=se,e[100]=U,e[101]=B,e[102]=de,e[103]=ye,e[104]=Ne,e[105]=Be,e[106]=he,e[107]=je):je=e[107];let ue;if(e[108]!==i||e[109]!==n.runId||e[110]!==b){let ve;e[112]!==i||e[113]!==n.runId?(ve=we=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:we.userPrompt}),(0,t.jsx)("td",{children:(0,t.jsx)(jo,{history:we.messageHistory,displayMode:"inline",collapsible:!0,emptyMessage:"None"})}),(0,t.jsx)("td",{children:(0,t.jsx)(eo,{status:we.status})}),i?(0,t.jsx)("td",{children:we.validationOutcome?(0,t.jsx)("span",{className:`${M.validationOutcome} ${HE[we.validationOutcome]??""}`,children:UE[we.validationOutcome]??we.validationOutcome}):"â"}):(0,t.jsx)("td",{className:`${M.winnerCell} ${we.winner?VE[we.winner]??"":""}`,children:we.winner??"â"}),(0,t.jsx)("td",{children:mi(we.assertionResultA)}),!i&&(0,t.jsx)("td",{children:mi(we.assertionResultB)}),(0,t.jsx)("td",{className:M.subJobErrorCell,children:we.outputAError??"â"}),!i&&(0,t.jsx)("td",{className:M.subJobErrorCell,children:we.outputBError??"â"}),(0,t.jsx)("td",{className:M.subJobErrorCell,children:we.error??"â"}),(0,t.jsx)("td",{children:(0,t.jsx)(be,{to:`/admin/ai/prompt-comparison/${we.jobId}`,state:{parentRunId:n.runId},className:M.jobLink,children:"View"})})]},we.jobId),e[112]=i,e[113]=n.runId,e[114]=ve):ve=e[114],ue=b.map(ve),e[108]=i,e[109]=n.runId,e[110]=b,e[111]=ue}else ue=e[111];let pe;e[115]!==ue?(pe=(0,t.jsx)("tbody",{children:ue}),e[115]=ue,e[116]=pe):pe=e[116];let ee;
218e[117]!==je||e[118]!==pe?(ee=(0,t.jsxs)("div",{className:M.card,children:[ae,(0,t.jsxs)("table",{className:M.subJobsTable,children:[je,pe]})]}),e[117]=je,e[118]=pe,e[119]=ee):ee=e[119];let xe;return e[120]!==te||e[121]!==ee||e[122]!==I.resultsSection?(xe=(0,t.jsxs)("div",{className:I.resultsSection,children:[te,ee]}),e[120]=te,e[121]=ee,e[122]=I.resultsSection,e[123]=xe):xe=e[123],xe}function XE(s){return s==="asc"?"desc":"asc"}function e5(s){return s.validationOutcome==="error"}function t5(s){return s.validationOutcome==="skipped"}function s5(s){return s.validationOutcome==="failed"}function n5(s){return s.validationOutcome==="passed"}function a5(s){return s.validationOutcome!=null}var o5=Q(ie());function i5(s){const e=(0,o5.c)(11),{onAdd:n}=s,[a,o]=(0,f.useState)("");let i;e[0]!==a||e[1]!==n?(i=async()=>{n(a.split(",").map(l5)),o("")},e[0]=a,e[1]=n,e[2]=i):i=e[2];const l=i;let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=h=>o(h.target.value),e[3]=r):r=e[3];let d;e[4]!==a?(d=(0,t.jsx)("input",{value:a,onChange:r}),e[4]=a,e[5]=d):d=e[5];let c;e[6]!==l?(c=(0,t.jsx)("button",{onClick:l,children:"Add asset(s)"}),e[6]=l,e[7]=c):c=e[7];let m;return e[8]!==d||e[9]!==c?(m=(0,t.jsxs)("div",{children:[d,c]}),e[8]=d,e[9]=c,e[10]=m):m=e[10],m}function l5(s){return s.replace(/[[\]'"']/g,"").trim()}function r5({onAdd:s}){const[e,n]=(0,f.useState)(""),[a,o]=(0,f.useState)(""),[i,l]=(0,f.useState)(!1),r=f.useRef(new Nc),d=async()=>{r.current.reset(),l(!0),o("Extracting asset from link...");try{const m=await Rc({url:e,progressCallback:()=>{},analyticsCallback:()=>{}});if(r.current.cancelled){console.info("Extraction cancelled");return}if(console.info("Asset extracted from link:",m),!m.asset.preview_asset_id){o("Running optimization...");const g=await Sc({asset_id:m.asset._id,conversion_type:"optimize-mp4",resource:m.asset.url||"",layer:{id:"original",type:"video",name:"original",asset_id:m.asset._id}});if(r.current.cancelled){console.info("Optimization cancelled");return}if(console.info("Optimization started:",g),o("Polling optimization status..."),await Do({retreive:()=>Ic(g),validate:_=>_.status===Zd.completed,name:"Optimization",cancelSource:r.current,options:{maxAttempts:30}}),r.current.cancelled){console.info("Cancelled optimization");return}}const{asset:{_id:h}}=m;o("Posting extraction job..."),await H.asset.extractionJob.mutate({assetId:h}),o("Polling scene extraction status...");const p=await Do({retreive:()=>aa(h),validate:g=>!!g.extracted_scenes_info&&g.extracted_scenes_info?.status!=="processing",name:"Extract scenes",cancelSource:r.current,options:{maxAttempts:30}});if(p.result==="cancelled"){console.info("Extract Scenes Cancelled");return}const u=p.resource;u.extracted_scenes_info?.status==="completed"&&(s(u.extracted_scenes_info.scene_assets.map(g=>g.id)),o("Scenes extracted successfully.")),u.extracted_scenes_info?.status==="failed"&&(console.error("Failed to extract scenes"),o("Failed to extract scenes."))}finally{n(""),l(!1)}},c=()=>{r.current.cancel(),l(!1),o("Operation cancelled.")};return(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{value:e,onChange:m=>n(m.target.value),disabled:i}),(0,t.jsx)("button",{onClick:d,disabled:i,children:"Submit"}),i&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{children:["Uploading: ",a]})," ",(0,t.jsx)("button",{onClick:c,children:"Cancel"})]})]})}var Xt=Q(ie()),Ul=f.forwardRef((s,e)=>{const n=(0,Xt.c)(11);let a,o,i;n[0]!==s?({style:i,highlight:a,...o}=s,n[0]=s,n[1]=a,n[2]=o,n[3]=i):(a=n[1],o=n[2],i=n[3]);const l=`1px solid ${a||"black"}`;let r;n[4]!==i||n[5]!==l?(r={borderRadius:"0.75rem",border:l,backgroundColor:"var(--bg-card)",color:"var(--text-card-foreground)",boxShadow:"var(--shadow)",position:"relative",...i},n[4]=i,n[5]=l,n[6]=r):r=n[6];let d;return n[7]!==o||n[8]!==e||n[9]!==r?(d=(0,t.jsx)("div",{ref:e,style:r,...o}),n[7]=o,n[8]=e,n[9]=r,n[10]=d):d=n[10],d});Ul.displayName="Card";var Zl=f.forwardRef((s,e)=>{const n=(0,Xt.c)(9);let a,o;n[0]!==s?({style:o,...a}=s,n[0]=s,n[1]=a,n[2]=o):(a=n[1],o=n[2]);let i;n[3]!==o?(i={display:"flex",flexDirection:"column",gap:"0.rem",padding:".5rem",...o},n[3]=o,n[4]=i):i=n[4];let l;return n[5]!==a||n[6]!==e||n[7]!==i?(l=(0,t.jsx)("div",{ref:e,style:i,...a}),n[5]=a,n[6]=e,n[7]=i,n[8]=l):l=n[8],l});
218Zl.displayName="CardHeader";var Wl=f.forwardRef((s,e)=>{const n=(0,Xt.c)(9);let a,o;n[0]!==s?({style:o,...a}=s,n[0]=s,n[1]=a,n[2]=o):(a=n[1],o=n[2]);let i;n[3]!==o?(i={margin:0,fontWeight:600,lineHeight:"1",letterSpacing:"tight",...o},n[3]=o,n[4]=i):i=n[4];let l;return n[5]!==a||n[6]!==e||n[7]!==i?(l=(0,t.jsx)("h3",{ref:e,style:i,...a}),n[5]=a,n[6]=e,n[7]=i,n[8]=l):l=n[8],l});Wl.displayName="CardTitle";var Kl=f.forwardRef((s,e)=>{const n=(0,Xt.c)(9);let a,o;n[0]!==s?({style:o,...a}=s,n[0]=s,n[1]=a,n[2]=o):(a=n[1],o=n[2]);let i;n[3]!==o?(i={fontSize:"0.875rem",color:"var(--text-muted-foreground)",...o},n[3]=o,n[4]=i):i=n[4];let l;return n[5]!==a||n[6]!==e||n[7]!==i?(l=(0,t.jsx)("p",{ref:e,style:i,...a}),n[5]=a,n[6]=e,n[7]=i,n[8]=l):l=n[8],l});Kl.displayName="CardDescription";var Gl=f.forwardRef((s,e)=>{const n=(0,Xt.c)(9);let a,o;n[0]!==s?({style:o,...a}=s,n[0]=s,n[1]=a,n[2]=o):(a=n[1],o=n[2]);let i;n[3]!==o?(i={padding:"1.5rem",paddingTop:"0",...o},n[3]=o,n[4]=i):i=n[4];let l;return n[5]!==a||n[6]!==e||n[7]!==i?(l=(0,t.jsx)("div",{ref:e,style:i,...a}),n[5]=a,n[6]=e,n[7]=i,n[8]=l):l=n[8],l});Gl.displayName="CardContent";var d5=f.forwardRef((s,e)=>{const n=(0,Xt.c)(9);let a,o;n[0]!==s?({style:o,...a}=s,n[0]=s,n[1]=a,n[2]=o):(a=n[1],o=n[2]);let i;n[3]!==o?(i={display:"flex",alignItems:"center",padding:"1.5rem",paddingTop:"0",...o},n[3]=o,n[4]=i):i=n[4];let l;return n[5]!==a||n[6]!==e||n[7]!==i?(l=(0,t.jsx)("div",{ref:e,style:i,...a}),n[5]=a,n[6]=e,n[7]=i,n[8]=l):l=n[8],l});d5.displayName="CardFooter";var c5=kr,u5=zi,In=f.forwardRef((s,e)=>{const n=(0,Xt.c)(9);let a,o;n[0]!==s?({style:o,...a}=s,n[0]=s,n[1]=a,n[2]=o):(a=n[1],o=n[2]);let i;n[3]!==o?(i={borderBottom:"1px solid",...o},n[3]=o,n[4]=i):i=n[4];let l;return n[5]!==a||n[6]!==e||n[7]!==i?(l=(0,t.jsx)(Vs,{ref:e,style:i,...a}),n[5]=a,n[6]=e,n[7]=i,n[8]=l):l=n[8],l});In.displayName="AccordionItem";var Tn=f.forwardRef((s,e)=>{const n=(0,Xt.c)(15);let a,o,i;n[0]!==s?({style:i,children:a,...o}=s,n[0]=s,n[1]=a,n[2]=o,n[3]=i):(a=n[1],o=n[2],i=n[3]);let l;n[4]===Symbol.for("react.memo_cache_sentinel")?(l={display:"flex"},n[4]=l):l=n[4];let r;n[5]!==i?(r={display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",padding:"1rem 0",fontSize:"0.875rem",fontWeight:500,transition:"all 0.2s ease",textDecoration:"underline",...i},n[5]=i,n[6]=r):r=n[6];let d;n[7]!==a?(d=(0,t.jsx)("div",{children:a}),n[7]=a,n[8]=d):d=n[8];let c;n[9]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(c5,{style:{height:"1rem",width:"1rem",flexShrink:0,color:"var(--text-muted-foreground)",transition:"transform 0.2s"}}),n[9]=c):c=n[9];let m;return n[10]!==o||n[11]!==e||n[12]!==r||n[13]!==d?(m=(0,t.jsx)(_d,{style:l,children:(0,t.jsxs)(qs,{ref:e,style:r,...o,children:[d,c]})}),n[10]=o,n[11]=e,n[12]=r,n[13]=d,n[14]=m):m=n[14],m});Tn.displayName="AccordionTrigger";var kn=f.forwardRef((s,e)=>{const n=(0,Xt.c)(14);let a,o,i;n[0]!==s?({style:i,children:a,...o}=s,n[0]=s,n[1]=a,n[2]=o,n[3]=i):(a=n[1],o=n[2],i=n[3]);let l;n[4]!==i?(l={overflow:"hidden",fontSize:"0.875rem",...i},n[4]=i,n[5]=l):l=n[5];let r;n[6]===Symbol.for("react.memo_cache_sentinel")?(r={paddingBottom:"1rem",paddingTop:"0"},n[6]=r):r=n[6];let d;n[7]!==a?(d=(0,t.jsx)("div",{style:r,children:a}),n[7]=a,n[8]=d):d=n[8];let c;return n[9]!==o||n[10]!==e||n[11]!==l||n[12]!==d?(c=(0,t.jsx)(Hs,{ref:e,style:l,...o,children:d}),n[9]=o,n[10]=e,n[11]=l,n[12]=d,n[13]=c):c=n[13],c});kn.displayName="AccordionContent";function m5(s,e){for(const n of e){const a=n.extracted_scenes_info;if(!(!a||a.status!=="completed")){for(const o of a.scene_assets)if(o.id===s._id)return{parentAsset:n,scene:o}}}}const _s=s=>{const e=(0,Xt.c)(41),{asset:n,originalAssets:a,metadata:o,selected:i,setSelected:l,highlight:r}=s,[d,c]=f.useState(!1),m=n.duration??0;let h;e[0]!==m?(h=m.toFixed(2),e[0]=m,e[1]=h):h=e[1];const p=h;let u;e[2]!==a?(u=a??[],e[2]=a,e[3]=u):u=e[3];const g=m5(n,u),{setVideoRef:_}=$o(n),{setVideoRef:v}=$o(g?.parentAsset);let b;e[4]!==n?(b=q=>rl({asset:n,timelineLayer:null,idbAsset:null,state:q}),e[4]=n,e[5]=b):b=e[5];const j=ys(b),x=Ul;let S;e[6]===Symbol.for("react.memo_cache_sentinel")?(S={width:"250px",height:"200px",display:"block"},e[6]=S):S=e[6];let C;
218e[7]!==i||e[8]!==l?(C=l&&(0,t.jsx)("button",{onClick:()=>l(!i),style:{position:"absolute",top:"0.5rem",right:"0.5rem",background:"none",border:"none",cursor:"pointer",fontSize:"1.5rem"},children:i?(0,t.jsx)(Tr,{style:{color:"SpringGreen"}}):(0,t.jsx)(wr,{style:{color:"gray"}})}),e[7]=i,e[8]=l,e[9]=C):C=e[9];let y;e[10]!==n.name?(y=(0,t.jsx)(Wl,{children:n.name}),e[10]=n.name,e[11]=y):y=e[11];let N;e[12]!==p?(N=(0,t.jsxs)(Kl,{children:["(",p," sec)"]}),e[12]=p,e[13]=N):N=e[13];let w;e[14]!==y||e[15]!==N?(w=(0,t.jsxs)(Zl,{children:[y,N]}),e[14]=y,e[15]=N,e[16]=w):w=e[16];const A=Gl;let I,D;e[17]===Symbol.for("react.memo_cache_sentinel")?(I={display:"flex",flexDirection:"column",gap:"1rem"},D={width:"100%",height:"auto",objectFit:"contain"},e[17]=I,e[18]=D):(I=e[17],D=e[18]);let L;e[19]!==n.name||e[20]!==j?(L=(0,t.jsx)("img",{style:D,src:j,alt:n.name}),e[19]=n.name,e[20]=j,e[21]=L):L=e[21];const $=d&&(0,t.jsxs)(un,{unsetCancelModal:()=>c(!1),children:[(0,t.jsx)("video",{ref:_,controls:!0}),(0,t.jsxs)(u5,{type:"multiple",children:[g&&(0,t.jsxs)(In,{value:"parent",children:[(0,t.jsx)(Tn,{children:"Parent Asset"}),(0,t.jsxs)(kn,{children:[(0,t.jsxs)("button",{onClick:()=>{const q=document.getElementById(g.parentAsset._id);
218q&&(q.currentTime=g.scene.start)},children:["Jump to scene (",g.scene.start.toFixed(2),"s)"]}),(0,t.jsx)("video",{ref:v,controls:!0,id:g.parentAsset._id})]})]}),(0,t.jsxs)(In,{value:"thumbnail",children:[(0,t.jsx)(Tn,{children:"Thumbnail"}),(0,t.jsx)(kn,{children:(0,t.jsx)("img",{style:{width:"100%",height:"auto",objectFit:"contain"},src:j,alt:n.name})})]}),(0,t.jsxs)(In,{value:"metadata",children:[(0,t.jsx)(Tn,{children:"Full Asset JSON"}),(0,t.jsx)(kn,{children:(0,t.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:JSON.stringify(n,null,2)})})]}),o&&Object.entries(o).map(p5)]})]});let R;e[22]!==d?(R=()=>c(!d),e[22]=d,e[23]=R):R=e[23];let P;e[24]===Symbol.for("react.memo_cache_sentinel")?(P={position:"absolute",bottom:"0.5rem",right:"0.5rem",background:"none",border:"none",cursor:"pointer",fontSize:"1.5rem"},e[24]=P):P=e[24];let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=(0,t.jsx)(Er,{style:{color:"gray"}}),e[25]=k):k=e[25];let T;e[26]!==R?(T=(0,t.jsx)("button",{onClick:R,style:P,children:k}),e[26]=R,e[27]=T):T=e[27];let E;e[28]!==A||e[29]!==I||e[30]!==L||e[31]!==$||e[32]!==T?(E=(0,t.jsxs)(A,{style:I,children:[L,$,T]}),e[28]=A,e[29]=I,e[30]=L,e[31]=$,e[32]=T,e[33]=E):E=e[33];let O;return e[34]!==x||e[35]!==r||e[36]!==E||e[37]!==S||e[38]!==C||e[39]!==w?(O=(0,t.jsxs)(x,{style:S,highlight:r,children:[C,w,E]}),e[34]=x,e[35]=r,e[36]=E,e[37]=S,e[38]=C,e[39]=w,e[40]=O):O=e[40],O};function p5(s){const[e,n]=s;return(0,t.jsxs)(In,{value:e,children:[(0,t.jsx)(Tn,{children:e}),(0,t.jsx)(kn,{children:(0,t.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:JSON.stringify(n,null,2)})})]},e)}var h5=({query:s,setQuery:e,inputAssets:n,setInputAssets:a,outputAssets:o,setOutputAssets:i})=>{const[l,r]=(0,f.useState)(""),[d,c]=(0,f.useState)([]),[m,h]=(0,f.useState)(null),p=async()=>{try{c(await H.admin.assetSearch.listValidationSets.query())}catch(j){console.error("Failed to load validation sets:",j)}};(0,f.useEffect)(()=>{p()},[]);const u=async j=>{const x={name:l,query:s,inputAssetIds:n,outputAssetIds:o};try{m&&m._id&&!j?await H.admin.assetSearch.updateValidationSet.mutate({id:m._id,validationSet:x}):(await H.admin.assetSearch.createValidationSet.mutate({validationSet:x}),h(null)),alert("Validation set saved successfully"),await p()}catch(S){console.error("Failed to save validation set:",S)}},g=async j=>{try{const x=await H.admin.assetSearch.getValidationSet.query({id:j});if(x){const{name:S,query:C,inputAssetIds:y,outputAssetIds:N}=x;r(S),e(C),a(y),i(N),h(x)}}catch(x){console.error("Failed to load validation set:",x)}},_=()=>{r(""),e(""),a([]),i([]),h(null)},v=async j=>{if(window.confirm("Are you sure you want to delete this validation set?"))try{await H.admin.assetSearch.deleteValidationSet.mutate({id:j}),alert("Validation set deleted successfully"),await p(),m?._id===j&&h(null)}
218catch(x){console.error("Failed to delete validation set:",x)}},b=async(j,x)=>{try{await H.admin.assetSearch.updateValidationSet.mutate({id:j,validationSet:{includeInReport:x}}),c(S=>S.map(C=>C._id===j?{...C,includeInReport:x}:C))}catch(S){console.error("Failed to update includeInReport:",S)}};return(0,t.jsxs)("div",{style:{padding:"20px",fontFamily:"Arial, sans-serif"},children:[(0,t.jsx)("h2",{style:{color:"#333",borderBottom:"2px solid #ccc"},children:"Validation Set Manager"}),(0,t.jsxs)("div",{style:{marginBottom:"15px"},children:[(0,t.jsx)("label",{htmlFor:"validationSetName",style:{display:"block",fontWeight:"bold",marginBottom:"5px"},children:"Name:"}),(0,t.jsx)("input",{id:"validationSetName",type:"text",value:l,onChange:j=>r(j.target.value),style:{padding:"8px",width:"100%",border:"1px solid #ccc",borderRadius:"4px"}})]}),(0,t.jsx)("div",{style:{marginBottom:"20px"},children:m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:()=>u(!1),style:{padding:"10px 15px",marginRight:"10px",backgroundColor:"#28a745",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Save Changes"}),(0,t.jsx)("button",{onClick:()=>u(!0),style:{padding:"10px 15px",backgroundColor:"#007bff",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Save As New"})]}):(0,t.jsx)("button",{onClick:()=>u(!0),style:{padding:"10px 15px",backgroundColor:"#007bff",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Save As New Validation Set"})}),(0,t.jsx)("h3",{style:{color:"#555"},children:"Existing Validation Sets"}),(0,t.jsxs)("ul",{style:{listStyleType:"none",paddingLeft:"0"},children:[d.map(j=>(0,t.jsxs)("li",{style:{display:"flex",alignItems:"center",marginBottom:"10px"},children:[(0,t.jsx)("button",{onClick:()=>g(j._id),style:{padding:"8px 12px",marginRight:"10px",backgroundColor:"#6c757d",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:j.name}),(0,t.jsx)("button",{onClick:()=>v(j._id),style:{padding:"8px 12px",backgroundColor:"#dc3545",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Delete"}),(0,t.jsxs)("label",{style:{marginLeft:"10px"},children:[(0,t.jsx)("input",{type:"checkbox",checked:j.includeInReport||!1,onChange:x=>b(j._id,x.target.checked)}),"Include in Report"]})]},j._id)),(0,t.jsx)("li",{children:(0,t.jsx)("button",{onClick:_,style:{padding:"8px 12px",backgroundColor:"#17a2b8",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer"},children:"Create New Validation Set"})})]})]})},f5=h5,Jl=Q(ie()),x5=Q(cn()),Et=function(s){return s.AddAsset="addAsset",s.FromLink="fromLink",s}(Et||{}),Ps=s=>{const e=(0,Jl.c)(17),{title:n,buttonLabel:a,buttonAction:o,children:i}=s,l=f.useRef(null);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=j=>{if(l.current){const x=l.current.clientWidth,S=j==="left"?-x*.9:x*.9;l.current.scrollBy({left:S,behavior:"smooth"})}},e[0]=r):r=e[0];const d=r;let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c={overflowY:"auto",marginBottom:"20px",padding:"10px",backgroundColor:"#fff",borderRadius:"5px",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.1)",position:"relative"},e[1]=c):c=e[1];let m;e[2]!==n?(m=(0,t.jsx)("h3",{children:n}),e[2]=n,e[3]=m):m=e[3];let h;e[4]!==o||e[5]!==a?(h=a&&o&&(0,t.jsx)("button",{onClick:o,style:{backgroundColor:"#f39c12",color:"#fff",border:"none",padding:"10px 15px",borderRadius:"5px",cursor:"pointer",marginBottom:"10px"},children:a}),e[4]=o,e[5]=a,e[6]=h):h=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"scroll",position:"relative"},e[7]=p):p=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u={display:"flex"},e[8]=u):u=e[8];let g;e[9]!==i?(g=(0,t.jsx)("div",{style:p,ref:l,children:(0,t.jsx)("div",{style:u,children:i})}),e[9]=i,e[10]=g):g=e[10];let _,v;e[11]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsx)("button",{onClick:()=>d("left"),style:{position:"absolute",top:"50%",left:"0",transform:"translateY(-50%)",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"#fff",border:"none",padding:"10px",cursor:"pointer"},children:"<"}),v=(0,t.jsx)("button",{onClick:()=>d("right"),style:{position:"absolute",top:"50%",right:"0",transform:"translateY(-50%)",backgroundColor:"rgba(0, 0, 0, 0.5)",color:"#fffa",border:"none",padding:"10px",cursor:"pointer"},children:">"}),e[11]=_,e[12]=v):(_=e[11],v=e[12]);let b;return e[13]!==m||e[14]!==h||e[15]!==g?(b=(0,t.jsxs)("div",{style:c,children:[m,h,g,_,v]}),e[13]=m,e[14]=h,e[15]=g,e[16]=b):b=e[16],b};function g5(){const s=(0,Jl.c)(135);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],s[0]=e):e=s[0];const[n,a]=(0,f.useState)(e),[o,i]=(0,f.useState)("");let l;s[1]===Symbol.for("react.memo_cache_sentinel")?(l={},s[1]=l):l=s[1];const[r,d]=(0,f.useState)(l);let c;s[2]===Symbol.for("react.memo_cache_sentinel")?(c=[],s[2]=c):c=s[2];const[m,h]=(0,f.useState)(c),[p,u]=(0,f.useState)(Et.AddAsset);let g;s[3]===Symbol.for("react.memo_cache_sentinel")?(g=[],s[3]=g):g=s[3];const[_,v]=(0,f.useState)(g);let b;s[4]===Symbol.for("react.memo_cache_sentinel")?(b=[],s[4]=b):b=s[4];const[j,x]=(0,f.useState)(b);let S;s[5]===Symbol.for("react.memo_cache_sentinel")?(S=[],s[5]=S):S=s[5];const[C,y]=(0,f.useState)(S);let N;s[6]===Symbol.for("react.memo_cache_sentinel")?(N=[],s[6]=N):N=s[6];const[w,A]=(0,f.useState)(N),[I,D]=(0,f.useState)(!1);let L,$,R,P,k,T,E,O,q,J;if(s[7]!==p||s[8]!==n||s[9]!==w||s[10]!==C||s[11]!==j||s[12]!==I||s[13]!==o||s[14]!==_){let Ne;s[25]!==j?(Ne=le=>j.includes(le._id),s[25]=j,s[26]=Ne):Ne=s[26];const Be=n.filter(Ne);
218if(s[27]!==p||s[28]!==n||s[29]!==w||s[30]!==C||s[31]!==I||s[32]!==o||s[33]!==_){let le;s[43]!==C?(le=ut=>C.includes(ut._id),s[43]=C,s[44]=le):le=s[44];const he=n.filter(le);let ge;s[45]!==w?(ge=ut=>w.includes(ut._id),s[45]=w,s[46]=ge):ge=s[46];const je=n.filter(ge);let ue;s[47]!==n||s[48]!==I||s[49]!==o?(ue=async()=>{const ut=await H.asset.searchEmbeddingsSearch.query({query:o,assetIds:I?void 0:n.map(N5)});d(ut);const Nt=Object.values(ut).flat().map(C5).filter(wt=>!n.some(us=>us._id===wt));if(Nt.length>0){const wt=await Qn(Nt,Cs.admin);h(us=>[...us,...wt])}},s[47]=n,s[48]=I,s[49]=o,s[50]=ue):ue=s[50],L=ue;let pe;s[51]===Symbol.for("react.memo_cache_sentinel")?(pe=async ut=>{A(wt=>[...wt,...ut]);const Nt=(0,x5.chunk)(ut,5);for(const wt of Nt)try{const{results:us}=await H.asset.searchEmbeddingsCreate.mutate({assetIds:wt});Object.entries(us).map(ms=>{const[,Is]=ms,{newlyIndexedAssetIds:Fn,alreadyIndexedAssetIds:On,failedToIndexAssetIds:qn}=Is,ca=Fn===void 0?[]:Fn,fn=On===void 0?[]:On,ua=qn===void 0?[]:qn;x(Ts=>[...Ts,...ca,...fn]),y(Ts=>[...Ts,...ua]),A(Ts=>Ts.filter(ma=>!wt.includes(ma)))})}catch{y(ms=>[...ms,...wt.filter(Is=>!ms.includes(Is))]),A(ms=>ms.filter(Is=>!wt.includes(Is)))}},s[51]=pe):pe=s[51];const ee=pe;let xe;s[52]===Symbol.for("react.memo_cache_sentinel")?(xe=async ut=>{const Nt=(await Qn(ut,Cs.admin)).filter(S5);return window.assets=Nt,window.objectIds=Nt.map(y5).join(","),ee(Nt.map(b5)),Nt},s[52]=xe):xe=s[52];const ve=xe;let we;s[53]===Symbol.for("react.memo_cache_sentinel")?(we=async ut=>{const Nt=await ve(ut);a(wt=>[...wt,...Nt])},s[53]=we):we=s[53];const re=we;let V;s[54]===Symbol.for("react.memo_cache_sentinel")?(V=async ut=>{x([]),y([]),A([]),a(await ve(ut))},s[54]=V):V=s[54];const Ie=V;let ke;s[55]!==C?(ke=async()=>{y([]),await ee(C)},s[55]=C,s[56]=ke):ke=s[56];const De=ke;s[57]===Symbol.for("react.memo_cache_sentinel")?(O={marginTop:"40px",padding:"20px",backgroundColor:"#f9f9f9",borderRadius:"10px"},s[57]=O):O=s[57];let Xe;s[58]!==n?(Xe=n.map(j5),s[58]=n,s[59]=Xe):Xe=s[59],s[60]!==o||s[61]!==Xe||s[62]!==_?(q=(0,t.jsx)(f5,{query:o,setQuery:i,inputAssets:Xe,setInputAssets:Ie,outputAssets:_,setOutputAssets:v}),s[60]=o,s[61]=Xe,s[62]=_,s[63]=q):q=s[63];let jt,Zt;s[64]===Symbol.for("react.memo_cache_sentinel")?(J=(0,t.jsx)("h2",{style:{color:"#444",borderBottom:"2px solid #eee",paddingBottom:"10px",marginBottom:"20px"},children:"Asset Controls"}),jt={display:"flex",gap:"10px",marginBottom:"20px"},Zt={display:"flex",alignItems:"center"},s[64]=jt,s[65]=Zt,s[66]=J):(jt=s[64],Zt=s[65],J=s[66]);const ws=p===Et.AddAsset;let es;s[67]!==p?(es=()=>u(p===Et.AddAsset?Et.FromLink:Et.AddAsset),s[67]=p,s[68]=es):es=s[68];let ts;s[69]===Symbol.for("react.memo_cache_sentinel")?(ts={marginRight:"10px"},s[69]=ts):ts=s[69];let cs;s[70]!==ws||s[71]!==es?(cs=(0,t.jsxs)("label",{style:Zt,children:[(0,t.jsx)("input",{type:"checkbox",checked:ws,onChange:es,style:ts}),"Add By Asset ID"]}),s[70]=ws,s[71]=es,s[72]=cs):cs=s[72];let ss;s[73]===Symbol.for("react.memo_cache_sentinel")?(ss={display:"flex",alignItems:"center"},s[73]=ss):ss=s[73];const As=p===Et.FromLink;let et;s[74]!==p?(et=()=>u(p===Et.FromLink?Et.AddAsset:Et.FromLink),s[74]=p,s[75]=et):et=s[75];let ns;s[76]===Symbol.for("react.memo_cache_sentinel")?(ns={marginRight:"10px"},s[76]=ns):ns=s[76];let Bt;s[77]!==As||s[78]!==et?(Bt=(0,t.jsxs)("label",{style:ss,children:[(0,t.jsx)("input",{type:"checkbox",checked:As,onChange:et,style:ns}),"Extract Scenes From Link"]}),s[77]=As,s[78]=et,s[79]=Bt):Bt=s[79],s[80]!==cs||s[81]!==Bt?($=(0,t.jsxs)("div",{style:jt,children:[cs,Bt]}),s[80]=cs,s[81]=Bt,s[82]=$):$=s[82];let At;s[83]===Symbol.for("react.memo_cache_sentinel")?(At={marginBottom:"20px"},s[83]=At):At=s[83];let as;s[84]!==p?(as=p===Et.AddAsset&&(0,t.jsx)(i5,{onAdd:re}),s[84]=p,s[85]=as):as=s[85];let os;s[86]!==p?(os=p===Et.FromLink&&(0,t.jsx)(r5,{onAdd:re}),s[86]=p,s[87]=os):os=s[87],s[88]!==as||s[89]!==os?(R=(0,t.jsxs)("div",{style:At,children:[as,os]}),s[88]=as,s[89]=os,s[90]=R):R=s[90],s[91]===Symbol.for("react.memo_cache_sentinel")?(P=(0,t.jsx)("div",{style:{marginBottom:"20px"},children:(0,t.jsx)("button",{onClick:()=>a([]),style:{backgroundColor:"#e74c3c",color:"#fff",border:"none",padding:"10px 15px",borderRadius:"5px",cursor:"pointer"},children:"Clear Assets"})}),s[91]=P):P=s[91],k=je.length>0&&(0,t.jsx)(Ps,{title:"Assets Being Indexed",assets:je,children:je.map(_5)}),T=he.length>0&&(0,t.jsx)(Ps,{title:"Failed to Index Assets",assets:he,buttonLabel:"Reattempt Indexing",buttonAction:De,children:he.map(v5)}),s[27]=p,s[28]=n,s[29]=w,s[30]=C,s[31]=I,s[32]=o,s[33]=_,s[34]=L,s[35]=$,s[36]=R,s[37]=P,s[38]=k,s[39]=T,s[40]=O,s[41]=q,s[42]=J}else L=s[34],$=s[35],R=s[36],P=s[37],k=s[38],T=s[39],O=s[40],q=s[41],J=s[42];E=Be.length>0&&(0,t.jsx)(Ps,{title:"Indexed Assets",assets:Be,children:Be.map(le=>(0,t.jsx)(_s,{asset:le,setSelected:()=>{v(he=>he.includes(le._id)?he.filter(ge=>ge!==le._id):[...he,le._id])},selected:_.includes(le._id)},le._id))}),s[7]=p,s[8]=n,s[9]=w,s[10]=C,s[11]=j,s[12]=I,s[13]=o,s[14]=_,s[
21815]=L,s[16]=$,s[17]=R,s[18]=P,s[19]=k,s[20]=T,s[21]=E,s[22]=O,s[23]=q,s[24]=J}else L=s[15],$=s[16],R=s[17],P=s[18],k=s[19],T=s[20],E=s[21],O=s[22],q=s[23],J=s[24];let K,z;s[92]===Symbol.for("react.memo_cache_sentinel")?(K={marginBottom:"20px"},z={display:"flex",alignItems:"center"},s[92]=K,s[93]=z):(K=s[92],z=s[93]);let Y;s[94]!==I?(Y=()=>D(!I),s[94]=I,s[95]=Y):Y=s[95];let me;s[96]===Symbol.for("react.memo_cache_sentinel")?(me={marginRight:"10px"},s[96]=me):me=s[96];let X;s[97]!==I||s[98]!==Y?(X=(0,t.jsx)("div",{style:K,children:(0,t.jsxs)("label",{style:z,children:[(0,t.jsx)("input",{type:"checkbox",checked:I,onChange:Y,style:me}),"Search All Assets"]})}),s[97]=I,s[98]=Y,s[99]=X):X=s[99];let te;s[100]===Symbol.for("react.memo_cache_sentinel")?(te={marginBottom:"20px"},s[100]=te):te=s[100];let ae,G;s[101]===Symbol.for("react.memo_cache_sentinel")?(ae=Ne=>i(Ne.target.value),G={padding:"10px",width:"calc(100% - 120px)",borderRadius:"5px",border:"1px solid #ddd",marginRight:"10px"},s[101]=ae,s[102]=G):(ae=s[101],G=s[102]);let se;s[103]!==o?(se=(0,t.jsx)("input",{value:o,onChange:ae,style:G}),s[103]=o,s[104]=se):se=s[104];let U;s[105]===Symbol.for("react.memo_cache_sentinel")?(U={backgroundColor:"#3498db",color:"#fff",border:"none",padding:"10px 15px",borderRadius:"5px",cursor:"pointer"},s[105]=U):U=s[105];let B;s[106]!==L?(B=(0,t.jsx)("button",{onClick:L,style:U,children:"Search"}),s[106]=L,s[107]=B):B=s[107];let oe;s[108]!==se||s[109]!==B?(oe=(0,t.jsxs)("div",{style:te,children:[se,B]}),s[108]=se,s[109]=B,s[110]=oe):oe=s[110];let de;if(s[111]!==n||s[112]!==m||s[113]!==r||s[114]!==_){let Ne;s[116]!==n||s[117]!==m||s[118]!==_?(Ne=Be=>{const[le,he]=Be;return(0,t.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,t.jsx)("h2",{style:{fontSize:"18px",color:"#333"},children:le}),(0,t.jsxs)("p",{children:["Recall:"," ",(_.filter(ge=>he?.some(je=>je.assetId===ge)).length/(_.length||1)).toFixed(2)," ","(",_.filter(ge=>he?.some(je=>je.assetId===ge)).length," ","out of ",_.length,")"]}),(0,t.jsxs)("p",{children:["Precision:"," ",(he?.filter(ge=>_.includes(ge.assetId)).length/he?.length).toFixed(2)," ","(",he?.filter(ge=>_.includes(ge.assetId)).length," ","out of ",(0,t.jsx)("span",{children:he?.length}),")"]}),(0,t.jsx)(Ps,{title:"Search Results",assets:[],children:he?.filter(ge=>{const{assetId:je}=ge;return[...n,...m].some(ue=>ue._id===je)}).map(ge=>{const{assetId:je,score:ue}=ge;return(0,t.jsx)(_s,{asset:[...n,...m].find(pe=>pe._id===je),metadata:{score:ue},highlight:_.includes(je)?"SpringGreen":"Red"},je)})}),(0,t.jsx)(Ps,{title:"Correct Search Results",assets:[],children:he?.filter(ge=>{const{assetId:je}=ge;return[...n,...m].some(ue=>ue._id===je)&&_.includes(je)}).map(ge=>{const{assetId:je,score:ue}=ge;return(0,t.jsx)(_s,{asset:[...n,...m].find(pe=>pe._id===je),metadata:{score:ue},highlight:"SpringGreen"},je)})}),(0,t.jsx)(Ps,{title:"Incorrect Search Results",assets:[],children:he?.filter(ge=>{const{assetId:je}=ge;return[...n,...m].some(ue=>ue._id===je)&&!_.includes(je)}).map(ge=>{const{assetId:je,score:ue}=ge;return(0,t.jsx)(_s,{asset:[...n,...m].find(pe=>pe._id===je),metadata:{score:ue},highlight:"Red"},je)})}),(0,t.jsx)(Ps,{title:"Missed Search Results",assets:[],children:_.filter(ge=>!he?.some(je=>je.assetId===ge)).map(ge=>(0,t.jsx)(_s,{asset:n.find(je=>je._id===ge),highlight:"Orange"},ge))})]},le)},s[116]=n,s[117]=m,s[118]=_,s[119]=Ne):Ne=s[119],de=Object.entries(r).map(Ne),s[111]=n,s[112]=m,s[113]=r,s[114]=_,s[115]=de}else de=s[115];let ye;s[120]!==de?(ye=(0,t.jsx)("div",{children:de}),s[120]=de,s[121]=ye):ye=s[121];let Le;return s[122]!==$||s[123]!==R||s[124]!==P||s[125]!==k||s[126]!==T||s[127]!==E||s[128]!==X||s[129]!==oe||s[130]!==ye||s[131]!==O||s[132]!==q||s[133]!==J?(Le=(0,t.jsxs)("div",{style:O,children:[q,J,$,R,P,k,T,E,X,oe,ye]}),s[122]=$,s[123]=R,s[124]=P,s[125]=k,s[126]=T,s[127]=E,s[128]=X,s[129]=oe,s[130]=ye,s[131]=O,s[132]=q,s[133]=J,s[134]=Le):Le=s[134],Le}function v5(s){return(0,t.jsx)(_s,{asset:s},s._id)}function _5(s){return(0,t.jsx)(_s,{asset:s},s._id)}function j5(s){return s._id}function b5(s){return s._id}function y5(s){return`ObjectId("${s._id}")`}function S5(s){return!!s}function C5(s){return s.assetId}function N5(s){return s._id}var w5=()=>{const{id:s}=Ys(),[e,n]=(0,f.useState)(""),[a,o]=(0,f.useState)(!1),[i,l]=(0,f.useState)([]),[r,d]=(0,f.useState)([]);(0,f.useEffect)(()=>{async function m(){try{if(!s)throw new Error("No id provided");const{extractionInfo:h}=await H.assetSearch.clipExtractionCollectionInfo.query({collectionId:s});d(await Qn(h.assetIds,Cs.admin))}catch(h){Ue({description:"Failed to fetch original assets",error:h})}}m()},[s]);async function c(){o(!0);try{if(!s)throw new Error("No id provided");const m=await H.assetSearch.clipExtractionCollectionSearch.query({collectionId:s,query:e,usePrivateReplicateDeployment:!1});if(m.status==="completed")l(await Qn(m.data.map(h=>h.assetId),Cs.admin));else throw new Error(`Search query returned ${m.status}`)}catch(m){Ue({description:"Search failed",error:m})}o(!1)}return(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{children:"Search BRoll"}
218),(0,t.jsx)("input",{placeholder:"query",value:e,onChange:m=>n(m.target.value)}),(0,t.jsx)("button",{onClick:c,children:"Search"}),a&&(0,t.jsx)("div",{children:"Loading..."}),i.map(m=>(0,t.jsx)("div",{children:(0,t.jsx)(_s,{asset:m,originalAssets:r})},m._id))]})},A5=w5;const I5=s=>{const{logos:e,images:n,colors:a,fonts:o}=s,i={logos:[],images:[],colors:[],fonts:[]};return e?.forEach(l=>{const r=l?.formats?.filter(m=>m.src),d=r?.filter(m=>m.format!=="svg");let c=r;d?.length&&(c=d),c?.forEach(m=>{i.logos.push({type:l.type,theme:l.theme,src:m.src})})}),n?.forEach(l=>{l?.formats?.forEach(r=>{const d=r?.src,c=r?.format==="svg";d&&!c&&i.images.push({type:l.type,src:d})})}),a?.forEach(l=>{const{hex:r}=l;r&&i.colors.push({value:r,default:!1,isPrepopulated:!0})}),o?.forEach(l=>{const{name:r,origin:d}=l;r&&d&&d==="google"&&i.fonts.push({fontFamily:r,type:"default",isPrepopulated:!0})}),i};const T5="1001",k5="1000",R5="58px",$5="BrandfetchAdminPage-module_home_E6DeU",P5="BrandfetchAdminPage-module_homeHowBackgroundWhite_7Sq03",E5="BrandfetchAdminPage-module_largeButton_gmIRY",L5="BrandfetchAdminPage-module_sectionContent_4R3dV",B5="BrandfetchAdminPage-module_sectionHeader_DPpe-",D5="BrandfetchAdminPage-module_spacer_mIQyE",M5="BrandfetchAdminPage-module_chevron_9cVw0",F5="BrandfetchAdminPage-module_splashText_PhvOx",O5="BrandfetchAdminPage-module_splashSubtext_EOswD",q5="BrandfetchAdminPage-module_aboutSection_Cg1IX",V5="BrandfetchAdminPage-module_mobile_kV4w-",H5="BrandfetchAdminPage-module_desktop_Ma27a",U5="BrandfetchAdminPage-module_screenReaderOnlyLabel_foEOd",Z5="BrandfetchAdminPage-module_disabled_Mw-Rm",W5="BrandfetchAdminPage-module_disabledWithPointerEvents_ZrKtY",K5="BrandfetchAdminPage-module_noScrollBar_bbqjc",G5="BrandfetchAdminPage-module_textOverflowEllipsis_swpIT",J5="BrandfetchAdminPage-module_modal_0KqnC",z5="BrandfetchAdminPage-module_disableTextHighlight_xvRZ6",Y5="BrandfetchAdminPage-module_genericButtonBlue_tMKCB",Q5="BrandfetchAdminPage-module_rmButtonUserAgentStyles_ruoxc",X5="BrandfetchAdminPage-module_link_X3E7Z",eL="BrandfetchAdminPage-module_main_4qzuh",tL="BrandfetchAdminPage-module_rowHeader_83iPF",sL="BrandfetchAdminPage-module_row_Rb6Q8",nL="BrandfetchAdminPage-module_noClick_yXCK0",aL="BrandfetchAdminPage-module_input_AfX8g",oL="BrandfetchAdminPage-module_label_6EwnI",iL="BrandfetchAdminPage-module_button_Eikbc",lL="BrandfetchAdminPage-module_status_-f-ht",rL="BrandfetchAdminPage-module_asset_EzGmb",dL="BrandfetchAdminPage-module_font_3GStg",cL="BrandfetchAdminPage-module_color_10H1n",uL="BrandfetchAdminPage-module_logo_-ltVx",mL="BrandfetchAdminPage-module_placeholder_A9Unu",pL="BrandfetchAdminPage-module_shimmer_ZxhDi",hL="BrandfetchAdminPage-module_statusBar_F3la6",fL="BrandfetchAdminPage-module_empty_gZJAA";var ft={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:T5,paywallBgZIndex:k5,collapsedMediaSidebarWidth:R5,home:$5,homeHowBackgroundWhite:P5,largeButton:E5,sectionContent:L5,sectionHeader:B5,spacer:D5,chevron:M5,splashText:F5,splashSubtext:O5,aboutSection:q5,mobile:V5,desktop:H5,screenReaderOnlyLabel:U5,disabled:Z5,disabledWithPointerEvents:W5,noScrollBar:K5,textOverflowEllipsis:G5,modal:J5,disableTextHighlight:z5,genericButtonBlue:Y5,rmButtonUserAgentStyles:Q5,link:X5,main:eL,rowHeader:tL,row:sL,noClick:nL,input:aL,label:oL,button:iL,status:lL,asset:rL,font:dL,color:cL,logo:uL,placeholder:mL,shimmer:pL,statusBar:hL,empty:fL};const zl=async s=>(await H.admin.getBrandfetchAssets.query({domain:s})).body,xL=async s=>(await H.admin.getQualifiedDomain.query({domain:s})).body,hi=async(s,e,n)=>H.admin.getQualifiedDomains.query({query:s,page:e,pageSize:n});var gL=Q(ie()),vL=(s,e,n)=>{const a=s.startsWith("#")?s.substring(1,7):s,o=parseInt(a.substring(0,2),16),i=parseInt(a.substring(2,4),16),l=parseInt(a.substring(4,6),16);return o*.299+i*.587+l*.114>186?n:e},_L=s=>{const e=(0,gL.c)(30),{domain:n,handleClose:a}=s,[o,i]=(0,f.useState)(),[l,r]=(0,f.useState)(!0),[d,c]=(0,f.useState)();let m;e[0]!==n?(m=async()=>{r(!0);const D=await xL(n);c(D),D.brandfetch&&i(I5(D.brandfetch)),r(!1)},e[0]=n,e[1]=m):m=e[1];const h=m;let p;e[2]!==n||e[3]!==h?(p=async()=>{r(!0),await zl(n),await h(),r(!1)},e[2]=n,e[3]=h,e[4]=p):p=e[4];const u=p;let g,_;e[5]!==h?(g=function(){h()},_=[h],e[5]=h,e[6]=g,e[7]=_):(g=e[6],_=e[7]),(0,f.useEffect)(g,_);const v=yL;let b;e[8]!==o?.images||e[9]!==o?.logos||e[10]!==l?(b=()=>(0,t.jsx)(Ca,{children:l?v():(0,t.jsxs)(t.Fragment,{children:[o?.logos.map(SL),o?.images.map(CL)]})}),e[8]=o?.images,e[9]=o?.logos,e[10]=l,e[11]=b):b=e[11];const j=b;let x;e[12]!==o?.colors||e[13]!==l?(x=()=>(0,t.jsx)(Ca,{children:l?v():o?.colors.map(NL)}),e[12]=o?.colors,e[13]=l,e[14]=x):x=e[14];const S=x;let C;e[15]!==o?.fonts||e[16]!==l?(C=()=>(0,t.jsx)(Ca,{children:l?v():o?.fonts.map(wL)}),e[15]=o?.fonts,e[16]=l,e[17]=C):C=e[17];const y=C;let N;e[18]!==n||e[19]!==d?.brandfetch?.lastUpdated||e[20]!==S||e[21]!==y||e[22]!==j||e[23]!==u?(N=()=>(0,t.jsxs)("div",{className:ft.modal,children:[(0,t.jsxs)("h2",{children:["Domain: ",n]}),(0,t.jsxs)("div",{className:ft.statusBar,children:[(0,t.jsxs)("div",{className:ft.status,children:["Last Fetched:"," ",ot(d?.brandfetch?.lastUpdated).calendar(
218)]}),(0,t.jsx)("button",{className:ft.button,onClick:u,children:"Refetch"})]}),(0,t.jsx)("div",{className:ft.label,children:"Logos"}),j(),(0,t.jsx)("div",{className:ft.label,children:"Colors"}),S(),(0,t.jsx)("div",{className:ft.label,children:"Fonts"}),y()]}),e[18]=n,e[19]=d?.brandfetch?.lastUpdated,e[20]=S,e[21]=y,e[22]=j,e[23]=u,e[24]=N):N=e[24];const w=N;let A;e[25]!==w?(A=w(),e[25]=w,e[26]=A):A=e[26];let I;return e[27]!==a||e[28]!==A?(I=(0,t.jsx)(un,{unsetCancelModal:a,usePortal:!0,noScrollBar:!0,noPadding:!0,children:A}),e[27]=a,e[28]=A,e[29]=I):I=e[29],I},jL=f.memo(_L);function bL(s,e){return(0,t.jsx)("div",{className:ft.placeholder},e)}function yL(){return Array(5).fill(0).map(bL)}function SL(s){return(0,t.jsx)("div",{className:ft.logo,children:(0,t.jsx)("img",{src:s.src,alt:s.src})},s.src)}function CL(s){return(0,t.jsx)("div",{className:ft.logo,children:(0,t.jsx)("img",{src:s.src,alt:s.src})},s.src)}function NL(s,e){return(0,t.jsx)("div",{className:ft.color,style:{backgroundColor:s.value},children:(0,t.jsx)("p",{style:{color:vL(s.value,"#ffffff","#000000")},children:s.value})},e)}function wL(s,e){return(0,t.jsxs)("div",{className:ft.font,style:{fontFamily:s.fontFamily},children:[(0,t.jsx)("h3",{children:"Aa"}),(0,t.jsx)("p",{children:s.fontFamily})]},e)}var AL=Q(ie()),IL=()=>{const s=(0,AL.c)(41),[e,n]=(0,f.useState)(""),[a]=(0,f.useState)(0);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],s[0]=o):o=s[0];const[i,l]=(0,f.useState)(o),[r,d]=(0,f.useState)(!1),[c,m]=(0,f.useState)(""),[h,p]=(0,f.useState)(!0);let u,g;s[1]!==a||s[2]!==e?(u=function(){(async()=>(l((await hi(e,a,10)).body),p(!1)))()},g=[a,e],s[1]=a,s[2]=e,s[3]=u,s[4]=g):(u=s[3],g=s[4]),(0,f.useEffect)(u,g);let _;s[5]!==a||s[6]!==e?(_=async z=>{z.preventDefault();try{p(!0),l((await hi(e,a,10)).body),p(!1)}catch(Y){console.error(Y)}},s[5]=a,s[6]=e,s[7]=_):_=s[7];const v=_;let b;s[8]===Symbol.for("react.memo_cache_sentinel")?(b=z=>{n(z.target.value)},s[8]=b):b=s[8];const j=b;let x;s[9]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{d(!1)},s[9]=x):x=s[9];const S=x;let C;s[10]!==v||s[11]!==e?(C=()=>(0,t.jsx)(ud,{onSubmit:v,children:(0,t.jsx)(Cd,{name:"Domain",className:ft.input,children:(0,t.jsx)(td,{asChild:!0,children:(0,t.jsx)("input",{value:e,onChange:j,placeholder:"Enter a domain..."})})})}),s[10]=v,s[11]=e,s[12]=C):C=s[12];const y=C,N=kL;let w;s[13]!==e||s[14]!==i?(w=()=>e&&!i.length?(0,t.jsx)("div",{className:ft.empty,children:"No results found."}):null,s[13]=e,s[14]=i,s[15]=w):w=s[15];const A=w;let I;s[16]!==h||s[17]!==i?(I=()=>h?null:(0,t.jsxs)(t.Fragment,{children:[N(),i.map((z,Y)=>{const{domain:me,isQualified:X,brandfetch:te}=z,ae=()=>{te&&(m(me),d(!0))},G=async()=>{await zl(me),m(me),d(!0)};return(0,t.jsxs)("div",{className:`${ft.row} ${!te&&ft.noClick}`,onClick:ae,children:[(0,t.jsx)("div",{children:me}),(0,t.jsx)("div",{children:X?"Qualified":""}),(0,t.jsx)("div",{children:te?.lastUpdated?ot(new Date(te.lastUpdated)).calendar():(0,t.jsx)("button",{className:ft.button,onClick:G,children:"Fetch brand assets"})})]},Y)})]}),s[16]=h,s[17]=i,s[18]=I):I=s[18];const D=I;let L;s[19]!==r||s[20]!==c?(L=()=>!r||!c?null:(0,t.jsx)(jL,{handleClose:S,domain:c}),s[19]=r,s[20]=c,s[21]=L):L=s[21];const $=L;let R;s[22]!==h?(R=()=>h?(0,t.jsx)(nu,{}):null,s[22]=h,s[23]=R):R=s[23];const P=R;let k;s[24]===Symbol.for("react.memo_cache_sentinel")?(k=(0,t.jsx)("h2",{children:"Qualified Domains"}),s[24]=k):k=s[24];let T;s[25]!==y?(T=y(),s[25]=y,s[26]=T):T=s[26];let E;s[27]!==D?(E=D(),s[27]=D,s[28]=E):E=s[28];let O;s[29]!==P?(O=P(),s[29]=P,s[30]=O):O=s[30];let q;s[31]!==A?(q=A(),s[31]=A,s[32]=q):q=s[32];let J;s[33]!==$?(J=$(),s[33]=$,s[34]=J):J=s[34];let K;return s[35]!==T||s[36]!==E||s[37]!==O||s[38]!==q||s[39]!==J?(K=(0,t.jsxs)("main",{className:ft.main,children:[k,T,E,O,q,J]}),s[35]=T,s[36]=E,s[37]=O,s[38]=q,s[39]=J,s[40]=K):K=s[40],K},TL=f.memo(IL);function kL(){return(0,t.jsxs)("div",{className:ft.rowHeader,children:[(0,t.jsx)("div",{children:"Domain"}),(0,t.jsx)("div",{children:"Qualified"}),(0,t.jsx)("div",{children:"Brandfetched"})]})}const RL="CompareTranscript-module_languageSelector_J3MAN",$L="CompareTranscript-module_inputContainer_Eu1Ck",PL="CompareTranscript-module_transcriptColumn_Fme-l",EL="CompareTranscript-module_jobId_T1C8X",LL="CompareTranscript-module_columnHeader_ooTHa",BL="CompareTranscript-module_inputGroup_xBcHY",DL="CompareTranscript-module_helpLabel_3bnpv",ML="CompareTranscript-module_copyButton_ifmzh";var St={languageSelector:RL,inputContainer:$L,transcriptColumn:PL,jobId:EL,columnHeader:LL,inputGroup:BL,helpLabel:DL,copyButton:ML},FL=Q(ie()),OL=()=>{const s=(0,FL.c)(60),[e,n]=(0,f.useState)("");let a;s[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],s[0]=a):a=s[0];const[o,i]=(0,f.useState)(a),[l,r]=(0,f.useState)("en"),[d,c]=(0,f.useState)("");let m;s[1]===Symbol.for("react.memo_cache_sentinel")?(m=[],s[1]=m):m=s[1];const[h,p]=(0,f.useState)(m),[u,g]=(0,f.useState)();let _;s[2]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{p([]),g(void 0)},s[2]=_):_=s[2];const v=_;let b;s[3]!==o||s[4]!==l||s[5]!==d||s[6]!==e?(b=async()=>{const{state:te}=Pn();p(o.map(he=>({provider:he,targetLanguage:d,status:"loading"}))),g({sourceLanguage:l,status:"loading"});const ae=(await H.video.getVideo.query({id:e})).video,G=Object.entries(ae.allLayers.byId);if(G.length!==1){console.error("Video must only contain one asset"),v();return}const se=G[0][1].asset_id;
218if(!se){console.error("Asset ID not found"),v();return}const U={assetId:se,languageCode:l,keep_whole:!0,disfluencies:!0,translateLanguageCode:void 0,teamId:Io(te)};if(Math.random()>-1)throw new Error("this page needs to be updated to support the transcription workflow changes");const{transcriptionId:B}=await Ua("/api/v2/transcriptions",{body:U});let oe,de=!0;const ye=()=>{de=!1,v(),Ue({description:"Failed to get transcription",error:oe,sendToSentry:!1})};for(;de;){try{oe=await H.transcription.pollTranscription.query({id:B,videoId:e})}catch{ye();return}if(!oe){ye();return}if(!oe.success||oe.response?.progress?.error){console.error("Failed to get transcription"),ye();return}oe.response?.done&&(de=!1),await new Promise(VL)}if(!oe?.response.done){console.error("No words found in transcription"),v();return}const Le=oe?.response.words.reduce(HL,""),Ne=Qd({text:Le,locale:l});g({subtitles:Ne,sourceLanguage:l,status:"success",transcriptionId:B});const Be=Ne.map(UL),le=o.map(async he=>wu({languageCode:l,translateLanguageCode:d,subtitles:Be,forcedProvider:he,teamId:Io(te)}));await Promise.all(le).then(he=>{const ge=[];he.forEach((je,ue)=>{if(!je){ge.push({provider:o[ue],targetLanguage:d,status:"error"});return}const{translationId:pe,subtitles:ee}=je,xe=ee.map(ZL);if(xe.length!==Ne.length){ge.push({provider:o[ue],targetLanguage:d,status:"error",translationId:pe});return}ge.push({provider:o[ue],subtitles:xe,targetLanguage:d,status:"success",translationId:pe})}),p(ge)})},s[3]=o,s[4]=l,s[5]=d,s[6]=e,s[7]=b):b=s[7];const j=b;let x;s[8]!==u?.subtitles||s[9]!==h?(x=te=>{const{dispatch:ae}=Pn();let G;if(te==="transcription"?G=u?.subtitles?.join(` 219`):G=h.find(se=>se.provider===te)?.subtitles?.join(` 220`),!G){Ue({description:"No text to copy",error:new Error("No text to copy")});return}navigator.clipboard.writeText(G),ae(He({description:"Copied text to clipboard",type:"success"}))},s[8]=u?.subtitles,s[9]=h,s[10]=x):x=s[10];const S=x;let C;s[11]!==h?(C=h.some(WL),s[11]=h,s[12]=C):C=s[12];const y=C;let N,w;s[13]===Symbol.for("react.memo_cache_sentinel")?(N=te=>n(te.target.value),w={marginLeft:"10px",marginBottom:"10px"},s[13]=N,s[14]=w):(N=s[13],w=s[14]);let A;s[15]!==y||s[16]!==e?(A=(0,t.jsxs)("label",{children:["Video ID:",(0,t.jsx)("input",{type:"text",value:e,onChange:N,style:w,disabled:y})]}),s[15]=y,s[16]=e,s[17]=A):A=s[17];let I;s[18]===Symbol.for("react.memo_cache_sentinel")?(I=(0,t.jsx)("span",{className:St.helpLabel,children:"*Video must only contain one asset you wish to compare translations for"}),s[18]=I):I=s[18];let D;s[19]!==A?(D=(0,t.jsxs)("div",{className:St.inputGroup,children:[A,I]}),s[19]=A,s[20]=D):D=s[20];let L;s[21]===Symbol.for("react.memo_cache_sentinel")?(L=(0,t.jsx)("span",{children:"Translation Provider(s):"}),s[21]=L):L=s[21];let $;s[22]!==y||s[23]!==o?($=el.map(te=>(0,t.jsxs)("label",{style:{marginLeft:"10px"},children:[(0,t.jsx)("input",{type:"checkbox",name:"provider",value:te,checked:o.includes(te),onChange:()=>i(ae=>ae.includes(te)?ae.filter(G=>G!==te):[...ae,te]),disabled:y}),te]},te)),s[22]=y,s[23]=o,s[24]=$):$=s[24];let R;s[25]!==$?(R=(0,t.jsxs)("div",{className:St.inputGroup,children:[L,$]}),s[25]=$,s[26]=R):R=s[26];let P;s[27]!==y||s[28]!==l?(P=(0,t.jsxs)("span",{children:["Source Language:",(0,t.jsx)(Ka,{languageCode:l,setLanguageCode:r,includeAutoDetect:!1,mode:Ja.Transcription,className:St.languageSelector,disabled:y})]}),s[27]=y,s[28]=l,s[29]=P):P=s[29];let k;s[30]!==y||s[31]!==d?(k=(0,t.jsxs)("span",{children:["Target Language:",(0,t.jsx)(Ka,{languageCode:d,setLanguageCode:c,includeAutoDetect:!1,mode:Ja.Translation,className:St.languageSelector,disabled:y})]}),s[30]=y,s[31]=d,s[32]=k):k=s[32];let T;s[33]!==P||s[34]!==k?(T=(0,t.jsxs)("div",{className:St.inputGroup,children:[P,k]}),s[33]=P,s[34]=k,s[35]=T):T=s[35];let E;s[36]===Symbol.for("react.memo_cache_sentinel")?(E={marginTop:"10px"},s[36]=E):E=s[36];const O=y||o.length===0||!d||!l||!e;let q;s[37]!==j||s[38]!==O?(q=(0,t.jsx)("button",{onClick:j,style:E,disabled:O,children:"Generate Translations"}),s[37]=j,s[38]=O,s[39]=q):q=s[39];let J;s[40]!==D||s[41]!==R||s[42]!==T||s[43]!==q?(J=(0,t.jsxs)("div",{className:St.inputContainer,children:[D,R,T,q]}),s[40]=D,s[41]=R,s[42]=T,s[43]=q,s[44]=J):J=s[44];let K;s[45]===Symbol.for("react.memo_cache_sentinel")?(K={display:"flex",flexDirection:"column",borderTop:"1px solid #ccc",paddingTop:"10px"},s[45]=K):K=s[45];let z;s[46]!==u?.status?(z=u?.status==="loading"&&(0,t.jsx)(it,{}),s[46]=u?.status,s[47]=z):z=s[47];let Y;s[48]!==S||s[49]!==l||s[50]!==d||s[51]!==u||s[52]!==h?(Y=u?.subtitles&&u.subtitles.map((te,ae)=>(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"row"},children:[(0,t.jsx)("div",{style:{flex:1,marginRight:"20px"},className:St.transcriptColumn,children:u&&(0,t.jsxs)(t.Fragment,{children:[ae===0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("h4",{className:St.columnHeader,children:["Transcription (",l,"):"]}),(0,t.jsx)("span",{className:St.jobId,children:u.transcriptionId}),u.subtitles&&(0,t.jsx)("button",{className:St.copyButton,onClick:()=>S("transcription"),children:"Copy Transcription"})]}),u.status==="loading"&&ae===0&&(0,t.jsx)(it,{}),(0,t.jsx)("p",{children:u.subtitles?.[ae]},`transcription_${ae}`)]})}),h.map(G=>(0,t.jsxs)("div",{style:{flex:1,marginRight:"20px"},className:St.transcriptColumn,children:[ae===0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("h4",{className:St.columnHeader,children:[G.provider," (",d,"):"]}),(0,t.jsx)("span",{className:St.jobId,children:G.translationId}),G.subtitles&&(0,t.jsx)("button",{className:St.copyButton,onClick:()=>S(G.provider),children:"Copy Translation"})]}),G.status==="loading"&&ae===0&&(0,t.jsx)(it,{}),G.status==="error"&&ae===0&&(0,t.jsx)("p",{children:"Error"}),(0,t.jsx)("p",{children:G.subtitles?G.subtitles[ae]:""},`${G.provider}_${ae}`)]},G.provider))]},ae)),s[48]=S,s[49]=l,s[50]=d,s[51]=u,s[52]=h,s[53]=Y):Y=s[53];let me;s[54]!==z||s[55]!==Y?(me=(0,t.jsxs)("div",{style:K,children:[z,Y]}),s[54]=z,s[55]=Y,s[56]=me):me=s[56];let X;return s[57]!==J||s[58]!==me?(X=(0,t.jsxs)("div",{children:[J,me]}),s[57]=J,s[58]=me,s[59]=X):X=s[59],X},qL=OL;function VL(s){return setTimeout(s,5e3)}function HL(s,e){return`${s} ${e.word}`}function UL(s,e){return{frameId:"not-needed",text:s,startTime:e,endTime:e+1}}function ZL(s){return s.text}function WL(s){return s.status==="loading"}const KL="1001",GL="1000",JL="58px",zL="CustomKaiAdminPage-module_customKaiAdminPage_r6mKn",YL="CustomKaiAdminPage-module_pageTitle_N-6Nr",QL="CustomKaiAdminPage-module_searchForm_AT7Hy",XL="CustomKaiAdminPage-module_searchInput_0-Wrj",eB="CustomKaiAdminPage-module_filterRadios_8nzs1",tB="CustomKaiAdminPage-module_radioLabel_o59Hw",sB="CustomKaiAdminPage-module_radioInput_1dvL4",nB="CustomKaiAdminPage-module_clearButton_-JVLS",aB="CustomKaiAdminPage-module_viewAllTableFooter_k9R29",oB="CustomKaiAdminPage-module_viewAllCell_vwLkV",iB="CustomKaiAdminPage-module_searchResults_o2MpM",lB="CustomKaiAdminPage-module_searchResultsTitle_wbuoV",rB="CustomKaiAdminPage-module_section_gwN-J",dB="CustomKaiAdminPage-module_sectionTitle_jDYl0",cB="CustomKaiAdminPage-module_sectionDescription_04HBn",uB="CustomKaiAdminPage-module_kaiTable_hXEni",mB="CustomKaiAdminPage-module_tableHeader_W1qcc",pB="CustomKaiAdminPage-module_tableCell_QDcxQ",hB="CustomKaiAdminPage-module_sortable_Co-W8",fB="CustomKaiAdminPage-module_tableRow_kvxJD",xB="CustomKaiAdminPage-module_firstCell_inbKC",gB="CustomKaiAdminPage-module_actions_U940J",vB="CustomKaiAdminPage-module_actionButton_jYcf2",_B="CustomKaiAdminPage-module_pagination_GyHto",jB="CustomKaiAdminPage-module_paginationButton_jLZiZ",bB="CustomKaiAdminPage-module_paginationInfo_AnDYJ";var Ce={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:KL,paywallBgZIndex:GL,collapsedMediaSidebarWidth:JL,customKaiAdminPage:zL,pageTitle:YL,searchForm:QL,searchInput:XL,filterRadios:eB,radioLabel:tB,radioInput:sB,clearButton:nB,viewAllTableFooter:aB,viewAllCell:oB,searchResults:iB,searchResultsTitle:lB,section:rB,sectionTitle:dB,sectionDescription:cB,kaiTable:uB,tableHeader:mB,tableCell:pB,sortable:hB,tableRow:fB,firstCell:xB,actions:gB,actionButton:vB,pagination:_B,paginationButton:jB,paginationInfo:bB};const yB="1001",SB="1000",CB="58px",NB="StageCustomKaiModal-module_home_uyBvL",wB="StageCustomKaiModal-module_homeHowBackgroun
220dWhite_X05pM",AB="StageCustomKaiModal-module_largeButton_2E-v5",IB="StageCustomKaiModal-module_sectionContent_xxmyX",TB="StageCustomKaiModal-module_sectionHeader_N-bQK",kB="StageCustomKaiModal-module_spacer_GnXua",RB="StageCustomKaiModal-module_chevron_L-sWy",$B="StageCustomKaiModal-module_splashText_nvfL-",PB="StageCustomKaiModal-module_splashSubtext_hPhtY",EB="StageCustomKaiModal-module_aboutSection_Ogkp5",LB="StageCustomKaiModal-module_mobile_6O61i",BB="StageCustomKaiModal-module_desktop_BK-mG",DB="StageCustomKaiModal-module_screenReaderOnlyLabel_HpOG0",MB="StageCustomKaiModal-module_disabled_TLUut",FB="StageCustomKaiModal-module_disabledWithPointerEvents_VyZaE",OB="StageCustomKaiModal-module_noScrollBar_Kwlff",qB="StageCustomKaiModal-module_textOverflowEllipsis_TPrHd",VB="StageCustomKaiModal-module_disableTextHighlight_FIxwY",HB="StageCustomKaiModal-module_genericButtonBlue_QkQ-y",UB="StageCustomKaiModal-module_rmButtonUserAgentStyles_Rr25a",ZB="StageCustomKaiModal-module_overlay_yiFc4",WB="StageCustomKaiModal-module_overlayShow_cPCZc",KB="StageCustomKaiModal-module_content_UpbJn",GB="StageCustomKaiModal-module_title_hrsze",JB="StageCustomKaiModal-module_subheader_8Uy2u",zB="StageCustomKaiModal-module_buttonsContainer_qtZ9L",YB="StageCustomKaiModal-module_inputContainer_814d7",QB="StageCustomKaiModal-module_input_U1XW7";var Es={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:yB,paywallBgZIndex:SB,collapsedMediaSidebarWidth:CB,home:NB,homeHowBackgroundWhite:wB,largeButton:AB,sectionContent:IB,sectionHeader:TB,spacer:kB,chevron:RB,splashText:$B,splashSubtext:PB,aboutSection:EB,mobile:LB,desktop:BB,screenReaderOnlyLabel:DB,disabled:MB,disabledWithPointerEvents:FB,noScrollBar:OB,textOverflowEllipsis:qB,disableTextHighlight:VB,genericButtonBlue:HB,rmButtonUserAgentStyles:UB,overlay:ZB,overlayShow:WB,content:KB,title:GB,subheader:JB,buttonsContainer:zB,inputContainer:YB,input:QB},XB=({open:s,onClose:e,customKai:n})=>{const[a,o]=(0,f.useState)(()=>n?`/${fu(n.name??"")}`:""),[i,l]=(0,f.useState)(!1),r=async()=>{if(n){if(a.includes(" ")){Ue({description:"Slug can't have whitespaces",error:new Error("Slug can't have whitespaces")});return}if(a[0]!=="/"){Ue({description:"Slug must start with a slash",error:new Error("Slug must start with a slash")});return}if(a.split("/").length>2){Ue({description:"Slug must not have other slashes",error:new Error("Slug must not have other slashes")});return}l(!0);try{e((await H.kai.stageCustomKai.mutate({customKaiId:n._id,slug:a})).stagedKai)}catch(c){Ue({description:"Failed to stage custom Kai:",error:c})}finally{l(!1)}}},d=()=>{e(null)};return n?(0,t.jsx)(nd,{open:s,onOpenChange:d,children:(0,t.jsxs)(cd,{children:[(0,t.jsx)(ld,{className:Es.overlay}),(0,t.jsxs)(sd,{className:Es.content,children:[(0,t.jsx)(ad,{className:Es.title,children:"Stage Custom Kai"}),(0,t.jsx)("div",{className:Es.subheader,children:(0,t.jsxs)(dd,{children:["Enter a slug for the Custom Kai: ",(0,t.jsx)("strong",{children:n.name})]})}),(0,t.jsx)("div",{className:Es.inputContainer,children:(0,t.jsx)("input",{type:"text",className:Es.input,placeholder:"Enter a slug (e.g. /my-custom-kai)...",value:a,onChange:c=>o(c.target.value)})}),(0,t.jsxs)("div",{className:Es.buttonsContainer,children:[(0,t.jsx)(Ws,{onClick:d,overrideColor:"gray",children:"Cancel"}),(0,t.jsx)(Ws,{onClick:r,disabled:i,overrideColor:"lightBlue",children:i?"Staging...":"Stage"})]})]})]})}):null},eD=XB,Ls=Q(Ns()),tD=Q(cn()),yn=20,sD=()=>{const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)([]),[o,i]=(0,f.useState)([]),[l,r]=(0,f.useState)(!0),[d,c]=(0,f.useState)(""),[m,h]=(0,f.useState)(""),[p,u]=(0,f.useState)(null),[g,_]=(0,f.useState)([]),[v,b]=(0,f.useState)(!1),[j,x]=(0,f.useState)(0),[S,C]=(0,f.useState)(0),[y,N]=(0,f.useState)("createdAt"),[w,A]=(0,f.useState)("desc"),[I,D]=(0,f.useState)("featuredAt"),[L,$]=(0,f.useState)("desc"),[R,P]=(0,f.useState)("createdAt"),[k,T]=(0,f.useState)("desc"),[E,O]=(0,f.useState)("createdAt"),[q,J]=(0,f.useState)("desc"),[K,z]=(0,f.useState)(null),Y=tt(),me=async()=>{e((await H.kai.getAllCustomKais.query({featured:!0,sortBy:I,sortOrder:L})).customKais)},X=async()=>{a((await H.kai.getAllCustomKais.query({staged:!0,sortBy:R,sortOrder:k})).customKais)},te=async()=>{i((await H.kai.getAllCustomKais.query({sortBy:E,sortOrder:q})).customKais)};na(()=>{(async()=>{await Promise.all([me(),X(),te()]),r(!1)})()});const ae=async ee=>{const xe=ee?.query??d,ve=ee?.emailQuery??m,we=ee?.filter??p,re=ee?.page??S,V=ee?.sortBy??y,Ie=ee?.sortOrder??w;if(!xe.trim()&&!ve.trim()&&!we){_([]),x(0),C(0);return}b(!0);try{const ke=await H.kai.getAllCustomKais.query({limit:yn,skip:re*yn,name:xe.trim()||void 0,userEmail:ve.trim()||void 0,sortBy:V,sortOrder:Ie,featured:we==="featured"?!0:void 0,staged:we==="staged"?!0:void 0});_(ke.customKais),x(ke.total)}catch(ke){console.error("Search error:",ke)}finally{b(!1)}},G=(0,tD.debounce)(ee=>{ae(ee)},300),se=ee=>new Date(ee).toLocaleDateString("en-US",{month:"2-digit",day:"2-digit",year:"2-digit"}),U=ee=>ee>=1e3?`${Math.round(ee/100)/10}k chats`:`${ee} chats`,B=ee=>{C(ee),ae({page:ee})},oe=()=>{c(""),h(""),u(null),C(0)},de=ee=>{y===ee?A(w==="asc"?"desc":"asc"):(N(ee),A("desc")),C(0)},ye=ee=>{I===ee?$(L==="asc"?"desc":"asc"):(D(ee),$("desc")),me()},Le=ee=>{R===ee?T(k==="asc"?"desc":"asc"):(P(ee),T("desc")),X()},Ne=ee=>{E===ee?J(q==="asc"?"desc":"asc"):(O(ee),J("desc")),te()},Be=async ee=>{try{await H.kai.featureCustomKai.mutate({customKaiId:ee});const[xe,ve]=await Promise.all([H.kai.getAllCustomKais.query({featured:!0}),H.kai.getAllCustomKais.query({staged:!0})]);e(xe.customKais),a(ve.customKais)}catch(xe){console.error("Error featuring KAI:",xe)}},le=async ee=>{try{await H.kai.unfeatureCustomKai.mutate({customKaiId:ee});const[xe,ve]=await Promise.all([H.kai.getAllCustomKais.query({featured:!0}),H.kai.getAllCustomKais.query({staged:!0})]);e(xe.customKais),a(ve.customKais)}catch(xe){console.error("Error unfeaturing KAI:",xe)}},he=async ee=>{if(window.confirm("Are you sure you want to delete this custom KAI?"))try{await H.kai.deleteCustomKai.mutate({id:ee});const[xe,ve,we]=await Promise.all([H.kai.getAllCustomKais.query({featured:!0}),H.kai.getAllCustomKais.query({staged:!0}),H.kai.getAllCustomKais.query({limit:yn,skip:0})]);e(xe.customKais),a(ve.customKais),i(we.customKais)}catch(xe){console.error("Error deleting KAI:",xe)}},ge=(ee,xe,ve)=>{const we=re=>!ve||ve.sortBy!==re?null:ve.sortOrder==="asc"?" â":" â";return(0,t.jsxs)("table",{className:Ce.kaiTable,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:Ce.tableRow,children:[(0,t.jsxs)("th",{className:(0,Ls.default)(Ce.tableHeader,{[Ce.sortable]:!!ve}),onClick:ve?()=>ve.onSort("name"):void 0,children:["Name",we("name")]}),(0,t.jsx)("th",{className:Ce.tableHeader,children:"ID"}),(0,t.jsxs)("th",{className:(0,Ls.default)(Ce.tableHeader,{[Ce.sortable]:!!ve}),onClick:ve?()=>ve.onSort("totalChats"):void 0,children:["Chat Count",we("totalChats")]}),(0,t.jsxs)("th",{className:(0,Ls.default)(Ce.tableHeader,{[Ce.sortable]:!!ve}),onClick:ve?()=>ve.onSort("slug"):void 0,children:["Slug",we("slug")]}),(0,t.jsxs)("th",{className:(0,Ls.default)(Ce.tableHeader,{[Ce.sortable]:!!ve}),onClick:ve?()=>ve.onSort("createdAt"):void 0,children:["Created",we("createdAt")]}),(0,t.jsxs)("th",{className:(0,Ls.default)(Ce.tableHeader,{[Ce.sortable]:!!ve}),onClick:ve?()=>ve.onSort("creatorEmail"):void 0,children:["Creator",we("creatorEmail")]}),(0,t.jsxs)("th",{className:(0,Ls.default)(Ce.tableHeader,{[Ce.sortable]:!!ve}),onClick:ve?()=>ve.onSort("originalCreatorEmail"):void 0,children:["Original Creator",we("originalCreatorEmail")]}),(0,t.jsx)("th",{className:Ce.tableHeader,children:"Actions"})]})}),(0,t.jsx)("tbody",{children:ee.map(re=>(0,t.jsxs)("tr",{className:Ce.tableRow,children:[(0,t.jsx)("td",{className:(0,Ls.default)(Ce.tableCell,Ce.firstCell),
220children:(0,t.jsx)("a",{href:re.slug?`/kai/create${re.slug}`:`/kai/create/${re._id}`,target:"_blank",rel:"noopener noreferrer",children:re.name})}),(0,t.jsx)("td",{className:Ce.tableCell,children:re._id}),(0,t.jsx)("td",{className:Ce.tableCell,children:U(re.totalChats||0)}),(0,t.jsx)("td",{className:Ce.tableCell,children:re.slug||"N/A"}),(0,t.jsx)("td",{className:Ce.tableCell,children:se(re.createdAt)}),(0,t.jsx)("td",{className:Ce.tableCell,children:re.creatorEmail}),(0,t.jsx)("td",{className:Ce.tableCell,children:re.originalCreatorEmail||"N/A"}),(0,t.jsx)("td",{className:Ce.tableCell,children:xe(re)})]},re._id))}),ve?.onViewAll&&(0,t.jsx)("tfoot",{children:(0,t.jsx)("tr",{onClick:ve.onViewAll,className:Ce.viewAllTableFooter,children:(0,t.jsx)("td",{colSpan:8,className:Ce.viewAllCell,children:"View All"})})})]})},je=ee=>(0,t.jsx)("a",{href:`/kai/new/${ee}`,target:"_blank",rel:"noopener noreferrer",children:(0,t.jsx)("button",{className:Ce.actionButton,children:"Edit"})}),ue=d.trim().length>0||m.trim().length>0||!!p,pe=()=>{if(!ue)return null;const ee=()=>v?(0,t.jsx)("div",{children:"Searching..."}):g.length===0?(0,t.jsx)("div",{children:"No results found"}):(0,t.jsxs)(t.Fragment,{children:[ge(g,xe=>{const ve=xe.featuredAt===null&&!!xe.originalCreatorId,we=!!xe.featuredAt;return(0,t.jsxs)("div",{className:Ce.actions,children:[je(xe._id),(0,t.jsx)("button",{onClick:()=>he(xe._id),className:Ce.actionButton,children:"Delete"}),!ve&&!we&&(0,t.jsx)("button",{onClick:()=>z(xe),className:Ce.actionButton,children:"Copy to Staging"}),ve&&(0,t.jsx)("button",{onClick:()=>Be(xe._id),className:Ce.actionButton,children:"Add to Featured"}),we&&(0,t.jsx)("button",{onClick:()=>le(xe._id),className:Ce.actionButton,children:"Remove from Featured"})]})},{sortBy:y,sortOrder:w,onSort:de}),(0,t.jsxs)("div",{className:Ce.pagination,children:[(0,t.jsx)("button",{disabled:S===0,onClick:()=>B(S-1),className:Ce.paginationButton,children:"Previous"}),(0,t.jsxs)("span",{className:Ce.paginationInfo,children:["Page ",S+1," of ",Math.
220ceil(j/yn)]}),(0,t.jsx)("button",{disabled:(S+1)*yn>=j,onClick:()=>B(S+1),className:Ce.paginationButton,children:"Next"})]})]});return(0,t.jsxs)("div",{className:Ce.searchResults,children:[!v&&(0,t.jsxs)("h2",{className:Ce.searchResultsTitle,children:["Search Results (",j," found)"]}),ee()]})};return l?(0,t.jsx)("div",{children:"Loading..."}):(0,t.jsxs)("div",{className:Ce.customKaiAdminPage,children:[(0,t.jsx)("h1",{className:Ce.pageTitle,children:"Custom Kai Admin Page"}),(0,t.jsxs)("div",{className:Ce.searchForm,children:[(0,t.jsx)("input",{type:"text",placeholder:"Search custom KAIs by name...",value:d,onChange:ee=>{const xe=ee.target.value;c(xe),G({query:xe})},className:Ce.searchInput}),(0,t.jsx)("input",{type:"text",placeholder:"Search by user email... (exact match required)",value:m,onChange:ee=>{const xe=ee.target.value;h(xe),G({emailQuery:xe})},className:Ce.searchInput}),(0,t.jsxs)("div",{className:Ce.filterRadios,children:[(0,t.jsxs)("label",{className:Ce.radioLabel,children:[(0,t.jsx)("input",{type:"radio",name:"searchFilter",value:"all",checked:p==="all",onChange:()=>{u("all"),G({filter:"all"})},className:Ce.radioInput}),"All"]}),(0,t.jsxs)("label",{className:Ce.radioLabel,children:[(0,t.jsx)("input",{type:"radio",name:"searchFilter",value:"featured",checked:p==="featured",onChange:()=>{u("featured"),G({filter:"featured"})},className:Ce.radioInput}),"Featured"]}),(0,t.jsxs)("label",{className:Ce.radioLabel,children:[(0,t.jsx)("input",{type:"radio",name:"searchFilter",value:"staged",checked:p==="staged",onChange:()=>{u("staged"),G({filter:"staged"})},className:Ce.radioInput}),"Staged"]})]}),ue&&(0,t.jsx)("button",{type:"button",onClick:oe,className:Ce.clearButton,children:"Clear Search"})]}),pe(),!ue&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:Ce.section,children:[(0,t.jsx)("h2",{className:Ce.sectionTitle,children:"Featured Custom KAIs"}),(0,t.jsx)("p",{className:Ce.sectionDescription,children:"These currently appear for all users in the Featured section of the Custom Kai page."}),s.length===0?(0,t.jsx)("div",{children:"No featured custom KAIs"}):ge(s,ee=>(0,t.jsxs)("div",{className:Ce.actions,children:[je(ee._id),(0,t.jsx)("button",{onClick:()=>he(ee._id),className:Ce.actionButton,children:"Delete"}),(0,t.jsx)("button",{onClick:()=>le(ee._id),className:Ce.actionButton,children:"Remove from Featured"})]}),{sortBy:I,sortOrder:L,onSort:ye,onViewAll:()=>{u("featured"),ae({filter:"featured"})}})]}),(0,t.jsxs)("div",{className:Ce.section,children:[(0,t.jsx)("h2",{className:Ce.sectionTitle,children:"Staging area"}),(0,t.jsx)("p",{className:Ce.sectionDescription,children:"This area is for the team to edit and review custom KAIs before officially featuring them."}),n.length===0?(0,t.jsx)("div",{children:"No staged custom KAIs"}):ge(n,ee=>(0,t.jsxs)("div",{className:Ce.actions,children:[je(ee._id),(0,t.jsx)("button",{onClick:()=>he(ee._id),className:Ce.actionButton,children:"Delete"}),(0,t.jsx)("button",{onClick:()=>Be(ee._id),className:Ce.actionButton,children:"Add to Featured"})]}),{sortBy:R,sortOrder:k,onSort:Le,onViewAll:()=>{u("staged"),ae({filter:"staged"})}})]}),(0,t.jsxs)("div",{className:Ce.section,children:[(0,t.jsx)("h2",{className:Ce.sectionTitle,children:"All Custom KAIs"}),(0,t.jsx)("p",{className:Ce.sectionDescription,children:"These are all the Custom KAIs that have been created by anyone ever."}),o.length===0?(0,t.jsx)("div",{children:"No custom KAIs found"}):ge(o,ee=>(0,t.jsxs)("div",{className:Ce.actions,children:[je(ee._id),(0,t.jsx)("button",{onClick:()=>he(ee._id),className:Ce.actionButton,children:"Delete"}),(0,t.jsx)("button",{onClick:()=>z(ee),className:Ce.actionButton,children:"Copy to Staging"})]}),{sortBy:E,sortOrder:q,onSort:Ne,onViewAll:()=>{u("all"),ae({filter:"all"})}})]})]}),(0,t.jsx)(eD,{open:!!K,onClose:ee=>{ee&&(a([ee,...n]),Y(He({description:"Custom KAI copied to staging",type:"success"}))),z(null)},customKai:K},K?._id??"stage-custom-kai-modal")]})},nD=sD;const aD="1001",oD="1000",iD="58px",lD="DevMachines-module_container_u3cS2",rD="DevMachines-module_header_m1fcD",dD="DevMachines-module_headerText_DTFmr",cD="DevMachines-module_description_L7HyT",uD="DevMachines-module_content_h3Hso",mD="DevMachines-module_section_g49YF",pD="DevMachines-module_sectionTitle_7804O",hD="DevMachines-module_noResults_MDsKj",fD="DevMachines-module_error_JCRpL",xD="DevMachines-module_listWrapper_lg0t7",gD="DevMachines-module_listHeaderRow_xyizu",vD="DevMachines-module_listRow_o8nIm",_D="DevMachines-module_noHost_dv10M",jD="DevMachines-module_colName_85YGs",bD="DevMachines-module_colHost_NFyaL",yD="DevMachines-module_colCluster_2dCZx",SD="DevMachines-module_colAuthor_dnQeB",CD="DevMachines-module_colDate_-P-gm",ND="DevMachines-module_colCommit_a-ru8",wD="DevMachines-module_colMessage_rEpNC",AD="DevMachines-module_colDeploy_zw8tL",ID="DevMachines-module_clusterBadge_v-2q-",TD="DevMachines-module_clusterDev_IkeWX",kD="DevMachines-module_clusterRotate_tTbNj",RD="DevMachines-module_version_GodRZ",$D="DevMachines-module_author_cOqXl",PD="DevMachines-module_avatar_h-K0P",ED="DevMachines-module_sha_cWECg",LD="DevMachines-module_deployBadge_ny1Wg",BD="DevMachines-module_botBadge_eLcxN",DD="DevMachines-module_resolving_Isg0M",MD="DevMachines-module_muted_pAFPq",FD="DevMachines-module_toolbar_gR1z1",OD="DevMachines-module_filterLabel_AZL6T",qD="DevMachines-module_filterSelect_wsNLV",VD="DevMachines-module_deployIcon_N2sfU",HD="DevMachines-module_deployQueued_r7e31",UD="DevMachines-module_deployRunning_ia3fz",ZD="DevMachines-module_deploySuccess_4gF9W",WD="DevMachines-module_deployFailure_BXpUY",KD="DevMachines-module_spinner_tftkp",GD="DevMachines-module_devMachineSpin_OzExl";var $e={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:aD,paywallBgZIndex:oD,collapsedMediaSidebarWidth:iD,container:lD,header:rD,headerText:dD,description:cD,content:uD,section:mD,sectionTitle:pD,noResults:hD,error:fD,listWrapper:xD,listHeaderRow:gD,listRow:vD,noHost:_D,colName:jD,colHost:bD,colCluster:yD,colAuthor:SD,colDate:CD,colCommit:ND,colMessage:wD,colDeploy:AD,clusterBadge:ID,clusterDev:TD,clusterRotate:kD,version:RD,author:$D,avatar:PD,sha:ED,deployBadge:LD,botBadge:BD,resolving:DD,muted:MD,toolbar:FD,filterLabel:OD,filterSelect:qD,deployIcon:VD,deployQueued:HD,deployRunning:UD,deploySuccess:ZD,deployFailure:WD,spinner:KD,devMachineSpin:GD},ra=Q(ie()),en="",fi=(s,e)=>{if(s.lastCommit?.isBot){const n=e?.[s.name];if(n)return n.login}return s.lastCommit?.authorLogin??s.lastCommit?.authorName??null},JD=s=>{const e=s?.trim()??"",n=e.toLowerCase();return!e||n==="default"||n==="none"?"dev":e},zD=s=>{const e=(0,ra.c)(5),{clusterGroup:n}=s;let a;e[0]!==n?(a=JD(n),e[0]=n,e[1]=a):a=e[1];const o=a,i=o==="dev"?$e.clusterDev:$e.clusterRotate,l=`${$e.clusterBadge} ${i}`;let r;
220return e[2]!==o||e[3]!==l?(r=(0,t.jsx)("span",{className:l,children:o}),e[2]=o,e[3]=l,e[4]=r):r=e[4],r},YD=s=>{const e=(0,ra.c)(7),{status:n}=s;if(!n){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("span",{className:$e.muted,children:"â"}),e[0]=h):h=e[0],h}const{state:a,conclusion:o,url:i}=n;let l="â·",r=$e.deployQueued,d="Deploy queued";if(a==="running"){let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("span",{className:$e.spinner,"aria-hidden":!0}),e[1]=h):h=e[1],l=h,r=$e.deployRunning,d="Deploy running"}else if(a==="complete"){const h=o==="success";l=h?"â":"â",r=h?$e.deploySuccess:$e.deployFailure,d=`Deploy ${o??"complete"}`}const c=`${$e.deployIcon} ${r}`;let m;return e[2]!==l||e[3]!==d||e[4]!==c||e[5]!==i?(m=(0,t.jsx)("a",{className:c,href:i,target:"_blank",rel:"noreferrer",title:d,"aria-label":d,children:l}),e[2]=l,e[3]=d,e[4]=c,e[5]=i,e[6]=m):m=e[6],m},QD=s=>s?new Date(s).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"â",XD=s=>{const e=(0,ra.c)(19),{machine:n,triggeredBy:a,resolvingDeploy:o}=s;if(a){const h=`Deployed via /deploy ${n.name}${a.prNumber?` on #${a.prNumber}`:""}`;let p;e[0]!==a.avatarUrl?(p=a.avatarUrl&&(0,t.jsx)("img",{className:$e.avatar,src:a.avatarUrl,alt:""}),e[0]=a.avatarUrl,e[1]=p):p=e[1];let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)("span",{className:$e.deployBadge,children:"/deploy"}),e[2]=u):u=e[2];let g;return e[3]!==h||e[4]!==p||e[5]!==a.login||e[6]!==a.url?(g=(0,t.jsxs)("a",{className:$e.author,href:a.url,target:"_blank",rel:"noreferrer",title:h,children:[p,a.login,u]}),e[3]=h,e[4]=p,e[5]=a.login,e[6]=a.url,e[7]=g):g=e[7],g}const{lastCommit:i}=n;if(!i){let h;return e[8]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("span",{className:$e.muted,children:"unknown"}),e[8]=h):h=e[8],h}const l=i.authorLogin?`https://github.com/${i.authorLogin}`:i.url;let r;e[9]!==i.avatarUrl?(r=i.avatarUrl&&(0,t.jsx)("img",{className:$e.avatar,src:i.avatarUrl,alt:""}),e[9]=i.avatarUrl,e[10]=r):r=e[10];const d=i.authorLogin??i.authorName;let c;e[11]!==i.isBot||e[12]!==o?(c=i.isBot&&(o?(0,t.jsx)("span",{className:$e.resolving,children:"resolvingâ¦"}):(0,t.jsx)("span",{className:$e.botBadge,children:"bot"})),e[11]=i.isBot,e[12]=o,e[13]=c):c=e[13];let m;return e[14]!==l||e[15]!==r||e[16]!==d||e[17]!==c?(m=(0,t.jsxs)("a",{className:$e.author,href:l,target:"_blank",rel:"noreferrer",children:[r,d,c]}),e[14]=l,e[15]=r,e[16]=d,e[17]=c,e[18]=m):m=e[18],m},xi=s=>{const e=(0,ra.c)(37),{title:n,machines:a,loading:o,error:i,showHostname:l,attribution:r,attributionLoading:d}=s,c=r===void 0?null:r,m=d===void 0?!1:d,h=l?$e.listRow:`${$e.listRow} ${$e.noHost}`,p=l?$e.listHeaderRow:`${$e.listHeaderRow} ${$e.noHost}`;let u;if(o){let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{className:$e.noResults,children:"Loading from GitHubâ¦"}),e[0]=v):v=e[0],u=v}else if(i){let v;e[1]!==i?(v=(0,t.jsx)("div",{className:$e.error,children:i}),e[1]=i,e[2]=v):v=e[2],u=v}else if(a.length===0){let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{className:$e.noResults,children:"No dev machines found."}),e[3]=v):v=e[3],u=v}else{let v,b;e[4]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{className:$e.colName,children:"Machine"}),b=(0,t.jsx)("div",{className:$e.colDeploy,children:"Deploy"}),e[4]=v,e[5]=b):(v=e[4],b=e[5]);let j;e[6]!==l?(j=l&&(0,t.jsx)("div",{className:$e.colCluster,children:"Cluster"}),e[6]=l,e[7]=j):j=e[7];let x;e[8]!==l?(x=l&&(0,t.jsx)("div",{className:$e.colHost,children:"Hostname"}),e[8]=l,e[9]=x):x=e[9];let S,C,y,N;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=(0,t.jsx)("div",{className:$e.colAuthor,children:"Last pushed by"}),y=(0,t.jsx)("div",{className:$e.colDate,children:"When"}),N=(0,t.jsx)("div",{className:$e.colCommit,children:"Deploy commit"}),S=(0,t.jsx)("div",{className:$e.colMessage,children:"Commit message"}),e[10]=S,e[11]=C,e[12]=y,e[13]=N):(S=e[10],C=e[11],y=e[12],N=e[13]);let w;e[14]!==p||e[15]!==j||e[16]!==x?(w=(0,t.jsxs)("div",{className:p,children:[v,b,j,x,C,y,N,S]}),e[14]=p,e[15]=j,e[16]=x,e[17]=w):w=e[17];let A;if(e[18]!==c||e[19]!==m||e[20]!==a||e[21]!==h||e[22]!==l){let D;
220e[24]!==c||e[25]!==m||e[26]!==h||e[27]!==l?(D=L=>{const $=L.lastCommit?.isBot??!1,R=$?c?.[L.name]??null:null,P=$&&!R&&m;return(0,t.jsxs)("div",{className:h,children:[(0,t.jsxs)("div",{className:$e.colName,children:[(0,t.jsx)("a",{href:L.fileUrl,target:"_blank",rel:"noreferrer",children:L.name}),L.deploymentVersion&&L.deploymentVersion!==L.name&&(0,t.jsx)("span",{className:$e.version,children:L.deploymentVersion})]}),(0,t.jsx)("div",{className:$e.colDeploy,children:(0,t.jsx)(YD,{status:L.deployStatus})}),l&&(0,t.jsx)("div",{className:$e.colCluster,children:(0,t.jsx)(zD,{clusterGroup:L.clusterGroup})}),l&&(0,t.jsx)("div",{className:$e.colHost,children:L.webHostname?(0,t.jsx)("a",{href:`https://${L.webHostname}`,target:"_blank",rel:"noreferrer",children:L.webHostname}):(0,t.jsx)("span",{className:$e.muted,children:"â"})}),(0,t.jsx)("div",{className:$e.colAuthor,children:(0,t.jsx)(XD,{machine:L,triggeredBy:R,resolvingDeploy:P})}),(0,t.jsx)("div",{className:$e.colDate,children:QD(L.lastCommit?.date??"")}),(0,t.jsx)("div",{className:$e.colCommit,children:L.deployedCommit?(0,t.jsx)("a",{className:$e.sha,href:L.deployedCommit.url,target:"_blank",rel:"noreferrer",title:L.deployedCommit.message??void 0,children:L.deployedCommit.sha}):(0,t.jsx)("span",{className:$e.muted,children:"â"})}),(0,t.jsx)("div",{className:$e.colMessage,title:L.deployedCommit?.message??void 0,children:L.deployedCommit?.message??(0,t.jsx)("span",{className:$e.muted,children:"â"})})]},L.name)},e[24]=c,e[25]=m,e[26]=h,e[27]=l,e[28]=D):D=e[28],A=a.map(D),e[18]=c,e[19]=m,e[20]=a,e[21]=h,e[22]=l,e[23]=A}else A=e[23];let I;e[29]!==w||e[30]!==A?(I=(0,t.jsxs)("div",{className:$e.listWrapper,children:[w,A]}),e[29]=w,e[30]=A,e[31]=I):I=e[31],u=I}let g;e[32]!==n?(g=(0,t.jsx)("div",{className:$e.sectionTitle,children:n}),e[32]=n,e[33]=g):g=e[33];let _;return e[34]!==u||e[35]!==g?(_=(0,t.jsxs)("div",{className:$e.section,children:[g,u]}),e[34]=u,e[35]=g,e[36]=_):_=e[36],_},e8=()=>{const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)(!0),[o,i]=(0,f.useState)(null),[l,r]=(0,f.useState)(null),[d,c]=(0,f.useState)(!1),[m,h]=(0,f.useState)([]),[p,u]=(0,f.useState)(!0),[g,_]=(0,f.useState)(null),[v,b]=(0,f.useState)(null),[j,x]=(0,f.useState)(null),S=(0,f.useMemo)(()=>s.map($=>({...$,clusterGroup:j?.[$.name]??$.clusterGroup,deployStatus:v?.kapwing[$.name]??$.deployStatus})),[s,j,v]),C=(0,f.useMemo)(()=>m.map($=>({...$,deployStatus:v?.scripts[$.name]??$.deployStatus})),[m,v]),[y,N]=(0,f.useState)(en),w=(0,f.useMemo)(()=>{const $=new Set;return[...s,...m].forEach(R=>{const P=fi(R,l);P&&$.add(P)}),Array.from($).sort((R,P)=>R.localeCompare(P))},[s,m,l]),A=w.includes(y)?y:en,I=$=>A===en||fi($,l)===A,D=S.filter(I),L=C.filter(I);return(0,f.useEffect)(function(){y!==en&&!w.includes(y)&&N(en)},[y,w]),(0,f.useEffect)(function(){H.admin.devMachines.list.query().then(R=>{e(R),i(null);const P=R.flatMap(T=>T.vaultSecretPath?[{name:T.name,vaultSecretPath:T.vaultSecretPath}]:[]);P.length>0&&H.admin.devMachines.clusterGroups.query({machines:P}).then(x).catch(()=>x({}));const k=R.filter(T=>T.lastCommit?.isBot).map(T=>({name:T.name,date:T.lastCommit?.date??""}));if(k.length===0){r({});return}c(!0),H.admin.devMachines.attribution.query({machines:k}).then(r).catch(()=>r({})).finally(()=>c(!1))}).catch(R=>i(R instanceof Error?R.message:"Failed to load")).finally(()=>a(!1))},[]),(0,f.useEffect)(function(){H.admin.devMachines.scriptsList.query().then(R=>{h(R),_(null)}).catch(R=>_(R instanceof Error?R.message:"Failed to load")).finally(()=>u(!1))},[]),(0,f.useEffect)(function(){H.admin.devMachines.deployStatuses.query().then(b).catch(()=>b({kapwing:{},scripts:{}}))},[]),(0,t.jsxs)("div",{className:$e.container,children:[(0,t.jsxs)("div",{className:$e.header,children:[(0,t.jsx)("div",{className:$e.headerText,children:"Dev Machines"}),(0,t.jsxs)("div",{className:$e.description,children:["Dev machines defined in"," ",(0,t.jsx)("a",{href:"https://github.com/kapwing/kapwing-infra/tree/main/charts",target:"_blank",rel:"noreferrer",children:"kapwing-infra"}),", and the person who last pushed to each machine's values file. Bot deploys are attributed to whoever ran"," ",(0,t.jsx)("code",{children:"/deploy <machine>"})," on the triggering PR."]})]}),(0,t.jsxs)("div",{className:$e.content,children:[(0,t.jsxs)("div",{className:$e.toolbar,children:[(0,t.jsx)("label",{className:$e.filterLabel,htmlFor:"devMachinesUserFilter",children:"GitHub user"}),(0,t.jsxs)("select",{id:"devMachinesUserFilter",className:$e.filterSelect,value:A,onChange:$=>N($.target.value),children:[(0,t.jsx)("option",{value:en,children:"All users"}),w.map($=>(0,t.jsx)("option",{value:$,children:$},$))]})]}),(0,t.jsx)(xi,{title:"Kapwing Dev Machines",machines:D,loading:n,error:o,showHostname:!0,attribution:l,attributionLoading:d}),(0,t.jsx)(xi,{title:"Kapwing-Scripts Dev Machines",machines:L,loading:p,error:g,showHostname:!1})]})]})},t8=f.memo(e8);function s8(s){return H.admin.dubbing.create.mutate(s)}function n8(){return H.admin.dubbing.getAll.query()}function a8(s,e){return H.admin.dubbing.update.mutate({id:s,...e})}function Yl(s){return H.admin.dubbing.start.mutate({id:s})}async function o8(s){for(const e of s)await Yl(e)}function i8(s){return H.admin.dubbing.delete.mutate({id:s})}
220const l8="1001",r8="1000",d8="58px",c8="AdminDubbingForm-module_container_Ni1fz",u8="AdminDubbingForm-module_reloadButton_pVZqK";var gi={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:l8,paywallBgZIndex:r8,collapsedMediaSidebarWidth:d8,container:c8,reloadButton:u8};const m8="1001",p8="1000",h8="58px",f8="AllowVideoAdjustments-module_container_VKQGC",x8="AllowVideoAdjustments-module_label_vGUj-";var vi={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:m8,paywallBgZIndex:p8,collapsedMediaSidebarWidth:h8,container:f8,label:x8},g8=Q(ie()),v8=s=>{const e=(0,g8.c)(7),{allowVideoAdjustments:n,setAllowVideoAdjustments:a}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:vi.label,children:(0,t.jsx)(mn,{children:"Allow video adjustments"})}),e[0]=o):o=e[0];let i;e[1]!==n||e[2]!==a?(i=()=>a(!n),e[1]=n,e[2]=a,e[3]=i):i=e[3];let l;return e[4]!==n||e[5]!==i?(l=(0,t.jsxs)("div",{className:vi.container,children:[o,(0,t.jsx)(su,{toggled:n,onClick:i})]}),e[4]=n,e[5]=i,e[6]=l):l=e[6],l},Ql=v8;const _8="1001",j8="1000",b8="58px",y8="AssetPreview-module_container_Yu06g",S8="AssetPreview-module_closeIcon_XIplV",C8="AssetPreview-module_video_5Gm71";var $a={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:_8,paywallBgZIndex:j8,collapsedMediaSidebarWidth:b8,container:y8,closeIcon:S8,video:C8},N8=Q(ie()),w8=s=>{const e=(0,N8.c)(11),{asset:n,onDelete:a}=s,{setVideoRef:o}=ul(n._id);let i;e[0]!==o?(i=(0,t.jsx)("video",{className:$a.video,ref:o,muted:!0,playsInline:!0}),e[0]=o,e[1]=i):i=e[1];let l;e[2]!==n.name?(l=(0,t.jsx)(mn,{children:n.name}),e[2]=n.name,e[3]=l):l=e[3];let r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(io,{color:"white"}),e[4]=r):r=e[4];let d;e[5]!==a?(d=(0,t.jsx)("div",{className:$a.closeIcon,onClick:a,children:r}),e[5]=a,e[6]=d):d=e[6];let c;return e[7]!==i||e[8]!==l||e[9]!==d?(c=(0,t.jsxs)("div",{className:$a.container,children:[i,l,d]}),e[7]=i,e[8]=l,e[9]=d,e[10]=c):c=e[10],c},A8=w8;const I8="1001",T8="1000",k8="58px",R8="OriginalLanguage-module_container_TZM8h",$8="OriginalLanguage-module_labelRow_UuacS";var _i={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:I8,paywallBgZIndex:T8,collapsedMediaSidebarWidth:k8,container:R8,labelRow:$8},P8=Q(ie()),E8=s=>{const e=(0,P8.c)(4),{originalLanguageCode:n,setOriginalLanguageCode:a}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:_i.labelRow,children:(0,t.jsx)(mn,{children:"Original language"})}),e[0]=o):o=e[0];let i;return e[1]!==n||e[2]!==a?(i=(0,t.jsxs)("div",{className:_i.container,children:[o,(0,t.jsx)(Ka,{languageCode:n,setLanguageCode:a,mode:Ja.Transcription,testid:"language-select"})]}),e[1]=n,e[2]=a,e[3]=i):i=e[3],i},Xl=E8;const L8="1001",B8="1000",D8="58px",M8="SubmitButton-module_container_AkaBY";var F8={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:L8,paywallBgZIndex:B8,collapsedMediaSidebarWidth:D8,container:M8},O8=Q(ie()),q8=s=>{const e=(0,O8.c)(5),{onSubmit:n,label:a,disabled:o,disabledReason:i}=s,l=a===void 0?"Dub":a;let r;return e[0]!==o||e[1]!==i||e[2]!==l||e[3]!==n?(r=(0,t.jsx)("div",{className:F8.container,children:(0,t.jsx)(Xs,{onClick:n,label:l,disabled:o,disabledReason:i})}),e[0]=o,e[1]=i,e[2]=l,e[3]=n,e[4]=r):r=e[4],r},to=q8;const V8="1001",H8="1000",U8="58px",Z8="TranslatedLanguage-module_container_DJxZR",W8="TranslatedLanguage-module_labelRow_yLJZX";var ji={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:V8,paywallBgZIndex:H8,collapsedMediaSidebarWidth:U8,container:Z8,labelRow:W8},K8=Xi.map(s=>({label:s,value:iu(s),canBeMultiSelected:Id(s)}));const er=({originalLanguageCode:s,translatedLanguageCode:e,setTranslatedLanguageCode:n})=>{const a=(0,f.useMemo)(()=>K8.filter(i=>{const l=Nd(i.label);if(l===s)return!0;const r=s.split("-")[0];return l.split("-")[0]!==r}),[s]),o=(0,f.useMemo)(()=>a.find(({value:i})=>i===e)??null,[e,a]);return(0,t.jsxs)("div",{className:ji.container,children:[(0,t.jsx)("div",{className:ji.labelRow,children:(0,t.jsx)(mn,{children:"Translation language"})}),(0,t.jsx)(Tu,{currentOption:o,options:a,setOption:i=>i?.value&&n(i.value.toString()),canSearch:!0})]})};const G8="1001",J8="1000",z8="58px",Y8="TranslationProvider-module_container_8vRVA",Q8="TranslationProvider-module_labelRow_S5U-n";var bi={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:G8,paywallBgZIndex:J8,collapsedMediaSidebarWidth:z8,container:Y8,labelRow:Q8},tr=Q(ie()),sr="translation-provider-select-selected-item";function X8(s){const e=(0,tr.c)(26),{translationProviderId:n,setTranslationProviderId:a,backgroundColor:o,hoverBackgroun
220dColor:i,disabled:l,testid:r,className:d}=s,c=o===void 0?"#202020":o,m=i===void 0?"#303030":i,h=l===void 0?!1:l,p=r===void 0?"translation-provider-select":r;let u;e[0]!==a?(u=T=>{T&&a(T?.value)},e[0]=a,e[1]=u):u=e[1];const g=u,_=p6;let v,b;e[2]!==n?(v=Object.values($n).map(m6),b=v.find(T=>T.value===n),e[2]=n,e[3]=v,e[4]=b):(v=e[3],b=e[4]);const j=b;let x,S;e[5]!==c||e[6]!==m?(S=(T,E)=>({...T,background:c,minHeight:"30px",height:"40px",border:"none",cursor:"pointer",opacity:E.isDisabled?"0.4":"1.0","&:hover":{backgroundColor:m}}),e[5]=c,e[6]=m,e[7]=S):S=e[7];let C;e[8]!==c?(C=T=>({...T,backgroundColor:c}),e[8]=c,e[9]=C):C=e[9];let y;e[10]!==S||e[11]!==C?(y={control:S,menuPortal:u6,valueContainer:c6,singleValue:d6,indicatorsContainer:r6,indicatorSeparator:l6,input:i6,menu:C,menuList:o6,option:a6,placeholder:n6},e[10]=S,e[11]=C,e[12]=y):y=e[12],x=y;const N=x,w=t6;let A,I;e[13]===Symbol.for("react.memo_cache_sentinel")?(I={option:e6},e[13]=I):I=e[13],A=I;const D=A;let L;e[14]===Symbol.for("react.memo_cache_sentinel")?(L=Fd()?void 0:cc(),e[14]=L):L=e[14];const $=L,R=`translation-provider-select-input-${p}`;let P;e[15]!==g||e[16]!==h||e[17]!==j||e[18]!==v||e[19]!==N||e[20]!==R?(P=(0,t.jsx)(Nr,{inputId:R,menuPortalTarget:$,value:j,options:v,onChange:g,isSearchable:!fc,isDisabled:h,noOptionsMessage:_,styles:N,classNames:D,onMenuOpen:w}),e[15]=g,e[16]=h,e[17]=j,e[18]=v,e[19]=N,e[20]=R,e[21]=P):P=e[21];let k;return e[22]!==d||e[23]!==P||e[24]!==p?(k=(0,t.jsx)("div",{"data-testid":p,className:d,children:P}),e[22]=d,e[23]=P,e[24]=p,e[25]=k):k=e[25],k}function e6(s){return s.isSelected?sr:""}function t6(){setImmediate(s6)}function s6(){const s=document?.getElementsByClassName(sr)?.item(0);s&&s.scrollIntoView({block:"center"})}function n6(s){return{...s,fontFamily:"Open Sans",fontStyle:"normal",fontWeight:"600",fontSize:"12px",color:"#A0A0A0"}}function a6(s,e){const{isFocused:n}=e;return{...s,fontFamily:"Open Sans",fontStyle:"normal",fontWeight:"600",fontSize:"12px",color:"white",backgroundColor:n?"#0083e2":""}}function o6(s){return{...s,zIndex:_l()+1}}function i6(s){return{...s,fontFamily:"Open Sans",fontStyle:"normal",fontWeight:"normal",fontSize:"12px",color:"white"}}function l6(){return{display:"none"}}function r6(s){return{...s,height:"40px"}}function d6(s){return{...s,fontFamily:"Open Sans",fontStyle:"normal",fontWeight:"600",fontSize:"12px",color:"white"}}function c6(s){return{...s,height:"30px",padding:"0 10px"}}function u6(s){return{...s,zIndex:_l()+1,pointerEvents:"all"}}function m6(s){return{value:s,label:s}}function p6(){return(0,t.jsx)("div",{style:{fontFamily:"Open Sans",fontStyle:"normal",fontWeight:"normal",fontSize:"12px",color:"white"},children:"Provider not available"})}var h6=s=>{const e=(0,tr.c)(4),{translationProviderId:n,setTranslationProviderId:a}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:bi.labelRow,children:(0,t.jsx)(mn,{children:"Translation Provider"})}),e[0]=o):o=e[0];let i;return e[1]!==a||e[2]!==n?(i=(0,t.jsxs)("div",{className:bi.container,children:[o,(0,t.jsx)(X8,{translationProviderId:n,setTranslationProviderId:a,testid:"language-select"})]}),e[1]=a,e[2]=n,e[3]=i):i=e[3],i},nr=h6;const f6="1001",x6="1000",g6="58px",v6="UploadAsset-module_container_IuGh3";var _6={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:f6,paywallBgZIndex:x6,collapsedMediaSidebarWidth:g6,container:v6},j6=Q(ie()),yi=()=>{},b6=s=>{const e=(0,j6.c)(8),{setAssetId:n}=s;let a,o;e[0]!==n?(a=d=>{const c=d[0];c&&n(c)},o=d=>{n(d)},e[0]=n,e[1]=a,e[2]=o):(a=e[1],o=e[2]);let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i={audioUpload:!0},e[3]=i):i=e[3];let l;e[4]===Symbol.for("react.memo_cache_sentinel")?(l={analyticsUploadSource:"Blank studio",uploadSourceComponent:"AdminDubbingForm",skipCMLCreation:!1,doDuplicateHandling:!1,skipAddTimelineLayer:!1,isMediaLibraryUpload:!0},e[4]=l):l=e[4];let r;return e[5]!==a||e[6]!==o?(r=(0,t.jsx)("div",{className:_6.container,children:(0,t.jsx)(vu,{assetThumbnail:null,handleRemoveAsset:yi,handleFileUploadFinish:a,handlePasteLinkFinish:o,theme:"dark",multiple:!1,loadingStyle:"poster",validationOptions:i,setUploadValidationInfo:yi,uploadOptions:l})}),e[5]=a,e[6]=o,e[7]=r):r=e[7],r},y6=b6,S6=Q(ie()),C6=s=>
220new Promise((e,n)=>{const a=document.createElement("video");a.src=s,a.preload="metadata",a.onloadedmetadata=()=>{e(a.duration)},a.onerror=()=>{n()}}),N6=async s=>{const e=await vc(s,Cs.dubbing);if(e.url&&!e.duration)try{const n=await C6(e.url);await bc(e._id,{duration:n})}catch(n){console.error(n)}},w6=s=>{const e=(0,S6.c)(27),{refetch:n,onDubAll:a,hasItems:o}=s,i=ys(I6),[l,r]=f.useState(null),[d,c]=(0,f.useState)("en-US"),[m,h]=(0,f.useState)("en-US"),[p,u]=(0,f.useState)($n.ChatGPT),[g,_]=(0,f.useState)(!1),[v,b]=(0,f.useState)(!1);let j;e[0]!==l?(j=$=>$.assets.byId[l??""],e[0]=l,e[1]=j):j=e[1];const x=ys(j);let S,C;e[2]!==l?(S=()=>{l&&N6(l)},C=[l],e[2]=l,e[3]=S,e[4]=C):(S=e[3],C=e[4]),(0,f.useEffect)(S,C);let y;e[5]!==a||e[6]!==n?(y=async()=>{b(!0);try{await a()}catch($){console.error($)}b(!1),n()},e[5]=a,e[6]=n,e[7]=y):y=e[7];const N=y;let w;e[8]!==g||e[9]!==x||e[10]!==i||e[11]!==d||e[12]!==n||e[13]!==m||e[14]!==p?(w=async()=>{if(!x)return;b(!0);const $=new bu({name:x.name??x.blob_name??"Dubbed Video",creatorId:i.user._id,teamId:gu,workspaceId:pu,aspectRatio:{width:x.dimensions?.width??1,height:x.dimensions?.height??1}});$.createVideoFromAsset(x);const{videoId:R}=await au({video:$.video});await s8({originalVideoId:R,originalLanguageCode:d,translatedLanguageCode:m,translationProviderId:p,allowVideoAdjustments:g}),r(null),b(!1),n()},e[8]=g,e[9]=x,e[10]=i,e[11]=d,e[12]=n,e[13]=m,e[14]=p,e[15]=w):w=e[15];const A=w;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=async()=>{r(null)},e[16]=I):I=e[16];const D=I;if(v){let $;return e[17]===Symbol.for("react.memo_cache_sentinel")?($=(0,t.jsx)("div",{className:gi.container,children:(0,t.jsx)(mn,{children:"Loading..."})}),e[17]=$):$=e[17],$}let L;return e[18]!==g||e[19]!==x||e[20]!==o||e[21]!==N||e[22]!==A||e[23]!==d||e[24]!==m||e[25]!==p?(L=(0,t.jsx)("div",{className:gi.container,children:x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(A8,{asset:x,onDelete:D}),(0,t.jsx)(Xl,{originalLanguageCode:d,setOriginalLanguageCode:c}),(0,t.jsx)(er,{originalLanguageCode:d,translatedLanguageCode:m,setTranslatedLanguageCode:h}),(0,t.jsx)(nr,{translationProviderId:p,setTranslationProviderId:u}),(0,t.jsx)(Ql,{allowVideoAdjustments:g,setAllowVideoAdjustments:_}),(0,t.jsx)(to,{onSubmit:A,disabled:!x.duration,disabledReason:"Asset is still processing"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(y6,{setAssetId:r}),(0,t.jsx)("br",{}),o&&(0,t.jsx)(to,{onSubmit:N,label:"Re-dub all videos"})]})}),e[18]=g,e[19]=x,e[20]=o,e[21]=N,e[22]=A,e[23]=d,e[24]=m,e[25]=p,e[26]=L):L=e[26],L},A6=w6;function I6(s){return s.currentUser}const T6="1001",k6="1000",R6="58px",$6="AdminDubbingList-module_container_kHLsQ",P6="AdminDubbingList-module_list_OGYFZ";var Si={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:T6,paywallBgZIndex:k6,collapsedMediaSidebarWidth:R6,container:$6,list:P6};const E6="1001",L6="1000",B6="58px",D6="AdminDubbingListItem-module_container_eEULM",M6="AdminDubbingListItem-module_row_abUES",F6="AdminDubbingListItem-module_dubbedVideos_VqrOX";var Pa={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:E6,paywallBgZIndex:L6,collapsedMediaSidebarWidth:B6,container:D6,row:M6,dubbedVideos:F6};const O6="1001",q6="1000",V6="58px",H6="DeleteButton-module_container_nljp3";var U6={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:O6,paywallBgZIndex:q6,collapsedMediaSidebarWidth:V6,container:H6},Z6=Q(ie());const W6=s=>{const e=(0,Z6.c)(5),{onDelete:n,disabled:a}=s;let o;e[0]!==n?(o=()=>{window.confirm("Are you sure you want to delete the original video and all dubbed videos?")&&n()},e[0]=n,e[1]=o):o=e[1];const i=o;let l;return e[2]!==a||e[3]!==i?(l=(0,t.jsx)("div",{className:U6.container,children:(0,t.jsx)(rs,{label:"Delete",onClick:i,color:"danger",isLoading:a,disabled:a})}),e[2]=a,e[3]=i,e[4]=l):l=e[4],l};var K6=W6;const G6="1001",J6="1000",z6="58px",Y6="DubbingStatus-module_status_MMTtM",Q6="DubbingStatus-module_success_m8nm-",X6="DubbingStatus-module_ready_8e6mf",eM="DubbingStatus-module_running_hW3qC",tM="DubbingStatus-module_canceled_puLEK",sM="DubbingStatus-module_failed_NfTA-";var tn={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:G6,paywallBgZIndex:J6,collapsedMediaSidebarWidth:z6,status:Y6,success:Q6,ready:X6,running:eM,canceled:tM,failed:sM},nM=Q(ie());function aM(s){const e=(0,nM.c)(14),{video:n,fetchVideo:a}=s,o=(0,f.useRef)(!1),{workflowMonitor:i,workflowStatus:l}=n,r=i?.idsToMonitor?.map(b=>l?.byId?.[b])?.find(gc),d=r?.status===ln.COMPLETE,c=Pd(r?.status||ln.FAILED),m=r?.status===ln.CANCELED,h=!d&&!c&&!m;let p,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=()=>(o.current=!0,()=>{o.current=!1}),u=[],e[0]=p,e[1]=u):(p=e[0],u=e[1]),(0,f.useEffect)(p,u);let g;e[2]!==a?(g=()=>{o.current&&a()},e[2]=a,e[3]=g):g=e[3];let _;if(e[4]!==h||e[5]!==g?(_={intervalMs:5e3,callback:g,shouldPoll:h},e[4]=h,e[5]=g,e[6]=_):_=e[6],xo(_),!r){if(!Object.values(l?.byId||{}).length)return null;let b;return e[7]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("div",{className:tn.success,children:"Complete"}),e[7]=b):b=e[7],b}if(c){let b;return e[8]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("div",{className:tn.failed,children:"Failed"}),e[8]=b):b=e[8],b}if(m){let b;return e[9]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("div",{className:tn.canceled,children:"Canceled"}),e[9]=b):b=e[9],b}if(h){const b=r?.stageProgress,j=C=>{const y=Object.keys(b||{}).find(N=>N.includes(C));return y&&!!b?.[y]?.endTime};let x="Dubbing";b?j(Us.TRANSCRIBE)?j(Us.TRANSLATE)?j(Us.SPLIT_VOCALS)?j(Us.VOICE_CLONE)?j(Us.DUBBING_TTS)?j(Us.DUBBING_PLAYBACK)||(x="Playback"):x="TTS":x="Cloning":x="Vocals":x="Translating":x="Transcribing":x="Starting";let S;return e[10]!==x?(S=(0,t.jsx)("div",{className:tn.running,children:x}),e[10]=x,e[11]=S):S=e[11],S}if(d){let b;return e[12]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("div",{className:tn.ready,children:"Ready"}),e[12]=b):b=e[12],b}let v;return e[13]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("div",{className:tn.success,children:"Complete"}),e[13]=v):v=e[13],v}var oM=aM;const iM="1001",lM="1000",rM="58px",dM="VideoLink-module_container_vU5TH",cM="VideoLink-module_buttonWrapper_BiHz-",uM="VideoLink-module_top_pRuSL",mM="VideoLink-module_bottom_cZVYi",pM="VideoLink-module_backgroundThumbnail_Wa1vA",hM="VideoLink-module_thumbnailOverlay_dJHQx",fM="VideoLink-module_icon_sb1HY",xM="VideoLink-module_timestamp_lXqfH",gM="VideoLink-module_created_Hvrx-",vM="VideoLink-module_status_ADrwe",_M="VideoLink-module_name_Dnzr7";var Gt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:iM,paywallBgZIndex:lM,collapsedMediaSidebarWidth:rM,container:dM,buttonWrapper:cM,top:uM,bottom:mM,backgroundThumbnail:pM,thumbnailOverlay:hM,icon:fM,timestamp:xM,created:gM,status:vM,name:_M},jM=Q(ie()),Ea=new Map;
220function bM(s){return new Promise((e,n)=>{if(Ea.has(s)){const i=Ea.get(s);if(i){e(i);return}}const a=document.createElement("video"),o=document.createElement("canvas");a.crossOrigin="anonymous",a.src=s,a.style.display="none",a.preload="metadata",a.addEventListener("loadeddata",function(){a.currentTime=1}),a.addEventListener("seeked",function(){const i=o.getContext("2d");o.width=a.videoWidth,o.height=a.videoHeight,i?.drawImage(a,0,0,o.width,o.height);const l=o.toDataURL("image/png");Ea.set(s,l),e(l)}),a.addEventListener("error",function(){n()}),document.body.appendChild(a),a.load()})}function yM(s){const e=String(s.getDate()).padStart(2,"0");return`${String(s.getMonth()+1).padStart(2,"0")}/${e}/${s.getFullYear()} ${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}:${String(s.getSeconds()).padStart(2,"0")}`}const SM=s=>{const e=(0,jM.c)(41),{videoId:n}=s,[a,o]=f.useState(),[i,l]=f.useState();let r;e[0]!==a?.allLayers.byId?(r=Object.values(a?.allLayers.byId??{}),e[0]=a?.allLayers.byId,e[1]=r):r=e[1];const d=r[0],c=d?.asset_id;let m;e[2]!==d||e[3]!==c||e[4]!==i?(m=async()=>{if(i||!c)return;const T=await aa(c,Cs.dubbing),E=rl({asset:T,timelineLayer:d,idbAsset:null});if(E)l(E);else{const O=T?.url;if(O)try{l(await bM(O))}catch(q){console.error("Failed to fetch video thumbnail",q)}}},e[2]=d,e[3]=c,e[4]=i,e[5]=m):m=e[5];const h=m;let p;e[6]!==n?(p=async()=>{o((await H.video.getVideo.query({id:n})).video)},e[6]=n,e[7]=p):p=e[7];const u=p;let g,_;e[8]!==h?(g=()=>{h()},_=[h],e[8]=h,e[9]=g,e[10]=_):(g=e[9],_=e[10]),(0,f.useEffect)(g,_);let v,b;if(e[11]!==u?(v=()=>{u()},b=[u],e[11]=u,e[12]=v,e[13]=b):(v=e[12],b=e[13]),(0,f.useEffect)(v,b),!a)return null;const j=a.duration,x=a.name??n,S=`/${n}/studio/editor/subtitles`;let C;e[14]!==i?(C=(0,t.jsx)("div",{className:Gt.backgroundThumbnail,children:(0,t.jsx)(kc,{thumbnailUrl:i,elementType:Qi.VIDEO})}),e[14]=i,e[15]=C):C=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsx)("div",{className:Gt.icon,children:(0,t.jsx)(Zr,{})}),e[16]=y):y=e[16];let N;e[17]!==j?(N=yc(Math.round(j)),e[17]=j,e[18]=N):N=e[18];let w;e[19]!==N?(w=(0,t.jsx)("div",{className:Gt.timestamp,children:N}),e[19]=N,e[20]=w):w=e[20];const A=a.createdAt??"";let I;e[21]!==A?(I=yM(new Date(A)),e[21]=A,e[22]=I):I=e[22];let D;e[23]!==I?(D=(0,t.jsx)("div",{className:Gt.created,children:I}),e[23]=I,e[24]=D):D=e[24];let L;e[25]!==u||e[26]!==a?(L=(0,t.jsx)("div",{className:Gt.status,children:(0,t.jsx)(oM,{video:a,fetchVideo:u})}),e[25]=u,e[26]=a,e[27]=L):L=e[27];let $;e[28]!==w||e[29]!==D||e[30]!==L?($=(0,t.jsxs)("div",{className:Gt.thumbnailOverlay,children:[y,w,D,L]}),e[28]=w,e[29]=D,e[30]=L,e[31]=$):$=e[31];let R;e[32]!==$||e[33]!==C?(R=(0,t.jsxs)("div",{className:Gt.top,children:[C,$]}),e[32]=$,e[33]=C,e[34]=R):R=e[34];let P;e[35]!==x?(P=(0,t.jsx)("div",{className:Gt.bottom,children:(0,t.jsx)("div",{className:Gt.name,children:x})}),e[35]=x,e[36]=P):P=e[36];let k;return e[37]!==R||e[38]!==P||e[39]!==S?(k=(0,t.jsxs)("a",{href:S,target:"_blank",rel:"noopener noreferrer",className:Gt.container,children:[R,P]}),e[37]=R,e[38]=P,e[39]=S,e[40]=k):k=e[40],k};var Ci=SM;function CM({refetch:s,item:e,index:n}){const[a,o]=(0,f.useState)(e.originalLanguageCode),[i,l]=(0,f.useState)(e.translatedLanguageCode),[r,d]=(0,f.useState)(e.allowVideoAdjustments),[c,m]=(0,f.useState)(e.translationProviderId||$n.ChatGPT),[h,p]=(0,f.useState)(!1),u=(0,f.useMemo)(()=>e.dubbedVideoIds.toReversed(),[e.dubbedVideoIds]);(0,f.useEffect)(()=>{(a!==e.originalLanguageCode||i!==e.translatedLanguageCode||r!==e.allowVideoAdjustments||c!==e.translationProviderId)&&a8(e._id,{originalLanguageCode:a,translatedLanguageCode:i,allowVideoAdjustments:r,translationProviderId:c})},[a,i,r,c,e.originalLanguageCode,e.translatedLanguageCode,e.allowVideoAdjustments,e.translationProviderId,e._id]);const g=async()=>{p(!0);try{await Yl(e._id)}catch(v){console.error(v)}p(!1),s()},_=async()=>{p(!0);try{await i8(e._id)}catch(v){console.error(v)}p(!1),s()};return(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:n+1}),(0,t.jsx)("td",{className:Pa.dubbedVideos,children:(0,t.jsx)(Ci,{videoId:e.originalVideoId})}),(0,t.jsxs)("td",{children:[(0,t.jsx)(Xl,{originalLanguageCode:a,setOriginalLanguageCode:o}),(0,t.jsx)(er,{originalLanguageCode:a,translatedLanguageCode:i,setTranslatedLanguageCode:l}),(0,t.jsx)(nr,{translationProviderId:c,setTranslationProviderId:m}),(0,t.jsx)(Ql,{allowVideoAdjustments:r,setAllowVideoAdjustments:d}),(0,t.jsxs)("div",{className:Pa.row,children:[(0,t.jsx)(K6,{onDelete:_,disabled:h}),(0,t.jsx)(to,{onSubmit:g,disabled:h,label:"Re-dub"})]})]}),(0,t.jsx)("td",{className:Pa.dubbedVideos,children:u.map(v=>(0,t.jsx)(Ci,{videoId:v},v))})]})}var NM=Q(ie());function wM(s){const e=(0,NM.c)(9),{refetch:n,items:a}=s;if(!a.length)return null;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Original Video"}),(0,t.jsx)("th",{children:"Settings"}),(0,t.jsx)("th",{children:"Dubbed Videos"})]})}),e[0]=o):o=e[0];let i;if(e[1]!==a||e[2]!==n){let r;e[4]!==a.length||e[5]!==n?(r=(d,c)=>(0,t.jsx)(CM,{item:d,refetch:n,index:a.length-c-1},d._id),e[4]=a.length,e[5]=n,e[6]=r):r=e[6],i=a.map(r),e[1]=a,e[2]=n,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=(0,t.jsx)("div",{className:Si.container,children:(0,t.jsxs)("table",{className:Si.list,children:[o,(0,t.jsx)("tbody",{children:i})]})}),e[7]=i,e[8]=l):l=e[8],l}const AM="1001",IM="1000",TM="58px",kM="Dubbing-module_container_Dkab-";var RM={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:AM,paywallBgZIndex:IM,collapsedMediaSidebarWidth:TM,container:kM},$M=Q(ie());const PM=()=>{const s=(0,$M.c)(14);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],s[0]=e):e=s[0];const[n,a]=f.useState(e);let o;s[1]===Symbol.for("react.memo_cache_sentinel")?(o=async()=>{a(await n8())},s[1]=o):o=s[1];const i=o;let l,r;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{i()},r=[i],s[2]=l,s[3]=r):(l=s[2],r=s[3]),(0,f.useEffect)(l,r);let d;s[4]!==n?(d=async()=>{a([]);try{await o8(n.map(EM))}catch(g){console.error(g)}await i()},s[4]=n,s[5]=d):d=s[5];const c=d,m=n.length>0;let h;s[6]!==c||s[7]!==m?(h=(0,t.jsx)(A6,{refetch:i,onDubAll:c,hasItems:m}),s[6]=c,s[7]=m,s[8]=h):h=s[8];let p;s[9]!==n?(p=(0,t.jsx)(wM,{items:n,refetch:i}),s[9]=n,s[10]=p):p=s[10];let u;return s[11]!==h||s[12]!==p?(u=(0,t.jsxs)("div",{className:RM.container,children:[h,p]}),s[11]=h,s[12]=p,s[13]=u):u=s[13],u};function EM(s){return s._id}const LM="AdminDebugDubbingWorkflow-module_container_ChEkZ",BM="AdminDebugDubbingWorkflow-module_translateResults_UHQ5w",DM="AdminDebugDubbingWorkflow-module_chunkRow_wHwD1",MM="AdminDebugDubbingWorkflow-module_chunkGroup_zxIVO",FM="AdminDebugDubbingWorkflow-module_chunkTime_JBQeu",OM="AdminDebugDubbingWorkflow-module_wordsContainer_n3dsp",qM="AdminDebugDubbingWorkflow-module_workflowSection_XVmq9",VM="AdminDebugDubbingWorkflow-module_workflowSelectLabel_Y9ygp",HM="AdminDebugDubbingWorkflow-module_workflowSelect_U3K-M",UM="AdminDebugDubbingWorkflow-module_workflowJson_-JdT1";var qt={container:LM,translateResults:BM,chunkRow:DM,chunkGroup:MM,chunkTime:FM,wordsContainer:OM,workflowSection:qM,workflowSelectLabel:VM,workflowSelect:HM,workflowJson:UM},ZM=Q(ie()),WM=()=>{const s=(0,ZM.c)(37),{workflowId:e}=Ys(),n=Lt(),[a,o]=(0,f.useState)(""),[i,l]=(0,f.useState)(null),[r,d]=(0,f.useState)(),[c,m]=(0,f.useState)(!1),[h,p]=(0,f.useState)(!1),[u,g]=(0,f.useState)(null);let _,v;if(s[0]!==e?(_=()=>{(async function(){if(!e)return;const E=(await H.workflows.adminGetDubbingWorkflow.query({workflowId:e}))[0];if(!E){console.error("Workflow not found");return}l(E);const{workflow:O}=E;o(O?.videoId.toString()||"");const q=O.stages.find(GM);if(!q){console.error("Translate stage not found in workflow");return}const J=kd(q),K=O.stageProgress?.[J]?.result?.toString();if(!K){console.error("Stage result ID not found");return}const{result:z}=await H.workflows.getWorkflowStageResult.query({stageResultId:K});z&&$d(z)&&d(z)})()},v=[e],s[0]=e,s[1]=_,s[2]=v):(_=s[1],v=s[2]),(0,f.useEffect)(_,v),!r){let T;return s[3]===Symbol.for("react.memo_cache_sentinel")?(T=(0,t.jsx)("div",{children:"Loading..."}),s[3]=T):T=s[3],T}let b;s[4]!==r?(b=()=>r?Object.keys(r).map((T,E)=>(0,t.jsx)("button",{onClick:()=>g(T),children:T}
220,E)):null,s[4]=r,s[5]=b):b=s[5];const j=b,x=zM;let S;s[6]!==r?.wordChunks||s[7]!==u?(S=()=>{if(!u)return(0,t.jsx)("div",{children:"choose a language"});const T=r?.wordChunks;return T?(0,t.jsx)("div",{children:T.map((E,O)=>{const q=E.originalWords[0],J=E.originalWords[E.originalWords.length-1],K=E.translatedWords?.[0],z=E.translatedWords?.[E.translatedWords.length-1];return(0,t.jsxs)("div",{className:qt.chunkRow,children:[(0,t.jsxs)("div",{className:qt.chunkGroup,children:[(0,t.jsx)("div",{className:qt.chunkTime,children:q?.start_time}),x(E.originalWords),(0,t.jsx)("div",{className:qt.chunkTime,children:J?.end_time})]}),(0,t.jsxs)("div",{className:qt.chunkGroup,children:[(0,t.jsx)("div",{className:qt.chunkTime,children:K?.start_time}),x(E.translatedWords||[]),(0,t.jsx)("div",{className:qt.chunkTime,children:z?.end_time})]})]},O)})}):(0,t.jsx)("div",{children:"No words found for this language."})},s[6]=r?.wordChunks,s[7]=u,s[8]=S):S=s[8];const C=S;let y;s[9]!==j||s[10]!==C||s[11]!==r||s[12]!==u?(y=()=>r?(0,t.jsxs)("div",{className:qt.translateResults,children:[(0,t.jsx)("h2",{children:"Translate Results"}),(0,t.jsx)("p",{children:"click a word to console log"}),j(),u&&C()]}):null,s[9]=j,s[10]=C,s[11]=r,s[12]=u,s[13]=y):y=s[13];const N=y;let w;s[14]!==i||s[15]!==h?(w=()=>!i||!h?null:(0,t.jsx)("pre",{className:qt.workflowJson,children:JSON.stringify(i.workflow,null,2)}),s[14]=i,s[15]=h,s[16]=w):w=s[16];const A=w;let I,D;s[17]===Symbol.for("react.memo_cache_sentinel")?(I=(0,t.jsx)("h1",{children:"Admin Debug Dubbing Workflow"}),D=(0,t.jsx)("p",{children:"This page is for debugging the dubbing workflow in the admin panel."}),s[17]=I,s[18]=D):(I=s[17],D=s[18]);let L;s[19]!==n||s[20]!==a?(L=a?(0,t.jsxs)("a",{onClick:()=>{n(`/${a}/studio/editor`)},children:["Video ID: ",a]}):(0,t.jsx)("div",{children:"Video ID not found"}),s[19]=n,s[20]=a,s[21]=L):L=s[21];let $;s[22]!==c||s[23]!==r?($=r?(0,t.jsx)("button",{onClick:()=>m(!c),children:"Toggle translate results"}):"no translate results found",s[22]=c,s[23]=r,s[24]=$):$=s[24];let R;s[25]!==N||s[26]!==c?(R=c&&N(),s[25]=N,s[26]=c,s[27]=R):R=s[27];let P;s[28]!==i||s[29]!==A||s[30]!==h?(P=i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{onClick:()=>p(!h),children:"Toggle Show Workflow Object"}),A()]}):null,s[28]=i,s[29]=A,s[30]=h,s[31]=P):P=s[31];let k;return s[32]!==R||s[33]!==P||s[34]!==L||s[35]!==$?(k=(0,t.jsxs)("div",{className:qt.container,children:[I,D,L,$,R,P]}),s[32]=R,s[33]=P,s[34]=L,s[35]=$,s[36]=k):k=s[36],k},KM=WM;function GM(s){return s.type===Us.TRANSLATE}function JM(s,e){return(0,t.jsx)("span",{onClick:()=>{console.info(s)},children:`${s.word} `},e)}function zM(s){return(0,t.jsx)("div",{className:qt.wordsContainer,children:s.map(JM)})}const YM="1001",QM="1000",XM="58px",eF="ExportSpeed-module_page_G8LaZ",tF="ExportSpeed-module_header_2u6Wv",sF="ExportSpeed-module_subtitle_t2Ziu",nF="ExportSpeed-module_sectionLabel_0xiaZ",aF="ExportSpeed-module_verdict_zHnJ-",oF="ExportSpeed-module_verdictPass_Bz4-t",iF="ExportSpeed-module_verdictFail_64ruz",lF="ExportSpeed-module_verdictValue_k8lq2",rF="ExportSpeed-module_verdictDetail_Mu8Od",dF="ExportSpeed-module_pathCards_1ARy-",cF="ExportSpeed-module_tiles_R0XHH",uF="ExportSpeed-module_card_sEQ8Y",mF="ExportSpeed-module_cardHead_pCsgu",pF="ExportSpeed-module_cardBig_UiSCV",hF="ExportSpeed-module_cardSub_18l6F",fF="ExportSpeed-module_flat_D2Bqt",xF="ExportSpeed-module_good_mxjLs",gF="ExportSpeed-module_tile_v7MLV",vF="ExportSpeed-module_tileLabel_42AFw",_F="ExportSpeed-module_tileValue_UrvRM",jF="ExportSpeed-module_controls_ZYrMj",bF="ExportSpeed-module_note_zC8ak",yF="ExportSpeed-module_table_6MmX-",SF="ExportSpeed-module_project_GZLGE",CF="ExportSpeed-module_muted_O24EO",NF="ExportSpeed-module_bad_8CX5e",wF="ExportSpeed-module_warnIcon_QvfGc",AF="ExportSpeed-module_jobsLink_zZhgb",IF="ExportSpeed-module_caret_szI6n",TF="ExportSpeed-module_cellSub_88rKL",kF="ExportSpeed-module_renderRow_4zizL",RF="ExportSpeed-module_runLabel_00MBT",$F="ExportSpeed-module_warning_FA1PH",PF="ExportSpeed-module_specs_zOQds",EF="ExportSpeed-module_specNote_mxt69",LF="ExportSpeed-module_rawJson_Acnee";var Re={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:YM,paywallBgZIndex:QM,collapsedMediaSidebarWidth:XM,page:eF,header:tF,subtitle:sF,sectionLabel:nF,verdict:aF,verdictPass:oF,verdictFail:iF,verdictValue:lF,verdictDetail:rF,pathCards:dF,tiles:cF,card:uF,cardHead:mF,cardBig:pF,cardSub:hF,flat:fF,good:xF,tile:gF,tileLabel:vF,tileValue:_F,controls:jF,note:bF,table:yF,project:SF,muted:CF,bad:NF,warnIcon:wF,jobsLink:AF,caret:IF,cellSub:TF,renderRow:kF,runLabel:RF,warning:$F,specs:PF,specNote:EF,rawJson:LF},BF=Q(ie()),Rn=s=>s==null?"â":`${Math.round(s)}s`,$t=(s,e=1)=>s==null?"â":s.toFixed(e),Zs=s=>s==null?"â":s>=0?`â${Math.round(s)}%`:`+${Math.round(-s)}
220%`,Ni=s=>s==null?Re.muted:s>=30?Re.good:s<=-2?Re.bad:Re.muted,DF=()=>{const s=(0,BF.c)(37);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],s[0]=e):e=s[0];const[n,a]=(0,f.useState)(e),[o,i]=(0,f.useState)(""),[l,r]=(0,f.useState)(""),[d,c]=(0,f.useState)(null),[m,h]=(0,f.useState)(null);let p;s[1]===Symbol.for("react.memo_cache_sentinel")?(p=new Set,s[1]=p):p=s[1];const[u,g]=(0,f.useState)(p),[_,v]=(0,f.useState)(!1);let b;s[2]===Symbol.for("react.memo_cache_sentinel")?(b=K=>{g(z=>{const Y=new Set(z);return Y.has(K)?Y.delete(K):Y.add(K),Y})},s[2]=b):b=s[2];const j=b;let x,S;s[3]===Symbol.for("react.memo_cache_sentinel")?(x=function(){H.admin.exportSpeed.listRuns.query().then(z=>{a(z);const Y=z[0];Y&&i(Y.label)}).catch(FF)},S=[],s[3]=x,s[4]=S):(x=s[3],S=s[4]),(0,f.useEffect)(x,S);let C;s[5]===Symbol.for("react.memo_cache_sentinel")?(C=(K,z)=>{K&&(v(!0),H.admin.exportSpeed.report.query({label:K,baseline_label:z||void 0}).then(Y=>{c(Y.report),h(Y.baseline_label),r(me=>me||Y.baseline_label)}).catch(OF).finally(()=>v(!1)))},s[5]=C):C=s[5];const y=C;let N,w;s[6]!==l||s[7]!==o?(N=function(){y(o,l)},w=[o,l,y],s[6]=l,s[7]=o,s[8]=N,s[9]=w):(N=s[8],w=s[9]),(0,f.useEffect)(N,w);let A,I;s[10]!==d?(I=d?Math.max(0,...d.projects.map(qF)):null,s[10]=d,s[11]=I):I=s[11],A=I;const D=A;let L,$;s[12]!==d?($=d?Math.max(0,...d.projects.map(VF)):null,s[12]=d,s[13]=$):$=s[13],L=$;const R=L;let P;s[14]===Symbol.for("react.memo_cache_sentinel")?(P=(0,t.jsx)(be,{to:"/admin",children:"Back to Admin"}),s[14]=P):P=s[14];let k;s[15]===Symbol.for("react.memo_cache_sentinel")?(k=(0,t.jsx)("div",{className:Re.header,children:(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{children:"Export speed benchmark"}),(0,t.jsx)("div",{className:Re.subtitle,children:"Build time and quality across the benchmark project set"})]})}),s[15]=k):k=s[15];let T;s[16]===Symbol.for("react.memo_cache_sentinel")?(T=(0,t.jsxs)("details",{className:Re.specs,children:[(0,t.jsx)("summary",{children:"Video dataset specifications"}),(0,t.jsx)("p",{children:"9 projects = 3 archetypes à the render paths they take, chosen to cover the export types that make up most of the fleet's render time. One project per render path so a win generalizes across the whole category."}),(0,t.jsx)("h4",{children:"Group A â Multi-layer overlap + subtitles"}),(0,t.jsx)("p",{className:Re.specNote,children:"Several overlapping visual layers plus animated subtitles. Heaviest common archetype (~18.5% of jobs, ~33% of render time)."}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"A-ffmpeg"})," (ffmpeg-single) â overlapping layers + subtitle burn-in composited in one ffmpeg filtergraph."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"A-multimachine"})," (multimachine) â a long/heavy export split into segments across machines and merged; stresses split/merge coordination, not just encode."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"A-canvas"})," (canvas) â animated subtitles + overlapping layers rendered frame-by-frame through the canvas/puppeteer path."]})]}),(0,t.jsx)("h4",{children:"Group B â Single-video + subtitles"}),(0,t.jsx)("p",{className:Re.specNote,children:"One video layer with burned-in subtitles. Highest-volume archetype (~24.7% of jobs, ~24% of render time); 86% take ffmpeg-single, so the three rows span its typical weight range rather than different paths."}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"B-light"})," (p30) â lighter/shorter single-clip + subtitle export."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"B-median"})," (p50) â the median single-clip + subtitle export."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"B-heavy"})," (p70) â heavier single-clip + subtitle export."]})]}),(0,t.jsx)("h4",{children:"Group C â Multi-layer overlap, no subtitles"}),(0,t.jsx)("p",{className:Re.specNote,children:"Overlapping visual layers without subtitles â isolates layer compositing cost from subtitle burn-in (~18.6% of jobs, ~21% of render time)."}),(0,t.jsxs)("ul",{children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"C-ffmpeg"})," (ffmpeg-single) â overlapping layers composited via ffmpeg."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"C-canvas"})," (canvas) â overlapping layers rendered via canvas/puppeteer."]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("b",{children:"C-multimachine"})," (multimachine) â heavier multi-layer export split/merged across machines."]})]})]}),s[16]=T):T=s[16];let E;
220s[17]!==_?(E=_&&(0,t.jsx)(it,{}),s[17]=_,s[18]=E):E=s[18];let O;s[19]!==m||s[20]!==u||s[21]!==_||s[22]!==R||s[23]!==D||s[24]!==d||s[25]!==n||s[26]!==l||s[27]!==o?(O=!_&&d&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:`${Re.verdict} ${d.krPass?Re.verdictPass:Re.verdictFail}`,children:[(0,t.jsx)("span",{className:Re.verdictValue,children:d.krPass?"PASS":"FAIL"}),(0,t.jsxs)("span",{className:Re.verdictDetail,children:["median ",Zs(d.overall.medianDeltaPct)," (need â30%"," ",d.overall.medianTargetMet?"â":"â",") · p75"," ",Zs(d.overall.p75DeltaPct)," (need â25%"," ",d.overall.p75TargetMet?"â":"â",") · no path left behind"," ",d.guardrails.noPathLeftBehind?"â":"â"]})]}),(0,t.jsx)("div",{className:Re.sectionLabel,children:"By render path"}),(0,t.jsx)("div",{className:Re.pathCards,children:d.paths.map(HF)}),(0,t.jsxs)("div",{className:Re.controls,children:[(0,t.jsx)("label",{htmlFor:"run",children:"Run"}),(0,t.jsx)("select",{id:"run",value:o,onChange:K=>i(K.target.value),children:n.map(UF)}),(0,t.jsx)("label",{htmlFor:"baseline",children:"Baseline"}),(0,t.jsxs)("select",{id:"baseline",value:l,onChange:K=>r(K.target.value),children:[m&&!n.some(K=>K.label===m)&&(0,t.jsx)("option",{value:m,children:m}),n.map(ZF)]}),(0,t.jsx)("span",{className:Re.note,children:"mem / cpu shown as avg · max across runs"})]}),(0,t.jsxs)("table",{className:Re.table,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Project"}),(0,t.jsx)("th",{children:"Base"}),(0,t.jsx)("th",{children:"Best"}),(0,t.jsx)("th",{children:"Î%"}),(0,t.jsx)("th",{children:"VMAF valleys"}),(0,t.jsx)("th",{children:"Mem GB"}),(0,t.jsx)("th",{children:"CPU %"})]})}),(0,t.jsx)("tbody",{children:d.projects.map(K=>{const z=K.path==="multimachine"&&K.warnings.length>0,Y=u.has(K.key),me=K.renders.length>0;return(0,t.jsxs)(f.Fragment,{children:[(0,t.jsxs)("tr",{children:[(0,t.jsxs)("td",{className:Re.project,children:[me&&(0,t.jsx)("button",{type:"button",className:Re.caret,onClick:()=>j(K.key),"aria-expanded":Y,"aria-label":Y?"collapse":"expand",children:Y?"â¾":"â¸"}),K.copyVideoId?(0,t.jsx)("a",{href:`https://www.kapwing.com/${K.copyVideoId}/studio/editor`,target:"_blank",rel:"noreferrer",children:K.key}):K.key,K.copyVideoId&&(0,t.jsx)("a",{className:Re.jobsLink,href:`https://www.kapwing.com/admin/process_video_jobs?page=1&per_page=20&filters%5Bvideo_id%5D=${K.copyVideoId}`,target:"_blank",rel:"noreferrer",title:"control export jobs for the copy",children:"jobs"}),z&&(0,t.jsx)("span",{className:Re.warnIcon,title:"rendered single-machine",children:"â "})]}),(0,t.jsx)("td",{className:Re.muted,children:Rn(K.baselineS)}),(0,t.jsx)("td",{children:Rn(K.measuredBest)}),(0,t.jsx)("td",{className:Ni(K.deltaPct),children:Zs(K.deltaPct)}),(0,t.jsx)("td",{children:K.vmafValleysMax}),(0,t.jsxs)("td",{children:[$t(K.memAvgGb)," ",(0,t.jsx)("span",{className:Re.muted,children:$t(K.memMaxGb)}),K.baselineMemAvgGb!=null&&(0,t.jsxs)("div",{className:Re.cellSub,children:["base ",$t(K.baselineMemAvgGb)," ·"," ",Zs(K.memDeltaPct)]})]}),(0,t.jsxs)("td",{children:[$t(K.cpuAvg,0)," ",(0,t.jsx)("span",{className:Re.muted,children:$t(K.cpuMax,0)}),K.baselineCpuAvg!=null&&(0,t.jsxs)("div",{className:Re.cellSub,children:["base ",$t(K.baselineCpuAvg,0)," ·"," ",Zs(K.cpuDeltaPct)]})]})]}),Y&&K.renders.map((X,te)=>(0,t.jsxs)("tr",{className:Re.renderRow,children:[(0,t.jsxs)("td",{className:Re.project,children:[(0,t.jsxs)("span",{className:Re.runLabel,children:["run ",te+1]}),X.testVideoId&&(0,t.jsx)("a",{className:Re.jobsLink,href:`https://www.kapwing.com/${X.testVideoId}/studio/editor`,target:"_blank",rel:"noreferrer",title:"test render (clone)",children:"video"}),X.testVideoId&&(0,t.jsx)("a",{className:Re.jobsLink,href:`https://www.kapwing.com/admin/process_video_jobs?page=1&per_page=20&filters%5Bvideo_id%5D=${X.testVideoId}`,target:"_blank",rel:"noreferrer",title:"test render job",children:"job"})]}),(0,t.jsx)("td",{className:Re.muted,children:"â"}),(0,t.jsx)("td",{children:Rn(X.buildDuration)}),(0,t.jsx)("td",{className:Ni(X.deltaPct),children:Zs(X.deltaPct)}),(0,t.jsx)("td",{children:X.vmafValleys??0}),(0,t.jsxs)("td",{children:[$t(X.memAvgGb)," ",(0,t.jsx)("span",{className:Re.muted,children:$t(X.memMaxGb)})]}
220),(0,t.jsxs)("td",{children:[$t(X.cpuAvg,0)," ",(0,t.jsx)("span",{className:Re.muted,children:$t(X.cpuMax,0)})]})]},X.jobId??`${K.key}-${te}`))]},K.key)})})]}),(0,t.jsxs)("div",{className:Re.tiles,children:[(0,t.jsxs)("div",{className:Re.tile,children:[(0,t.jsx)("div",{className:Re.tileLabel,children:"Renders valid"}),(0,t.jsxs)("div",{className:Re.tileValue,children:[d.guardrails.rendersValid," /"," ",d.guardrails.rendersTotal]})]}),(0,t.jsxs)("div",{className:Re.tile,children:[(0,t.jsx)("div",{className:Re.tileLabel,children:"VMAF valleys"}),(0,t.jsx)("div",{className:`${Re.tileValue} ${d.guardrails.anyVmafValley?"":Re.good}`,children:d.projects.reduce(WF,0)})]}),(0,t.jsxs)("div",{className:Re.tile,children:[(0,t.jsx)("div",{className:Re.tileLabel,children:"Peak mem"}),(0,t.jsxs)("div",{className:Re.tileValue,children:[$t(D)," GB"]})]}),(0,t.jsxs)("div",{className:Re.tile,children:[(0,t.jsx)("div",{className:Re.tileLabel,children:"Peak CPU"}),(0,t.jsxs)("div",{className:Re.tileValue,children:[$t(R,0),"%"]})]})]}),d.warnings.length>0&&(0,t.jsx)("div",{className:Re.warning,children:d.warnings.map(KF)}),(0,t.jsxs)("details",{className:Re.rawJson,children:[(0,t.jsx)("summary",{children:"Raw report JSON"}),(0,t.jsx)("pre",{children:JSON.stringify(d,null,2)})]})]}),s[19]=m,s[20]=u,s[21]=_,s[22]=R,s[23]=D,s[24]=d,s[25]=n,s[26]=l,s[27]=o,s[28]=O):O=s[28];let q;s[29]!==_||s[30]!==d||s[31]!==n?(q=!_&&!d&&n.length===0&&(0,t.jsxs)("div",{className:Re.subtitle,children:["No export-speed benchmark runs found. Dispatch one from kapwing-scripts: ",(0,t.jsx)("code",{children:"make run-export-speed-benchmark"}),"."]}),s[29]=_,s[30]=d,s[31]=n,s[32]=q):q=s[32];let J;return s[33]!==E||s[34]!==O||s[35]!==q?(J=(0,t.jsxs)("div",{className:`container ${Re.page}`,children:[P,k,T,E,O,q]}),s[33]=E,s[34]=O,s[35]=q,s[36]=J):J=s[36],J},MF=f.memo(DF);function FF(s){return Ss(s)}function OF(s){return Ss(s)}function qF(s){return s.memMaxGb??0}function VF(s){return s.cpuMax??0}function HF(s){return(0,t.jsxs)("div",{className:`${Re.card} ${s.improved?Re.good:Re.flat}`,children:[(0,t.jsx)("div",{className:Re.cardHead,children:(0,t.jsx)("span",{children:s.path})}),(0,t.jsx)("div",{className:Re.cardBig,children:Zs(s.deltaPct)}),(0,t.jsxs)("div",{className:Re.cardSub,children:[Rn(s.baselineMedian)," â"," ",Rn(s.measuredMedian)," · ",s.nProjects," projects"]})]},s.path)}function UF(s){return(0,t.jsxs)("option",{value:s.label,children:[s.label," (",s.renders," renders)"]},s.label)}function ZF(s){return(0,t.jsxs)("option",{value:s.label,children:[s.label," (",s.renders," renders)"]},s.label)}function WF(s,e){return s+e.vmafValleysMax}function KF(s,e){return(0,t.jsx)("div",{children:(0,t.jsx)("strong",{children:s})},e)}const GF="EmailListManager-module_modalOverlay_-IulP",JF="EmailListManager-module_modalContent_M2zYz",zF="EmailListManager-module_modalHeader_dmf-5",YF="EmailListManager-module_emailList_A5cbM",QF="EmailListManager-module_emailRow_2nUHu",XF="EmailListManager-module_emailText_99aI0",e7="EmailListManager-module_inputSection_giFZN",t7="EmailListManager-module_textarea_BUeZP";var fs={modalOverlay:GF,modalContent:JF,modalHeader:zF,emailList:YF,emailRow:QF,emailText:XF,inputSection:e7,textarea:t7};const wi=f.memo(({flagId:s,emails:e,access:n,disabled:a,onFlagUpdate:o})=>{const i=tt(),[l,r]=(0,f.useState)(""),[d,c]=(0,f.useState)(""),[m,h]=(0,f.useState)(!1),p=(0,f.useCallback)(v=>{r(v.target.value)},[]),u=(0,f.useCallback)(async()=>{if(a)return;const v=d.split(",").map(j=>j.trim()).filter(Boolean);c("");const b=await H.flags.updateAccess.mutate({flagId:s,emails:v,access:n});i(Za.setFlag(b)),o(b)},[d,s,i,a,n,o]),g=(0,f.useCallback)(async v=>{if(a)return;const b=await H.flags.removeAccess.mutate({flagId:s,email:v});i(Za.setFlag(b)),o(b)},[s,i,a,o]),_=(0,f.useMemo)(()=>e.filter(v=>v.includes(l)),[e,l]);return(0,t.jsxs)("div",{children:[(0,t.jsx)(rs,{onClick:()=>h(!0),label:`${n?"Allow":"Deny"} list emails (${e.length})`,color:n?"primary":"secondary"}),m&&(0,t.jsx)("div",{className:fs.modalOverlay,role:"dialog","aria-modal":"true",children:(0,t.jsxs)("div",{className:fs.modalContent,children:[(0,t.jsxs)("div",{className:fs.modalHeader,children:[(0,t.jsxs)("h2",{children:[n?"Allowed":"Denied"," Emails"]}
220),(0,t.jsx)(qo,{label:"Ã",onClick:()=>h(!1),width:"small"})]}),(0,t.jsx)("input",{type:"text",placeholder:"Filter Emails",value:l,onChange:p}),(0,t.jsxs)("div",{children:["Showing ",_.length," of ",e.length," emails"]}),!!_.length&&(0,t.jsx)("div",{className:fs.emailList,children:_.map(v=>(0,t.jsxs)("div",{className:fs.emailRow,children:[(0,t.jsx)("span",{title:v,className:fs.emailText,children:v}),(0,t.jsx)(qo,{label:"Remove",onClick:()=>g(v),disabled:a,width:"small"})]},v))}),(0,t.jsxs)("div",{className:fs.inputSection,children:[(0,t.jsx)("textarea",{placeholder:"[email protected],[email protected],...",className:fs.textarea,value:d,onChange:v=>c(v.target.value),disabled:a}),(0,t.jsx)(Xs,{onClick:u,label:"Add Email(s)",disabled:a})]})]})})]})}),s7="FlagAuditLog-module_updateHistoryWrapper_J7QWo",n7="FlagAuditLog-module_toggleButton_m-upK",a7="FlagAuditLog-module_modalOverlay_cHUNM",o7="FlagAuditLog-module_modalContent_hdbZH",i7="FlagAuditLog-module_modalHeader_-VA-k",l7="FlagAuditLog-module_closeButton_qQK1p",r7="FlagAuditLog-module_updateHistory_7OWHL",d7="FlagAuditLog-module_updateEntry_fTZot";var vs={updateHistoryWrapper:s7,toggleButton:n7,modalOverlay:a7,modalContent:o7,modalHeader:i7,closeButton:l7,updateHistory:r7,updateEntry:d7},c7=Q(ie());function u7(s){const e=(0,c7.c)(6),{updates:n}=s,[a,o]=(0,f.useState)(!1);if(!n?.length)return null;let i;if(e[0]!==a||e[1]!==n){const l=[...n].sort(h7);let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=()=>o(!0),e[3]=r):r=e[3];let d;e[4]!==n.length?(d=(0,t.jsxs)("button",{className:vs.toggleButton,onClick:r,"aria-haspopup":"dialog",children:["Audit Log (",n.length,")"]}),e[4]=n.length,e[5]=d):d=e[5],i=(0,t.jsxs)("div",{className:vs.updateHistoryWrapper,children:[d,a&&(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("div",{className:vs.modalOverlay,role:"dialog","aria-modal":"true","aria-label":"Audit log modal",onClick:()=>o(!1),children:(0,t.jsxs)("div",{className:vs.modalContent,onClick:p7,children:[(0,t.jsxs)("div",{className:vs.modalHeader,children:[(0,t.jsx)("h2",{children:"Audit Log"}),(0,t.jsx)("button",{className:vs.closeButton,onClick:()=>o(!1),"aria-label":"Close audit log modal",children:"Ã"})]}),(0,t.jsx)("div",{className:vs.updateHistory,children:l.map(m7)})]})})})]}),e[0]=a,e[1]=n,e[2]=i}else i=e[2];return i}function m7(s){return(0,t.jsxs)("div",{className:vs.updateEntry,children:[(0,t.jsx)("p",{children:new Date(s.timestamp).toLocaleString()}),(0,t.jsxs)("p",{children:["Field changed: ",s.field]}),(0,t.jsxs)("p",{children:["From: ",Ai(s.oldValue)," â"," ",Ai(s.newValue)]}),(0,t.jsx)("p",{children:s.updatedBy})]},s.timestamp)}function p7(s){return s.stopPropagation()}function h7(s,e){return e.timestamp-s.timestamp}function Ai(s){return JSON.stringify(s)}const f7="FlagsAdmin-module_tableWrapper_QUy-A",x7="FlagsAdmin-module_creatorName_-TI-O",g7="FlagsAdmin-module_headerInputContainer_6VRok",v7="FlagsAdmin-module_newFlagInput_CU529",_7="FlagsAdmin-module_filterFlagInput_S2v2l",j7="FlagsAdmin-module_flagName_PNnOh",b7="FlagsAdmin-module_flagsTable_C4CUL";var is={tableWrapper:f7,creatorName:x7,headerInputContainer:g7,newFlagInput:v7,filterFlagInput:_7,flagName:j7,flagsTable:b7},y7=Q(cn()),S7={[js.OFF]:"Off",[js.ON]:"On",[js.ADMIN_ONLY]:"Admin Only",[js.BETA]:"Beta"};const C7=()=>{const[s,e]=(0,f.useState)(""),[n,a]=(0,f.useState)({}),[o,i]=(0,f.useState)(""),[l,r]=(0,f.useState)(!0),[d,c]=(0,f.useState)({});na(()=>{(async()=>{r(!0);try{const x=await H.flags.allFlagsAdmin.query();a(Object.fromEntries(x.map(S=>[S.name,S])))}catch(x){alert(`Failed to fetch flags: ${String(x)}`)}finally{r(!1)}})()});const m=(0,f.useMemo)(()=>{const j=o.toLowerCase();return Object.entries(n??{}).filter(([x,S])=>S?x.toLowerCase().includes(j):!1)},[n,o]),h=j=>{i(j.target.value)},p=async()=>{if(s)try{const j=await H.flags.create.mutate({name:s});a(x=>({...x,[j.name]:j})),e("")}catch(j){j?.status===409?alert("A flag with this name already exists."):alert("Failed to create flag.")}},u=async(j,x)=>{const S=await H.flags.update.mutate({flagId:j,updates:x});a(C=>({...C,[S.name]:S}))},g=(0,f.useMemo)(()=>(0,y7.debounce)(u,1e3),[]),_=(0,f.useCallback)(j=>{a(x=>({...x,[j.name]:j}))},[]),v=async(j,x)=>u(j,{message:x}),b=async j=>{const x=Object.values(n).find(S=>S._id===j)?.name;window.confirm(`All features behind this flag will be inaccessible to users. Are you sure you want to delete the flag "${x}"?`)&&(await H.flags.delete.mutate({flagId:j}),a(Object.values(n).reduce((S,C)=>(C._id!==j&&(S[C.name]=C),S),{})))};return l?(0,t.jsx)("p",{children:"Loading..."}):(0,t.jsxs)("div",{style:{padding:"1rem"},children:[" ",(0,t.jsxs)("div",{className:is.headerInputContainer,children:[(0,t.jsx)("div",{children:(0,t.jsx)("h1",{children:"Feature Flags"})}),(0,t.jsx)("div",{children:(0,t.jsx)("a",{style:{fontSize:"1rem"},href:"https://www.notion.so/kapwing/Feature-Flag-Documentation-1cab51a3250a8072b28cca219959cede",children:"Documentation and exact feature flag logic here"})})]}),(0,t.jsxs)("div",{className:is.headerInputContainer,children:[(0,t.jsx)("div",{className:is.newFlagInput,children:(0,t.jsx)("input",{placeholder:"Enter new flag",value:s,onChange:j=>e(j.target.value.toUpperCase().replaceAll(" ","_"))})}),(0,t.jsx)(Xs,{width:"small",label:"Save",onClick:p})]}),(0,t.jsx)("div",{className:is.headerInputContainer,children:(0,t.jsx)("div",{className:is.filterFlagInput,children:(0,t.jsx)("input",{type:"text",placeholder:"Filter Flags",onChange:h})})}),(0,t.jsx)("div",{className:is.tableWrapper,children:(0,t.jsxs)("table",{className:is.flagsTable,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Name"}),(0,t.jsx)("th",{children:"Status"}),(0,t.jsx)("th",{children:"Allow/Deny List"}),(0,t.jsx)("th",{children:"Message"}),(0,t.jsx)("th",{children:"Options"}),(0,t.jsx)("th",{}),(0,t.jsx)("th",{children:" Audit Log "})]})}),(0,t.jsx)("tbody",{children:m.map(([j,x],S)=>{const{rollout:C}=x,y=Object.entries(x.accessMap||{}).reduce((A,[I,D])=>(D?A.allow.push(I):A.deny.push(I),A),{allow:[],deny:[]}),N=C&&x.status!==js.BETA,w=x.status===js.OFF&&y.allow.length>0;return(0,t.jsxs)("tr",{children:[(0,t.jsxs)("td",{title:j,children:[(0,t.jsx)("p",{className:is.flagName,children:j}),(0,t.jsxs)("p",{children:[(0,t.jsx)("span",{children:"Creator: "})," ",(0,t.jsx)("span",{className:is.creatorName,children:x.creator?.split("@")[0]})]}),(0,t.jsxs)("p",{children:[(0,t.jsx)("span",{children:"Last Updated: "}
220),new Date(x.lastUpdated||0).toLocaleString()]})]}),(0,t.jsx)("td",{style:{maxWidth:300},children:(0,t.jsx)("select",{value:x.status,onChange:A=>{u(x._id,{status:A.target.value})},children:Object.entries(S7).map(([A,I])=>(0,t.jsx)("option",{value:A,children:I},A))})}),(0,t.jsxs)("td",{children:[(0,t.jsx)(wi,{flagId:x._id,emails:y.allow,access:!0,disabled:!1,onFlagUpdate:_}),(0,t.jsx)(wi,{flagId:x._id,emails:y.deny,access:!1,disabled:!1,onFlagUpdate:_}),w&&(0,t.jsx)("div",{style:{color:"red",fontWeight:"bold"},children:"Warning: Allow list overrides OFF status! (for specified users)"})]}),(0,t.jsx)("td",{children:(0,t.jsx)("textarea",{onBlur:A=>v(x._id,A.target.value),disabled:x.status!==js.ON,defaultValue:x.message||""})}),(0,t.jsxs)("td",{children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{type:"checkbox",checked:x.disabledInProd,onChange:A=>u(x._id,{disabledInProd:A.target.checked})}),(0,t.jsx)("span",{children:"Disabled in prod"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{type:"checkbox",checked:!!x.rollout,disabled:x.status!==js.BETA,onChange:()=>{u(x._id,{rollout:x.rollout?null:{percentage:0,basedOn:"teamId"}})}}),(0,t.jsx)("span",{children:"Partial Rollout"})]}),C&&(0,t.jsxs)("div",{style:{display:"flex"},children:[(0,t.jsx)("input",{style:{width:"45px"},type:"text",value:d[x._id]??C.percentage.toString(),onChange:A=>{const I=A.target.value;if(c($=>({...$,[x._id]:I})),I===""){g(x._id,{rollout:{...C,percentage:0}});return}if(!/^\d+$/.test(I))return;const D=parseInt(I,10),L=Math.max(Math.min(D,100),0);g(x._id,{rollout:{...C,percentage:L}})}}),(0,t.jsx)("span",{style:{whiteSpace:"nowrap"},children:"% by "}),(0,t.jsxs)("select",{value:C.basedOn,onChange:A=>{u(x._id,{rollout:{...C,basedOn:A.target.value}})},children:[(0,t.jsx)("option",{value:"teamId",children:"Team"}),(0,t.jsx)("option",{value:"userId",children:"User"})]})]}),N&&(0,t.jsx)("div",{style:{color:"red",fontWeight:"bold",width:160},children:'Rollout will have no effect because flag is not set to "BETA".'})]}),(0,t.jsx)("td",{children:(0,t.jsx)(rs,{color:"danger",label:"Delete Flag",onClick:()=>b(x._id)})}),(0,t.jsx)("td",{children:(0,t.jsx)(u7,{updates:x.updateHistory})})]},x._id)})})]})})]})};var N7=C7;const w7="mcp_beta_tools",A7="McpFlagsAdmin-module_page_U8hPM",I7="McpFlagsAdmin-module_header_JHdtM",T7="McpFlagsAdmin-module_headerLinks_G4PTO",k7="McpFlagsAdmin-module_subtitle_uwOlc",R7="McpFlagsAdmin-module_section_xZ-6s",$7="McpFlagsAdmin-module_configValue_y0CV3",P7="McpFlagsAdmin-module_hint_dGLmf",E7="McpFlagsAdmin-module_ok_t2OvZ",L7="McpFlagsAdmin-module_error_eH7I-",B7="McpFlagsAdmin-module_warning_2BGqE",D7="McpFlagsAdmin-module_notice_cdIDP",M7="McpFlagsAdmin-module_busy_r-yZh",F7="McpFlagsAdmin-module_driftList_jxZ9U",O7="McpFlagsAdmin-module_driftEmail_0r-Xa",q7="McpFlagsAdmin-module_addRow_15JtK",V7="McpFlagsAdmin-module_emailInput_T7Fo8",H7="McpFlagsAdmin-module_tableWrapper_jnBD5",U7="McpFlagsAdmin-module_table_LHM3B",Z7="McpFlagsAdmin-module_emailCell_fSXH0",W7="McpFlagsAdmin-module_driftRow_yMiua",K7="McpFlagsAdmin-module_rowActions_-77fi",G7="McpFlagsAdmin-module_allowed_inOOm",J7="McpFlagsAdmin-module_denied_5h339",z7="McpFlagsAdmin-module_missing_DP1Nw";var We={page:A7,header:I7,headerLinks:T7,subtitle:k7,section:R7,configValue:$7,hint:P7,ok:E7,error:L7,warning:B7,notice:D7,busy:M7,driftList:F7,driftEmail:O7,addRow:q7,emailInput:V7,tableWrapper:H7,table:U7,emailCell:Z7,driftRow:W7,rowActions:K7,allowed:G7,denied:J7,missing:z7};const Y7="MCP_",Ii=s=>{const e=new Set;return s.split(",").map(n=>n.trim().toUpperCase()).filter(n=>!n||e.has(n)?!1:(e.add(n),!0))},Q7=(s,e)=>{const n=new Set(s),a=new Set(e),o=e.filter(l=>!n.has(l)),i=s.filter(l=>!a.has(l));return{added:o,removed:i,changed:!!o.length||!!i.length}},X7=s=>s.toUpperCase().startsWith(Y7),eO=(s,e)=>{const n=s?.accessMap?.[e];return n===void 0?"missing":n?"allowed":"denied"},tO=(s,e)=>{const n=new Set(e.map(o=>String(o.name))),a=new Set(s);return{names:s,unknownNames:s.filter(o=>!n.has(o)),unlistedNames:e.map(o=>String(o.name)).filter(o=>!a.has(o))}},sO=(s,e)=>{const n=s.map(o=>e[o]).filter(o=>!!o),a=new Set;
220return n.forEach(o=>{Object.entries(o.accessMap||{}).forEach(([i,l])=>{l&&a.add(i)})}),[...a].sort().map(o=>{const i={},l=[],r=[];return s.forEach(d=>{const c=e[d];if(!c)return;const m=eO(c,o);i[d]=m,m==="missing"&&l.push(d),m==="denied"&&r.push(d)}),{email:o,byFlag:i,missingFrom:l,deniedOn:r}})},La=s=>s.missingFrom.length>0||s.deniedOn.length>0;var nO="https://www.notion.so/kapwing/Feature-Flag-Documentation-1cab51a3250a8072b28cca219959cede",aO={allowed:"â",denied:"deny",missing:"â"};const oO=()=>{const s=tt(),[e,n]=(0,f.useState)({}),[a,o]=(0,f.useState)(!0),[i,l]=(0,f.useState)(null),[r,d]=(0,f.useState)(null),[c,m]=(0,f.useState)(null),[h,p]=(0,f.useState)(""),[u,g]=(0,f.useState)({current:null,previous:null}),_=(0,f.useMemo)(()=>Ii(u.current?.value??""),[u]),v=(0,f.useMemo)(()=>{if(!u.current||!u.previous)return null;const P=Q7(Ii(u.previous.value),_);return P.changed?P:null},[u,_]);na(()=>{(async()=>{o(!0);try{const[k,T]=await Promise.all([H.flags.allFlagsAdmin.query(),H.flags.mcpBetaTools.query()]);n(Object.fromEntries(k.filter(E=>X7(String(E.name))).map(E=>[E.name,E]))),g(T)}catch(k){d(`Failed to load MCP flags: ${String(k)}`)}finally{o(!1)}})()});const b=(0,f.useMemo)(()=>Object.values(e).sort((P,k)=>String(P.name).localeCompare(String(k.name))),[e]),j=(0,f.useMemo)(()=>tO(_,b),[_,b]),x=(0,f.useMemo)(()=>sO(_,e),[_,e]),S=(0,f.useMemo)(()=>x.filter(La),[x]),C=(0,f.useCallback)(P=>{n(k=>{const T={...k};return P.forEach(E=>{T[String(E.name)]=E}),T}),P.forEach(k=>
220s(Za.setFlag(k)))},[s]),y=(0,f.useCallback)(async(P,k,T)=>{m(P);const E=[];try{for(const O of k){const q=e[O];q&&E.push(await T(q))}}catch(O){const q=`${P} failed partway through: ${String(O)}`;l(J=>J?`${J} 221${q}`:q)}finally{C(E),m(null)}},[e,C]),N=(0,f.useCallback)((P,k,T)=>y(T,k,E=>H.flags.updateAccess.mutate({flagId:E._id,emails:P,access:!0})),[y]),w=(0,f.useCallback)(async()=>{const P=h.split(",").map(k=>k.trim()).filter(Boolean);P.length&&(l(null),await N(P,_,`Adding ${P.length} email(s) to the beta`),p(""))},[h,_,N]),A=(0,f.useCallback)(P=>N([P.email],[...P.missingFrom,...P.deniedOn],`Syncing ${P.email}`),[N]),I=(0,f.useCallback)(async()=>{l(null);for(const P of S)await A(P)},[S,A]),D=(0,f.useCallback)(P=>(l(null),A(P)),[A]),L=(0,f.useCallback)(P=>{const k=_.filter(T=>e[T]).length;if(window.confirm(`Remove ${P} from the allow list of all ${k} beta flag(s)?`))return l(null),y(`Removing ${P} from the beta`,_,T=>H.flags.removeAccess.mutate({flagId:T._id,email:P}))},[_,e,y]);if(a)return(0,t.jsx)("p",{children:"Loading..."});const $=_.filter(P=>e[P]),R=!u.current||!!v||!!j.unknownNames.length||!!j.unlistedNames.length||!!S.length;return(0,t.jsxs)("div",{className:We.page,children:[(0,t.jsxs)("header",{className:We.header,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{children:"MCP feature flags"}),(0,t.jsxs)("p",{className:We.subtitle,children:["The MCP beta is the set of flags named by the"," ",(0,t.jsx)("code",{children:w7})," app config. A beta tester belongs on the allow list of every one of them."]})]}),(0,t.jsxs)("div",{className:We.headerLinks,children:[(0,t.jsx)(be,{to:"/admin/flags",children:"All feature flags â"}),(0,t.jsx)("a",{href:nO,children:"Flag documentation â"})]})]}),r&&(0,t.jsx)("div",{className:We.error,children:r}),i&&(0,t.jsx)("div",{className:We.error,children:i}),c&&(0,t.jsxs)("div",{className:We.busy,children:[c,"â¦"]}),(0,t.jsxs)("section",{className:We.section,children:[(0,t.jsx)("h2",{children:"Configured beta set"}),u.current&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:We.configValue,children:(0,t.jsx)("code",{children:u.current.value})}),(0,t.jsxs)("p",{className:We.hint,children:[(0,t.jsxs)("code",{children:["app_config.","mcp_beta_tools"]})," v",u.current.version,u.current.createdAt?`, published ${new Date(u.current.createdAt).toLocaleString()}`:"",". app_config is append-only â changing the list means inserting a new version, and this tool reads the highest one."]})]}),!u.current&&!r&&(0,t.jsxs)("div",{className:We.warning,children:[(0,t.jsxs)("strong",{children:["No ",(0,t.jsx)("code",{children:"mcp_beta_tools"})," app config found for this app."]})," ","Nothing below can be managed until a version exists. Seed it with"," ",(0,t.jsx)("code",{children:"server/scripts/publishMcpBetaToolsAppConfig.ts"}),"."]})]}),(0,t.jsxs)("section",{className:We.section,children:[(0,t.jsx)("h2",{children:"Needs attention"}),!R&&(0,t.jsxs)("p",{className:We.ok,children:["mcp_beta_tools"," has not changed since the previous version and all ",x.length," beta tester(s) are on every flag in it."]}),v&&u.current&&u.previous&&(0,t.jsxs)("div",{className:We.warning,children:[(0,t.jsxs)("strong",{children:["mcp_beta_tools"," changed in v",u.current.version," ","(was v",u.previous.version,")."]}),!!v.added.length&&(0,t.jsxs)("p",{children:["Added: ",(0,t.jsx)("code",{children:v.added.join(", ")})," â testers admitted before this version are not on"," ",v.added.length>1?"these flags":"this flag"," ","yet. The drift list below says exactly who."]}),!!v.removed.length&&(0,t.jsxs)("p",{children:["Removed: ",(0,t.jsx)("code",{children:v.removed.join(", ")})," â testers still hold access there; dropping the name from the config does not revoke it. Clear those allow lists in"," ",(0,t.jsx)(be,{to:"/admin/flags",children:"the main flags tool"})," if that access should end."]})]}),!!j.unknownNames.length&&(0,t.jsxs)("div",{className:We.warning,children:[(0,t.jsxs)("strong",{children:["Named by ","mcp_beta_tools"," but no such flag exists:"]})," ",(0,t.jsx)("code",{children:j.unknownNames.join(", ")}),". Create the flag in ",(0,t.jsx)(be,{to:"/admin/flags",children:"the main flags tool"}),", or publish a config version without that name."]}),!!u.current&&!!j.unlistedNames.length&&(0,t.jsxs)("div",{className:We.notice,children:[(0,t.jsx)("strong",{children:"MCP flags outside the beta set:"})," ",(0,t.jsx)("code",{children:j.unlistedNames.join(", ")}
221),". Beta testers are not added to these. Publish a config version including them if they should be part of the beta."]}),!!S.length&&(0,t.jsxs)("div",{className:We.warning,children:[(0,t.jsxs)("strong",{children:[S.length," beta tester(s) are not on every beta flag."]}),(0,t.jsx)("ul",{className:We.driftList,children:S.map(P=>(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:We.driftEmail,children:P.email}),!!P.missingFrom.length&&(0,t.jsxs)("span",{children:[" missing from ",P.missingFrom.join(", "),"."]}),!!P.deniedOn.length&&(0,t.jsxs)("span",{children:[" denied on ",P.deniedOn.join(", "),"."]})]},P.email))}),(0,t.jsx)(rs,{color:"primary",width:"wrap-content",label:`Grant access on all ${S.length} tester(s)`,disabled:!!c,onClick:I})]})]}),(0,t.jsxs)("section",{className:We.section,children:[(0,t.jsx)("h2",{children:"Beta testers"}),(0,t.jsxs)("div",{className:We.addRow,children:[(0,t.jsx)("textarea",{className:We.emailInput,placeholder:"[email protected], [email protected], â¦",value:h,onChange:P=>p(P.target.value),disabled:!!c}),(0,t.jsx)(Xs,{width:"small",label:`Add to all ${$.length} beta flag(s)`,disabled:!!c||!h.trim(),onClick:w})]}),!x.length&&(0,t.jsx)("p",{className:We.hint,children:"Nobody is on the allow list of any beta flag yet."}),!!x.length&&(0,t.jsx)("div",{className:We.tableWrapper,children:(0,t.jsxs)("table",{className:We.table,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:We.emailCell,children:"Email"}),$.map(P=>(0,t.jsx)("th",{title:P,children:P.replace("MCP_TOOL_","").replace("MCP_","")},P)),(0,t.jsx)("th",{})]})}),(0,t.jsx)("tbody",{children:x.map(P=>(0,t.jsxs)("tr",{className:La(P)?We.driftRow:void 0,children:[(0,t.jsx)("td",{className:We.emailCell,children:P.email}),$.map(k=>{const T=P.byFlag[k]??"missing";return(0,t.jsx)("td",{className:We[T],title:`${k}: ${T}`,children:aO[T]},k)}),(0,t.jsxs)("td",{className:We.rowActions,children:[La(P)&&(0,t.jsx)(rs,{color:"primary",width:"wrap-content",label:"Sync",disabled:!!c,onClick:()=>D(P)}),(0,t.jsx)(rs,{color:"danger",width:"wrap-content",label:"Remove",disabled:!!c,onClick:()=>L(P.email)})]})]},P.email))})]})})]}),(0,t.jsxs)("section",{className:We.section,children:[(0,t.jsx)("h2",{children:"All MCP_* flags"}),(0,t.jsx)("div",{className:We.tableWrapper,children:(0,t.jsxs)("table",{className:We.table,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Name"}),(0,t.jsx)("th",{children:"In beta set"}),(0,t.jsx)("th",{children:"Status"}),(0,t.jsx)("th",{children:"Allowed"}),(0,t.jsx)("th",{children:"Denied"}),(0,t.jsx)("th",{children:"Disabled in prod"}),(0,t.jsx)("th",{children:"Last updated"})]})}),(0,t.jsx)("tbody",{children:b.map(P=>{const k=Object.values(P.accessMap||{}),T=_.includes(String(P.name));return(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:P.name}),(0,t.jsx)("td",{children:T?"yes":"no"}),(0,t.jsx)("td",{children:P.status}),(0,t.jsx)("td",{children:k.filter(Boolean).length}),(0,t.jsx)("td",{children:k.filter(E=>!E).length}),(0,t.jsx)("td",{children:P.disabledInProd?"yes":"no"}),(0,t.jsx)("td",{children:P.lastUpdated?new Date(P.lastUpdated).toLocaleString():"â"})]},P._id)})})]})}),(0,t.jsxs)("p",{className:We.hint,children:["Status, rollout and per-flag editing stay in"," ",(0,t.jsx)(be,{to:"/admin/flags",children:"the main flags tool"}),"."]})]})]})};var iO=oO;const ds={filterDate:(s,e)=>{if(!s)return"";const n=new Date(s),{format:a}=e.options||{format:"YYYY-MM-DD h:mm:ss a"};return ot(n).format(a)},round:s=>(e,n)=>e?parseFloat(e).toFixed(s):""};var lO=Q(ie()),Ti=Q(Qt()),rO=s=>{const e=(0,lO.c)(50),{numItems:n,totalItems:a,totalPages:o,pageSize:i,currentPage:l,onChangePage:r}=s,d=n===void 0?0:n,c=a===void 0?0:a,m=o===void 0?-1:o,h=i===void 0?10:i,p=l===void 0?1:l;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];const[g,_]=(0,f.useState)(u),v=zs(),b=cO;let j;e[1]!==d||e[2]!==r||e[3]!==h||e[4]!==c||e[5]!==m?(j=(T,E)=>{E<1||m>0&&E>m||(_(b(d,E,h,c,m)),r&&T&&(T.preventDefault(),T.stopPropagation(),r(E)))},e[1]=d,e[2]=r,e[3]=h,e[4]=c,e[5]=m,e[6]=j):j=e[6];const x=j;let S;e[7]!==p||e[8]!==d||e[9]!==x?(S=()=>{(d&&d>=1||p&&p>=1)&&x(null,p)},e[7]=p,e[8]=d,e[9]=x,e[10]=S):S=e[10];let C;e[11]!==p||e[12]!==d||e[13]!==h||e[14]!==x||e[15]!==c?(C=[d,p,c,h,x],e[11]=p,e[12]=d,e[13]=h,e[14]=x,e[15]=c,e[16]=C):C=e[16],(0,f.useEffect)(S,C);let y;e[17]!==v||e[18]!==g.pageSize?(y=T=>{let E;if(v&&v.search){const{page:O,q}=Ti.default.parse(v.search,{ignoreQueryPrefix:!0});E={page:T,per_page:O,q}}else E={page:T,per_page:g.pageSize};return Ti.default.stringify(E,{addQueryPrefix:!0})},e[17]=v,e[18]=g.pageSize,e[19]=y):y=e[19];const N=y;let w;e[20]!==g.currentPage||e[21]!==g.endPage||e[22]!==g.totalPages||e[23]!==x?(w=()=>g.endPage<=g.currentPage?null:(0,t.jsx)("a",{className:"pagination-next",...g.currentPage>=g.totalPages?{disabled:!0}:{},onClick:T=>x(T,g.currentPage+1),children:"Next"}),e[20]=g.currentPage,e[21]=g.endPage,e[22]=g.totalPages,e[23]=x,e[24]=w):w=e[24];const A=w;if(!g.pages||g.pages.length<=1)return null;let I;e[25]!==g.currentPage?(I=g.currentPage<=1?{disabled:!0}:{},e[25]=g.currentPage,e[26]=I):I=e[26];let D;e[27]!==g.currentPage||e[28]!==x?(D=T=>x(T,g.currentPage-1),e[27]=g.currentPage,e[28]=x,e[29]=D):D=e[29];let L;e[30]!==I||e[31]!==D?(L=(0,t.jsx)("a",{className:"pagination-previous",...I,onClick:D,children:"Previous"}),e[30]=I,e[31]=D,e[32]=L):L=e[32];let $;e[33]!==A?($=A(),e[33]=A,e[34]=$):$=e[34];let R;if(e[35]!==g.currentPage||e[36]!==g.pages||e[37]!==N||e[38]!==x){let T;e[40]!==g.currentPage||e[41]!==N||e[42]!==x?(T=(E,O)=>(0,t.jsx)("li",{children:(0,t.jsx)("a",{href:N(E),className:`pagination-link ${g.currentPage===E?"is-current":""}`,onClick:q=>x(q,E),children:E})},O),e[40]=g.currentPage,e[41]=N,e[42]=x,e[43]=T):T=e[43],R=g.pages.map(T),e[35]=g.currentPage,e[36]=g.pages,e[37]=N,e[38]=x,e[39]=R}else R=e[39];let P;e[44]!==R?(P=(0,t.jsx)("ul",{className:"pagination-list",children:R}),e[44]=R,e[45]=P):P=e[45];let k;return e[46]!==L||e[47]!==$||e[48]!==P?(k=(0,t.jsx)("div",{className:"pagination-wrapper",children:(0,t.jsxs)("nav",{className:"pagination is-centered is-small",children:[L,$,P]})}),e[46]=L,e[47]=$,e[48]=P,e[49]=k):k=e[49],k},dO=f.memo(rO);
221function cO(s,e,n,a,o){const i=e===void 0?1:e,l=n===void 0?10:n;let r,d,c=o;!c&&a&&(c=Math.ceil(a/l)),c<=10?(r=1,d=c):i<=6?(r=1,d=10):i+4>=c?(r=c-9,d=c):(r=i-5,d=i+4),c||((!s||s<l)&&(d=i),s===l&&(d=i+1));const m=d+1-r,h=m>0?Array.from(Array(m).keys()):[],p=Array.from(h,u=>r+u);return{numItems:s,totalItems:a,currentPage:i,pageSize:l,totalPages:c,startPage:r,endPage:d,pages:p}}var uO=Q(ie()),ki=(s,e)=>e.split(".").reduce((n,a)=>(n||{})[a],s),mO=s=>{const e=(0,uO.c)(35),{onChangePage:n,data:a,renderHeader:o,renderRow:i,renderSectionHeader:l,loading:r,columns:d}=s;let c;e[0]!==n?(c=k=>{n&&n(k)},e[0]=n,e[1]=c):c=e[1];const m=c,h=hO;let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=(k,T)=>{let E=ki(k,T.key);return E===void 0&&k.data&&(E=ki(k.data,T.key)),T.filters&&(E=h(E,T)),T.renderCell?T.renderCell(E,k,T):E===void 0?"":typeof E=="object"||typeof E=="boolean"?JSON.stringify(E):E},e[2]=p):p=e[2];const u=p;let g;e[3]!==d||e[4]!==i?(g=(k,T)=>i?(k.columns=d,i(k,T)):(0,t.jsx)("div",{className:"flex-row",children:d.map((E,O)=>(0,t.jsx)("div",{className:"flex-cell",style:E.style||{},children:u(k,E)},O))},T),e[3]=d,e[4]=i,e[5]=g):g=e[5];const _=g;let v;e[6]!==_?(v=k=>k?k.map((T,E)=>_(T,E)):null,e[6]=_,e[7]=v):v=e[7];const b=v;let j;e[8]!==d||e[9]!==o?(j=()=>o?o():(0,t.jsx)("div",{className:"flex-table header",role:"rowgroup",children:d.map(fO)}),e[8]=d,e[9]=o,e[10]=j):j=e[10];const x=j;let S;e[11]!==d||e[12]!==a||e[13]!==r||e[14]!==b||e[15]!==x?(S=()=>r||!d?(0,t.jsx)("div",{children:(0,t.jsx)(it,{})}):(0,t.jsxs)("div",{className:"table-container",children:[x(),b(a.data)]}),e[11]=d,e[12]=a,e[13]=r,e[14]=b,e[15]=x,e[16]=S):S=e[16];const C=S;let y;e[17]!==a||e[18]!==m?(y=()=>{if(a&&(a.data&&a.data.length>0||a.meta&&a.meta.page>1)){const{page:k,per_page:T,last_page:E,total:O}=a.meta;return(0,t.jsx)(dO,{currentPage:k,pageSize:T,totalPages:E,totalItems:O,numItems:a.data.length,onChangePage:m})}return null},e[17]=a,e[18]=m,e[19]=y):y=e[19];const N=y;let w;e[20]!==l?(w=()=>l?l():null,e[20]=l,e[21]=w):w=e[21];const A=w;let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I={display:"flex",flexDirection:"column",width:"100%",background:"#fff",border:"default"},e[22]=I):I=e[22];let D;e[23]!==A?(D=A(),e[23]=A,e[24]=D):D=e[24];let L;e[25]!==D?(L=(0,t.jsx)("span",{children:D}),e[25]=D,e[26]=L):L=e[26];let $;e[27]!==C?($=(0,t.jsx)("div",{children:C()}),e[27]=C,e[28]=$):$=e[28];let R;e[29]!==N?(R=N(),e[29]=N,e[30]=R):R=e[30];let P;return e[31]!==L||e[32]!==$||e[33]!==R?(P=(0,t.jsx)("div",{children:(0,t.jsxs)("div",{style:I,children:[L,$,R]})}),e[31]=L,e[32]=$,e[33]=R,e[34]=P):P=e[34],P},pO=f.memo(mO);function hO(s,e){return e.filters.reduce((n,a)=>{const o={col:e};if(typeof a=="function")return a(n,o);if("filter"in a){const{filter:i,...l}=a;return i(n,{...o,...l})}return n},s)}function fO(s){return(0,t.jsx)("div",{className:"flex-row",style:s.style||{},role:"columnheader",children:s.name||""},s.key)}var Gn=Q(Qt()),xO=({filters:s,renderSectionHeader:e,renderRow:n,loading:a,renderHeader:o,data:i,onChangePage:l,listData:r,columns:d})=>{const c=zs(),m=Lt(),h=Gn.default.parse(c.search,{ignoreQueryPrefix:!0}),[p,u]=(0,f.useState)({page:parseInt(h.page||1),per_page:parseInt(h.per_page||20),filters:s}),[g,_]=(0,f.useState)(d),v=(0,f.useCallback)(()=>{r&&r(p)},[r,p]),b=(0,f.useCallback)(()=>{if(d)_(d);else{let x;i&&i.data?i.data[0]&&i.data[0].data?x=i.data[0].data:[x]=i.data:i[0]&&([x]=i),x&&_(Object.keys(x).map(S=>({key:S,name:S})))}},[i,d]);(0,f.useEffect)(function(){b()},[]),(0,f.useEffect)(()=>{v(),m(Gn.default.stringify(p,{addQueryPrefix:!0}))},[p,v,m]),(0,f.useEffect)(()=>{const x=Gn.default.parse(c.search,{ignoreQueryPrefix:!0}),S={...p,page:parseInt(x.page||1),per_page:parseInt(x.per_page||20)};JSON.stringify(p)!==JSON.stringify(S)&&u(S)},[c.search]),(0,f.useEffect)(()=>{JSON.stringify(s)!==JSON.stringify(p.filters)&&u(x=>({...x,page:1,filters:{...x.filters,...s}}))},[s]);const j=(0,f.useCallback)(x=>{l?l(x):m(Gn.default.stringify({...p,page:x},{addQueryPrefix:!0}))},[m,l,p]);return(0,t.jsx)(pO,{columns:g,data:i,loading:a,renderSectionHeader:(0,f.useCallback)(()=>e?e():null,[e]),renderHeader:o,renderRow:n,onChangePage:j})},da=f.memo(xO);const gO=[{label:"All",value:""},{label:"Running",value:"running"},{label:"Success",value:"success"},{label:"Failed",value:"failed"},{label:"Unknown",value:"unknown"}],zt=(s,e=null)=>Object.keys(s).map(n=>{if(n){let a=s[n];return(typeof a=="object"||typeof a=="boolean")&&(a=JSON.stringify(a,null,2)),(0,t.jsxs)("div",{className:"flex-row",style:{padding:0},role:"rowgroup",children:[(0,t.jsx)("div",{className:"flex-cell",style:{flex:.5,backgroundColor:"#ffffed"},children:n}),(0,t.jsx)("div",{className:"flex-cell",style:{padding:0},children:e?e(n,a):(0,t.jsx)("pre",{style:{textAlign:"left",margin:"0"},children:a})})]},n)}return null});var Ba=Q(Qt()),ar=class extends f.Component{constructor(s){super(s);const e=Ba.default.parse(this.props.location.search,{ignoreQueryPrefix:!0}),n=this.getTaskId(),{task:a}=this.props;let{showTaskError:o}=this.props;"showError"in e&&!o&&(o=!0),this.state={task:a,taskId:n,loading:!a,showTaskError:!!o,viewRawStack:!1,sections:{status:!0,video:!1,input:!1,output:!1,server:!1}}}componentDidMount(){this.state.task||this.fetchData()}componentDidUpdate(s,e){const n=this.getTaskId(),{taskId:a,showTaskError:o}=this.state;if(!this.props.task){const i=Ba.default.parse(this.props.location.search,{ignoreQueryPrefix:!0});if(e.showTaskError!==o){o?i.showError="true":delete i.showError;const l=`${this.props.location.pathname}${Ba.default.stringify(i,{addQueryPrefix:!0})}`;this.props.navigate(l)}else"showError"in i?o||this.setState({showTaskError:!0}):o&&this.setState({showTaskError:!1})}n&&a!==n&&this.setState({taskId:n}),e.taskId!==a&&this.fetchData()}getTaskId=()=>{let s;return this.props.task?s=this.props.task.id:this.props.taskId?s=this.props.taskId:s=this.props.match.params.taskId,s};fetchData=()=>{this.state.taskId&&(this.setState({loading:!0}),H.admin.tasks.getById.query({id:this.state.taskId}).then(s=>{this.setState({task:s.data})}).catch(s=>{console.error("ERROR: ",s)}).finally(()=>{this.setState({loading:!1})}
221))};toggleExpand=s=>{const{sections:e}=this.state;this.setState({sections:{...e,[s]:!e[s]}})};toggleShowTaskError=s=>{s.preventDefault(),this.setState({showTaskError:!this.state.showTaskError})};parseErr=s=>{const e=s.split(` 222`).slice(1);return Array.from({length:Math.ceil(e.length/2)},(n,a)=>e.slice(a*2,a*2+2)).map(n=>{const a=n[0].match(/File ([^,\s]+),?\s?line ([^,]+), in (.*)$/),o=n[1]?n[1].trim():n[0].trim();return a?{functionCall:o,fileName:a[1],lineNumber:a[2],functionName:a[3]}:{functionCall:o}})};renderSectionHeader=(s,e)=>(0,t.jsxs)("div",{className:"panel-heading level",onClick:()=>this.toggleExpand(e),children:[(0,t.jsx)("h4",{className:"level-left",children:s}),(0,t.jsx)("span",{className:"level-right",children:this.state.sections[e]?"Collapse":"Expand"})]});renderServerInfo=s=>(0,t.jsxs)("section",{className:"panel",children:[this.renderSectionHeader("Server Info","server"),(0,t.jsx)("code",{children:this.state.sections.server?zt(s):""})]});renderInputInfo=s=>(0,t.jsxs)("section",{className:"panel",children:[this.renderSectionHeader("Build Input","input"),(0,t.jsx)("code",{children:this.state.sections.input?zt(s):""})]});renderOutputInfo=s=>(0,t.jsxs)("section",{className:"panel",children:[this.renderSectionHeader("Build Output","output"),(0,t.jsx)("code",{children:this.state.sections.output?zt(s):""})]});renderStatus=s=>s.status==="failed"&&s.output&&s.output.error?(0,t.jsx)("a",{href:"?showError=true",onClick:this.toggleShowTaskError,children:"failed"}):(0,t.jsx)("span",{children:s.status});renderTaskState=s=>{const e=new Date(s.startedAt).getTime();let n=-1;return s.finishedAt&&(n=(new Date(s.finishedAt).getTime()-e)/1e3),(0,t.jsxs)("section",{className:"panel",children:[(0,t.jsx)("div",{className:"panel-heading",children:(0,t.jsx)("h4",{children:"Task Status"})}),(0,t.jsx)("div",{className:"panel-body",children:(0,t.jsxs)("div",{className:"level",children:[(0,t.jsxs)("div",{className:"level-left",children:[(0,t.jsxs)("div",{children:["Status: ",this.renderStatus(s)]}),(0,t.jsxs)("div",{children:["Started: ",s.startedAt]}),(0,t.jsxs)("div",{children:["Finished: ",s.finishedAt]}),(0,t.jsxs)("div",{children:["Runtime: ",n," sec"]})]}),(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsxs)("div",{children:["AssociatedType: ",s.associatedType]}),(0,t.jsxs)("div",{children:["AssociatedId:"," ",(0,t.jsx)("a",{href:`/${s.associatedType}s/${s.associatedId}`,children:s.associatedId})]}),(0,t.jsxs)("div",{children:["JobId:"," ",(0,t.jsx)(be,{to:`/admin/process_video_jobs/${s.jobId}`,children:s.jobId})]}),(0,t.jsxs)("div",{children:["Logs: ",this.renderLogLink()]})]})]})})]})};renderDetails=()=>{const{task:s}=this.state;return s?(0,t.jsxs)("div",{children:[this.renderTaskState(s),this.renderInputInfo(s.input),this.renderOutputInfo(s.output),this.renderServerInfo(s.serverInfo)]}):null};renderBreadCrumbs=()=>(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsx)(be,{to:"/admin",children:"Admin"})," Â / Â ",(0,t.jsx)(be,{to:"/admin/tasks",children:"Job Tasks"})," Â / Â ",(0,t.jsxs)(be,{to:`/admin/tasks/${this.state.taskId}`,children:["Task ",this.state.taskId]}),this.state.showTaskError&&(0,t.jsx)(be,{to:`/admin/tasks/${this.state.taskId}?showError=true`,children:"Â / Error View"})]});renderErrorStack=s=>{const{stack:e}=s,n=this.parseErr(e);let a;this.state.viewRawStack?a=(0,t.jsx)("pre",{children:e}):a=n.map((i,l)=>(0,t.jsx)("div",{className:"flex-row",style:{padding:0},role:"rowgroup",children:Object.keys(i).map(r=>{const d={backgroundColor:"#ffffed"};switch(r){case"functionCall":d.flex="2";break;case"lineNumber":d.flex="0.25";break;default:break}return(0,t.jsx)("div",{className:"flex-cell",style:d,children:(0,t.jsx)("pre",{style:{margin:0},children:i[r]})},r)})},`line${l}`));const o=this.state.viewRawStack?"View as Table":"View Raw";return(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{children:"StackTrace"}),(0,t.jsx)("button",{type:"button",onClick:()=>this.setState({viewRawStack:!this.state.viewRawStack}),children:o}),a]},"stack")};renderErrorRow=(s,e)=>{const n=s[e];return n==null?null:(0,t.jsxs)("div",{className:"flex-row",style:{padding:0},role:"rowgroup",children:[(0,t.jsx)("div",{className:"flex-cell",style:{flex:.25,backgroundColor:"#ffffed"},children:e}),(0,t.jsx)("div",{className:"flex-cell",style:{backgroundColor:"#ffffed"},children:(0,t.jsx)("pre",{style:{margin:0},children:n.toString()})})]},e)};renderLogLink=()=>{const{task:s}=this.state;let e=`from=${s.createdAt}`;if(s.finishedAt)e+=`&to=${s.finishedAt}`;else{const n=new Date(s.createdAt);n.setDate(n.getDate()+1),e+=`&to=${n.toISOString()}`}return(0,t.jsx)("a",{href:`https://logging.kapwing-dev.com/search/62e922d58da94e6877510166?q=${s.serverInfo.hostName}+AND+${s.id}&rangetype=absolute&${e}`,target:"_blank",rel:"noopener noreferrer",children:"Graylog Logs"})};renderTaskError=()=>{if(!this.state.showTaskError)return null;const s=this.state.task.output.error||{},e=["message","category","subcategory","task","tasks","type"];return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{children:(0,t.jsx)("a",{href:this.props.location.pathname,onClick:this.toggleShowTaskError,children:"Show Details"})}),this.renderLogLink(),(0,t.jsxs)("div",{children:[e.map(n=>this.renderErrorRow(s,n)),Object.keys(s).map(n=>e.includes(n)?null:n==="stack"?this.renderErrorStack(s):this.renderErrorRow(s,n))]})]})};render(){const{loading:s,showTaskError:e}=this.state;let n;return s?n=(0,t.jsx)(it,{}):e?n=this.renderTaskError():n=this.renderDetails(),(0,t.jsxs)("div",{className:"container process-video-job",children:[(0,t.jsx)("div",{className:"header",children:(0,t.jsx)("h2",{className:"headerText",children:"Show Task"})}),this.renderBreadCrumbs(),n]})}},vO=Qs(ar),Ri=Q(Qt()),_O=class extends f.Component{timeframeOptions=[{today:"Today"},{last1:"Last Hour"},{last12:"Last 12hrs"},{last24:"Last 24hrs"}];constructor(s){super(s);const e=Ri.default.parse(this.props.location.search,{ignoreQueryPrefix:!0}).filters||{},n={...e};this.state={taskFilters:{associatedId:"",jobId:"",status:"",hostName:"",clusterGroup:"",timeframe:"",createdAt:"",finishedAt:"",errorSubcat:"",...e},loading:!0,filters:n,data:[],show:void 0,showTaskError:!1,columns:[{key:"actions",name:"Actions",style:{flex:"0.3 0 0"},renderCell:this.renderAction},{key:"createdAt",name:"Created At",style:{flex:"0.8 0 0"},filters:[{filter:ds.filterDate,options:{format:"YYYY-MM-DD h:mm:ss a"}}]},{key:"finishedAt",name:"Finished At",style:{flex:"0.8 0 0"},filters:[ds.filterDate]},{key:"status",name:"Status",style:{flex:"1 0 0"},renderCell:this.renderStatus},{key:"serverInfo.hostName",name:"Hostname",style:{flex:"1 0 0"}},{key:"serverInfo.clusterGroup",name:"Cluster",style:{flex:"1 0 0"}},{key:"jobId",name:"JobID",style:{flex:"0.5 0 0"}},{key:"associatedId",name:"AssociatedId",style:{flex:"1 0 0"}},{key:"associatedType",name:"AssociatedType",style:{flex:"0.5 0 0"}}]}}componentDidUpdate(s){if(s.location.search!==this.props.location.search){const e={...Ri.default.parse(this.props.location.search,{ignoreQueryPrefix:!0}).filters||{}};e!==this.state.filters&&this.setState({taskFilters:e,filters:e})}}fetchData=s=>{H.admin.tasks.search.query(s).then(e=>{const n={data:e.data.map(a=>({key:a.id,data:a,props:{expanded:!1}})),meta:e.meta};this.setState({data:n})}).catch(e=>{console.error("ERROR: ",e)}).finally(()=>{this.setState({loading:!1})})};updateFilter=s=>
222{s.preventDefault();const{taskFilters:e}=this.state;this.setState({filters:{...e}})};showItem=(s,e,n=!1)=>{s.preventDefault(),this.setState({show:e,showTaskError:n})};updateTaskFilter=(s,e)=>{const{taskFilters:n}=this.state;this.setState({taskFilters:{...n,[s]:e.currentTarget.value}})};handleUnsetCancelModal=()=>{this.setState({show:void 0,showTaskError:!1})};renderAction=(s,e)=>(0,t.jsx)("a",{href:`/admin/tasks/${e.key}`,onClick:n=>this.showItem(n,e),children:"VIEW"});renderStatus=(s,e)=>{const{data:n}=e;return s==="failed"&&n.output.error?(0,t.jsxs)("a",{href:`/admin/tasks/${e.key}?showError=true`,onClick:a=>this.showItem(a,e,!0),children:["failed ",(0,t.jsx)("br",{}),n.output.error.subcategory]}):(0,t.jsxs)("span",{children:[s,(0,t.jsx)("br",{}),n.reason]})};renderTimeFilter=()=>{const{taskFilters:s}=this.state,e=s.timeframe==="";return(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("div",{className:"level-left",children:(0,t.jsx)("span",{children:"Timeframe: "})}),(0,t.jsxs)("div",{className:"level-right flex-row",children:[(0,t.jsxs)("label",{className:"level-left pr-2",children:["Custom",(0,t.jsx)("input",{type:"radio",name:"timeframe",value:"",checked:e,onChange:n=>{this.updateTaskFilter("timeframe",n)}})]}),this.timeframeOptions.map(n=>{const[a,o]=Object.entries(n)[0],i=s.timeframe===a;return(0,t.jsx)("div",{className:"level-left pr-2",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:o}),(0,t.jsx)("input",{type:"radio",name:"timeframe",value:a,checked:i,onChange:l=>{this.updateTaskFilter("timeframe",l)}})]})},a)})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsxs)("span",{className:"level-left",style:{whiteSpace:"pre"},children:["Created At: Â ",(0,t.jsx)("span",{style:{fontSize:".5em"},children:"ISO Format"})]}),(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("input",{type:"text",value:s.createdAt,onChange:n=>{this.updateTaskFilter("createdAt",n)}}),(0,t.jsxs)("div",{style:{fontSize:".5em"},children:["Ex: ",new Date().toISOString()]})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",style:{whiteSpace:"pre"},children:"Finished At:"}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:s.finishedAt,onChange:n=>{this.updateTaskFilter("finishedAt",n)}})})]})]})};renderTaskFilter=()=>{const{taskFilters:s}=this.state;return(0,t.jsx)("form",{onSubmit:this.updateFilter,className:"flex-container",children:(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Filter"}),(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsxs)("div",{className:"column",children:[(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"JobId: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:s.jobId,onChange:e=>{this.updateTaskFilter("jobId",e)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"HostName: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:s.hostName,onChange:e=>{this.updateTaskFilter("hostName",e)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Cluster Group: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:s.clusterGroup,onChange:e=>{this.updateTaskFilter("clusterGroup",e)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Status: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("select",{className:"options-select",onChange:e=>{this.updateTaskFilter("status",e)},value:s.status,children:gO.map((e,n)=>(0,t.jsx)("option",{value:e.value,children:e.label},n))})})]})]}),(0,t.jsxs)("div",{className:"column pl-4",children:[this.renderTimeFilter(),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left pr-2",style:{whiteSpace:"pre"},children:"Error Subcategory:"}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:s.errorSubcat,onChange:e=>{this.updateTaskFilter("errorSubcat",e)}})})]})]})]}),(0,t.jsx)("div",{className:"level",children:(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("button",{type:"submit",children:"Filter"})," "]})})]})})};renderShow=()=>
222{if(!this.state.show)return null;const{show:s,showTaskError:e}=this.state;return(0,t.jsx)(un,{biggerPadding:!0,unsetCancelModal:this.handleUnsetCancelModal,children:(0,t.jsx)("div",{className:"admin",children:(0,t.jsx)(ar,{...this.props,task:s.data,showTaskError:e})})})};render(){return(0,t.jsxs)("div",{className:"container",children:[this.renderShow(),(0,t.jsx)(be,{to:"/admin",children:"Back to Admin"}),(0,t.jsxs)("div",{className:"header",children:[(0,t.jsx)("h2",{className:"headerText",children:"Job Tasks"}),(0,t.jsx)("div",{className:"description",children:"All processed tasks"})]}),this.renderTaskFilter(),(0,t.jsx)(da,{data:this.state.data,columns:this.state.columns,filters:this.state.filters,listData:this.fetchData,loading:this.state.loading})]})}},jO=Qs(_O),bO=class extends f.Component{renderTask=()=>(0,t.jsx)(vO,{});renderTaskList=()=>(0,t.jsx)(jO,{...this.props});render(){return(0,t.jsx)("div",{className:"container process-video-job",children:(0,t.jsxs)(Bn,{children:[(0,t.jsx)(Te,{path:"/:taskId/*",element:this.renderTask()}),(0,t.jsx)(Te,{path:"/*",element:this.renderTaskList()})]})})}};const yO="1001",SO="1000",CO="58px",NO="K2LicenseKeys-module_container_G8DRu",wO="K2LicenseKeys-module_header_-xehR",AO="K2LicenseKeys-module_headerText_2QypR",IO="K2LicenseKeys-module_description_jjvtH",TO="K2LicenseKeys-module_formContainer_VikbS",kO="K2LicenseKeys-module_form_7PQV7",RO="K2LicenseKeys-module_formRow_A-pZU",$O="K2LicenseKeys-module_labelInput_0xPD-",PO="K2LicenseKeys-module_submitButton_y7LKL",EO="K2LicenseKeys-module_content_waOlF",LO="K2LicenseKeys-module_noResults_1OOez",BO="K2LicenseKeys-module_listWrapper_Vempz",DO="K2LicenseKeys-module_listHeaderRow_A5mEN",MO="K2LicenseKeys-module_listRow_6ixJY",FO="K2LicenseKeys-module_colLabel_n5swQ",OO="K2LicenseKeys-module_colKey_6kR30",qO="K2LicenseKeys-module_colExpires_b2XNK",VO="K2LicenseKeys-module_colCreated_svPmY",HO="K2LicenseKeys-module_colApiKey_-kkO-",UO="K2LicenseKeys-module_colActions_slEn4",ZO="K2LicenseKeys-module_keyCode_cmwHM",WO="K2LicenseKeys-module_expired_3-gcp",KO="K2LicenseKeys-module_hasKey_BY5cn",GO="K2LicenseKeys-module_noKey_BUvQN",JO="K2LicenseKeys-module_copyButton_VmzJ-";var ze={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:yO,paywallBgZIndex:SO,collapsedMediaSidebarWidth:CO,container:NO,header:wO,headerText:AO,description:IO,formContainer:TO,form:kO,formRow:RO,labelInput:$O,submitButton:PO,content:EO,noResults:LO,listWrapper:BO,listHeaderRow:DO,listRow:MO,colLabel:FO,colKey:OO,colExpires:qO,colCreated:VO,colApiKey:HO,colActions:UO,keyCode:ZO,expired:WO,hasKey:KO,noKey:GO,copyButton:JO},zO=()=>{const s=tt(),[e,n]=(0,f.useState)([]),[a,o]=(0,f.useState)(""),[i,l]=(0,f.useState)(!1),[r,d]=(0,f.useState)(null);(0,f.useEffect)(function(){H.admin.k2LicenseKeys.list.query().then(n)},[]);const c=async u=>{if(u.preventDefault(),!!a.trim())try{l(!0);const g=await H.admin.k2LicenseKeys.generate.mutate({label:a.trim()});n(await H.admin.k2LicenseKeys.list.query()),o(""),s(He({description:`License key generated for "${g.label}".`,type:"success"}))}catch(g){s(He({description:`Failed to generate key: ${g instanceof Error?g.message:"Unknown error"}`,type:"error"}))}finally{l(!1)}},m=u=>{navigator.clipboard.writeText(u.key),d(u.id),setTimeout(()=>d(null),2e3)},h=u=>u?new Date(u).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never",p=u=>u?new Date(u)<new Date:!1;return(0,t.jsxs)("div",{className:ze.container,children:[(0,t.jsxs)("div",{className:ze.header,children:[(0,t.jsx)("div",{className:ze.headerText,children:"License Key Manager"}),(0,t.jsxs)("div",{className:ze.description,children:["Generate license keys for desktop app customers. Each key expires at the end of the current calendar year and uses the"," ",(0,t.jsx)("code",{children:"ANTHROPIC_K2_CUSTOMER_API_KEY"})," env var as the Anthropic API key."]})]}),(0,t.jsx)("div",{className:ze.formContainer,children:(0,t.jsx)("form",{onSubmit:c,className:ze.form,children:(0,t.jsxs)("div",{className:ze.formRow,children:[(0,t.jsx)("input",{type:"text",placeholder:"Customer label (e.g. Acme Corp)",value:a,onChange:u=>o(u.target.value),className:ze.labelInput,required:!0,autoComplete:"off"}),(0,t.jsx)("button",{type:"submit",className:ze.submitButton,disabled:!a.trim()||i,children:i?"Generating...":"Generate Key"})]})})}),(0,t.jsx)("div",{className:ze.content,children:e.length===0?(0,t.jsx)("div",{className:ze.noResults,children:"No license keys yet. Generate one above."}):(0,t.jsxs)("div",{className:ze.listWrapper,children:[(0,t.jsxs)("div",{className:ze.listHeaderRow,children:[(0,t.jsx)("div",{className:ze.colLabel,children:"Label"}),(0,t.jsx)("div",{className:ze.colKey,children:"Key"}),(0,t.jsx)("div",{className:ze.colExpires,children:"Expires"}),(0,t.jsx)("div",{className:ze.colCreated,children:"Created"}),(0,t.jsx)("div",{className:ze.colApiKey,children:"API Key"}),(0,t.jsx)("div",{className:ze.colActions})]}),e.map(u=>(0,t.jsxs)("div",{className:ze.listRow,children:[(0,t.jsx)("div",{className:ze.colLabel,children:u.label}),(0,t.jsx)("div",{className:ze.colKey,children:(0,t.jsx)("code",{className:ze.keyCode,children:u.key})}),(0,t.jsx)("div",{className:`${ze.colExpires} ${p(u.expiresAt)?ze.expired:""}`,children:h(u.expiresAt)}),(0,t.jsx)("div",{className:ze.colCreated,children:h(u.createdAt)}),(0,t.jsx)("div",{className:ze.colApiKey,children:u.hasAnthropicKey?(0,t.jsx)("span",{className:ze.hasKey,children:"Yes"}):(0,t.jsx)("span",{className:ze.noKey,children:"No"})}),(0,t.jsx)("div",{className:ze.colActions,children:(0,t.jsx)("button",{className:ze.copyButton,onClick:()=>m(u),type:"button",children:r===u.id?"Copied!":"Copy"})})]},u.id))]})})]})},YO=f.memo(zO),QO=Q(Gr());const XO="NPS-module_container_UIIYQ",e9="NPS-module_littleText_xuHWI",t9="NPS-module_centerText_mrTMk",s9="NPS-module_row_csLJ7",n9="NPS-module_categorizationContainer_eeZWC",a9="NPS-module_chartContainer_YaEKO",o9="NPS-module_commentsContainer_UWhSQ",i9="NPS-module_commentsTable_UNi-9",l9="NPS-module_chart_pRtQR";var pt={container:XO,littleText:e9,centerText:t9,row:s9,categorizationContainer:n9,chartContainer:a9,commentsContainer:o9,commentsTable:i9,chart:l9}
222,$i=["#FF6633","#FFB399","#FF33FF","#FFFF99","#00B3E6","#E6B333","#3366E6","#999966","#99FF99","#B34D4D","#80B300","#809900","#E6B3B3"],r9={fontSize:"4px",textShadow:"white 1px 0 10px"},Pi=["creatorEmail","browser","device","comment","category","score"];function d9(){const[s,e]=(0,f.useState)(!1),[n,a]=(0,f.useState)(!1),[o,i]=(0,f.useState)(),[l,r]=(0,f.useState)(""),[d,c]=(0,f.useState)(""),[m,h]=(0,f.useState)(),[p,u]=(0,f.useState)(Pi),[g,_]=(0,f.useState)([]),[v,b]=(0,f.useState)([]),j=(0,f.useCallback)($=>{_(R=>R.includes($)?R:[...R,$])},[]),[x,S]=(0,f.useState)(0),[C,y]=(0,f.useState)(10),N=(0,f.useCallback)(($,R)=>{a(!0),H.nps.admin.commentsForDateRange.query({startDate:$,endDate:R}).then(P=>{h(P),P.forEach(k=>{k.category&&j(k.category)})}).catch(P=>console.error(P)).finally(()=>{a(!1)})},[j]);(0,f.useEffect)(function(){const R=setInterval(()=>H.nps.admin.uncategorizedCommentsCount.query().then(({count:P})=>{i(P)}).catch(P=>console.error(P)),1e4);return()=>clearInterval(R)},[]),(0,f.useEffect)(function(){const R=new Date;R.setDate(R.getDate()+1);const P=new Date(R);P.setDate(R.getDate()-7),r(P.toISOString().substr(0,10)),c(R.toISOString().substr(0,10)),N(P.toISOString().substr(0,10),R.toISOString().substr(0,10))},[]);function w(){return(0,t.jsxs)("div",{className:pt.categorizationContainer,children:[(0,t.jsx)("div",{children:typeof o<"u"?`There are ${o} uncategorized nps comments. When you click the button below, the server will categorize them in the background. This process can take a while. I'd recommend checking back on it later in the day.`:"loading..."}),(0,t.jsx)("button",{onClick:()=>{e(!0),H.nps.admin.categorize.mutate().catch($=>{console.error($)}).finally(()=>{e(!1)})},type:"button",disabled:s,children:s?"loading...":"Categorize NPS comments"})]})}function A(){return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:pt.littleText,children:"Select the dates you want to view comments from. (Longer ranges might take a long time to load or fail.)"}),(0,t.jsxs)("div",{className:pt.row,children:[(0,t.jsx)("input",{type:"date",value:l,onChange:$=>r($.target.value)}),(0,t.jsx)("input",{type:"date",value:d,onChange:$=>c($.target.value)}),(0,t.jsx)("button",{type:"button",onClick:()=>N(l,d),children:"Select Range"})]})]})}const I=(0,f.useCallback)(({dataEntry:$})=>`${$.title}: ${$.value}`,[]);function D(){const $=typeof m>"u"||n,R=new Map;for(const k of m??[]){if((k.score??0)<x||(k.score??0)>C||!k.category||v.length>0&&!v.includes(k.category))continue;const T=R.get(k.category)??0;R.set(k.category,T+1)}const P=Array.from(R.entries()).map(([k,T],E)=>({title:k,value:T,color:$i[E%$i.length]}));return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:pt.littleText,children:"Pie charts shows the category ditribution of loaded comments. Comments with no category are left off the chart."}),(0,t.jsx)("div",{className:pt.chartContainer,children:$?(0,t.jsx)("div",{children:"loading..."}):(0,t.jsx)(QO.PieChart,{data:P,className:pt.chart,labelStyle:r9,labelPosition:80,label:I})})]})}function L(){const $=typeof m>"u"||n;return(0,t.jsxs)("div",{className:pt.commentsContainer,children:[(0,t.jsx)("h3",{className:pt.centerText,children:"Comments"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:pt.littleText,children:"Select which columns you want to see in the table below."}),(0,t.jsx)("div",{className:pt.row,children:Pi.map(R=>(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:p.includes(R),onChange:P=>{P.target.checked?u(k=>[...k,R]):u(k=>k.filter(T=>T!==R))}}),R]},R))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:pt.littleText,children:"Select which categories to show in the table below."}),(0,t.jsx)("div",{className:pt.row,children:g.map(R=>(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:v.includes(R),onChange:P=>{P.target.checked?b(k=>[...k,R]):b(k=>k.filter(T=>T!==R))}}),R]},R))})]}),(0,t.jsxs)("div",{className:pt.row,children:[(0,t.jsxs)("div",{className:pt.littleText,children:["Minumum score to show (current ",x,"):"]}),(0,t.jsx)("input",{type:"range",max:C,min:0,step:1,value:x,onChange:R=>{const{value:P}=R.target;S(Number(P))}}),(0,t.jsxs)("div",{className:pt.littleText,children:["Maximum score to show (current ",C,"):"]}),(0,t.jsx)("input",{type:"range",max:10,min:x,step:1,value:C,onChange:R=>{const{value:P}=R.target;y(Number(P))}})]}),$?(0,t.jsx)("div",{children:"loading..."}):(0,t.jsxs)("table",{className:pt.commentsTable,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[p.includes("creatorEmail")&&(0,t.jsx)("th",{children:"Creator Email"}),p.includes("browser")&&(0,t.jsx)("th",{children:"Browser"}),p.includes("device")&&(0,t.jsx)("th",{children:"Device"}),p.includes("comment")&&(0,t.jsx)("th",{children:"Comment"}),p.includes("category")&&(0,t.jsx)("th",{children:"Category"}),p.includes("score")&&(0,t.jsx)("th",{children:"Score"})]})}),(0,t.jsx)("tbody",{children:m.map(R=>v.length>0&&(!R.category||!v.includes(R.category))||(R.score??0)<x||(R.score??0)>C?null:(0,t.jsxs)("tr",{children:[p.includes("creatorEmail")&&(0,t.jsx)("td",{children:R.creatorEmail}),p.includes("browser")&&(0,t.jsx)("td",{children:JSON.stringify(R.browser)}
222),p.includes("device")&&(0,t.jsx)("td",{children:R.device}),p.includes("comment")&&(0,t.jsx)("td",{children:R.comment}),p.includes("category")&&(0,t.jsx)("td",{className:pt.centerText,children:(0,t.jsx)("select",{value:R.category,onChange:P=>{const k=P.target.value;H.nps.admin.updateComment.mutate({commentId:R._id,category:k}).then(()=>{h(T=>T&&T.map(E=>E._id===R._id?{...E,category:k}:E))}).catch(T=>console.error("error while setting comment value",T))},children:g.map(P=>(0,t.jsx)("option",{children:P},P))})}),p.includes("score")&&(0,t.jsx)("td",{className:pt.centerText,children:R.score})]},String(R._id)))})]})]})}return(0,t.jsxs)("div",{className:pt.container,children:[w(),D(),A(),L()]})}const c9="PerformanceReports-module_container_ujSo-";var u9={container:c9};function m9(s){function e(a){if(a==null)return[];const{frameId:o,parentId:i}=s.stacks[a];return[...e(i),o]}const n={type:"sampled",name:"profile",unit:"milliseconds",startValue:Math.min.apply(null,s.samples.map(a=>a.timestamp)),endValue:Math.max.apply(null,s.samples.map(a=>a.timestamp)),samples:s.samples.map(({stackId:a})=>e(a)),weights:s.samples.map(({timestamp:a},o)=>o===0?0:a-s.samples[o-1].timestamp)};return{$schema:"https://www.speedscope.app/file-format-schema.json",shared:{frames:s.frames.map(a=>({name:a.name,line:a.line,col:a.column,file:a.resourceId!=null?s.resources[a.resourceId]:"(unknown)"}))},profiles:[n]}}var Ei=async(s,e,n)=>{const a=await fetch(`data:application/octet-stream;base64,${e}`);if(!a.ok)throw new Error("Issue decoding trace");const o=await a.blob(),i=m9(JSON.parse(await Tc(o))),l=new TextEncoder;Jc({url:`data:application/json;base64,${await _u(new Blob([l.encode(JSON.stringify(i))]))}`,options:{name:`${s}.${n}.speedscope`,format:"speedscope",addExtraFormatting:!1}})},p9=async s=>{const e=await dl(`/api/v2/performance/report/${s}`);return!e.success||e.report==null||(Ei(s,e.report.trace,"first"),e.report.lastTrace&&Ei(s,e.report.lastTrace,"second")),e.error};function h9(){const[s,e]=(0,f.useState)(!1),[n,a]=(0,f.useState)(),o=(0,f.useCallback)(async i=>{i.preventDefault();const l=new FormData(i.currentTarget);let r=String(l.get("profileId"));e(!0),a(void 0);try{r=r.replace(/^['"]+/,""),r=r.replace(/['"]+$/,""),a(await p9(r))}catch(d){const c=dc(d);c?a(c):d instanceof Error?a(String(d)):a(JSON.stringify(d))}finally{e(!1)}},[]);return(0,t.jsxs)("div",{className:u9.container,children:[(0,t.jsxs)("form",{onSubmit:o,children:[(0,t.jsxs)("label",{children:["profileId: ",(0,t.jsx)("input",{name:"profileId",type:"text",disabled:s})]}),(0,t.jsx)("button",{type:"submit",disabled:s,children:"submit"}),s&&(0,t.jsx)("div",{children:'"Loading..."'})]}),n&&(0,t.jsx)("div",{children:n}),(0,t.jsx)("a",{href:"https://speedscope.app",target:"_blank",rel:"noopener noreferrer",children:"speedscope.app"})]})}const f9="1001",x9="1000",g9="58px",v9="Personas-module_container_
222cagvP",_9="Personas-module_title_D8pB8",j9="Personas-module_subtitle_-j4yx",b9="Personas-module_loading_b2W5U",y9="Personas-module_videoGrid_86sfS",S9="Personas-module_loadMoreButton_hk0hh";var xs={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:f9,paywallBgZIndex:x9,collapsedMediaSidebarWidth:g9,container:v9,title:_9,subtitle:j9,loading:b9,videoGrid:y9,loadMoreButton:S9};function C9(){const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)([]),[o,i]=(0,f.useState)(!1),[l,r]=(0,f.useState)(!1),[d,c]=(0,f.useState)(1),m=async u=>{i(!0);try{const g=await H.admin.videos.getPersonas.query({page:u});e(u===1?g.videos:_=>[..._,...g.videos])}catch(g){Ue({description:"Error fetching persona videos",error:g,sendToSentry:!0})}finally{i(!1)}},h=()=>{const u=d+1;c(u),m(u)},p=async()=>{r(!0);try{a((await H.admin.videos.getCustomPersonas.query()).videos)}catch(u){Ue({description:"Error fetching custom personas",error:u,sendToSentry:!0})}finally{r(!1)}};return na(()=>{m(1),p()}),(0,t.jsxs)("div",{className:xs.container,children:[(0,t.jsx)("h1",{className:xs.title,children:"Personas Exports"}),o&&d===1?(0,t.jsx)("div",{className:xs.loading,children:"Loading persona videos..."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:xs.videoGrid,children:s.map(u=>(0,t.jsx)(za,{content:u},u._id))}),(0,t.jsx)("button",{className:xs.loadMoreButton,onClick:h,disabled:o,children:o?"Loading...":"Load More Personas"})]}),(0,t.jsx)("h2",{className:xs.subtitle,children:"Custom Personas"}),l?(0,t.jsx)("div",{className:xs.loading,children:"Loading custom personas..."}):(0,t.jsx)("div",{className:xs.videoGrid,children:n.map(u=>(0,t.jsx)(za,{content:u},u._id))})]})}var or=Q(ie());function so(s){const e=(0,or.c)(5),[n,a]=(0,f.useState)(!1);let o;if(e[0]!==n||e[1]!==s){const l=()=>{const{title:d,info:c}=s;if(!c)return null;const{status:m,runtime:h,tasks:p}=c,u=Object.keys(p||[]).length;let g;e:switch(m){case"success":g="#00ff00";break e;case"failed":g="#ff0000";break e;default:g="#FFA500"}return(0,t.jsxs)("div",{className:"table-container",children:[(0,t.jsx)("div",{className:"flex-table",children:(0,t.jsxs)("div",{className:"flex-row",onClick:()=>a(!n),children:[(0,t.jsx)("b",{className:"flex-cell",children:d}),(0,t.jsx)("span",{className:"flex-cell",style:{backgroundColor:g},children:m}),(0,t.jsx)("span",{className:"flex-cell",children:h}),(0,t.jsx)("span",{className:"flex-cell",children:u}),(0,t.jsx)("span",{className:"flex-cell",children:n?"Collapse":"Expand"})]})}),r()]})},r=()=>{const{info:d}=s;if(!n)return null;const{tasks:c}=d;return"tasks"in d?Object.keys(c).map(m=>(0,t.jsx)(ir,{taskkey:m,info:c[m]},m)):(0,t.jsx)("div",{children:zt(d)})};o=l(),e[0]=n,e[1]=s,e[2]=o}else o=e[2];let i;return e[3]!==o?(i=(0,t.jsx)("div",{children:o}),e[3]=o,e[4]=i):i=e[4],i}function ir(s){const e=(0,or.c)(3),[n,a]=(0,f.useState)(!1);let o;if(e[0]!==n||e[1]!==s){const i=()=>{const{taskkey:r,info:d}=s,{status:c,runtime:m,tasks:h}=d,p=Object.keys(h||[]).length;let u;e:switch(c){case"success":u="#00ff00";break e;case"failed":u="#ff0000";break e;default:u="#FFA500"}return(0,t.jsxs)("div",{className:"flex-cell",children:[(0,t.jsxs)("div",{className:"flex-row",onClick:()=>a(!n),children:[(0,t.jsx)("b",{className:"flex-cell",children:r}),(0,t.jsx)("span",{className:"flex-cell",style:{backgroundColor:u},children:c}),(0,t.jsx)("span",{className:"flex-cell",children:m}),(0,t.jsx)("span",{className:"flex-cell",children:p}),(0,t.jsx)("span",{className:"flex-cell",children:n?"Collapse":"Expand"})]}),l()]})},l=()=>{const{info:r}=s;if(!n)return null;const{tasks:d}=r;return"tasks"in r?Object.keys(d).map(c=>(0,t.jsx)(ir,{taskkey:c,info:d[c]},c)):(0,t.jsx)("div",{children:zt(r)})};o=(0,t.jsxs)("div",{className:"flex-row",children:[" ",i()]}),e[0]=n,e[1]=s,e[2]=o}else o=e[2];return o}var N9=class extends f.Component{renderStages=()=>{const{info:s}=this.props,e=["download","preprocessLayers","preprocessScenes","createVideo"];return(0,t.jsxs)("div",{children:[e.map(n=>(0,t.jsx)("div",{children:(0,t.jsx)(so,{title:n,info:s[n]})}
222,n)),Object.keys(s).map(n=>e.includes(n)?null:(0,t.jsx)("div",{children:(0,t.jsx)(so,{title:n,info:s[n]})},n))]})};render(){return(0,t.jsx)("div",{className:"container",children:this.renderStages()})}},w9=Q(ie()),A9={color:"yellow"};function I9(s){const e=(0,w9.c)(5),[n,a]=(0,f.useState)(!1);let o;if(e[0]!==n||e[1]!==s){const l=()=>{const{task:d}=s;if(!d)return null;const{status:c,createdAt:m,startedAt:h,finishedAt:p,taskType:u,serverInfo:g}=d;let _;h?_=new Date(h).getTime():_=new Date(m).getTime();const v=new Date(p).getTime();let b="";g&&g.clusterGroup&&(b=g.clusterGroup);let j;e:switch(c){case"success":j="#00ff00";break e;case"failed":j="#ff0000";break e;default:j="#FFA500"}return(0,t.jsxs)("div",{className:"table-container",children:[(0,t.jsx)("div",{className:"flex-table",children:(0,t.jsxs)("div",{className:"flex-row",onClick:()=>a(!n),children:[(0,t.jsx)("b",{className:"flex-cell",children:(0,t.jsxs)(be,{style:A9,to:`/admin/tasks/${d.id}`,children:[" ",d.id]})}),(0,t.jsx)("span",{className:"flex-cell",style:{backgroundColor:j},children:c}),(0,t.jsxs)("span",{className:"flex-cell",children:[(v-_)/1e3," sec",(v-_)/1e3," sec"]}),(0,t.jsx)("span",{className:"flex-cell",children:u}),(0,t.jsx)("span",{className:"flex-cell",children:b}),(0,t.jsx)("span",{className:"flex-cell",children:n?"Collapse":"Expand"})]})}),r()]})},r=()=>{const{task:d}=s;return n?(0,t.jsx)("div",{children:zt(d)}):null};o=l(),e[0]=n,e[1]=s,e[2]=o}else o=e[2];let i;return e[3]!==o?(i=(0,t.jsx)("div",{children:o}),e[3]=o,e[4]=i):i=e[4],i}var T9=class extends f.Component{renderTasks=()=>{const{info:s}=this.props;return(0,t.jsx)("div",{children:Object.keys(s).map(e=>{const n=s[e];return(0,t.jsx)("div",{children:(0,t.jsx)(I9,{...this.props,task:n})},e)})})};render(){return(0,t.jsx)("div",{className:"container",children:this.renderTasks()})}},k9=Q(ie()),Jn=Q(Qt()),R9=s=>{const e=(0,k9.c)(93),n=zs(),a=Lt(),{processVideoJobId:o}=Ys(),i=n.search;let l;e[0]!==o||e[1]!==s.job?(l=()=>{let le;return s.job?le=s.job._id:le=o,le},e[0]=o,e[1]=s.job,e[2]=l):l=e[2];const r=l;let d;e[3]!==r||e[4]!==s||e[5]!==i?(d=()=>{const{job:le}=s;let{showJobError:he}=s;return"showError"in Jn.default.parse(i,{ignoreQueryPrefix:!0})&&!he&&(he=!0),{job:le,jobId:r(),tasks:[],loading:!le,loadingTasks:!1,showJobError:!!he,viewRawStack:!1,sections:{status:!0,video:!1,stages:!1,tasks:!1,build:!1,server:!1,validation:!1}}},e[3]=r,e[4]=s,e[5]=i,e[6]=d):d=e[6];const[c,m]=(0,f.useState)(d),h=En(()=>{c.jobId&&(m($9),H.admin.processVideoJobs.getById.query({id:c.jobId}).then(le=>{m(he=>({...he,job:le.data})),u()}).catch(P9).finally(()=>{m(E9)}))});let p;e[7]!==c.jobId?(p=()=>{if(!c.jobId)return;const le={filters:{jobId:c.jobId}};m(L9),H.admin.tasks.search.query(le).then(he=>{m(ge=>({...ge,tasks:he.data}))}).catch(B9).finally(()=>{m(D9)})},e[7]=c.jobId,e[8]=p):p=e[8];const u=En(p);let g;e[9]!==r?(g=r(),e[9]=r,e[10]=g):g=e[10];const _=g,v=!!c.job;let b;e[11]!==h||e[12]!==u||e[13]!==v?(b=()=>{v||h(),u()},e[11]=h,e[12]=u,e[13]=v,e[14]=b):b=e[14];let j;e[15]!==h||e[16]!==u||e[17]!==v?(j=[h,u,v],e[15]=h,e[16]=u,e[17]=v,e[18]=j):j=e[18],(0,f.useEffect)(b,j);let x,S;e[19]!==_?(x=()=>{_&&m(le=>({...le,jobId:_}))},S=[_],e[19]=_,e[20]=x,e[21]=S):(x=e[20],S=e[21]),(0,f.useEffect)(x,S);let C;e[22]!==h?(C=()=>{h()},e[22]=h,e[23]=C):C=e[23];let y;e[24]!==h||e[25]!==c.jobId?(y=[c.jobId,h],e[24]=h,e[25]=c.jobId,e[26]=y):y=e[26],(0,f.useEffect)(C,y);let N,w;e[27]!==n.pathname||e[28]!==n.search||e[29]!==a||e[30]!==s.job||e[31]!==c.showJobError?(N=()=>{if(s.job)return;const le=Jn.default.parse(n.search,{ignoreQueryPrefix:!0});c.showJobError?le.showError="true":delete le.showError,a(`${n.pathname}${Jn.default.stringify(le,{addQueryPrefix:!0})}`)},w=[n.pathname,n.search,a,s.job,c.showJobError],e[27]=n.pathname,e[28]=n.search,e[29]=a,e[30]=s.job,e[31]=c.showJobError,e[32]=N,e[33]=w):(N=e[32],w=e[33]),(0,f.useEffect)(N,w);let A,I;e[34]!==n.search||e[35]!==s.job?(A=()=>{if(s.job)return;const le="showError"in Jn.default.parse(n.search,{ignoreQueryPrefix:!0});m(he=>({...he,showJobError:le}))}
222,I=[n.search,s.job],e[34]=n.search,e[35]=s.job,e[36]=A,e[37]=I):(A=e[36],I=e[37]),(0,f.useEffect)(A,I);let D;e[38]===Symbol.for("react.memo_cache_sentinel")?(D=le=>{m(he=>({...he,sections:{...he.sections,[le]:!he.sections[le]}}))},e[38]=D):D=e[38];const L=D;let $;e[39]!==c.showJobError?($=le=>{le.preventDefault(),m(he=>({...he,showJobError:!c.showJobError}))},e[39]=c.showJobError,e[40]=$):$=e[40];const R=$,P=F9;let k;e[41]!==c.sections?(k=(le,he)=>(0,t.jsxs)("div",{className:"panel-heading level",onClick:()=>L(he),children:[(0,t.jsx)("h4",{className:"level-left",children:le}),(0,t.jsx)("span",{className:"level-right",children:c.sections[he]?"Collapse":"Expand"})]}),e[41]=c.sections,e[42]=k):k=e[42];const T=k;let E;e[43]!==T||e[44]!==c.sections.validation?(E=le=>{if(le.errors){const he=le.errors.map(O9),ge=(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex-row",style:{padding:0},role:"rowgroup",children:[(0,t.jsx)("div",{className:"flex-cell"}),(0,t.jsx)("div",{className:"flex-cell",children:"Actual"}),(0,t.jsx)("div",{className:"flex-cell",children:"Expected"})]}),he]});return(0,t.jsxs)("section",{className:"panel",children:[T("Validation Errors","validation"),c.sections.validation?ge:""]})}return null},e[43]=T,e[44]=c.sections.validation,e[45]=E):E=e[45];const O=E;let q;e[46]!==T||e[47]!==c.sections.server?(q=le=>(0,t.jsxs)("section",{className:"panel",children:[T("Server Info","server"),(0,t.jsx)("code",{children:c.sections.server?zt(le):""})]}),e[46]=T,e[47]=c.sections.server,e[48]=q):q=e[48];const J=q;let K;e[49]!==T||e[50]!==c.sections.metrics?(K=le=>(0,t.jsxs)("section",{className:"panel",children:[T("Metrics","metrics"),(0,t.jsx)("code",{children:c.sections.metrics?zt(le):""})]}),e[49]=T,e[50]=c.sections.metrics,e[51]=K):K=e[51];const z=K;let Y;e[52]!==T||e[53]!==c.sections.build?(Y=le=>(0,t.jsxs)("section",{className:"panel",children:[T("Build Info","build"),(0,t.jsx)("code",{children:c.sections.build?zt(le):""})]}),e[52]=T,e[53]=c.sections.build,e[54]=Y):Y=e[54];const me=Y;let X;e[55]!==T||e[56]!==c.sections.stages?(X=le=>(0,t.jsxs)("section",{className:"panel",children:[T("Build Stages","stages"),(0,t.jsx)("div",{children:c.sections.stages?(0,t.jsx)(N9,{info:le}):""})]}),e[55]=T,e[56]=c.sections.stages,e[57]=X):X=e[57];const te=X;let ae;e[58]!==T||e[59]!==c.job||e[60]!==c.loadingTasks||e[61]!==c.sections.tasks?(ae=le=>c.job&&c.job.buildInfo&&c.job.buildInfo.isMultimachine===!0?c.loadingTasks?(0,t.jsx)(it,{}):(0,t.jsxs)("section",{className:"panel",children:[T("MM Tasks","tasks"),(0,t.jsx)("div",{children:c.sections.tasks?(0,t.jsx)(T9,{info:le}):""})]}):null,e[58]=T,e[59]=c.job,e[60]=c.loadingTasks,e[61]=c.sections.tasks,e[62]=ae):ae=e[62];const G=ae;let se;e[63]!==T||e[64]!==c.sections.video?(se=le=>(0,t.jsxs)("section",{className:"panel",children:[T("Video Info","video"),(0,t.jsx)("code",{children:c.sections.video?zt(le):""})]}),e[63]=T,e[64]=c.sections.video,e[65]=se):se=e[65];const U=se;let B;e[66]!==R?(B=le=>le.status==="failed"&&(le.error||le.buildInfo.error)?(0,t.jsx)("a",{href:"?showError=true",onClick:R,children:"failed"}):(0,t.jsx)("span",{children:le.status}),e[66]=R,e[67]=B):B=e[67];const oe=B;let de,ye;if(e[68]!==n.pathname||e[69]!==me||e[70]!==z||e[71]!==J||e[72]!==te||e[73]!==oe||e[74]!==G||e[75]!==O||e[76]!==U||e[77]!==c||e[78]!==R){const le=V=>{const Ie=new Date(V.startedAt).getTime(),ke=new Date(V.finishedAt).getTime();return(0,t.jsxs)("section",{className:"panel",children:[(0,t.jsx)("div",{className:"panel-heading",children:(0,t.jsx)("h4",{children:"Job Status"})}),(0,t.jsx)("div",{className:"panel-body",children:(0,t.jsxs)("div",{className:"level",children:[(0,t.jsxs)("div",{className:"level-left",children:[(0,t.jsxs)("div",{children:["State: ",V.state]}),(0,t.jsxs)("div",{children:["Status: ",oe(V)]}),(0,t.jsxs)("div",{children:["Valid: ",(0,t.jsx)("span",{children:V.valid?"true":"false"})]}),(0,t.jsxs)("div",{children:["Logs: ",ee()]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(be,{to:`/admin/process_video_jobs/compare?jobId=${V._id}`,children:"Compare to Previous Jobs"})," ","Â "]})]}),(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsxs)("div",{children:["Video: ",(0,t.jsx)("a",{href:`/videos/${V.video_id}`,children:V.video_id})]}),(0,t.jsxs)("div",{children:["Started: ",V.startedAt]}
222),(0,t.jsxs)("div",{children:["Finished: ",V.finishedAt]}),(0,t.jsxs)("div",{children:["Runtime: ",(ke-Ie)/1e3," sec"]})]})]})})]})},he=()=>{const{job:V,tasks:Ie}=c;return V?(0,t.jsxs)("div",{children:[le(V),O(V.validation||{}),te(V.stages||{}),G(Ie||{}),U(V.videoStats||{}),me(V.buildInfo||{}),J(V.serverInfo||{}),z(V.metrics||{})]}):null};let ge;e[81]!==c.jobId||e[82]!==c.showJobError?(ge=()=>(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsx)(be,{to:"/admin",children:"Admin"})," Â / Â ",(0,t.jsx)(be,{to:"/admin/process_video_jobs",children:"Video Jobs"})," Â / Â ",(0,t.jsxs)(be,{to:`/admin/process_video_jobs/${c.jobId}`,children:["Job ",c.jobId]}),c.showJobError&&(0,t.jsx)(be,{to:`/admin/process_video_jobs/${c.jobId}?showError=true`,children:"Â / Error View"})]}),e[81]=c.jobId,e[82]=c.showJobError,e[83]=ge):ge=e[83],ye=ge;let je;e[84]!==c.viewRawStack?(je=V=>{const{stack:Ie}=V,ke=P(Ie);let De;c.viewRawStack?De=(0,t.jsx)("pre",{children:Ie}):De=ke.map(q9);const Xe=c.viewRawStack?"View as Table":"View Raw";return(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{children:"StackTrace"}),(0,t.jsx)("button",{type:"button",onClick:()=>m(V9),children:Xe}),De]},"stack")},e[84]=c.viewRawStack,e[85]=je):je=e[85];const ue=je,pe=H9,ee=()=>{const{job:V}=c,Ie=V.serverInfo||{},ke=new Date().getTime();let De;V.finishedAt?De=`to=${(ke-new Date(V.finishedAt).getTime())/1e3}`:De=`from=${1200+(ke-new Date(V.createdAt).getTime())/1e3}`;let Xe="";return Ie.hostName&&(Xe=`host:${Ie.hostName}+AND+`),Xe=Xe+`${V._id}`,(0,t.jsx)("a",{href:`https://logging.kapwing-dev.com/search/62e922d58da94e6877510166?q=${Xe}&rangetype=relative&${De}`,target:"_blank",rel:"noopener noreferrer",children:"Graylog Logs"})},xe=U9,ve=()=>{if(!c.showJobError)return null;const V=c.job.buildInfo.error||{},Ie=c.job.stages||{},ke=["message","category","subcategory","stage","task","tasks","type"];return(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{children:(0,t.jsx)("a",{href:n.pathname,onClick:R,children:"Show Details"})}),ee(),(0,t.jsxs)("div",{children:[ke.map(De=>pe(V,De)),Object.keys(V).map(De=>De==="stage"?xe(V[De],Ie):ke.includes(De)?null:De==="stack"?ue(V):pe(V,De))]})]})},{loading:we,showJobError:re}=c;if(we){let V;e[86]===Symbol.for("react.memo_cache_sentinel")?(V=(0,t.jsx)(it,{}),e[86]=V):V=e[86],de=V}else re?de=ve():de=he();e[68]=n.pathname,e[69]=me,e[70]=z,e[71]=J,e[72]=te,e[73]=oe,e[74]=G,e[75]=O,e[76]=U,e[77]=c,e[78]=R,e[79]=de,e[80]=ye}else de=e[79],ye=e[80];let Le;e[87]===Symbol.for("react.memo_cache_sentinel")?(Le=(0,t.jsx)("div",{className:"header",children:(0,t.jsx)("h2",{className:"headerText",children:"Show Process Video Job"})}),e[87]=Le):Le=e[87];let Ne;e[88]!==ye?(Ne=ye(),e[88]=ye,e[89]=Ne):Ne=e[89];let Be;return e[90]!==de||e[91]!==Ne?(Be=(0,t.jsxs)("div",{className:"container process-video-job",children:[Le,Ne,de]}),e[90]=de,e[91]=Ne,e[92]=Be):Be=e[92],Be},lr=f.memo(R9);function $9(s){return{...s,loading:!0}}function P9(s){console.error("ERROR: ",s)}function E9(s){return{...s,loading:!1}}function L9(s){return{...s,loadingTasks:!0}}function B9(s){console.error("ERROR: ",s)}function D9(s){return{...s,loadingTasks:!1}}function M9(s){const e=s[0].match(/File ([^,\s]+),?\s?line ([^,]+), in (.*)$/),n=s[1]?s[1].trim():s[0].trim();return e?{functionCall:n,fileName:e[1],lineNumber:e[2],functionName:e[3]}:{functionCall:n}}function F9(s){const e=s.split(` 223`).slice(1);return Array.from({length:Math.ceil(e.length/2)},(n,a)=>e.slice(a*2,a*2+2)).map(M9)}function O9(s){const e=Object.keys(s)[0],n=s[e];return(0,t.jsxs)("div",{className:"flex-row",style:{padding:0},role:"rowgroup",children:[(0,t.jsx)("div",{className:"flex-cell",style:{backgroundColor:"#ffffed"},children:e}),(0,t.jsx)("div",{className:"flex-cell",style:{backgroundColor:"#ffffed"},children:n.actual||""}),(0,t.jsx)("div",{className:"flex-cell",children:n.build||""})]},e)}function q9(s,e){return(0,t.jsx)("div",{className:"flex-row",style:{padding:0},role:"rowgroup",children:Object.keys(s).map(n=>{const a={backgroundColor:"#ffffed"};e:switch(n){case"functionCall":a.flex="2";break e;case"lineNumber":a.flex="0.25";break e;default:}return(0,t.jsx)("div",{className:"flex-cell",style:a,children:(0,t.jsx)("pre",{style:{margin:0},children:s[n]})},n)})},`line${e}`)}function V9(s){return{...s,viewRawStack:!s.viewRawStack}}function H9(s,e){const n=s[e];return n==null?null:(0,t.jsxs)("div",{className:"flex-row",style:{padding:0},role:"rowgroup",children:[(0,t.jsx)("div",{className:"flex-cell",style:{flex:.25,backgroundColor:"#ffffed"},children:e}),(0,t.jsx)("div",{className:"flex-cell",style:{backgroundColor:"#ffffed"},children:(0,t.jsx)("pre",{style:{margin:0},children:n.toString()})})]},e)}function U9(s,e){return(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{children:"Stage"}),(0,t.jsx)(so,{title:s,info:e[s]}),";"]},s)}const Z9=[{label:"All",value:""},{label:"Success",value:"success"},{label:"Failed",value:"failed"},{label:"Unknown",value:"unknown"}],W9=[{label:"All",value:""},{label:"Running",value:"running"},{label:"Finished",value:"finished"}],K9=[{label:"All",value:""},{label:"Valid",value:"true"},{label:"Invalid",value:"false"}];var G9=Q(ie()),Li=Q(Qt()),J9=[{today:"Today"},{last1:"Last Hour"},{last12:"Last 12hrs"},{last24:"Last 24hrs"}],z9=()=>{const s=(0,G9.c)(44),e=zs()?.search;let n;s[0]!==e?(n=()=>{const G=Li.default.parse(e||"",{ignoreQueryPrefix:!0}).filters||{},se={...G};return{jobFilters:{video_id:"",status:"",state:"",valid:"",hostName:"",clusterGroup:"",user:"",timeframe:"",createdAt:"",finishedAt:"",errorSubcat:"",explained:"",...G},loading:!0,filters:se,data:[],show:void 0,showJobError:!1}},s[0]=e,s[1]=n):n=s[1];const[a,o]=(0,f.useState)(n);let i,l;s[2]!==e?(i=function(){const se={...Li.default.parse(e,{ignoreQueryPrefix:!0}).filters||{}};o(U=>({...U,jobFilters:se,filters:se}))},l=[e],s[2]=e,s[3]=i,s[4]=l):(i=s[3],l=s[4]),(0,f.useEffect)(i,l);let r;s[5]===Symbol.for("react.memo_cache_sentinel")?(r=G=>{H.admin.processVideoJobs.search.query(G).then(se=>{const U={data:se.data.map(Q9),meta:se.meta};o(B=>({...B,data:U}))}).catch(X9).finally(()=>{o(eq)})},s[5]=r):r=s[5];const d=En(r);let c;s[6]===Symbol.for("react.memo_cache_sentinel")?(c=G=>{G.preventDefault(),o(tq)},s[6]=c):c=s[6];const m=c;let h;s[7]===Symbol.for("react.memo_cache_sentinel")?(h=(G,se,U)=>{const B=U===void 0?!1:U;G.preventDefault(),o(oe=>({...oe,show:se,showJobError:B}))},s[7]=h):h=s[7];const p=h;let u;s[8]===Symbol.for("react.memo_cache_sentinel")?(u=(G,se)=>{o(U=>({...U,jobFilters:{...U.jobFilters,[G]:se.currentTarget.value}}))},s[8]=u):u=s[8];const g=u;let _;s[9]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{o(sq)},s[9]=_):_=s[9];const v=_;let b;s[10]===Symbol.for("react.memo_cache_sentinel")?(b=(G,se)=>(0,t.jsx)("a",{href:`/admin/process_video_jobs/${se.key}`,onClick:U=>p(U,se),children:"VIEW"}),s[10]=b):b=s[10];const j=b;let x;s[11]===Symbol.for("react.memo_cache_sentinel")?(x=(G,se)=>{const{data:U}=se;return G==="failed"&&U.buildInfo&&U.buildInfo.error?(0,t.jsxs)("a",{href:`/admin/process_video_jobs/${se.key}?showError=true`,onClick:B=>p(B,se,!0),children:["failed ",(0,t.jsx)("br",{}),U.buildInfo.error.subcategory]}):(0,t.jsxs)("span",{children:[G,(0,t.jsx)("br",{}),U.reason]})},s[11]=x):x=s[11];const S=x;let C;
223s[12]!==a?(C=()=>{const{jobFilters:G}=a,se=G.timeframe==="";return(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("div",{className:"level-left",children:(0,t.jsx)("span",{children:"Timeframe: "})}),(0,t.jsxs)("div",{className:"level-right flex-row",children:[(0,t.jsxs)("label",{className:"level-left pr-2",children:["Custom",(0,t.jsx)("input",{type:"radio",name:"timeframe",value:"",checked:se,onChange:U=>{g("timeframe",U)}})]}),J9.map(U=>{const[B,oe]=Object.entries(U)[0],de=G.timeframe===B;return(0,t.jsx)("div",{className:"level-left pr-2",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:oe}),(0,t.jsx)("input",{type:"radio",name:"timeframe",value:B,checked:de,onChange:ye=>{g("timeframe",ye)}})]})},B)})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsxs)("span",{className:"level-left",style:{whiteSpace:"pre"},children:["Created At: Â ",(0,t.jsx)("span",{style:{fontSize:".5em"},children:"ISO Format"})]}),(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("input",{type:"text",value:G.createdAt,onChange:U=>{g("createdAt",U)}}),(0,t.jsxs)("div",{style:{fontSize:".5em"},children:["Ex: ",new Date().toISOString()]})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",style:{whiteSpace:"pre"},children:"Finished At:"}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:G.finishedAt,onChange:U=>{g("finishedAt",U)}})})]})]})},s[12]=a,s[13]=C):C=s[13];const y=C;let N;s[14]!==y||s[15]!==a?(N=()=>{const{jobFilters:G}=a;return(0,t.jsx)("form",{onSubmit:m,className:"flex-container",children:(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Filter"}),(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsxs)("div",{className:"column",children:[(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"User (id or email): "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:G.user,onChange:se=>{g("user",se)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"VideoID: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:G.video_id,onChange:se=>{g("video_id",se)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"HostName: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:G.hostName,onChange:se=>{g("hostName",se)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Cluster Group: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:G.clusterGroup,onChange:se=>{g("clusterGroup",se)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"State: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("select",{className:"options-select",onChange:se=>{g("state",se)},value:G.state,children:W9.map(nq)})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Status: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("select",{className:"options-select",onChange:se=>{g("status",se)},value:G.status,children:Z9.map(aq)})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Valid: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("select",{className:"options-select",onChange:se=>{g("valid",se)},value:G.valid,children:K9.map(oq)})})]})]}),(0,t.jsxs)("div",{className:"column pl-4",children:[y(),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left pr-2",style:{whiteSpace:"pre"},children:"Error Subcategory:"}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:G.errorSubcat,onChange:se=>{g("errorSubcat",se)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left pr-2",style:{whiteSpace:"pre"},children:"Error Explained:"}),(0,t.jsx)("div",{className:"level-right",children:[{"":"All"},{true:"True"},{false:"False"}].map(se=>
223{const[U,B]=Object.entries(se)[0],oe=G.explained===U;return(0,t.jsx)("span",{className:"level-left pr-2",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:B}),(0,t.jsx)("input",{type:"radio",name:"explained",value:U,checked:oe,onChange:de=>{g("explained",de)}})]})},U)})})]})]})]}),(0,t.jsx)("div",{className:"level",children:(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("button",{type:"submit",children:"Filter"})," "]})})]})})},s[14]=y,s[15]=a,s[16]=N):N=s[16];const w=N;let A;s[17]!==a?(A=()=>{if(!a.show)return null;const{show:G,showJobError:se}=a;return(0,t.jsx)(un,{biggerPadding:!0,unsetCancelModal:v,children:(0,t.jsx)("div",{className:"admin",children:(0,t.jsx)(lr,{job:G.data,showJobError:se})})})},s[17]=a,s[18]=A):A=s[18];const I=A;let D,L;s[19]===Symbol.for("react.memo_cache_sentinel")?(L={key:"actions",name:"Actions",style:{flex:"0.3 0 0"},renderCell:j},s[19]=L):L=s[19];let $;s[20]===Symbol.for("react.memo_cache_sentinel")?($={flex:"0.8 0 0"},s[20]=$):$=s[20];let R;s[21]===Symbol.for("react.memo_cache_sentinel")?(R={key:"createdAt",name:"Created At",style:$,filters:[{filter:ds.filterDate,options:{format:"YYYY-MM-DD h:mm:ss a"}}]},s[21]=R):R=s[21];let P;s[22]===Symbol.for("react.memo_cache_sentinel")?(P={key:"finishedAt",name:"Finished At",style:{flex:"0.8 0 0"},filters:[ds.filterDate]},s[22]=P):P=s[22];let k;s[23]===Symbol.for("react.memo_cache_sentinel")?(k={key:"state",name:"State",style:{flex:"0.4 0 0"}},s[23]=k):k=s[23];let T;s[24]===Symbol.for("react.memo_cache_sentinel")?(T={key:"status",name:"Status",style:{flex:"1 0 0"},renderCell:S},s[24]=T):T=s[24];let E;s[25]===Symbol.for("react.memo_cache_sentinel")?(E={key:"serverInfo.hostName",name:"Hostname",style:{flex:"1 0 0"}},s[25]=E):E=s[25];let O;s[26]===Symbol.for("react.memo_cache_sentinel")?(O={key:"serverInfo.clusterGroup",name:"Cluster",style:{flex:"1 0 0"}},s[26]=O):O=s[26];let q;s[27]===Symbol.for("react.memo_cache_sentinel")?(q={key:"valid",name:"Valid?",style:{flex:"0.5 0 0"}},s[27]=q):q=s[27];let J;s[28]===Symbol.for("react.memo_cache_sentinel")?(J=[L,R,P,k,T,E,O,q,{key:"video_id",name:"VideoID",style:{flex:"1 0 0"}}],s[28]=J):J=s[28],D=J;const K=D;let z;s[29]!==I?(z=I(),s[29]=I,s[30]=z):z=s[30];let Y;s[31]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,t.jsx)(be,{to:"/admin",children:"Back to Admin"}),s[31]=Y):Y=s[31];let me;s[32]===Symbol.for("react.memo_cache_sentinel")?(me=(0,t.jsxs)("div",{className:"header",children:[(0,t.jsx)("h2",{className:"headerText",children:"Process Video Jobs"}),(0,t.jsx)("div",{className:"description",children:"All processed videos"})]}),s[32]=me):me=s[32];let X;s[33]!==w?(X=w(),s[33]=w,s[34]=X):X=s[34];let te;s[35]!==d||s[36]!==a.data||s[37]!==a.filters||s[38]!==a.loading?(te=(0,t.jsx)(da,{data:a.data,columns:K,filters:a.filters,listData:d,loading:a.loading}),s[35]=d,s[36]=a.data,s[37]=a.filters,s[38]=a.loading,s[39]=te):te=s[39];let ae;return s[40]!==z||s[41]!==X||s[42]!==te?(ae=(0,t.jsxs)("div",{className:"container",children:[z,Y,me,X,te]}),s[40]=z,s[41]=X,s[42]=te,s[43]=ae):ae=s[43],ae},Y9=f.memo(z9);function Q9(s){return{key:s._id,data:s,props:{expanded:!1}}}function X9(s){console.error("ERROR: ",s)}function eq(s){return{...s,loading:!1}}function tq(s){return{...s,filters:{...s.jobFilters}}}function sq(s){return{...s,show:void 0,showJobError:!1}}function nq(s,e){return(0,t.jsx)("option",{value:s.value,children:s.label},e)}function aq(s,e){return(0,t.jsx)("option",{value:s.value,children:s.label},e)}function oq(s,e){return(0,t.jsx)("option",{value:s.value,children:s.label},e)}const dn=(s,e)=>{const n={};return Object.keys(s).filter(a=>e(a,s[a])).reduce((a,o)=>(a[o]=s[o],a),n),n};var iq=Q(ie()),Bi=Q(Wr()),lq=s=>{const e=(0,iq.c)(8),{strA:n,strB:a}=s;let o;e[0]!==n||e[1]!==a?(o=Dr((0,Bi.formatLines)((0,Bi.diffLines)(n,a))),e[0]=n,e[1]=a,e[2]=o):o=e[2];const i=o[0];if(!i){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("div",{children:"Could not create diff"}),e[3]=c):c=e[3],c}const l=rq;let r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r=c=>c.map(l),e[4]=r):r=e[4];let d;return e[5]!==i.hunks||e[6]!==i.type?(d=(0,t.jsx)(Yr,{viewType:"split",diffType:i.type,hu
223nks:i.hunks,children:r}),e[5]=i.hunks,e[6]=i.type,e[7]=d):d=e[7],d},yo=f.memo(lq);function rq(s){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(Br,{children:[null,s.content]}),(0,t.jsx)(zr,{hunk:s},s.content)]})}var dq=Q(ie());function rr(s){const e=(0,dq.c)(12),[n,a]=(0,f.useState)(!1),{alist:o,blist:i,kind:l,Component:r}=s;let d;e[0]!==r||e[1]!==o||e[2]!==i||e[3]!==l||e[4]!==s?(d=()=>{const{akey:u,bkey:g}=s;let _=u,v=g;_||(_="id"),v||(v="id");const b=Object.assign({},...o.map((y,N)=>({[y[_]]:N}))),j=Object.assign({},...i.map((y,N)=>({[y[v]]:N})));let x=0;const S=o.map((y,N)=>{const w=j[y.id];let A=null;switch(w!==void 0&&(A=i[w],delete j[y.id]),x=x+N,l){case"layers":return(0,t.jsx)(r,{layer:y,layerIndex:N,otherLayer:A,otherLayerIndex:w,expanded:!1},N);case"scenes":return(0,t.jsx)(r,{scene:y,sceneIndex:N,otherScene:A,otherSceneIndex:w,expanded:!1},N);default:return(0,t.jsx)("div",{},N)}}),C=Object.keys(j).map(y=>{x=x+1;const N=j[y],w=i[N],A=b[y],I={};switch(l){case"layers":return(0,t.jsx)(r,{layer:I,layerIndex:A,otherLayer:w,otherLayerIndex:N,expanded:!1},x);case"scenes":return(0,t.jsx)(r,{scene:I,sceneIndex:A,otherScene:w,otherSceneIndex:N,expanded:!1},x);default:return(0,t.jsx)("div",{},x)}});return(0,t.jsx)("div",{className:"body",children:S.concat(C)})},e[0]=r,e[1]=o,e[2]=i,e[3]=l,e[4]=s,e[5]=d):d=e[5];const c=d;let m;e[6]!==n||e[7]!==s||e[8]!==c?(m=()=>{const{header:u}=s,g=s.blist.length;return(0,t.jsxs)("section",{className:"panel m-2 p-2",children:[(0,t.jsxs)("div",{className:"panel-heading p-1 level",onClick:()=>{console.debug(`Expand ${u} ${!n}`),a(!n)},children:[(0,t.jsx)("h4",{className:"level-left",children:u}),(0,t.jsxs)("span",{className:"level-left",children:["(",g,")"]})]}),(0,t.jsx)("div",{className:`${u}`,children:n?c():null})]})},e[6]=n,e[7]=s,e[8]=c,e[9]=m):m=e[9];const h=m;let p;return e[10]!==h?(p=(0,t.jsx)("div",{children:h()}),e[10]=h,e[11]=p):p=e[11],p}var cq=Q(ie());function uq(s){const e=(0,cq.c)(11),[n,a]=(0,f.useState)(s.expanded||!1);let o;e[0]!==s?(o=(h,p)=>{const{excludeKeys:u}=s;return u?!u.includes(h):!0},e[0]=s,e[1]=o):o=e[1];const i=o;let l;e[2]!==s||e[3]!==i?(l=()=>{let{layer:h,otherLayer:p}=s;return h||(h={}),p||(p={}),(0,t.jsx)("div",{children:(0,t.jsx)(yo,{strA:JSON.stringify(dn(h,i),null,2),strB:JSON.stringify(dn(p,i),null,2)})})},e[2]=s,e[3]=i,e[4]=l):l=e[4];const r=l;let d;e[5]!==n||e[6]!==s||e[7]!==r?(d=()=>{const{layerIndex:h,otherLayerIndex:p}=s;let{layer:u,otherLayer:g}=s;return u||(u={}),g||(g={}),(0,t.jsxs)("section",{className:"panel",children:[(0,t.jsx)("div",{className:"panel-heading p-0",onClick:()=>a(!n),children:(0,t.jsx)("div",{className:"table-container",children:(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsx)("b",{className:"flex-cell",children:u.id||""}),(0,t.jsx)("span",{className:"flex-cell",style:{flex:.3},children:h}),(0,t.jsx)("span",{className:"flex-cell",style:{flex:.3},children:p}),(0,t.jsx)("span",{className:"flex-cell",children:g?g.id:""})]})})}),n?r():null]})},e[5]=n,e[6]=s,e[7]=r,e[8]=d):d=e[8];const c=d;let m;return e[9]!==c?(m=(0,t.jsx)("div",{children:c()}),e[9]=c,e[10]=m):m=e[10],m}var mq=Q(ie()),Di=[];function pq(s){const e=(0,mq.c)(6),[n,a]=(0,f.useState)(!1),o=hq;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(m,h)=>(0,t.jsxs)("div",{children:[(0,t.jsx)(yo,{strA:JSON.stringify(dn(m,o),null,2),strB:JSON.stringify(dn(h,o),null,2)}),(0,t.jsx)(rr,{alist:m.layers||Di,blist:h.layers||Di,kind:"layers",header:"Layers",Component:uq})]}),e[0]=i):i=e[0];const l=i;let r;e[1]!==n||e[2]!==s?(r=()=>{const{sceneIndex:m,otherSceneIndex:h}=s;let{scene:p,otherScene:u}=s;return p||(p={}),u||(u={}),(0,t.jsxs)("section",{className:"panel m-2",children:[(0,t.jsx)("div",{className:"panel-heading p-0",onClick:()=>a(!n),children:(0,t.jsx)("div",{className:"table-container",children:(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsx)("b",{className:"flex-cell",children:p.id}),(0,t.jsx)("span",{className:"flex-cell",style:{flex:.3},children:m}),(0,t.jsx)("span",{className:"flex-cell",style:{flex:.3},children:h}),(0,t.jsx)("span",{className:"flex-cell",children:u.id})]})})}),n?l(p,u):null]})},e[1]=n,e[2]=s,e[3]=r):r=e[3];const d=r;let c;return e[4]!==d?(c=(0,t.jsx)("div",{children:d()}),e[4]=d,e[5]=c):c=e[5],c}function hq(s,e){return!["layers"].includes(s)}var fq=Q(ie()),Mi=[];function xq(s){const e=(0,fq.c)(11),[n,a]=(0,f.useState)(!1);let o;e[0]!==s?(o=(h,p)=>{let{excludeKeys:u}=s;return u||(u=["scenes"]),!u.includes(h)},e[0]=s,e[1]=o):o=e[1];const i=o;let l;e[2]!==s||e[3]!==i?(l=()=>{let{video:h,otherVideo:p}=s;return h||(h={}),p||(p={}),(0,t.jsxs)("div",{children:[(0,t.jsx)(yo,{strA:JSON.stringify(dn(h,i),null,2),strB:JSON.stringify(dn(p,i),null,2)}),(0,t.jsx)(rr,{alist:h.scenes||Mi,blist:p.scenes||Mi,kind:"scenes",header:"Scenes",Component:pq})]})},e[2]=s,e[3]=i,e[4]=l):l=e[4];const r=l;let d;e[5]!==n||e[6]!==s||e[7]!==r?(d=()=>{let{video:h,otherVideo:p}=s;return h||(h={}),p||(p={}),(0,t.jsxs)("section",{className:"panel m-2",children:[(0,t.jsx)("div",{className:"panel-heading p-0",onClick:()=>a(!n),children:(0,t.jsx)("div",{className:"table-container",children:(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsx)("b",{className:"flex-cell",children:h._id}),(0,t.jsx)("span",{className:"flex-cell",children:p._id})]})})}),r()]})},e[5]=n,e[6]=s,e[7]=r,e[8]=d):d=e[8];const c=d;let m;return e[9]!==c?(m=(0,t.jsx)("div",{children:c()}
223),e[9]=c,e[10]=m):m=e[10],m}var Fi="play pause seeking".split(/\s+/g);function gq(s){const[e,n]=(0,f.useState)(!0),a=(0,f.useRef)(e),[o,i]=(0,f.useState)(2),l=(0,f.useRef)(null),r=(0,f.useRef)(null),d=(0,f.useRef)(""),c=(0,f.useCallback)(()=>{l.current&&r.current&&Fi.forEach(_=>{r.current?.addEventListener(_,p),l.current?.addEventListener(_,p)})},[]),{onLoadError:m}=s,h=(0,f.useCallback)((_,v)=>{const b=new Event("sync");_.addEventListener("error",j=>{console.error("Error Loading Video"),m&&m(v)},!0),_.onloadedmetadata=()=>{_.dispatchEvent(b)},_.readyState===4&&_.dispatchEvent(b),e?_.addEventListener("sync",c):(_.removeEventListener("sync",c),Fi.forEach(j=>{_.removeEventListener(j,p)}))},[e,c,m]);(0,f.useEffect)(()=>{a.current=e,l.current&&h(l.current,"original"),r.current&&h(r.current,"other")},[e,h]),(0,f.useEffect)(()=>{const _=Number(o)||1;l.current&&(l.current.playbackRate=_),r.current&&(r.current.playbackRate=_)},[o]);const p=_=>{const v=_.type;let b,j;if(_.target===l.current?(b=r.current,j=l.current):(b=l.current,j=r.current),!(j&&b)||!a.current)return;const{currentTime:x,duration:S}=j;if(d.current===v){d.current="";return}v==="seeking"&&b.currentTime!==x&&(d.current=v,b.currentTime=x),!(v==="pause"&&x===S)&&(v==="play"||v==="pause")&&(d.current=v,b[v](),b.currentTime=x,j.currentTime=x)},u=(_,v,b="")=>{const j=_.signed_url||_.fullPath;return _.outputMime&&_.outputMime.includes("image")?(0,t.jsx)("img",{ref:v,alt:"",src:j,className:b}):(0,t.jsx)("video",{ref:v,src:j,className:b,controls:!0})},g=()=>{const{videoObj:_,otherVideoObj:v}=s;return _?(0,t.jsxs)("div",{className:"table-container",children:[(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsxs)("div",{children:["Sync :",(0,t.jsx)("input",{type:"checkbox",value:"sync",defaultChecked:!0,onChange:b=>n(b.currentTarget.checked)})]}),(0,t.jsxs)("div",{children:["Playback Rate:",(0,t.jsx)("input",{type:"input",value:o,onChange:b=>i(b.currentTarget.value)})]})]}),(0,t.jsxs)("div",{className:"flex-row ",children:[(0,t.jsx)("div",{className:"flex-cell",children:(0,t.jsx)("div",{className:"video-wrapper",children:u(_,l,"pull-right")})}),(0,t.jsx)("div",{className:"flex-cell",children:(0,t.jsx)("div",{className:"video-wrapper",children:u(v,r)})})]})]}):null};return(0,t.jsx)("div",{children:g()})}var Da=Q(Qt()),vq=["clipboard","scenes","temp_dir"],_q=class extends f.Component{constructor(s){super(s);const e=Da.default.parse(this.props.location.search,{ignoreQueryPrefix:!0}),n=e.jobId||this.getJobId(),a=e.otherJobId||"",{otherJob:o,job:i}=this.props,l={videoId:"",otherVideoId:""};i&&(l.videoId=i.video_id),o&&(l.otherVideoId=o.video_id),this.state={job:i,jobId:n,otherJob:o,otherJobId:a,filters:l,loadingJob:!1,loadingOtherJob:!1,loadingJobList:!1,loadingOtherJobList:!1,sections:{overview:!0,visual:!1,build:!1,video:this.props.location.hash.startsWith("#d2"),scenes:!1}}}componentDidMount(){const{job:s,jobId:e,otherJob:n,otherJobId:a,filters:o}=this.state;e||o.videoId&&this.fetchJobList(o.videoId,"jobList"),!s&&e&&this.fetchJob(e,"job"),!n&&a&&this.fetchJob(a,"otherJob")}componentDidUpdate(s,e){const n=this.getJobId(),{jobId:a,otherJobId:o,filters:i}=this.state,l=Da.default.parse(this.props.location.search,{ignoreQueryPrefix:!0});if(l.jobId!==a||l.otherJobId!==o){l.jobId=a,l.otherJobId=o;const p=`${this.props.location.pathname}${Da.default.stringify(l,{addQueryPrefix:!0})}`;this.props.navigate(p)}n&&a!==n&&this.setState({jobId:n});const{jobList:r,otherJobList:d,videoId:c,otherVideoId:m}=i;if(e.jobId!==a){const p=(r||[]).find(u=>u.id===a);p?this.setState({...this.state,job:p}):this.fetchJob(a,"job")}if(e.otherJobId!==o){let p=d;(c&&!m||c===m)&&(p=r);const u=(p||[]).find(g=>g.id===o);u?this.setState({...this.state,otherJob:u}):this.fetchJob(o,"otherJob")}const h=e.filters;i.videoId!==h.videoId&&this.fetchJobList(i.videoId,"jobList"),m!==h.otherVideoId&&(m?(this.fetchJobList(m,"otherJobList"),h.otherVideoId&&this.setState({...this.state,otherJobId:"",otherJob:null})):this.setState({otherJobId:"",otherJob:null,filters:{...i,otherJobList:null,otherVideoId:null}}))}getJobId=()=>{let s;return this.props.job?s=this.props.job.id:this.props.jobId?s=this.props.jobId:s=this.props.match.params.processVideoJobId,s||""};fetchJob=(s,e)=>{if(!s)return;const n=`loading${e.replace(/^./,e[0].toUpperCase())}`;this.setState(a=>({...a,[n]:!0})),H.admin.processVideoJobs.getById.query({id:s}).then(a=>{const o=a.data;let i="videoId";e==="otherJob"&&(i="otherVideoId");const l={[i]:o?.video_id};this.setState(r=>({...r,[e]:o,filters:{...r.filters,...l}}))}).catch(a=>{console.error(`Error fetching job ${s}`),console.error(a)}).finally(()=>{this.setState(a=>({...a,[n]:!1}))})};fetchJobList=(s,e)=>{if(!s)return;const n=`loading${e.replace(/^./,e[0].toUpperCase())}`;this.setState(a=>({...a,[n]:!0})),H.admin.processVideoJobs.search.query({filters:{video_id:s}}).then(a=>{this.updateJobFilter(e,a.data)}).catch(a=>{console.error("ERROR: ",a)}).finally(()=>{this.setState(a=>({...a,[n]:!1}))})};fetchSignedUrl=s=>{let e,n;s==="other"?(e=this.state.otherJob,n="otherJob"):(e=this.state.job,n="job"),e&&(e.buildInfo.signed_url||H.admin.processVideoJobs.getByIdSigned.query({id:e.id}).then(a=>{Object.assign(e.buildInfo,a),this.setState(o=>({...o,[n]:e}))}).catch(a=>{console.error("ERROR: ",a)}))};toggleExpand=s=>{const{sections:e}=this.state;this.setState({sections:{...e,[s]:!e[s]}})};handleVideoClick=s=>{if(s.target.className.includes("d2h-file-collapse-input")){const e=s.target.closest(".d2h-file-wrapper"),n=s.target.checked?"None":"Block";e&&(e.querySelector(".d2h-files-diff").style.display=n)}};updateJobFilter=(s,e)=>{this.setState(n=>({filters:{...n.filters,[s]:e}}))};renderSectionHeader=(s,e)=>(0,t.jsxs)("div",{className:"panel-heading level",onClick:()=>this.toggleExpand(e),children:[(0,t.jsx)("h4",{className:"level-left",children:s}),(0,t.jsx)("span",{className:"level-right",children:this.state.sections[e]?"Collapse":"Expand"})]});renderJobList=(s,e,n,a)=>e?(0,t.jsx)(it,{}):s?(0,t.jsxs)("select",{className:"options-select",onChange:o=>{this.setState(i=>({...i,[n]:o.target.value}))},value:a,children:[(0,t.jsx)("option",{value:"",children:"Select Job"},"Select"),s.map((o,i)=>(0,t.jsx)("option",{value:o.id,children:o.createdAt},i))]}):null;renderCompareState=()=>{const{jobId:s,otherJobId:e,loadingJobList:n,loadingOtherJobList:a,filters:o}=this.state,{videoId:i,jobList:l}=o;let{otherVideoId:r,otherJobList:d}=o;return i&&!r&&(r=i),l&&!d&&(d=l),(0,t.jsxs)("section",{className:"compare panel",children:[(0,t.jsx)("div",{className:"panel-heading",children:(0,t.jsx)("h4",{children:"Compare"})}),(0,t.jsx)("div",{className:"panel-body",children:(0,t.jsxs)("div",{className:"level",children:[(0,t.jsxs)("div",{className:"level-left",children:[(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Video ID:"}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:i,onChange:c=>{this.updateJobFilter("videoId",c.target.value)}})})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Select Job: "}),(0,t.jsx)("div",{className:"level-right",children:this.renderJobList(l,n,"jobId",s)})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Job ID: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:s,onChange:c=>{this.setState(m=>({...m,jobId:c.target.value}))}})})]})]}),(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsxs)("div",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Other VideoID: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:r,onChange:c=>{this.updateJobFilter("otherVideoId",c.target.value)}})})]}),(0,t.jsx)("div",{children:(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Select Other Job: "}),(0,t.jsx)("div",{className:"level-right",children:this.renderJobList(d,a,"otherJobId",e)})]})}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Other Job ID: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",value:e,onCh
223ange:c=>{this.setState(m=>({...m,otherJobId:c.target.value}))}})})]})]})]})})]})};renderCompareRow=(s,e,n,a=!0)=>{let o="#ffffed",i="black";return a&&e!==n&&(o="#CC5500",i="white"),(0,t.jsxs)("div",{className:"flex-row",style:{padding:0,backgroundColor:o,color:i},role:"rowgroup",children:[(0,t.jsx)("div",{className:"flex-cell",style:{flex:.5},children:s}),(0,t.jsx)("div",{className:"flex-cell",children:(0,t.jsx)("pre",{style:{margin:0},children:e})}),(0,t.jsx)("div",{className:"flex-cell",children:(0,t.jsx)("pre",{style:{margin:0},children:n})})]})};renderOverview=()=>{const{job:s,otherJob:e}=this.state;if(!s||!e)return null;const n=new Date(s.startedAt).getTime(),a=new Date(s.finishedAt).getTime(),o=new Date(e.startedAt).getTime(),i=new Date(e.finishedAt).getTime(),l=s.video||{},r=e.video||{},d=s.buildInfo||{},c=e.buildInfo||{},m=s.videoStats||{},h=e.videoStats||{};return(0,t.jsxs)("div",{className:"panel-body",children:[this.renderCompareRow("",(0,t.jsx)(be,{to:`/admin/process_video_jobs/${s.id}`,children:s.id}),(0,t.jsx)(be,{to:`/admin/process_video_jobs/${e.id}`,children:e.id}),!1),this.renderCompareRow("Status",s.status,e.status),this.renderCompareRow("CreatedAt",s.createdAt,e.createdAt,!1),this.renderCompareRow("Build Time",(a-n)/1e3,(i-o)/1e3),this.renderCompareRow("Duration",l.duration,r.duration),this.renderCompareRow("Output Duration",m.duration,h.duration),this.renderCompareRow("Output Dimensions W x H",`${m.file_width} x ${m.file_height}`,`${h.file_width} x ${h.file_height}`),this.renderCompareRow("Dimensions W x H",`${l.width} x ${l.height}`,`${r.width} x ${r.height}`),this.renderCompareRow("Scene Count",d.sceneCount,c.sceneCount),this.renderCompareRow("Layer Count",d.layerCount,c.layerCount),this.renderCompareRow("Download Count",d.downloadCount,c.downloadCount),this.renderCompareRow("Remove Backgroun
223d",`${d.hasRemoveBg}`,`${c.hasRemoveBg}`),this.renderCompareRow("Blur Background",`${d.hasBlurBg}`,`${c.hasBlurBg}`)]})};renderVideo=()=>{const{job:s,otherJob:e}=this.state;return!s||!e?null:(0,t.jsx)("div",{className:"compareVideo",onClick:this.handleVideoClick,children:(0,t.jsx)(xq,{video:s.video,otherVideo:e.video,excludeKeys:vq})})};renderVisualCompare=()=>{const{job:s,otherJob:e}=this.state;return!s||!e?null:(0,t.jsx)(gq,{videoObj:s.buildInfo||{},otherVideoObj:e.buildInfo||{},onLoadError:this.fetchSignedUrl})};renderBreadCrumbs=()=>(0,t.jsxs)("div",{className:"flex-row",children:[(0,t.jsx)(be,{to:"/admin",children:"Admin"})," Â / Â ",(0,t.jsx)(be,{to:"/admin/process_video_jobs",children:"Video Jobs"})," Â / Â ",(0,t.jsxs)(be,{to:`/admin/process_video_jobs/${this.state.jobId}`,children:["Job ",this.state.jobId]})]});renderOverviewSection=()=>(0,t.jsxs)("section",{className:"panel",children:[this.renderSectionHeader("Overview","overview"),this.state.sections.overview?this.renderOverview():""]});renderVisualSection=()=>(0,t.jsxs)("section",{className:"panel",children:[this.renderSectionHeader("Visual","visual"),this.state.sections.visual?this.renderVisualCompare():""]});renderVideoSection=()=>(0,t.jsxs)("section",{className:"panel",children:[this.renderSectionHeader("Video Object","video"),this.state.sections.video?this.renderVideo():""]});renderSections=()=>{const{loadingJob:s,loadingOtherJob:e}=this.state;return s||e?(0,t.jsx)(it,{}):(0,t.jsxs)("div",{children:[this.renderOverviewSection(),this.renderVisualSection(),this.renderVideoSection()]})};render(){return(0,t.jsxs)("div",{className:"compare container",children:[(0,t.jsx)("div",{className:"header",children:(0,t.jsx)("h2",{className:"headerText",children:"Compare Video Jobs"})}),this.renderBreadCrumbs(),this.renderCompareState(),this.renderSections()]})}},jq=Qs(_q),bq=Q(ie()),yq=()=>{const s=(0,bq.c)(3);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(Te,{path:"/compare/*",element:(0,t.jsx)(jq,{})}),s[0]=e):e=s[0];let n;s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(Te,{path:"/:processVideoJobId/*",element:(0,t.jsx)(lr,{})}),s[1]=n):n=s[1];let a;return s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("div",{className:"container process-video-job",children:(0,t.jsxs)(Bn,{children:[e,n,(0,t.jsx)(Te,{path:"/*",element:(0,t.jsx)(Y9,{})})]})}),s[2]=a):a=s[2],a},Sq=f.memo(yq);const Cq="1001",Nq="1000",wq="58px",Aq="ProductNotifications-module_page_XKFzK",Iq="ProductNotifications-module_form_YyPoI",Tq="ProductNotifications-module_field_7T-Aj",kq="ProductNotifications-module_label_tVDqZ",Rq="ProductNotifications-module_input_muNLS",$q="ProductNotifications-module_textarea_EaDQO",Pq="ProductNotifications-module_hint_tJDEQ",Eq="ProductNotifications-module_actions_yxNrp",Lq="ProductNotifications-module_primaryButton_IwLmC",Bq="ProductNotifications-module_cancelButton_efEdE",Dq="ProductNotifications-module_campaignList_jzvoL",Mq="ProductNotifications-module_pastNotifications_PC2rf",Fq="ProductNotifications-module_notificationsSectionTitle_wl7QS",Oq="ProductNotifications-module_pastNotificationsTrigger_Kpdf6",qq="ProductNotifications-module_pastNotificationsChevron_JJwNH",Vq="ProductNotifications-module_pastNotificationsChevronOpen_jfFPV",Hq="ProductNotifications-module_campaign_c5f0Z",Uq="ProductNotifications-module_campaignHeader_Qm9Sb",Zq="ProductNotifications-module_campaignTitle_ELUMJ",Wq="ProductNotifications-module_campaignBody_1yF2F",Kq="ProductNotifications-module_campaignMetadata_CFEuI",Gq="ProductNotifications-module_campaignLink_511ob",Jq="ProductNotifications-module_emptyState_pdNfx";var Ze={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:Cq,paywallBgZIndex:Nq,collapsedMediaSidebarWidth:wq,page:Aq,form:Iq,field:Tq,label:kq,input:Rq,textarea:$q,hint:Pq,actions:Eq,primaryButton:Lq,cancelButton:Bq,campaignList:Dq,pastNotifications:Mq,notificationsSectionTitle:Fq,pastNotificationsTrigger:Oq,pastNotificationsChevron:qq,pastNotificationsChevronOpen:Vq,campaign:Hq,campaignHeader:Uq,campaignTitle:Zq,campaignBody:Wq,campaignMetadata:Kq,campaignLink:Gq,emptyState:Jq},zq=()=>{const s=tt(),[e,n]=(0,f.useState)(""),[a,o]=(0,f.useState)(""),[i,l]=(0,f.useState)(""),[r,d]=(0,f.useState)(""),[c,m]=(0,f.useState)([]),[h,p]=(0,f.useState)(!1),[u,g]=(0,f.useState)(!1),_=(0,f.useRef)(null),v=(0,f.useCallback)(async function(N=!0){try{m((await H.admin.productNotifications.list.query()).campaigns.map(w=>({...w,_id:w._id.toString(),scheduledAt:w.scheduledAt.toString()})))}catch(w){console.error("Error loading product notifications:",w),N&&s(He({description:"Could not load product notifications.",type:"error"}))}},[s]);(0,f.useEffect)(function(){v();const N=window.setInterval(()=>void v(!1),5e3);return()=>window.clearInterval(N)},[v]);const b=async y=>{y.preventDefault(),p(!0);try{const N=_.current?.value??r,w=new Date(N);if(Number.isNaN(w.getTime()))throw new Error("A valid send date and time is required.");await H.admin.productNotifications.create.mutate({title:e,body:a,link:i,scheduledAt:w.toISOString()}),n(""),o(""),l(""),d(""),await v(),s(He({description:"Product notification scheduled.",type:"success"}))}catch(N){console.error("Error scheduling product notification:",N),s(He({description:`Could not schedule the product notification: ${N instanceof Error?N.message:"Unknown error"}`,type:"error"}))}finally{p(!1)}},j=async y=>{try{await H.admin.productNotifications.cancel.mutate({id:y}),await v(),s(He({description:"Product notification cancelled.",type:"success"}))}catch(N){console.error("Error cancelling product notification:",N),s(He({description:"Could not cancel the product notification.",type:"error"}))}},x=c.filter(y=>y.status===xn.Scheduled||y.status===xn.Processing),S=c.filter(y=>y.status!==xn.Scheduled&&y.status!==xn.Processing),C=y=>(0,t.jsxs)("article",{className:Ze.campaign,children:[(0,t.jsxs)("div",{className:Ze.campaignHeader,children:[(0,t.jsx)("span",{className:Ze.campaignTitle,children:y.title}),y.status===xn.Scheduled&&(0,t.jsx)("button",{className:Ze.cancelButton,onClick:()=>void j(y._id),type:"button",children:"Cancel"})]}),(0,t.jsx)("p",{className:Ze.campaignBody,children:y.body}),(0,t.jsx)("a",{className:Ze.campaignLink,href:y.link,rel:"noreferrer",target:"_blank",children:y.link}),(0,t.jsxs)("div",{className:Ze.campaignMetadata,children:[(0,t.jsxs)("span",{children:["Status: ",y.status]}),(0,t.jsxs)("span",{children:["Sender: ",y.senderEmail??"Not recorded"]}),(0,t.jsxs)("span",{children:["Scheduled: ",new Date(y.scheduledAt).toLocaleStr
223ing()]}),y.recipientCount!==void 0&&(0,t.jsxs)("span",{children:["Recipients: ",y.recipientCount]})]})]},y._id);return(0,t.jsxs)("main",{className:Ze.page,children:[(0,t.jsx)("h1",{children:"Product notifications"}),(0,t.jsx)("p",{children:"Schedule product tips and updates for users who have in-app product notifications enabled."}),(0,t.jsx)("p",{children:"Dev delivery is restricted to admin accounts. The PRODUCT_NOTIFICATIONS flag must be set to Admin Only before scheduling."}),(0,t.jsxs)("form",{className:Ze.form,onSubmit:b,children:[(0,t.jsxs)("div",{className:Ze.field,children:[(0,t.jsx)("label",{className:Ze.label,htmlFor:"product-notification-title",children:"Title"}),(0,t.jsx)("input",{className:Ze.input,id:"product-notification-title",maxLength:80,onChange:y=>n(y.target.value),required:!0,value:e}),(0,t.jsxs)("span",{className:Ze.hint,children:[e.length,"/80 characters"]})]}),(0,t.jsxs)("div",{className:Ze.field,children:[(0,t.jsx)("label",{className:Ze.label,htmlFor:"product-notification-body",children:"Body"}),(0,t.jsx)("textarea",{className:Ze.textarea,id:"product-notification-body",maxLength:240,onChange:y=>o(y.target.value),required:!0,value:a}),(0,t.jsxs)("span",{className:Ze.hint,children:[a.length,"/240 characters"]})]}),(0,t.jsxs)("div",{className:Ze.field,children:[(0,t.jsx)("label",{className:Ze.label,htmlFor:"product-notification-link",children:"Destination link"}),(0,t.jsx)("input",{className:Ze.input,id:"product-notification-link",onChange:y=>l(y.target.value),placeholder:"https://www.kapwing.com/...",required:!0,type:"url",value:i})]}),(0,t.jsxs)("div",{className:Ze.field,children:[(0,t.jsx)("label",{className:Ze.label,htmlFor:"product-notification-scheduled-at",children:"Send date and time"}),(0,t.jsx)("input",{className:Ze.input,id:"product-notification-scheduled-at",onChange:y=>d(y.target.value),ref:_,required:!0,type:"datetime-local",value:r}),(0,t.jsx)("span",{className:Ze.hint,children:"Times are entered in your local timezone and stored in UTC."})]}),(0,t.jsx)("div",{className:Ze.actions,children:(0,t.jsx)("button",{className:Ze.primaryButton,disabled:h,type:"submit",children:h?"Schedulingâ¦":"Schedule notification"})})]}),(0,t.jsxs)("h2",{className:Ze.notificationsSectionTitle,children:["Queued notifications (",x.length,")"]}),(0,t.jsxs)("div",{className:Ze.campaignList,children:[c.length===0&&(0,t.jsx)("p",{className:Ze.emptyState,children:"No campaigns scheduled yet."}),c.length>0&&x.length===0&&(0,t.jsx)("p",{className:Ze.emptyState,children:"No queued notifications."}),x.map(C)]}),S.length>0&&(0,t.jsxs)("section",{className:Ze.pastNotifications,children:[(0,t.jsxs)("button",{"aria-controls":"past-product-notifications","aria-expanded":u,className:`${Ze.notificationsSectionTitle} ${Ze.pastNotificationsTrigger}`,onClick:()=>g(y=>!y),type:"button",children:[(0,t.jsx)("span",{"aria-hidden":"true",className:`${Ze.pastNotificationsChevron} ${u?Ze.pastNotificationsChevronOpen:""}`,children:"â¾"}),"Past notifications (",S.length,")"]}),u&&(0,t.jsx)("div",{className:Ze.campaignList,id:"past-product-notifications",children:S.map(C)})]})]})},Yq=f.memo(zq),Qq=class extends f.Component{handleChange=s=>{this.props.updateCell(this.props.rowIndex,this.props.rowKey,s.currentTarget.value,!1)};handleKeyPress=s=>{s.key==="Enter"&&(s.preventDefault(),s.currentTarget.blur(),this.props.updateCell(this.props.rowIndex,this.props.rowKey,s.currentTarget.value,!0))};handleSelectChange=s=>{this.props.updateCell(this.props.rowIndex,this.props.rowKey,JSON.parse(s.currentTarget.value),!0)};render(){return this.props.type==="boolean"?(0,t.jsxs)("select",{value:this.props.cell,onChange:this.handleSelectChange,children:[(0,t.jsx)("option",{value:"true",children:"True"}),(0,t.jsx)("option",{value:"false",children:"False"})]}):(0,t.jsx)("input",{value:this.props.cell,onKeyPress:this.handleKeyPress,onChange:this.handleChange})}},Ma=Qq,Oi=Q(Qt()),Xq=[{key:"videoId",name:"Video ID",style:{flex:"0.5 0 0"}},{key:"createdAt",name:"Created At",style:{flex:"0.5 0 0"},renderCell:ds.filterDate},{key:"updatedAt",name:"Updated At",style:{flex:"0.5 0 0"},renderCell:ds.filterDate},{key:"isDisabled",name:"Is Disabled",style:{flex:"0.5 0 0"}},{key:"lastProcessed",name:"Last Processed",style:{flex:"0.5 0 0"},renderCell:ds.filterDate},{key:"description",name:"Description",style:{flex:"0.5 0 0"}},{key:"update",name:"Update",style:{flex:"0.2 0 0"}},{key:"delete",name:"Delete",style:{flex:"0.1 0 0"}}],eV=()=>{const s=zs(),[e,n]=(0,f.useState)(()=>{const b=Oi.default.parse(s.search,{ignoreQueryPrefix:!0}).filters||{},j={...b};if(b.createdAt){const x="YYYY-MM-DD h:mm:ss a",S=ot(new Date(b.createdAt));S.isValid()&&(b.createdAt=S.format(x))}return{videoFilters:{videoId:"",createdAt:"",updatedAt:"",isDisabled:"",lastProcessed:"",description:"",...b},create:{videoId:"",isDisabled:"",description:""},loading:!0,filters:j,tableData:[]}});(0,f.useEffect)(()=>{const b=Oi.default.parse(s.search,{ignoreQueryPrefix:!0}).filters||{},j={...b};if(b.createdAt){const x="YYYY-MM-DD h:mm:ss a",S=ot(new Date(b.createdAt));S.isValid()&&(b.createdAt=S.format(x))}if(b.updatedAt){const x="YYYY-MM-DD h:mm:ss a",S=ot(new Date(b.updatedAt));S.isValid()&&(b.updatedAt=S.format(x))}if(b.lastProcessed){const x="YYYY-MM-DD h:mm:ss a",S=ot(new Date(b.lastProcessed));S.isValid()&&(b.lastProcessed=S.format(x))}n(x=>({...x,videoFilters:b,filters:j}))},[s.search]);const a=En(b=>{H.admin.regressionVideos.search.query(b).then(j=>{const x={data:j.data.map(S=>(S.edits={...S},S.delete=!1,{key:S.id,data:S,props:{expanded:!1}})),meta:j.meta};n(S=>({...S,tableData:x}))}).catch(j=>{console.error("ERROR: ",j)}).finally(()=>{n(j=>({...j,loading:!1}))})}),o=En(b=>{b.preventDefault();const{videoFilters:j}=e;let x=j.createdAt,S=j.updatedAt,C=j.lastProcessed;if(j.createdAt){const y=ot(new Date(j.createdAt));y.isValid()&&(x=y.toISOString())}if(j.updatedAt){const y=ot(new Date(j.updatedAt));y.isValid()&&(S=y.toISOString())}if(j.lastProcessed){const y=ot(new Date(j.lastProcessed));y.isValid()&&(C=y.toISOString())}n(y=>({...y,filters:{...j,createdAt:x,updatedAt:S,lastProcessed:C}}))}),i=(0,f.useCallback)(b=>{b.preventDefault(),H.admin.regressionVideos.create.mutate({...e.create}).catch(j=>{console.error("ERROR: ",j)}).finally(()=>{window.location.reload()})},[e.create]),l=b=>{window.confirm(`Are you sure you want to delete ${b}?`)&&H.admin.regressionVideos.delete.mutate({id:b}).catch(j=>{console.error("ERROR: ",j)}).finally(()=>{window.location.reload()})},r=(b,j)=>{n(x=>({...x,videoFilters:{...x.videoFilters,[b]:j}}))},d=(b,j)=>{n(x=>({...x,create:{...x.create,[b]:j}}))},c=()=>{n(b=>{const j={...b.tableData};return j.data=j.data.map(x=>(delete x.data.edits,x.data.edits={...x.data},x.data.delete=!1,x)),{...b,tableData:j}})},m=async b=>{window.confirm(`Update ${b.id}: ${JSON.stringify(b.edits)}`)&&await H.admin.regressionVideos.update.mutate({id:b.id,...b.edits})},h=(b,j,x,S)=>{if(S){const{data:C}=e.tableData.data[b];window.confirm(`Update ${C.id}: ${C[j]} -> ${x}`)?H.admin.regressionVideos.update.mutate({...C,[j]:x}).then(y=>{n(N=>{const w={...N.tableData};return w.data[b].data={...w.data[b].data,..."changed"in y?y.changed:{}},delete w.data[b].data.edits,w.data[b].data.edits={...w.data[b].data},w.data[b].data.delete=!1,{...N,tableData:{...w}}})}).catch(y=>{console.error("ERROR: ",y),c()}):c()}else{const C=e.tableData;C.data[b].data.edits[j]=x,n(y=>({...y,tableData:C}))}},p=(b,j,x)=>{const{data:S}=b,C=j.key,y=S.edits[C];if(j.renderCell)return j.renderCell(y,b,j);switch(C){case"videoId":return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ma,{updateCell:h,type:"string",cell:y,rowKey:C,rowIndex:x}),(0,t.jsx)("a",{href:`/videos/${y}/debug`,target:"_blank",rel:"noopener noreferrer",children:"Go to Video"})]});case"isDisabled":return(0,t.jsx)(Ma,{updateCell:h,type:"boolean",cell:y,rowKey:C,rowIndex:x});
223case"description":return(0,t.jsx)(Ma,{updateCell:h,type:"string",cell:y,rowKey:C,rowIndex:x});case"update":return(0,t.jsx)("button",{type:"button",onClick:()=>m(S),children:"Update"});case"delete":return(0,t.jsx)("button",{type:"button",onClick:()=>l(S.id),children:"x"});default:return JSON.stringify(S[C])}},u=(b,j)=>(0,t.jsx)("div",{className:"column",children:(0,t.jsx)("div",{className:"flex-row",role:"rowgroup",children:b.columns.map((x,S)=>(0,t.jsx)("div",{className:"flex-cell",style:x.style||{},children:p(b,x,j)},S))})},`row_${j}`),g=(0,f.useCallback)(()=>{const{videoFilters:b}=e;return(0,t.jsx)("form",{onSubmit:o,className:"flex-container",children:(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Filter"}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Created At: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:b.createdAt,onChange:j=>{r("createdAt",j.currentTarget.value)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Updated At: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:b.updatedAt,onChange:j=>{r("updatedAt",j.currentTarget.value)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Last Processed: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:b.lastProcessed,onChange:j=>{r("lastProcessed",j.currentTarget.value)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Description: "}),(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:b.description,onChange:j=>{r("description",j.currentTarget.value)}}),(0,t.jsx)("div",{style:{fontSize:"9px"},children:'* Regex Ex: "regression.*"'})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Video ID: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:b.videoId,onChange:j=>{r("videoId",j.currentTarget.value)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Is Disabled: "}),(0,t.jsxs)("select",{style:{width:"200px"},value:b.isDisabled,onChange:j=>{r("isDisabled",JSON.parse(j.currentTarget.value))},children:[(0,t.jsx)("option",{value:"",children:"All"}),(0,t.jsx)("option",{value:"true",children:"True"}),(0,t.jsx)("option",{value:"false",children:"False"})]})]}),(0,t.jsx)("div",{className:"level",children:(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("button",{type:"submit",children:"Filter"})," "]})})]})})},[e,o]),_=(0,f.useCallback)(()=>(0,t.jsx)("form",{onSubmit:i,className:"flex-container",children:(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Create"}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Video ID: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:e.create.videoId,onChange:b=>{d("videoId",b.currentTarget.value)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Is Disabled: "}),(0,t.jsxs)("select",{style:{width:"200px"},value:e.create.isDisabled,onChange:b=>{d("isDisabled",JSON.parse(b.currentTarget.value))},children:[(0,t.jsx)("option",{value:"true",children:"True"}),(0,t.jsx)("option",{value:"false",children:"False"})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Description: "}),(0,t.jsx)("div",{className:"level-right",children:(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:e.create.description,onChange:b=>{d("description",b.currentTarget.value)}})})]}),(0,t.jsx)("div",{className:"level",children:(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("button",{type:"submit",children:"Create"})," "]})})]})}),[i,e.create]),v=(0,f.useCallback)(()=>(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"row"},children:[g(),_()]}),[_,g]);return(0,t.jsxs)("div",{className:"container video-validation",children:[(0,t.jsx)(be,{to:"/admin",children:"Back to Admin"}),(0,t.jsxs)("div",{className:"header",children:[(0,t.jsx)("h2",{className:"headerText",children:"Regression Videos"}),(0,t.jsx)("div",{className:"description",children:"Add, remove, disable, or view our regression videos."})]}),(0,t.jsx)(da,{data:e.tableData,columns:Xq,filters:e.filters,listData:a,loading:e.loading,renderRow:u,renderSectionHeader:v})]})},tV=f.memo(eV);const sV="1001",nV="1000",aV="58px",oV="AdminRepurposeGallery-module_container_sxHF6",iV="AdminRepurposeGallery-module_thumbnailContainer_XIWCH",lV="AdminRepurposeGallery-module_card_nnhI6",rV="AdminRepurposeGallery-module_title_dVCo8",dV="AdminRepurposeGallery-module_status_dPAwa",cV="AdminRepurposeGallery-module_moreContainer_f6Wih",uV="AdminRepurposeGallery-module_moreButton_ZK9q4";var Bs={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:sV,paywallBgZIndex:nV,collapsedMediaSidebarWidth:aV,container:oV,thumbnailContainer:iV,card:lV,title:rV,status:dV,moreContainer:cV,moreButton:uV},mV=()=>{const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)(!0),[o,i]=(0,f.useState)(null),l=(0,f.useRef)(0),r=(0,f.useCallback)(async()=>{try{a(!0);const{workflows:d,newOffset:c}=await H.workflows.adminRepurposeGallery.query({offset:l.current});e(m=>[...m,...d]),l.current=c}catch(d){i(String(d))}finally{a(!1)}},[]);return(0,f.useEffect)(()=>{r()},[r]),n&&!s.length?(0,t.jsx)("div",{children:"Loading..."}):o?(console.error(o),(0,t.jsx)("div",{children:"Error..."})):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:Bs.container,children:s.map(d=>{const c=d.status===ln.COMPLETE,m=Date.now()-new Date(d.createdAt).getTime(),h=Math.round(m/1e3/60);let p="",u="";return c?(p=`${d.assetDurationMin} min - ${d.numHighlights} highlights`,u="hsla(114, 50%, 21%, 1)"):d.status===ln.RUNNING||d.status===ln.PENDING?(p=`Processing (${h} min)`,u="hsla(42, 50%, 38%, 1)"):(p="Failed",u="hsla(0, 50%, 23%, 1)"),(0,t.jsxs)("a",{className:Bs.card,href:`/repurpose/${d._id}`,children:[(0,t.jsx)("div",{className:Bs.thumbnailContainer,children:(0,t.jsx)(hu,{elementType:Qi.WORKFLOW,thumbnailUrl:d.thumbnailUrl})}),(0,t.jsx)("div",{className:Bs.title,children:d.name}),(0,t.jsx)("div",{className:Bs.status,style:{color:u},children:p})]},d._id)})}),(0,t.jsx)("div",{className:Bs.moreContainer,children:n?(0,t.jsx)("div",{children:"Loading more..."}):(0,t.jsx)("button",{onClick:r,className:Bs.moreButton,children:"Load more"})})]})}
223,pV=f.memo(mV),Fa={top:20,right:20,bottom:20,left:20},Oa={strokeDasharray:"3 3"};function qi(s){const e=s.started,n=s.finished;if(!e||!n)return 1;const a=new Date(e).getTime()/1e3;return new Date(n).getTime()/1e3-a}var hV=async()=>(await H.admin.getSpeakerFocusJobs.query()).body,fV=()=>{const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)(!0),o=(0,f.useCallback)(()=>s.filter(p=>p.status==="error").splice(0,5).map(p=>({id:p._id,message:p.errorMessage})),[s]),i=(0,f.useCallback)(()=>{const p=s.filter(_=>_.status===Sa.SUCCESS),u=s.filter(_=>_.status===Sa.QUEUED),g=s.filter(_=>_.status===Sa.ERROR);return{count:s.length,success:p,queued:u,error:g,assetDuration:p.reduce((_,v)=>_+(v.asset_duration??0),0)/p.length,duration:p.reduce((_,v)=>_+qi(v),0)/p.length,assetDownloadDuration:p.reduce((_,v)=>_+(v.job_result?.asset_download_duration??0),0)/p.length,transcriptionDuration:p.reduce((_,v)=>_+(v.job_result?.transcription_duration??0),0)/p.length,sceneSplitDuration:p.reduce((_,v)=>_+(v.job_result?.scene_split_duration??0),0)/p.length,frameExtractionDuration:p.reduce((_,v)=>_+(v.job_result?.frame_extraction_duration??0),0)/p.length,yoloDuration:p.reduce((_,v)=>_+(v.job_result?.yolo_duration??0),0)/p.length,mediapipeDuration:p.reduce((_,v)=>_+(v.job_result?.mp_duration??0),0)/p.length,mtcnnDuration:p.reduce((_,v)=>_+(v.job_result?.mtcnn_duration??0),0)/p.length,deepfaceDuration:p.reduce((_,v)=>_+(v.job_result?.deepface_duration??0),0)/p.length,deepfaceFacesProcessed:p.reduce((_,v)=>_+(v.job_result?.deepface_faces_processed??0),0)/p.length,talknetDuration:p.reduce((_,v)=>_+(v.job_result?.talknet_duration??0),0)/p.length,talknetIntervalsProcessed:p.reduce((_,v)=>_+(v.job_result?.talknet_intervals_processed??0),0)/p.length,framesProcessed:p.reduce((_,v)=>_+(v.job_result?.frames_processed??0),0)/p.length,framesWithPeople:p.reduce((_,v)=>_+(v.job_result?.framesWithPeople??0),0)/p.length,speakersDetected:p.reduce((_,v)=>_+(v.job_result?.speakerCount??0),0)/p.length,transcriptTimestamps:p.reduce((_,v)=>_+(v.job_result?.transcript_speaker_switch_timestamps?.length??0),0)/p.length,sceneSplitTimestamps:p.reduce((_,v)=>_+(v.job_result?.scene_split_timestamps.length??0),0)/p.length,faceDetectedPerPerson:p.reduce((_,v)=>{const b=v.job_result.personCount,j=v.job_result.faceCount/b;return _+(isNaN(j)?0:j)},0)/p.length}},[s]),l=(0,f.useMemo)(()=>i(),[i]),r=(0,f.useMemo)(()=>o(),[o]),d=(0,f.useCallback)(p=>p.map(u=>({x:u.asset_duration,y:qi(u),name:u._id})),[]),c=(0,f.useCallback)(p=>p.map(u=>({x:u.job_result?.frames_processed,y:(u.job_result?.frame_extraction_duration??0)+(u.job_result?.yolo_duration??0)+(u.job_result?.mp_duration??0)+(u.job_result?.mtcnn_duration??0)+(u.job_result?.deepface_duration??0)+(u.job_result?.talknet_duration??0),name:u._id})),[]),m=(0,f.useCallback)(p=>p.map(u=>({x:u.job_result?.frames_processed,y:u.asset_duration,name:u._id})),[]),h=(p,u)=>(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{children:p}),(0,t.jsxs)("div",{children:["Count: ",(0,t.jsx)("strong",{children:u.count})]}),(0,t.jsxs)("div",{children:["Success: ",(0,t.jsx)("strong",{children:u.success.length})]}),(0,t.jsxs)("div",{children:["Failures: ",(0,t.jsx)("strong",{children:u.error.length})]}),(0,t.jsxs)("div",{children:["Queued: ",(0,t.jsx)("strong",{children:u.queued.length})]}),(0,t.jsxs)("div",{children:["Average Asset Duration: ",(0,t.jsx)("strong",{children:u.assetDuration})]}),(0,t.jsxs)("div",{children:["Average Duration: ",(0,t.jsx)("strong",{children:u.duration})]}),(0,t.jsxs)("div",{children:["Asset Download:"," ",(0,t.jsxs)("strong",{children:[u.assetDownloadDuration," (",((u.assetDownloadDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Transcription:"," ",(0,t.jsxs)("strong",{children:[u.transcriptionDuration," (",((u.transcriptionDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Scene Split:"," ",(0,t.jsxs)("strong",{children:[u.sceneSplitDuration," (",((u.sceneSplitDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Frame Extraction:"," ",(0,t.jsxs)("strong",{children:[u.frameExtractionDuration," (",((u.frameExtractionDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Object Detection:"," ",(0,t.jsxs)("strong",{children:[u.yoloDuration," (",((u.yoloDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Face Landmark Detection:"," ",(0,t.jsxs)("strong",{children:[u.mediapipeDuration," (",((u.mediapipeDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Face Detection:"," ",(0,t.jsxs)("strong",{children:[u.mtcnnDuration," (",((u.mtcnnDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Face Recognition:"," ",(0,t.jsxs)("strong",{children:[u.deepfaceDuration," (",((u.deepfaceDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Faces Processed: ",(0,t.jsx)("strong",{children:u.deepfaceFacesProcessed})]}),(0,t.jsxs)("div",{children:["Active Speaker Detection:"," ",(0,t.jsxs)("strong",{children:[u.talknetDuration," (",((u.talknetDuration??0)/u.duration*100).toFixed(2),"%)"]})]}),(0,t.jsxs)("div",{children:["Active Speaker Detection Intervals Processed:"," ",(0,t.jsx)("strong",{children:u.talknetIntervalsProcessed})]}),(0,t.jsxs)("div",{children:["Faces Detected per Person:"," ",(0,t.jsx)("strong",{children:u.faceDetectedPerPerson})]}),(0,t.jsxs)("div",{children:["Frames Processed: ",(0,t.jsx)("strong",{children:u.framesProcessed})]}),(0,t.jsxs)("div",{children:["Frames with people: ",(0,t.jsx)("strong",{children:u.framesWithPeople})]}),(0,t.jsxs)("div",{children:["Speakers detected: ",(0,t.jsx)("strong",{children:u.speakersDetected})]}),(0,t.jsxs)("div",{children:["Transcript Timestamps: ",(0,t.jsx)("strong",{children:u.transcriptTimestamps})]}),(0,t.jsxs)("div",{children:["Scene Split Timestamps: ",(0,t.jsx)("strong",{children:u.sceneSplitTimestamps})]})]});return(0,f.useEffect)(function(){(async()=>(e(await hV()),a(!1)))()},[]),n?(0,t.jsx)(ml,{}):(0,t.jsxs)("div",{style:{padding:"24px"},children:[(0,t.jsxs)("section",{style:{display:"flex",width:"100%",columnGap:"48px"},children:[h("Speaker Focus Stats",l),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{children:"Recent errors"}),(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.map((p,u)=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Job Id:"})," ",p.id]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Message: "})," ",p.message]})]},u))})]})]}),(0,t.jsxs)("section",{style:{marginTop:"64px"},children:[(0,t.jsx)("div",{children:"Total Processing time by Asset Duration"}),(0,t.jsx)(ba,{width:"100%",height:600,children:(0,t.jsxs)(xa,{margin:Fa,children:[(0,t.jsx)(va,{}),(0,t.jsx)(fa,{type:"number",dataKey:"x",name:"source video duration",unit:"s"}),(0,t.jsx)(ga,{type:"number",dataKey:"y",name:"time to process",unit:"s"}),(0,t.jsx)(_a,{cursor:Oa}),(0,t.jsx)(ja,{}),(0,t.jsx)(ha,{name:"Processing time by asset duration",data:d(l.success),fill:"#82ca9d"})]})})]}),(0,t.jsxs)("section",{style:{marginTop:"64px"},children:[(0,t.jsx)("div",{children:"Total Processing time by Frames extracted"}),(0,t.jsx)(ba,{width:"100%",height:600,children:(0,t.jsxs)(xa,{margin:Fa,children:[(0,t.jsx)(va,{}),(0,t.jsx)(fa,{type:"number",dataKey:"x",name:"frames processed"}),(0,t.jsx)(ga,{type:"number",dataKey:"y",name:"time to process",unit:"s"}),(0,t.jsx)(_a,{cursor:Oa}),(0,t.jsx)(ja,{}),(0,t.jsx)(ha,{name:"Processing time by frames processed",data:m(l.success),fill:"#82ca9d"})]})})]}),(0,t.jsxs)("section",{style:{marginTop:"64px"},children:[(0,t.jsx)("div",{children:"Frame Processing time by Frames Extracted"}),(0,t.jsx)(ba,{width:"100%",height:600,children:(0,t.jsxs)(xa,{margin:Fa,children:[(0,t.jsx)(va,{}),(0,t.jsx)(fa,{type:"number",dataKey:"x",name:"frames processed"}),(0,t.jsx)(ga,{type:"number",dataKey:"y",name:"time to process",unit:"s"}),(0,t.jsx)(_a,{cursor:Oa}),(0,t.jsx)(ja,{}),(0,t.jsx)(ha,{name:"Processing time by frames extracted",data:c(l.success),fill:"#82ca9d"})]})})]})]})},xV=f.memo(fV),gV=Q(ie()),vV=s=>{const e=(0,gV.c)(16),{currentTimestamp:n,currentGroup:a,boundingBoxesByObject:o}=s;let i;e[0]!==n?(i=(0,t.jsxs)("div",{children:["Current Time: ",(0,t.jsx)("pre",{children:n})]}),e[0]=n,e[1]=i):i=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("div",{children:"Current Bounding Boxes"}),e[2]=l):l=e[2];let r;e[3]!==o?(r=JSON.stringify(o,null,2),e[3]=o,e[4]=r):r=e[4];let d;e[5]!==r?(d=(0,t.jsx)("pre",{children:r}),e[5]=r,e[6]=d):d=e[6];let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("div",{children:"Current Group"}),e[7]=c):c=e[7];let m;e[8]!==a?(m=JSON.stringify({...a,scenes:a?.scenes},null,2),e[8]=a,e[9]=m):m=e[9];let h;e[10]!==m?(h=(0,t.jsx)("pre",{children:m}),e[10]=m,e[11]=h):h=e[11];let p;return e[12]!==i||e[13]!==d||e[14]!==h?(p=(0,t.jsxs)("div",{children:[i,l,d,c,h]}),e[12]=i,e[13]=d,e[14]=h,e[15]=p):p=e[15],p},_V=f.memo(vV);const jV="1001",bV="1000",yV="58px",SV="styles-module_home_MYrA4",CV="styles-module_homeHowBackgroun
223dWhite_ajNRw",NV="styles-module_largeButton_P7-Cz",wV="styles-module_sectionContent_kE6Dq",AV="styles-module_sectionHeader_98Yte",IV="styles-module_spacer_Tk3Ds",TV="styles-module_chevron_Qs-Da",kV="styles-module_splashText_E5Ofg",RV="styles-module_splashSubtext_ocUr6",$V="styles-module_aboutSection_xnlQL",PV="styles-module_mobile_L-Mu-",EV="styles-module_desktop_hcapN",LV="styles-module_screenReaderOnlyLabel_phQth",BV="styles-module_disabled_8nPCt",DV="styles-module_disabledWithPointerEvents_EPvaX",MV="styles-module_noScrollBar_seAuT",FV="styles-module_textOverflowEllipsis_1-adx",OV="styles-module_disableTextHighlight_qHfaX",qV="styles-module_genericButtonBlue_Kty1P",VV="styles-module_rmButtonUserAgentStyles_Fw0Rt",HV="styles-module_transcriptAndVisualizerContainer_ig1K6",UV="styles-module_visualizerContainer_DRM-e",ZV="styles-module_controlsContainer_Q5vit",WV="styles-module_analyticsContainer_oEfFn",KV="styles-module_visualizer_AXy3p",GV="styles-module_generateBenchmarkButton_YYBew",JV="styles-module_title_AKjYt",zV="styles-module_button_P6IBs",YV="styles-module_generateBenchmarkStatus_AcbVt",QV="styles-module_status_Dcs69",XV="styles-module_controls_ZRD6E",eH="styles-module_root_9PCsD",tH="styles-module_track_ZSxbz",sH="styles-module_bufferedRange_CUaBy",nH="styles-module_speakerFocusRange_UzXLK",aH="styles-module_highlighted_EbLct",oH="styles-module_range_YFeKr",iH="styles-module_thumb_OiJPj",lH="styles-module_controlsButton_TOJ2o",rH="styles-module_settings_gfvXb",dH="styles-module_trigger_JsiNS",cH="styles-module_content_4MYfm",uH="styles-module_section_xJ9Hc",mH="styles-module_label_FnipB",pH="styles-module_flexRowContainer_opWSi",hH="styles-module_buttonSelected_Jzt03",fH="styles-module_accordionRoot_U0uK4",xH="styles-module_accordionItem_WRNCu",gH="styles-module_accordionTrigger_gsdfK",vH="styles-module_accordionContent_wa20i",_H="styles-module_transcript_GSveF",jH="styles-module_paragraph_vTqH8",bH="styles-module_speakerFocusJobList_WYq9x",yH="styles-module_speakerFocusJobCard_FL-JW",SH="styles-module_selected_HCWj4",CH="styles-module_groups_V8zNP",NH="styles-module_group_Tcf6L",wH="styles-module_groupSelected_Y9Uq8",AH="styles-module_groupTrigger_OZBRL",IH="styles-module_groupSceneContainer_7Vr-T",TH="styles-module_groupTriggerIcon_ZxMTn",kH="styles-module_scene_Bl4vv",RH="styles-module_sceneSelected_xTIFa",$H="styles-module_sceneTooltip_RZXBY",PH="styles-module_fade_IiG5i",EH="styles-module_sceneLoading_HV7MR",LH="styles-module_shimmer_j5wPJ";var _e={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:jV,paywallBgZIndex:bV,collapsedMediaSidebarWidth:yV,home:SV,homeHowBackgroundWhite:CV,largeButton:NV,sectionContent:wV,sectionHeader:AV,spacer:IV,chevron:TV,splashText:kV,splashSubtext:RV,aboutSection:$V,mobile:PV,desktop:EV,screenReaderOnlyLabel:LV,disabled:BV,disabledWithPointerEvents:DV,noScrollBar:MV,textOverflowEllipsis:FV,disableTextHighlight:OV,genericButtonBlue:qV,rmButtonUserAgentStyles:VV,debugger:"styles-module_debugger_rirgL",transcriptAndVisualizerContainer:HV,visualizerContainer:UV,controlsContainer:ZV,analyticsContainer:WV,visualizer:KV,generateBenchmarkButton:GV,title:JV,button:zV,generateBenchmarkStatus:YV,status:QV,controls:XV,root:eH,track:tH,bufferedRange:sH,speakerFocusRange:nH,highlighted:aH,range:oH,thumb:iH,controlsButton:lH,settings:rH,trigger:dH,content:cH,section:uH,label:mH,flexRowContainer:pH,buttonSelected:hH,accordionRoot:fH,accordionItem:xH,accordionTrigger:gH,accordionContent:vH,transcript:_H,paragraph:jH,speakerFocusJobList:bH,speakerFocusJobCard:yH,selected:SH,groups:CH,group:NH,groupSelected:wH,groupTrigger:AH,groupSceneContainer:IH,groupTriggerIcon:TH,scene:kH,sceneSelected:RH,sceneTooltip:$H,fade:PH,sceneLoading:EH,shimmer:LH};function BH(s){const e=[],n=360/s;for(let a=0;a<s;a++){const{r:o,g:i,b:l}=DH(a*n%360,100,50),r=`${o}, ${i}, ${l}`;e.push(r)}return e}var qa=(s,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?s+(e-s)*6*n:n<1/2?e:n<2/3?s+(e-s)*(2/3-n)*6:s);function DH(s,e,n){s/=360,e/=100,n/=100;let a,o,i;if(e===0)a=o=i=n;else{const l=n<.5?n*(1+e):n+e-n*e,r=2*n-l;a=qa(r,l,s+1/3),o=qa(r,l,s),i=qa(r,l,s-1/3)}return{r:Math.round(a*255),g:Math.round(o*255),b:Math.round(i*255)}}const MH=async s=>(await H.admin.getSpeakerFocusByAssetId.query({assetId:s})).body;let nt=function(s){return s.Face="face",s.People="people",s.Object="object",s}({});var dr=Q(ie()),gs=Q(Ns()),FH=s=>{const e=(0,dr.c)(47);let n,a,o,i,l,r,d,c,m,h;e[0]!==s?({isPlaying:r,handlePlayPause:l,currentTime:o,duration:i,videoControlTime:h,setVideoControlTime:d,buffered:a,bufferIndex:n,speakerFocusIntervals:m,...c}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=o,e[4]=i,e[5]=l,e[6]=r,e[7]=d,e[8]=c,e[9]=m,e[10]=h):(n=e[1],a=e[2],o=e[3],i=e[4],l=e[5],r=e[6],d=e[7],c=e[8],m=e[9],h=e[10]);let p;e[11]!==c?(p=(0,t.jsx)(OH,{...c}),e[11]=c,e[12]=p):p=e[12];let u;e[13]!==r?(u=r?(0,t.jsx)(Mr,{}):(0,t.jsx)(Hr,{}),e[13]=r,e[14]=u):u=e[14];let g;e[15]!==l||e[16]!==u?(g=(0,t.jsx)("div",{className:_e.controlsButton,onClick:l,children:u}),e[15]=l,e[16]=u,e[17]=g):g=e[17];let _;e[18]===Symbol.for("react.memo_cache_sentinel")?(_={fontSize:12,fontWeight:500},e[18]=_):_=e[18];let v;e[19]!==o?(v=Bo(o),e[19]=o,e[20]=v):v=e[20];const b=i??0;let j;e[21]!==b?(j=Bo(b),e[21]=b,e[22]=j):j=e[22];let x;e[23]!==v||e[24]!==j?(x=(0,t.jsxs)("div",{style:_,children:[v," / ",j]}),e[23]=v,e[24]=j,e[25]=x):x=e[25];let S;e[26]!==n||e[27]!==a||e[28]!==i?(S=!!a?.length&&!!i&&(0,t.jsx)("div",{style:{width:`${a?.end(n)/(i??0)*100}%`},className:_e.bufferedRange}),e[26]=n,e[27]=a,e[28]=i,e[29]=S):S=e[29];let C;e[30]===Symbol.for("react.memo_cache_sentinel")?(C=(0,t.jsx)(hd,{className:_e.range}),e[30]=C):C=e[30];let y;e[31]!==i||e[32]!==m?(y=m?.map((I,D)=>{const{layerStartEndTimes:L}=I;return(0,t.jsx)("div",{style:{left:`${L[0]/(i??0)*100}%`,width:`${(L[1]-L[0])/(i??0)*100}%`},className:_e.speakerFocusRange},D)}),e[31]=i,e[32]=m,e[33]=y):y=e[33];let N;
223e[34]!==y||e[35]!==S?(N=(0,t.jsxs)(fd,{className:_e.track,children:[S,C,y]}),e[34]=y,e[35]=S,e[36]=N):N=e[36];let w;e[37]!==i||e[38]!==d||e[39]!==N||e[40]!==h?(w=(0,t.jsx)(bd,{min:0,max:i,value:h,onValueChange:d,className:_e.root,children:N}),e[37]=i,e[38]=d,e[39]=N,e[40]=h,e[41]=w):w=e[41];let A;return e[42]!==p||e[43]!==w||e[44]!==g||e[45]!==x?(A=(0,t.jsxs)("div",{className:_e.controls,children:[p,g,x,w]}),e[42]=p,e[43]=w,e[44]=g,e[45]=x,e[46]=A):A=e[46],A},OH=f.memo(s=>{const e=(0,dr.c)(75),{setSpeakerFocusCropAspectRatio:n,speakerFocusCropAspectRatio:a,visibleBoundingBoxes:o,setVisibleBoundingBoxes:i}=s;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(jd,{className:_e.trigger,children:(0,t.jsx)(Or,{})}),e[0]=l):l=e[0];let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("div",{className:_e.label,children:"Speaker Focus Crop Ratio"}),e[1]=r):r=e[1];let d;e[2]!==n?(d=()=>n(0),e[2]=n,e[3]=d):d=e[3];const c=a===0;let m;e[4]!==c?(m=(0,gs.default)(_e.button,{[_e.buttonSelected]:c}),e[4]=c,e[5]=m):m=e[5];let h;e[6]!==d||e[7]!==m?(h=(0,t.jsx)("div",{onClick:d,className:m,children:"Off"}),e[6]=d,e[7]=m,e[8]=h):h=e[8];let p;e[9]!==n?(p=()=>n(1.7777777777777777),e[9]=n,e[10]=p):p=e[10];const u=a===1.7777777777777777;let g;e[11]!==u?(g=(0,gs.default)(_e.button,{[_e.buttonSelected]:u}),e[11]=u,e[12]=g):g=e[12];let _;e[13]!==p||e[14]!==g?(_=(0,t.jsx)("div",{onClick:p,className:g,children:"16:9"}),e[13]=p,e[14]=g,e[15]=_):_=e[15];let v;e[16]!==n?(v=()=>n(.5625),e[16]=n,e[17]=v):v=e[17];const b=a===.5625;let j;e[18]!==b?(j=(0,gs.default)(_e.button,{[_e.buttonSelected]:b}),e[18]=b,e[19]=j):j=e[19];let x;e[20]!==v||e[21]!==j?(x=(0,t.jsx)("div",{onClick:v,className:j,children:"9:16"}),e[20]=v,e[21]=j,e[22]=x):x=e[22];let S;e[23]!==n?(S=()=>n(1),e[23]=n,e[24]=S):S=e[24];const C=a===1;let y;e[25]!==C?(y=(0,gs.default)(_e.button,{[_e.buttonSelected]:C}),e[25]=C,e[26]=y):y=e[26];let N;e[27]!==S||e[28]!==y?(N=(0,t.jsx)("div",{onClick:S,className:y,children:"1:1"}),e[27]=S,e[28]=y,e[29]=N):N=e[29];let w;e[30]!==n?(w=()=>n(.8),e[30]=n,e[31]=w):w=e[31];const A=a===.8;let I;e[32]!==A?(I=(0,gs.default)(_e.button,{[_e.buttonSelected]:A}),e[32]=A,e[33]=I):I=e[33];let D;e[34]!==w||e[35]!==I?(D=(0,t.jsx)("div",{onClick:w,className:I,children:"4:5"}),e[34]=w,e[35]=I,e[36]=D):D=e[36];let L;e[37]!==_||e[38]!==x||e[39]!==N||e[40]!==D||e[41]!==h?(L=(0,t.jsxs)("div",{className:_e.section,children:[r,(0,t.jsxs)("div",{className:_e.flexRowContainer,children:[h,_,x,N,D]})]}),e[37]=_,e[38]=x,e[39]=N,e[40]=D,e[41]=h,e[42]=L):L=e[42];let $;e[43]===Symbol.for("react.memo_cache_sentinel")?($=(0,t.jsx)("div",{className:_e.label,children:"Bounding Boxes"}),e[43]=$):$=e[43];let R;e[44]!==i||e[45]!==o?(R=()=>{o.includes(nt.Face)?i(o.filter(VH)):o.includes(nt.People)?i([...o,nt.Face]):i([...o,nt.People,nt.Face])},e[44]=i,e[45]=o,e[46]=R):R=e[46];let P;e[47]!==o?(P=(0,gs.default)(_e.button,{[_e.buttonSelected]:o.includes(nt.Face)&&o.includes(nt.People)}),e[47]=o,e[48]=P):P=e[48];let k;e[49]!==R||e[50]!==P?(k=(0,t.jsx)("div",{onClick:R,className:P,children:"Faces"}),e[49]=R,e[50]=P,e[51]=k):k=e[51];let T;e[52]!==i||e[53]!==o?(T=()=>{o.includes(nt.People)?i(o.filter(HH)):i([...o,nt.People])},e[52]=i,e[53]=o,e[54]=T):T=e[54];let E;e[55]!==o?(E=(0,gs.default)(_e.button,{[_e.buttonSelected]:o.includes(nt.People)}),e[55]=o,e[56]=E):E=e[56];let O;e[57]!==T||e[58]!==E?(O=(0,t.jsx)("div",{onClick:T,className:E,children:"People"}),e[57]=T,e[58]=E,e[59]=O):O=e[59];let q;e[60]!==i||e[61]!==o?(q=()=>{o.includes(nt.Object)?i(o.filter(UH)):i([...o,nt.Object])},e[60]=i,e[61]=o,e[62]=q):q=e[62];let J;e[63]!==o?(J=(0,gs.default)(_e.button,{[_e.buttonSelected]:o.includes(nt.Object)}),e[63]=o,e[64]=J):J=e[64];let K;e[65]!==q||e[66]!==J?(K=(0,t.jsx)("div",{onClick:q,className:J,children:"Objects"}),e[65]=q,e[66]=J,e[67]=K):K=e[67];let z;e[68]!==k||e[69]!==O||e[70]!==K?(z=(0,t.jsxs)("div",{className:_e.section,children:[$,(0,t.jsxs)("div",{className:_e.flexRowContainer,children:[k,O,K]})]}),e[68]=k,e[69]=O,e[70]=K,e[71]=z):z=e[71];let Y;return e[72]!==L||e[73]!==z?(Y=(0,t.jsx)("div",{className:_e.settings,children:(0,t.jsxs)(Sd,{children:[l,(0,t.jsxs)(ed,{side:"top",align:"start",alignOffset:4,sideOffset:4,className:_e.content,children:[L,z]})]})}),e[72]=L,e[73]=z,e[74]=Y):Y=e[74],Y}),qH=f.memo(FH);function VH(s){return s!==nt.Face}function HH(s){return s!==nt.People&&s!==nt.Face}function UH(s){return s!==nt.Object}var So=Q(ie()),cr=Q(Ns()),ZH=s=>{const e=(0,So.c)(8),{groups:n,asset:a,currentGroup:o,currentScene:i,handleSetCurrentTime:l}=s;let r;e[0]!==a||e[1]!==o||e[2]!==i||e[3]!==n||e[4]!==l?(r=n?.map((c,m)=>(0,t.jsx)(WH,{group:c,asset:a,currentGroup:o,currentScene:i,handleSetCurrentTime:l},m)),e[0]=a,e[1]=o,e[2]=i,e[3]=n,e[4]=l,e[5]=r):r=e[5];let d;return e[6]!==r?(d=(0,t.jsx)("div",{className:_e.groups,children:r}),e[6]=r,e[7]=d):d=e[7],d},WH=f.memo(s=>{const e=(0,So.c)(20),{group:n,asset:a,currentGroup:o,currentScene:i,handleSetCurrentTime:l}=s,[r,d]=(0,f.useState)(!1),c=o?.id===n.id;let m;e[0]!==c?(m=(0,cr.default)(_e.group,{[_e.groupSelected]:c}),e[0]=c,e[1]=m):m=e[1];let h;e[2]!==r?(h=(0,t.jsx)("div",{className:_e.groupTriggerIcon,children:r?(0,t.jsx)(lo,{}):(0,t.jsx)(ao,{})}),e[2]=r,e[3]=h):h=e[3];let p;e[4]!==n.id||e[5]!==h?(p=(0,t.jsxs)(ro,{className:_e.groupTrigger,children:[n.id,h]}),e[4]=n.id,e[5]=h,e[6]=p):p=e[6];let u;e[7]!==n.scenes?(u=Array.from(n.scenes),e[7]=n.scenes,e[8]=u):u=e[8];let g;e[9]!==a||e[10]!==o||e[11]!==i||e[12]!==l||e[13]!==u?(g=(0,t.jsx)(uo,{children:(0,t.jsx)("div",{className:_e.groupSceneContainer,children:u.map((v,b)=>{const j=v.timestamp;return(0,t.jsx)("div",{onClick:()=>{l(Number(j))},children:(0,t.jsx)(Co,{asset:a,scene:v,currentScene:i,currentGroup:o})},b)})})}),e[9]=a,e[10]=o,e[11]=i,e[12]=l,e[13]=u,e[14]=g):g=e[14];let _;return e[15]!==r||e[16]!==m||e[17]!==p||e[18]!==g?(_=(0,t.jsxs)(co,{className:m,open:r,onOpenChange:d,children:[p,g]}
223),e[15]=r,e[16]=m,e[17]=p,e[18]=g,e[19]=_):_=e[19],_});const Co=f.memo(s=>{const e=(0,So.c)(32),{scene:n,asset:a,currentGroup:o,currentScene:i,speakerBox:l,crop:r}=s,d=a._id,c=Number(n.timestamp);let m;e[0]!==r||e[1]!==l?(m=r&&l?sc(l):void 0,e[0]=r,e[1]=l,e[2]=m):m=e[2];let h;e[3]!==a._id||e[4]!==c||e[5]!==m?(h={assetId:d,timestamp:c,crop:m},e[3]=a._id,e[4]=c,e[5]=m,e[6]=h):h=e[6];const p=du(h);let u;e[7]!==r||e[8]!==l?(u=N=>{const w=N===void 0?1:N;if(!(!l||r))return(0,t.jsx)("div",{style:{position:"absolute",left:`${l.x1*100}%`,top:`${l.y1*100}%`,width:`${(l.x2-l.x1)*100}%`,height:`${(l.y2-l.y1)*100}%`,borderStyle:"solid",borderColor:"blue",borderWidth:`${w}px`,zIndex:0,pointerEvents:"none",opacity:1}})},e[7]=r,e[8]=l,e[9]=u):u=e[9];const g=u;let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_={position:"relative"},e[10]=_):_=e[10];let v;e[11]!==p||e[12]!==g?(v=p&&g(),e[11]=p,e[12]=g,e[13]=v):v=e[13];let b;e[14]!==o?.scenes||e[15]!==i?.timestamp||e[16]!==p||e[17]!==n.timestamp?(b=p?(0,t.jsx)("img",{src:p,alt:"",className:(0,cr.default)(_e.scene,{[_e.sceneSelected]:i?.timestamp===n.timestamp&&o?.scenes.some(N=>N.timestamp===n.timestamp)})}):(0,t.jsx)("div",{className:_e.sceneLoading}),e[14]=o?.scenes,e[15]=i?.timestamp,e[16]=p,e[17]=n.timestamp,e[18]=b):b=e[18];let j;e[19]!==v||e[20]!==b?(j=(0,t.jsx)(md,{asChild:!0,children:(0,t.jsxs)("div",{style:_,children:[v,b]})}),e[19]=v,e[20]=b,e[21]=j):j=e[21];let x;e[22]!==g?(x=g(3),e[22]=g,e[23]=x):x=e[23];let S;e[24]!==p?(S=(0,t.jsx)("img",{src:p,alt:""}),e[24]=p,e[25]=S):S=e[25];let C;e[26]!==x||e[27]!==S?(C=(0,t.jsx)(yd,{children:(0,t.jsxs)(id,{className:_e.sceneTooltip,side:"top",sideOffset:8,children:[x,S]})}),e[26]=x,e[27]=S,e[28]=C):C=e[28];let y;return e[29]!==C||e[30]!==j?(y=(0,t.jsx)(od,{children:(0,t.jsxs)(pd,{delayDuration:200,disableHoverableContent:!0,children:[j,C]})}),e[29]=C,e[30]=j,e[31]=y):y=e[31],y});var KH=f.memo(ZH),GH=Q(ie()),JH=Q(Ns()),zH=s=>{const e=(0,GH.c)(9),{speakerFocusJobs:n,selectedSpeakerFocusJobId:a,setSelectedSpeakerFocusJobId:o}=s;let i;if(e[0]!==a||e[1]!==o||e[2]!==n){let r;e[4]!==a||e[5]!==o?(r=d=>(0,t.jsxs)("div",{className:(0,JH.default)(_e.speakerFocusJobCard,{[_e.selected]:a===d._id}),onClick:()=>o(d._id),children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Job Id: "}),d._id]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Date Complete: "}),ot(d.finished).calendar()]})]},d._id),e[4]=a,e[5]=o,e[6]=r):r=e[6],i=n.map(r),e[0]=a,e[1]=o,e[2]=n,e[3]=i}else i=e[3];let l;return e[7]!==i?(l=(0,t.jsx)("div",{className:_e.speakerFocusJobList,children:i}),e[7]=i,e[8]=l):l=e[8],l},YH=f.memo(zH),QH=Q(ie()),XH=s=>{const e=(0,QH.c)(8),{paragraphs:n,currentTime:a,setCurrentTime:o,speakerColorByLabel:i,parentContainerRef:l}=s,r=(0,f.useRef)(null),d=tU;let c;e[0]!==a||e[1]!==n||e[2]!==l?.current||e[3]!==o||e[4]!==i?(c=n.map((h,p)=>(0,t.jsx)("div",{className:_e.paragraph,children:h.map(u=>{const g=u.startRelativeToAsset<=a&&u.endRelativeToAsset>a,_=u.speaker?`rgba(${i?.[u.speaker]}, ${g?.8:.4})`:void 0;return(0,t.jsx)("div",{style:{textDecoration:g?"underline":"none",background:_,cursor:"pointer"},onClick:()=>o(u.startRelativeToAsset),ref:v=>{g&&d(v,l?.current??r.current)},children:u.text},u.transcriptionNdx)})},p)),e[0]=a,e[1]=n,e[2]=l?.current,e[3]=o,e[4]=i,e[5]=c):c=e[5];let m;return e[6]!==c?(m=(0,t.jsx)("div",{ref:r,className:_e.transcript,children:c}),e[6]=c,e[7]=m):m=e[7],m},eU=f.memo(XH);function tU(s,e){if(s&&e){const{top:n,bottom:a}=s.getBoundingClientRect(),{top:o,bottom:i}=e.getBoundingClientRect();(n<o||a>i)&&s.scrollIntoView({behavior:"smooth",block:"center"})}}var ur=Q(ie()),sU=Q(Ns()),nU=s=>{const e=(0,ur.c)(17),{asset:n,speakerColorByLabel:a,handleSetCurrentTime:o,currentGroup:i,currentScene:l,groups:r,speakerFocusIntervals:d}=s;let c;if(e[0]!==n||e[1]!==i||e[2]!==l||e[3]!==r||e[4]!==o||e[5]!==a||e[6]!==d){let h;e[8]!==n||e[9]!==i||e[10]!==l||e[11]!==r||e[12]!==o||e[13]!==d?(h=(p,u)=>{const[g,_]=p;return(0,t.jsx)(aU,{speakerLabel:g,speakerColor:_,asset:n,handleSetCurrentTime:o,currentScene:l,currentGroup:i,groups:r,speakerFocusIntervals:d},u)},e[8]=n,e[9]=i,e[10]=l,e[11]=r,e[12]=o,e[13]=d,e[14]=h):h=e[14],c=Object.entries(a).map(h),e[0]=n,e[1]=i,e[2]=l,e[3]=r,e[4]=o,e[5]=a,e[6]=d,e[7]=c}else c=e[7];let m;return e[15]!==c?(m=(0,t.jsx)("div",{className:_e.groups,children:c}),e[15]=c,e[16]=m):m=e[16],m},aU=f.memo(s=>{const e=(0,ur.c)(27),{asset:n,speakerLabel:a,speakerColor:o,handleSetCurrentTime:i,groups:l,currentGroup:r,currentScene:d,speakerFocusIntervals:c}=s,[m,h]=(0,f.useState)(!1);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=(0,sU.default)(_e.group),e[0]=p):p=e[0];let u,g;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={display:"flex",flexDirection:"row",alignItems:"center"},g=(0,t.jsx)("span",{children:"Speaker"}),e[1]=u,e[2]=g):(u=e[1],g=e[2]);const _=`rgba(${o}, 0.5)`;let v;e[3]!==_?(v=(0,t.jsx)("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:_,marginLeft:5,marginRight:2}}),e[3]=_,e[4]=v):v=e[4];let b;e[5]!==a||e[6]!==v?(b=(0,t.jsxs)("div",{style:u,children:[g,a,v]}),e[5]=a,e[6]=v,e[7]=b):b=e[7];let j;e[8]!==m?(j=(0,t.jsx)("div",{className:_e.groupTriggerIcon,children:m?(0,t.jsx)(lo,{}):(0,t.jsx)(ao,{})}),e[8]=m,e[9]=j):j=e[9];let x;e[10]!==b||e[11]!==j?(x=(0,t.jsxs)(ro,{className:_e.groupTrigger,children:[b,j]}
223),e[10]=b,e[11]=j,e[12]=x):x=e[12];let S;e[13]!==n||e[14]!==r||e[15]!==d||e[16]!==l||e[17]!==i||e[18]!==c||e[19]!==a?(S=c?.map((N,w)=>{const{groupId:A,boundingBoxesTimestamp:I,transcriptSpeaker:D,defaultSpeaker:L,defaultSpeakerBox:$,layerStartEndTimes:R}=N;if(D!==a||I===void 0||!L||!$)return null;const P=l?.find(k=>k.id===A)?.scenes.find(k=>{const{startEndTimes:T}=k;return T[0]<=I&&T[1]>=I});return P?(0,t.jsx)("div",{onClick:()=>{i((R[0]+R[1])/2)},children:(0,t.jsx)(Co,{asset:n,scene:P,speakerBox:$,currentScene:d,currentGroup:r,crop:!0})},w):null}),e[13]=n,e[14]=r,e[15]=d,e[16]=l,e[17]=i,e[18]=c,e[19]=a,e[20]=S):S=e[20];let C;e[21]!==S?(C=(0,t.jsx)(uo,{children:(0,t.jsx)("div",{className:_e.groupSceneContainer,children:S})}),e[21]=S,e[22]=C):C=e[22];let y;return e[23]!==m||e[24]!==C||e[25]!==x?(y=(0,t.jsxs)(co,{className:p,open:m,onOpenChange:h,children:[x,C]}),e[23]=m,e[24]=C,e[25]=x,e[26]=y):y=e[26],y}),oU=f.memo(nU),mr=Q(ie()),iU=Q(Ns()),lU=s=>{const e=(0,mr.c)(10),{asset:n,verifiedPeople:a,handleSetCurrentTime:o,currentGroup:i,currentScene:l,groups:r,boundingBoxes:d}=s;let c;e[0]!==a?(c=Array.from(a??[]),e[0]=a,e[1]=c):c=e[1];let m;return e[2]!==n||e[3]!==d||e[4]!==i||e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==c?(m=(0,t.jsx)("div",{className:_e.groups,children:c.map((h,p)=>(0,t.jsx)(rU,{asset:n,label:h,handleSetCurrentTime:o,currentScene:l,currentGroup:i,groups:r,boundingBoxes:d},p))}),e[2]=n,e[3]=d,e[4]=i,e[5]=l,e[6]=r,e[7]=o,e[8]=c,e[9]=m):m=e[9],m},rU=f.memo(s=>{const e=(0,mr.c)(23),{asset:n,label:a,handleSetCurrentTime:o,groups:i,currentGroup:l,currentScene:r,boundingBoxes:d}=s,[c,m]=(0,f.useState)(!1);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=(0,iU.default)(_e.group),e[0]=h):h=e[0];let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p={display:"flex",flexDirection:"row",alignItems:"center"},e[1]=p):p=e[1];let u;e[2]!==a?(u=(0,t.jsx)("div",{style:p,children:a}),e[2]=a,e[3]=u):u=e[3];let g;e[4]!==c?(g=(0,t.jsx)("div",{className:_e.groupTriggerIcon,children:c?(0,t.jsx)(lo,{}):(0,t.jsx)(ao,{})}),e[4]=c,e[5]=g):g=e[5];let _;e[6]!==u||e[7]!==g?(_=(0,t.jsxs)(ro,{className:_e.groupTrigger,children:[u,g]}),e[6]=u,e[7]=g,e[8]=_):_=e[8];let v;e[9]!==n||e[10]!==d||e[11]!==l||e[12]!==r||e[13]!==i||e[14]!==o||e[15]!==a?(v=i?.flatMap((x,S)=>{const{scenes:C}=x;return C.map((y,N)=>{const w=wn({object:d,key:y.timestamp})?.[a];if(w)return(0,t.jsx)("div",{onClick:()=>{o(Number(y.timestamp))},children:(0,t.jsx)(Co,{asset:n,scene:y,speakerBox:w||void 0,currentScene:r,currentGroup:l,crop:!0})},`${S}-${N}`)})}),e[9]=n,e[10]=d,e[11]=l,e[12]=r,e[13]=i,e[14]=o,e[15]=a,e[16]=v):v=e[16];let b;e[17]!==v?(b=(0,t.jsx)(uo,{children:(0,t.jsx)("div",{className:_e.groupSceneContainer,children:v})}),e[17]=v,e[18]=b):b=e[18];let j;return e[19]!==c||e[20]!==_||e[21]!==b?(j=(0,t.jsxs)(co,{className:h,open:c,onOpenChange:m,children:[_,b]}),e[19]=c,e[20]=_,e[21]=b,e[22]=j):j=e[22],j}),dU=f.memo(lU);const cU=({boundingBoxesByObject:s,transcriptSpeaker:e,transcriptSpeakerColor:n,speakerFocusCropAspectRatio:a,visibleBoundingBoxes:o,speaker:i,box:l,assetDimensions:r,speakerMatchScores:d,speakerScores:c})=>{const m=ac({box:l,canvasAspectRatio:a,assetWidth:r?.width??0,assetHeight:r?.height??0,assetAspectRatio:r?.aspectRatio??0})??{x:0,y:0,width:100,height:100};return(0,t.jsxs)(t.Fragment,{children:[a!==0&&(0,t.jsx)("div",{style:{position:"absolute",left:`${m.x}%`,top:`${m.y}%`,width:`${m.width}%`,height:`${m.height}%`,backgroundColor:"black",zIndex:0,pointerEvents:"none",opacity:.5}}),Object.entries(s).filter(([h,p])=>ya(p.name)?o.includes(nt.People):o.includes(nt.Object)).map(([h,p])=>{const u=ya(p.name),g=h===i,_=ol(h),v=c?c[h]:void 0,b=e&&d?Gd({transcriptSpeaker:e,speakerFocusJobSpeaker:h,speakerMatchScores:d}):void 0,j=uc(p);return(0,t.jsxs)("div",{children:[p.face_box&&o.includes(nt.Face)&&(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("div",{style:{position:"absolute",left:`${p.face_box.x1*100}%`,top:`${p.face_box.y1*100}%`,width:`${(p.face_box.x2-p.face_box.x1)*100}%`,height:`${(p.face_box.y2-p.face_box.y1)*100}%`,border:"3px solid green",zIndex:0,pointerEvents:"none",opacity:g?1:.25}},`${h}_face`)}),(0,t.jsx)("div",{style:{position:"absolute",left:`${p.x1*100}%`,top:`${p.y1*100}%`,width:`${(p.x2-p.x1)*100}
223%`,height:`${(p.y2-p.y1)*100}%`,borderStyle:"solid",borderColor:ya(p.name)?"blue":"red",borderWidth:"3px",zIndex:0,pointerEvents:"none",opacity:g?1:.25}},h),(0,t.jsx)("div",{style:{position:"absolute",left:`${p.x1*100}%`,top:`${p.y1*100}%`,margin:"4px",padding:"2px 4px",color:"white",background:"rgba(0,0,0,0.5)",fontSize:"12px",zIndex:1,pointerEvents:"none"},children:(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:2},children:[g&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:`rgba(${n}, 1)`}},`${h}_speaker_dot`),(0,t.jsx)("div",{children:e}),"|"]}),(0,t.jsx)("div",{children:h}),!_&&u&&(0,t.jsxs)(t.Fragment,{children:["|",(0,t.jsx)("div",{style:{fontWeight:"bold",color:g?"rgb(0, 255, 0)":"rgb(255, 0, 0)"},children:j!==void 0?j.toFixed(2):"--"})]}),_&&(0,t.jsxs)(t.Fragment,{children:["|",(0,t.jsx)("div",{style:{fontWeight:"bold",color:g?"rgb(0, 255, 0)":"rgb(255, 0, 0)"},children:v!==void 0?v.toFixed(2):"--"})]}),_&&(0,t.jsxs)(t.Fragment,{children:["|",(0,t.jsx)("div",{style:{fontWeight:"bold",color:g?"rgb(0, 255, 0)":"rgb(255, 0, 0)"},children:b!==void 0?b.toFixed(2):"--"})]})]},`${h}_label_speaker`)},`${h}_label`)]},`${h}_container`)})]})};var uU=f.memo(cU),mU=Q(ie()),pU=f.forwardRef((s,e)=>{const n=(0,mU.c)(44);let a,o,i,l,r,d,c,m,h,p,u,g,_,v;n[0]!==s?({asset:a,boundingBoxes:i,currentSpeakerFocusInterval:r,speakerFocusCropAspectRatio:u,colorBySpeaker:l,visibleBoundingBoxes:v,assetDimensions:o,currentSpeakerScores:d,speakerMatchScores:g,handleProgress:h,handlePlay:m,handlePause:c,handleSeek:p,..._}=s,n[0]=s,n[1]=a,n[2]=o,n[3]=i,n[4]=l,n[5]=r,n[6]=d,n[7]=c,n[8]=m,n[9]=h,n[10]=p,n[11]=u,n[12]=g,n[13]=_,n[14]=v):(a=n[1],o=n[2],i=n[3],l=n[4],r=n[5],d=n[6],c=n[7],m=n[8],h=n[9],p=n[10],u=n[11],g=n[12],_=n[13],v=n[14]);let b;n[15]!==r?(b=r??{},n[15]=r,n[16]=b):b=n[16];const{boundingBoxesTimestamp:j,transcriptSpeaker:x,defaultSpeaker:S,defaultSpeakerBox:C}=b;let y;n[17]!==i||n[18]!==j?(y=j&&i?wn({object:i,key:j}):void 0,n[17]=i,n[18]=j,n[19]=y):y=n[19];const N=y,{setVideoRef:w}=ul(a?._id);let A;n[20]!==e||n[21]!==w?(A=[e,w],n[20]=e,n[21]=w,n[22]=A):A=n[22];const I=qr(A);let D;n[23]!==o||n[24]!==N||n[25]!==l||n[26]!==d||n[27]!==S||n[28]!==C||n[29]!==u||n[30]!==g||n[31]!==x||n[32]!==v?(D=N&&(0,t.jsx)(uU,{assetDimensions:o,boundingBoxesByObject:N,transcriptSpeaker:x,transcriptSpeakerColor:x?l?.[x]:void 0,speakerFocusCropAspectRatio:u,visibleBoundingBoxes:v,speaker:S,box:C,speakerScores:d,speakerMatchScores:g}),n[23]=o,n[24]=N,n[25]=l,n[26]=d,n[27]=S,n[28]=C,n[29]=u,n[30]=g,n[31]=x,n[32]=v,n[33]=D):D=n[33];let L;n[34]!==c||n[35]!==m||n[36]!==h||n[37]!==p||n[38]!==I||n[39]!==_?(L=(0,t.jsx)("video",{ref:I,onTimeUpdate:h,onPlay:m,onPause:c,onSeeking:p,..._}),n[34]=c,n[35]=m,n[36]=h,n[37]=p,n[38]=I,n[39]=_,n[40]=L):L=n[40];let $;return n[41]!==D||n[42]!==L?($=(0,t.jsxs)("div",{className:_e.visualizer,children:[D,L]}),n[41]=D,n[42]=L,n[43]=$):$=n[43],$}),hU=pU,fU=()=>{const{assetId:s}=Ys(),[e,n]=(0,f.useState)(),[a,o]=(0,f.useState)(!0),[i,l]=(0,f.useState)([]),[r,d]=(0,f.useState)(),[c,m]=(0,f.useState)(),[h,p]=(0,f.useState)(),u=f.useRef(null),g=Lt(),_=tt(),[v,b]=(0,f.useState)(0),[j,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(16/9),[y,N]=(0,f.useState)([nt.People,nt.Object,nt.Face]),[w,A]=(0,f.useState)([]),I=(0,f.useMemo)(()=>{const ue=i.find(pe=>pe._id===e);return ue&&nc(ue)},[e,i]),{paragraphs:D,colorBySpeaker:L}=(0,f.useMemo)(()=>{if(!h||!c)return;const ue=new Set,pe=h?.words.map((ve,we)=>(ve.speaker&&ue.add(ve.speaker),{assetId:c?._id,startRelativeToAsset:ve.start_time,endRelativeToAsset:ve.end_time,text:ve.word,transcriptionNdx:we,speaker:ve.speaker})),ee=BH(5),xe=Array.from(ue).reduce((ve,we,re)=>({...ve,[we]:ee[re]}),{});return{paragraphs:Xd(pe,h?.language_code),speakers:ue,colorBySpeaker:xe}},[c,h])??{},{boundingBoxes:$,debugGroups:R,sceneSplitTimestamps:P,transcriptSpeakerSwitchTimestamps:k,speakerScores:T}=(0,f.useMemo)(()=>({boundingBoxes:I?.job_result?.result,debugGroups:I?.groups,sceneSplitTimestamps:I?.job_result?.scene_split_timestamps,transcriptSpeakerSwitchTimestamps:I?.job_result?.transcript_speaker_switch_timestamps,speakerScores:I?.job_result?.speaker_scores}),[I])??{},E=(0,f.useMemo)(()=>
223{if(!$||!R)return;const ue=new Set;return R.forEach(pe=>{pe.scenes.forEach(ee=>{const xe=wn({object:$,key:ee.timestamp});Object.entries(xe??{}).forEach(([ve,we])=>{ol(ve)&&ue.add(ve)})})}),ue},[$,R]),O=(0,f.useMemo)(()=>{if(!(!P||!R||!I?.asset_duration||!$))return rc({speakerFocusJobId:I._id,sceneSplitTimes:P,transcriptSpeakerSwitchTimes:k,groups:R,assetDuration:I?.asset_duration,transcript:h?.words,speakerScores:T,boundingBoxes:$})},[P,R,I?.asset_duration,I?._id,$,k,h?.words,T]),q=(0,f.useMemo)(()=>{if(O)return Jd({intervals:O})},[O]),J=(0,f.useMemo)(()=>O?.find(ue=>{const[pe,ee]=ue.layerStartEndTimes;return v>=pe&&v<ee}),[v,O]),K=(0,f.useMemo)(()=>R?.find(ue=>ue.id===J?.groupId),[J?.groupId,R]),z=(0,f.useMemo)(()=>K?.scenes.find(ue=>ue.timestamp===J?.boundingBoxesTimestamp),[K?.scenes,J?.boundingBoxesTimestamp]),Y=(0,f.useMemo)(()=>J?.boundingBoxesTimestamp!==void 0&&$!==void 0?wn({object:$,key:J.boundingBoxesTimestamp}):void 0,[$,J]),me=(0,f.useMemo)(()=>J?.speakerScoreTimestamp!==void 0&&T!==void 0?wn({object:T,key:J.speakerScoreTimestamp}):void 0,[J,T]),X=(0,f.useCallback)(()=>{u.current&&b(u.current?.currentTime||0)},[]),te=(0,f.useCallback)(()=>{u.current&&(x(!0),u.current.play())},[]),ae=(0,f.useCallback)(()=>{u.current&&(x(!1),u.current.pause())},[]),G=(0,f.useCallback)(()=>{u.current?.paused?te():ae()},[ae,te]),se=(0,f.useCallback)(()=>{},[]),U=(0,f.useCallback)(ue=>{u.current&&(u.current.currentTime=ue)},[]);(0,f.useEffect)(function(){try{(async()=>{if(!s)return;const pe=await MH(s);if(!pe.asset||!pe.speakerFocusJobs.length)throw new Error("No speaker focus jobs found.");pe.transcript&&p(pe.transcript),_(fo([pe.asset,...pe.previewAsset?[pe.previewAsset]:[]])),d(pe.asset),m(pe.previewAsset??void 0),l(pe.speakerFocusJobs),n(pe.speakerFocusJobs[0]?._id),o(!1)})()}catch(pe){Ue({description:"Could not load speaker focus job.",error:pe}),g("/admin/speakerFocus")}},[s,_,g]);const{videoControlTime:B,setVideoControlTime:oe,duration:de,buffered:ye,bufferIndex:Le}=(0,f.useMemo)(()=>{const{duration:ue,buffered:pe}=u.current??{};let ee=0;if(pe?.length){for(let xe=0;xe<pe.length;xe++)if(pe.end(xe)>v){ee=xe;break}}return{setVideoControlTime:xe=>{u.current&&(u.current.currentTime=xe[0]??0),b(xe[0]??0)},videoControlTime:[v],duration:ue,buffered:pe,bufferIndex:ee}},[v]),Ne=(0,f.useMemo)(()=>window?.innerHeight*.7,[]),{containerRef:Be,containerDimensions:le}=pl(),he=(0,f.useMemo)(()=>{if(!le||!c?.dimensions)return;const ue=le.width,pe=c.dimensions.width/c.dimensions.height;let ee,xe;return pe===1?(ee=Math.min(ue,Ne),xe=ee):pe>1?(ee=ue,xe=Math.min(ue/pe,Ne),ee=xe*pe):(xe=Ne,ee=Math.min(Ne*pe,ue),xe=ee/pe),{width:ee,height:xe}},[Ne,c?.dimensions,le]),ge=(0,f.useMemo)(()=>({maxHeight:Ne,maxWidth:"100%",width:he?.width,height:he?.height}),[Ne,he?.height,he?.width]),je=(0,f.useRef)(null);return a?(0,t.jsx)(ml,{}):(0,t.jsx)("div",{className:_e.debugger,children:(0,t.jsxs)("div",{className:_e.transcriptAndVisualizerContainer,children:[(0,t.jsxs)(zi,{type:"multiple",className:_e.accordionRoot,value:w,onValueChange:A,children:[(0,t.jsxs)(Vs,{value:"transcript",className:_e.accordionItem,children:[(0,t.jsx)(qs,{className:_e.accordionTrigger,children:"Transcript"}),(0,t.jsx)(Hs,{className:_e.accordionContent,ref:je,children:D&&(0,t.jsx)(eU,{speakerColorByLabel:L,currentTime:v,setCurrentTime:U,paragraphs:D,parentContainerRef:je})})]}),(0,t.jsxs)(Vs,{value:"speakerFocusJobs",className:_e.accordionItem,children:[(0,t.jsx)(qs,{className:_e.accordionTrigger,children:"Speaker Focus Jobs"}),(0,t.jsx)(Hs,{className:_e.accordionContent,children:(0,t.jsx)(YH,{selectedSpeakerFocusJobId:e,setSelectedSpeakerFocusJobId:n,speakerFocusJobs:i})})]}),(0,t.jsxs)(Vs,{value:"scenes",className:_e.accordionItem,children:[(0,t.jsx)(qs,{className:_e.accordionTrigger,children:"Scenes"}),(0,t.jsx)(Hs,{className:_e.accordionContent,children:R&&r&&(0,t.jsx)(KH,{groups:R,asset:r,currentGroup:K,currentScene:z,handleSetCurrentTime:U})})]}),(0,t.jsxs)(Vs,{value:"debug",className:_e.accordionItem,children:[(0,t.jsx)(qs,{className:_e.accordionTrigger,children:"Debug"}),(0,t.jsx)(Hs,{className:_e.accordionContent,children:(0,t.jsx)(_V,{currentTimestamp:v,currentGroup:K,boundingBoxesByObject:Y})})]}),(0,t.jsxs)(Vs,{value:"transcript-speakers",className:_e.accordionItem,children:[(0,t.jsx)(qs,{className:_e.accordionTrigger,children:"Transcript Speakers"}),(0,t.jsx)(Hs,{className:_e.accordionContent,children:$&&L&&r&&(0,t.jsx)(oU,{asset:r,groups:R,currentGroup:K,currentScene:z,speakerColorByLabel:L,handleSetCurrentTime:U,boundingBoxes:$,speakerFocusIntervals:O})})]}),!!E?.size&&(0,t.jsxs)(Vs,{value:"speaker-focus-speakers",className:_e.accordionItem,children:[(0,t.jsx)(qs,{className:_e.accordionTrigger,children:"Vision Job Speakers"}),(0,t.jsx)(Hs,{className:_e.accordionContent,children:$&&L&&r&&(0,t.jsx)(dU,{verifiedPeople:E,asset:r,groups:R,currentGroup:K,currentScene:z,handleSetCurrentTime:U,boundingBoxes:$})})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:_e.visualizerContainer,children:(0,t.jsx)("div",{ref:Be,style:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,t.jsx)("div",{style:ge,children:(0,t.jsx)(hU,{asset:r,assetDimensions:pc(r??c),boundingBoxes:$,currentSpeakerFocusInterval:J,speakerFocusCropAspectRatio:S,visibleBoundingBoxes:y,currentSpeakerScores:me,colorBySpeaker:L,handleProgress:X,handlePlay:te,handlePause:ae,handleSeek:se,ref:u,speakerMatchScores:q})})})}),(0,t.jsx)("div",{className:_e.controlsContainer,children:(0,t.jsx)(qH,{isPlaying:j,handlePlayPause:G,currentTime:v,duration:de,videoControlTime:B,setVideoControlTime:oe,buffered:ye,bufferIndex:Le,speakerFocusCropAspectRatio:S,setSpeakerFocusCropAspectRatio:C,visibleBoundingBoxes:y,setVisibleBoundingBoxes:N,speakerFocusIntervals:O})})]})]})})},xU=f.memo(fU);const gU="1001",vU="1000",_U="58px",jU="StockKaiCharactersAdminPage-module_page_Bz5jh",bU="StockKaiCharactersAdminPage-module_headerRow_Bm1lq",yU="StockKaiCharactersAdminPage-module_title_vNwNa",SU="StockKaiCharactersAdminPage-module_subtitle_qh-Sg",CU="StockKaiCharactersAdminPage-module_primaryButton_MouD4",NU="StockKaiCharactersAdminPage-module_controlsRow_XUgGZ",wU="StockKaiCharactersAdminPage-module_filterLabel_otvCX",AU="StockKaiCharactersAdminPage-module_filterText_BC8mK",IU="StockKaiCharactersAdminPage-module_select_-ox2x",TU="StockKaiCharactersAdminPage-module_grid_x8S5q",kU="StockKaiCharactersAdminPage-module_card_pU3x8",RU="StockKaiCharactersAdminPage-module_cardButton_fqf47",$U="StockKaiCharactersAdminPage-module_deleteButton_vmESv",PU="StockKaiCharactersAdminPage-module_photoFrame_Jzywj",EU="StockKaiCharactersAdminPage-module_photo_1hu9b",LU="StockKaiCharactersAdminPage-module_photoPlaceholder_FzKC4",BU="StockKaiCharactersAdminPage-module_cardText_Uo1TK",DU="StockKaiCharactersAdminPage-module_characterName_JbjQg",MU="StockKaiCharactersAdminPage-module_characterCategory_Zpn01",FU="StockKaiCharactersAdminPage-module_emptyState_9o3la";var rt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:gU,paywallBgZIndex:vU,collapsedMediaSidebarWidth:_U,page:jU,headerRow:bU,title:yU,subtitle:SU,primaryButton:CU,controlsRow:NU,filterLabel:wU,filterText:AU,select:IU,grid:TU,card:kU,cardButton:RU,deleteButton:$U,photoFrame:PU,photo:EU,photoPlaceholder:LU,cardText:BU,characterName:DU,characterCategory:MU,emptyState:FU}
223;function OU(){const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)(!0),[o,i]=(0,f.useState)("All categories"),[l,r]=(0,f.useState)(!1),[d,c]=(0,f.useState)(),[m,h]=(0,f.useState)(),p=(0,f.useCallback)(async()=>{a(!0);try{e((await H.admin.kai.stockCharacters.list.query()).characters.filter(j=>j.type==="stock"))}catch(j){Ue({error:j,description:"Failed to load stock characters."})}finally{a(!1)}},[]);(0,f.useEffect)(()=>{p()},[p]);const u=(0,f.useMemo)(()=>["All categories",...Array.from(new Set(s.map(j=>j.category.trim()).filter(j=>j.length>0))).sort((j,x)=>j.localeCompare(x))],[s]),g=(0,f.useMemo)(()=>[...o==="All categories"?s:s.filter(j=>j.category===o)].sort((j,x)=>j.name.localeCompare(x.name)),[s,o]),_=(0,f.useCallback)(()=>{r(!1),c(void 0)},[]),v=(0,f.useCallback)(async()=>{await p()},[p]),b=(0,f.useCallback)(async()=>{if(m)try{await H.admin.kai.stockCharacters.delete.mutate({characterId:m._id}),d?._id===m._id&&_(),await p(),h(void 0)}catch(j){Ue({error:j,description:"Failed to delete stock character."})}},[m,d?._id,p,_]);return(0,f.useEffect)(()=>{u.includes(o)||i("All categories")},[u,o]),(0,t.jsxs)("div",{className:rt.page,children:[l&&(0,t.jsx)(qc,{onClose:_,onCharacterSaved:v,characterToEdit:d,existingCharacters:s,characterMode:"stock-admin",stockCategoryOptions:u.filter(j=>j!=="All categories")}),m&&(0,t.jsx)(ju,{delete:b,hideDelete:()=>h(void 0),headerTitle:"Delete stock character?",description:`Deleting ${m.name} will remove it from the stock character library.`,confirmButtonText:"Delete stock character"}),(0,t.jsxs)("div",{className:rt.headerRow,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:rt.title,children:"Stock Kai Characters"}),(0,t.jsx)("div",{className:rt.subtitle,children:"Manage the global stock characters available to admins."})]}),(0,t.jsx)("button",{className:rt.primaryButton,onClick:()=>{c(void 0),r(!0)},children:"Add Stock Character"})]}),(0,t.jsx)("div",{className:rt.controlsRow,children:(0,t.jsxs)("label",{className:rt.filterLabel,children:[(0,t.jsx)("span",{className:rt.filterText,children:"Category"}),(0,t.jsx)("select",{className:rt.select,value:o,onChange:j=>i(j.target.value),children:u.map(j=>(0,t.jsx)("option",{value:j,children:j},j))})]})}),n&&(0,t.jsx)("div",{className:rt.emptyState,children:"Loading stock characters..."}),!n&&g.length===0&&(0,t.jsx)("div",{className:rt.emptyState,children:"No stock characters found for this category."}),!n&&g.length>0&&(0,t.jsx)("div",{className:rt.grid,children:g.map(j=>{const x=j.referencePhotos[0]?.url;return(0,t.jsxs)("div",{className:rt.card,children:[(0,t.jsx)("button",{type:"button",className:rt.deleteButton,onClick:()=>{h(j)},"aria-label":`Delete ${j.name}`,children:(0,t.jsx)(io,{})}),(0,t.jsxs)("button",{type:"button",className:rt.cardButton,onClick:()=>{c(j),r(!0)},"aria-label":`Edit ${j.name}`,children:[(0,t.jsx)("div",{className:rt.photoFrame,children:x?(0,t.jsx)("img",{src:x,alt:j.name,className:rt.photo}):(0,t.jsx)("div",{className:rt.photoPlaceholder,children:"No image"})}),(0,t.jsxs)("div",{className:rt.cardText,children:[(0,t.jsx)("div",{className:rt.characterName,children:j.name}),(0,t.jsx)("div",{className:rt.characterCategory,children:j.category})]})]})]},j._id)})})]})}const qU="DeleteTemplate-module_container_aeNKf",VU="DeleteTemplate-module_title_i07zl",HU="DeleteTemplate-module_imageWrapper_fUTXg",UU="DeleteTemplate-module_image_7OPOo",ZU="DeleteTemplate-module_warning_M4jnO",WU="DeleteTemplate-module_helperWarning_yOgdK",KU="DeleteTemplate-module_button_5xRsd",GU="DeleteTemplate-module_cancel_x1oiM";var Ft={container:qU,title:VU,imageWrapper:HU,image:UU,warning:ZU,helperWarning:WU,button:KU,delete:"DeleteTemplate-module_delete_RgDgk",cancel:GU},JU=Q(ie());function zU(){const s=(0,JU.c)(17),[e,n]=(0,f.useState)(!1),a=tt();let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=al.get("CURRENT_TEMPLATE",{disabled:null}),s[0]=o):o=s[0];const i=o;let l;s[1]!==a?(l=async()=>{try{n(!0),await ku(i),a(He({description:"Template deleted successfully.",type:"success"})),sl("/admin/templates")}
223catch(x){Ue({description:"An error occurred while deleting the template.",error:x})}n(!1)},s[1]=a,s[2]=l):l=s[2];const r=l;if(!i){let x;return s[3]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)("div",{children:"Can't find template to delete. Please try again."}),s[3]=x):x=s[3],x}let d;s[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const{preview:x}=i;if(!x)return null;const{fullPath:S,videoPath:C,regularPath:y}=x;return x.type==="image"?(0,t.jsx)("img",{src:S,alt:i.title,className:Ft.image}):x.type==="video"?(0,t.jsx)("video",{src:C,poster:y,controls:!0,className:Ft.image}):null},s[4]=d):d=s[4];const c=d;let m;s[5]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsxs)("h1",{children:["You are trying to delete:"," ",(0,t.jsx)("span",{className:Ft.title,children:i.title})]}),s[5]=m):m=s[5];let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("div",{className:Ft.imageWrapper,children:c()}),s[6]=h):h=s[6];let p,u;s[7]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsxs)("div",{className:Ft.warning,children:["Are you sure you want to delete this template?",(0,t.jsx)("p",{className:Ft.helperWarning,children:"If this template has already launched to prod and ranks on Google, you may want to first ask an engineer to help redirect the template page before deletion."})]}),u=[Ft.button,Ft.delete],s[7]=p,s[8]=u):(p=s[7],u=s[8]);const g=e?"Loading...":"Delete";let _;s[9]!==r||s[10]!==e||s[11]!==g?(_=(0,t.jsx)("button",{className:u.join(" "),type:"button",disabled:e,onClick:r,children:g}),s[9]=r,s[10]=e,s[11]=g,s[12]=_):_=s[12];let v;s[13]===Symbol.for("react.memo_cache_sentinel")?(v=[Ft.button,Ft.cancel],s[13]=v):v=s[13];let b;s[14]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("button",{className:v.join(" "),onClick:YU,type:"button",children:"Cancel"}),s[14]=b):b=s[14];let j;return s[15]!==_?(j=(0,t.jsxs)("div",{className:Ft.container,children:[m,h,p,_,b]}),s[15]=_,s[16]=j):j=s[16],j}function YU(){sl("/admin/templates")}
223const QU="TranslationPairs-module_pairTable_vvXMN",XU="TranslationPairs-module_filterBox_kmtjc",eZ="TranslationPairs-module_pairRow_HjnoJ",tZ="TranslationPairs-module_paginationButtonContainer_CQ0ku",sZ="TranslationPairs-module_flexColumn_ctxA0",nZ="TranslationPairs-module_flexColumnChild_p3sGB";var Ds={pairTable:QU,filterBox:XU,pairRow:eZ,paginationButtonContainer:tZ,flexColumn:sZ,flexColumnChild:nZ},aZ=30,Vi=async(s,e)=>await H.translation.getTranslationPairs.query({page:s,query:e,pageSize:aZ}),oZ=async(s,e)=>{await H.translation.updateTranslationPair.mutate({updateMap:{[s]:e}})},Hi={selected_provider:[$n.Deepl,$n.ChatGPT]},iZ=()=>{const[s,e]=(0,f.useState)(1),[n,a]=(0,f.useState)(Hi),[o,i]=(0,f.useState)(!0),[l,r]=(0,f.useState)([]),[d,c]=(0,f.useState)({}),m=(0,f.useRef)(1),h=(0,f.useCallback)(async x=>{i(!0);const S=await Vi(x,n);r(S.data),m.current=S.meta.lastPage,i(!1)},[n]),p=(0,f.useCallback)(async()=>{const x=await Vi(1,Hi);r(x.data),m.current=x.meta.lastPage,i(!1)},[]),u=(0,f.useCallback)(async x=>{await h(x),e(x)},[h]);(0,f.useEffect)(()=>{p()},[p]);const g=(0,f.useCallback)(async(x,S)=>{i(!0);try{await oZ(x,S),await h(s)}catch(C){Ue({description:"Failed to update translation pair",error:C})}finally{i(!1)}},[h,s]),_=async(x,S)=>{g(x,{selected_provider:S})},v=async(x,S)=>{g(x,{is_testing:S})},b=(0,f.useCallback)(x=>{const{pair_string:S,supported_providers:C,provider_weights:y,is_testing:N}=x;if(!(C.length>1))return(0,t.jsx)("div",{children:"Language pair only has one supported provider"});const w=async()=>{if(Object.values(d[x._id]||{}).reduce((A,I)=>A+I,0)!==100){Ss({description:"Total weight must be 100"});return}g(x._id,{provider_weights:d[x._id]})};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:Ds.flexColumn,children:C.map(A=>{const I=d[x._id],D=I&&I[A],L=y[A],$=D||L||0,R=P=>{c({...d,[x._id]:{...y,...d[x._id],[A]:parseInt(P.target.value)}})};return(0,t.jsxs)("div",{className:Ds.flexColumnChild,children:[A," ",(0,t.jsx)("input",{type:"text",inputMode:"numeric",value:$,disabled:!N,onChange:R})]},`${S}_weight_${A}`)})}),(0,t.jsx)("div",{className:Ds.flexColumn,children:(0,t.jsx)("button",{disabled:!d[x._id]||o,onClick:w,children:"Save Weight Edits"})})]})},[o,d,g]),j=x=>{const{pair_string:S,supported_providers:C,is_testing:y}=x;return C.length>1?(0,t.jsx)("select",{disabled:o||y,onChange:N=>{const w=N.target.value;_(x._id,w)},value:x.selected_provider,children:C.map(N=>(0,t.jsx)("option",{value:N,children:N},`${S}_${N}`))}):C[0]};return(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{children:"Translation Pairs"}),(0,t.jsx)("div",{className:Ds.filterBox,children:(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Filter"}),(0,t.jsx)("div",{style:{fontSize:"9px"},children:'* filters support Regex, e.g. "English*"'}),(0,t.jsxs)("label",{className:"level",children:["Source Language Code",(0,t.jsx)("input",{type:"text",onChange:x=>a({...n,source_language:x.target.value})})]}),(0,t.jsxs)("label",{className:"level",children:["Source Language Name",(0,t.jsx)("input",{type:"text",onChange:x=>a({...n,source_language_name:x.target.value})})]}),(0,t.jsxs)("label",{className:"level",children:["Target Language Code",(0,t.jsx)("input",{type:"text",onChange:x=>a({...n,target_language:x.target.value})})]}),(0,t.jsxs)("label",{className:"level",children:["Target Language Name",(0,t.jsx)("input",{type:"text",onChange:x=>a({...n,target_language_name:x.target.value})})]}),(0,t.jsxs)("label",{className:"level",children:["Selected Provider",(0,t.jsx)("span",{children:el.map(x=>(0,t.jsxs)("label",{children:[(0,t.jsx)("input",{type:"checkbox",checked:(n.selected_provider||[]).includes(x),onChange:S=>{const C=S.target.checked?[...n.selected_provider||[],x]:(n.selected_provider||[]).filter(y=>y!==x);a({...n,selected_provider:C})}}),x]},x))})]}),(0,t.jsxs)("label",{className:"level",children:["Is Testing",(0,t.jsx)("input",{type:"checkbox",checked:n.is_testing||!1,onChange:x=>a({...n,is_testing:x.target.checked})})]}),(0,t.jsx)("button",{type:"submit",onClick:()=>{e(1),h(1)},disabled:o,children:"Search"})]})}),(0,t.jsxs)("table",{className:Ds.pairTable,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Pair String"}),(0,t.jsx)("th",{children:"Source Language"}),(0,t.jsx)("th",{children:"Target Language"}),(0,t.jsx)("th",{children:"Provider Weights"}),(0,t.jsx)("th",{children:"Selected Provider"}),(0,t.jsx)("th",{children:"Is Testing"})]})}),(0,t.jsx)("tbody",{children:l.map((x,S)=>{const{pair_string:C,source_language:y,source_language_name:N,target_language:w,target_language_name:A,supported_providers:I,is_testing:D}=x,L=S%2===0,$=I.length>1;return(0,t.jsxs)("tr",{style:L?{backgroundColor:"#f4f2f1"}:{},className:Ds.pairRow,children:[(0,t.jsx)("td",{children:C}),(0,t.jsxs)("td",{children:[N," (",y,")"]}),(0,t.jsxs)("td",{children:[A," (",w,")"]}),(0,t.jsx)("td",{style:{display:"flex"},children:b(x)}),(0,t.jsx)("td",{children:j(x)}),(0,t.jsx)("td",{style:{width:"20px"},children:$?(0,t.jsx)("input",{type:"checkbox",disabled:o,checked:D,onChange:R=>v(x._id,R.target.checked)}):(0,t.jsx)("div",{children:"Language pair only has one supported provider"})})]},C)})})]}),(0,t.jsxs)("div",{className:Ds.paginationButtonContainer,children:[(0,t.jsx)(Ga,{buttonText:"â Previous Page",onClick:()=>u(s-1),disabled:s===1||o}
223),(0,t.jsx)(Ga,{buttonText:"Next Page â",onClick:()=>u(s+1),disabled:s===m.current||o})]})]})},lZ=iZ,iY=Q(cn());const rZ=(s,e)=>s.isMultiLingual?s.provider==="ELEVENLABS"&&!Rd.includes(e)?!1:s.accent?!(e==="English (US)"&&!s.accent.includes("american")||e==="English (UK)"&&!s.accent.includes("british")&&!s.accent.includes("irish")||e==="English (Australia)"&&!s.accent.includes("australian")||e==="English (India)"&&!s.accent.includes("indian")):!0:s.languageLabel===e,bs=s=>{const{dispatch:e}=Pn();e(He(s))};var dZ=Q(ie());function cZ(s){const e=(0,dZ.c)(18),{allVoiceOptions:n,configuredVoice:a,onVoiceSelected:o}=s,[i,l]=(0,f.useState)(""),[r,d]=(0,f.useState)("English (US)");let c;const m=n[r];let h;if(e[0]!==i||e[1]!==m){let b;e[3]!==i?(b=j=>Yc(j,i),e[3]=i,e[4]=b):b=e[4],h=m.filter(b).map(uZ),e[0]=i,e[1]=m,e[2]=h}else h=e[2];c=h;const p=c;let u;e[5]!==i?(u=(0,t.jsx)("div",{className:Hn.filterRow,children:(0,t.jsx)(Fc,{search:i,setSearch:l,placeholder:"Search voices"})}),e[5]=i,e[6]=u):u=e[6];let g;e[7]!==r?(g=(0,t.jsx)("div",{className:Hn.filterRow,children:(0,t.jsx)(wc,{value:r,listItems:Su,onChange:d,className:Hn.languageDropDown,dropdownListClassName:Hn.languageDropDownList,alignItemsLeft:!0})}),e[7]=r,e[8]=g):g=e[8];let _;e[9]!==a||e[10]!==o||e[11]!==r||e[12]!==p?(_=(0,t.jsx)(eu,{voices:p,selectedVoice:a,onSelectVoice:o,selectedLanguage:r}),e[9]=a,e[10]=o,e[11]=r,e[12]=p,e[13]=_):_=e[13];let v;return e[14]!==u||e[15]!==g||e[16]!==_?(v=(0,t.jsxs)(t.Fragment,{children:[u,g,_]}),e[14]=u,e[15]=g,e[16]=_,e[17]=v):v=e[17],v}function uZ(s){return{...s,isPaywalled:!1}}var mZ=cZ;const pZ="1001",hZ="1000",fZ="58px",xZ="TTSVoices-module_container_T6XhN",gZ="TTSVoices-module_header_ylh1Y",vZ="TTSVoices-module_secondaryHeader_6Om-S",_Z="TTSVoices-module_previewHeader_-OJE3",jZ="TTSVoices-module_disclaimer_Y39P5",bZ="TTSVoices-module_TabsRoot_cEgHt",yZ="TTSVoices-module_TabsList_V2AEC",SZ="TTSVoices-module_TabsTrigger_6QjM-",CZ="TTSVoices-module_TabsContent_p3jjg",NZ="TTSVoices-module_TabContentInner_rXpY-",wZ="TTSVoices-module_inputInstructions_Jtg7V",AZ="TTSVoices-module_inputContainer_lSBy-",IZ="TTSVoices-module_inputLabel_Ibu1k",TZ="TTSVoices-module_voiceInput_ttWbU",kZ="TTSVoices-module_addVoiceButton_0Mxa2",RZ="TTSVoices-module_inputRow_ui6n-",$Z="TTSVoices-module_inpuRow_kK9rS",PZ="TTSVoices-module_generateAllButton_MKQWB",EZ="TTSVoices-module_voiceSelector_-JNKq",LZ="TTSVoices-module_deleteVoiceRow_4ip1e",BZ="TTSVoices-module_deleteVoiceButton_tXw7J";var Ke={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:pZ,paywallBgZIndex:hZ,collapsedMediaSidebarWidth:fZ,container:xZ,header:gZ,secondaryHeader:vZ,previewHeader:_Z,disclaimer:jZ,TabsRoot:bZ,TabsList:yZ,TabsTrigger:SZ,TabsContent:CZ,TabContentInner:NZ,inputInstructions:wZ,inputContainer:AZ,inputLabel:IZ,voiceInput:TZ,addVoiceButton:kZ,inputRow:RZ,inpuRow:$Z,generateAllButton:PZ,voiceSelector:EZ,deleteVoiceRow:LZ,deleteVoiceButton:BZ},DZ=Q(ie()),MZ=s=>{const e=(0,DZ.c)(6),{handleAddVoice:n}=s,a=f.useRef(null),o=f.useRef(null);let i;e[0]!==n?(i=async()=>{const m=a.current?.value;if(!m){bs({type:"error",description:"Add id for Elevenlabs voice"});return}const h=o.current?.value;if(!h){bs({type:"error",description:"Add name for Elevenlabs voice"});return}await n({voiceId:m,label:h,provider:"ELEVENLABS"})&&(a.current.value="",o.current.value="")},e[0]=n,e[1]=i):i=e[1];const l=i;let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxs)("div",{className:Ke.inputContainer,children:[(0,t.jsx)("div",{className:Ke.inputLabel,children:"Voice ID"}),(0,t.jsx)("input",{ref:a,className:Ke.voiceInput,placeholder:"ex: pNInz6obpgDQGcFmaJgB"})]}),e[2]=r):r=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsxs)("div",{className:Ke.inputRow,children:[r,(0,t.jsxs)("div",{className:Ke.inputContainer,children:[(0,t.jsx)("div",{className:Ke.inputLabel,children:"(Optional) Voice Name"}),(0,t.jsx)("input",{ref:o,className:Ke.voiceInput,placeholder:"ex: Hiro"})]})]}),e[3]=d):d=e[3];let c;return e[4]!==l?(c=(0,t.jsxs)("div",{className:Ke.TabContentInner,children:[d,(0,t.jsx)("button",{className:Ke.addVoiceButton,onClick:l,children:"Add Voice"})]}),e[4]=l,e[5]=c):c=e[5],c},FZ=MZ,OZ=Q(ie()),qZ=s=>{const e=(0,OZ.c)(6),{handleAddVoice:n}=s,a=f.useRef(null),o=f.useRef(null);let i;e[0]!==n?(i=async()=>{const m=a.current?.value?.trim();if(!m){bs({type:"error",description:"Add voice name for google voice"});return}const h=o.current?.value?.trim();if(!h){bs({type:"error",description:"Add voice label for google voice"});return}
223await n({voiceId:m,label:h,provider:"GOOGLE"})&&(a.current.value="",o.current.value="")},e[0]=n,e[1]=i):i=e[1];const l=i;let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxs)("div",{className:Ke.inputContainer,children:[(0,t.jsx)("span",{className:Ke.inputLabel,children:"Voice Name"}),(0,t.jsx)("br",{}),(0,t.jsx)("input",{className:Ke.voiceInput,ref:a,placeholder:"ex: af-ZA-Standard-A"})]}),e[2]=r):r=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("div",{children:(0,t.jsxs)("div",{className:Ke.inputRow,children:[r,(0,t.jsxs)("div",{className:Ke.inputContainer,children:[(0,t.jsx)("span",{className:Ke.inputLabel,children:"Voice Label"}),(0,t.jsx)("br",{}),(0,t.jsx)("input",{className:Ke.voiceInput,ref:o,placeholder:"ex: Adam"})]})]})}),e[3]=d):d=e[3];let c;return e[4]!==l?(c=(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:Ke.TabContentInner,children:[d,(0,t.jsx)("button",{className:Ke.addVoiceButton,onClick:l,children:"Add Voice"})]})}),e[4]=l,e[5]=c):c=e[5],c},VZ=qZ,HZ=s=>{const e=s.languageSampleURLs;return e?Xi.filter(n=>rZ(s,n)).some(n=>!e[n]):!0},UZ=()=>{const[s,e]=(0,f.useState)([]),[n,a]=(0,f.useState)(void 0),[o,i]=(0,f.useState)(void 0),[l,r]=(0,f.useState)(!1),d=(0,f.useCallback)(()=>r(!0),[]),c=(0,f.useCallback)(()=>r(!1),[]),m=(0,f.useCallback)(async()=>{try{e(await H.admin.tts.getMultilingualVoices.query())}catch{bs({type:"error",description:"Failed to fetch multilingual voices"})}},[]),h=(0,f.useCallback)(async()=>{a(await H.admin.tts.getAllDefaultVoices.query())},[]);(0,f.useEffect)(function(){m(),h()},[]);const p=(0,f.useMemo)(()=>!!s.find(b=>HZ(b)),[s]),u=(0,f.useMemo)(()=>!!s.some(b=>b.sampleURLsUpdating),[s]),g=(0,f.useCallback)(async()=>{(await H.admin.tts.addMissingPreviews.mutate()).success&&m()},[m]);(0,f.useEffect)(function(){if(u){const j=setInterval(m,5e3);return()=>clearInterval(j)}},[u,m]);const _=(0,f.useCallback)(async b=>{const{status:j,statusString:x}=await H.admin.tts.addVoice.mutate(b);return bs({type:j,description:x}),j==="success"&&(h(),b.provider==="ELEVENLABS"&&m()),j==="success"},[m,h]),v=(0,f.useCallback)(async()=>{if(!o)return;const b=await H.admin.tts.removeVoice.mutate({voiceId:o.id});b.success?(bs({type:"success",description:"Voice deleted successfully"}),h(),o.provider==="ELEVENLABS"&&m()):bs({type:"error",description:b.error||"Failed to delete voice. Please try again."}),i(void 0),c()},[o,c,h,m]);return(0,t.jsxs)("div",{className:Ke.container,children:[(0,t.jsx)("div",{className:Ke.header,children:"Default TTS Voices Admin Tool ð£ï¸"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:Ke.secondaryHeader,children:"Add Voice:"}),(0,t.jsxs)(gd,{className:Ke.TabsRoot,defaultValue:"elevenlabs",children:[(0,t.jsxs)(rd,{className:Ke.TabsList,children:[(0,t.jsx)(Ao,{className:Ke.TabsTrigger,value:"elevenlabs",children:"ElevenLabs"}),(0,t.jsx)(Ao,{className:Ke.TabsTrigger,value:"google",children:"Google Voice"})]}),(0,t.jsx)(wo,{className:Ke.TabsContent,value:"elevenlabs",children:(0,t.jsx)(FZ,{handleAddVoice:_})}),(0,t.jsx)(wo,{className:Ke.TabsContent,value:"google",children:(0,t.jsx)(VZ,{handleAddVoice:_})})]})]}),n&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:Ke.previewHeader,children:"Preview Voices"}),(0,t.jsx)("div",{className:Ke.disclaimer,children:"* note: these voices include all recent updates and may be out of sync with the voices in Kapwing*"}),(0,t.jsx)("div",{className:Ke.voiceSelector,children:(0,t.jsx)(mZ,{allVoiceOptions:n,configuredVoice:o,onVoiceSelected:i})})]}),o&&(0,t.jsx)("div",{className:Ke.deleteVoiceRow,children:(0,t.jsx)("div",{className:Ke.deleteVoiceButton,onClick:d,children:"Delete Selected Voice"})}),o&&(0,t.jsx)(go,{isOpen:l,onClose:c,title:"Delete Voice?",onConfirm:v,children:(0,t.jsxs)("div",{children:["You will delete voice ",(0,t.jsx)("b",{children:o.label})," from"," ",o.provider," with voice id of ",o.id,"."]})}),p&&(0,t.jsx)("div",{className:Ke.secondaryHeader,children:"Some Voices are missing previews:"}),p&&!u&&(0,t.jsx)("div",{className:Ke.generateAllButton,onClick:g,children:"Generate missing previews for all voices"}),p&&u&&(0,t.jsx)("div",{children:"Voice Previews Updating..."})]})},ZZ=UZ,WZ=Q(ie()),KZ=s=>
223{const e=(0,WZ.c)(14),{toggleKey:n,toggleVal:a}=s,[o,i]=(0,f.useState)(!1);let l;e[0]!==o?(l=()=>i(!o),e[0]=o,e[1]=l):l=e[1];const r=l;let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={maxWidth:"50vw"},e[2]=d):d=e[2];let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c={backgroundColor:"#ccc",flex:"none",cursor:"pointer"},e[3]=c):c=e[3];let m;e[4]!==r||e[5]!==n?(m=(0,t.jsx)("div",{className:"flex-cell",style:c,onClick:r,children:n}),e[4]=r,e[5]=n,e[6]=m):m=e[6];let h;e[7]!==o||e[8]!==a?(h=o&&(0,t.jsx)("div",{className:"flex-cell",style:{flex:"none"},children:(0,t.jsx)("pre",{style:{textAlign:"left",margin:0},children:a})}),e[7]=o,e[8]=a,e[9]=h):h=e[9];let p;return e[10]!==m||e[11]!==h||e[12]!==n?(p=(0,t.jsxs)("div",{className:"flex-row column",role:"rowgroup",style:d,children:[m,h]},n),e[10]=m,e[11]=h,e[12]=n,e[13]=p):p=e[13],p},Va=f.memo(KZ),GZ=class extends f.Component{changePlaybackTimeout=null;events="play pause seeking".split(/\s+/g);testVideo=null;originalVideo=null;scrub=null;event=new Event("sync");constructor(s){super(s),this.state={sync:!0,playbackRate:2,videoSettings:{playbackRate:2},saving:!1,review:{notes:"",status:""},error:null,vmafExpanded:!1,vmafZeroesExpanded:!1,vmafValleysExpanded:!0,test:{},submitting:!1}}componentDidMount(){const{data:s}=this.props.item;this.fetchTest(),this.setState({review:{notes:s.notes||"",status:s.status}})}reviewVideo=s=>{const{item:e,updateItem:n}=this.props;s.preventDefault(),this.setState({saving:!0,error:null}),H.admin.videoTest.update.mutate({id:e.key,updates:this.state.review}).then(a=>{n&&n(e.key,{data:{...e.data,...a.changed}})}).catch(a=>{console.error(a),this.setState({error:a})}).finally(()=>{this.setState({saving:!1})})};toggleExpand=()=>{this.props.toggleExpand&&this.props.toggleExpand(this.props.item)};toggleVMAFExpand=()=>{this.setState(s=>({vmafExpanded:!s.vmafExpanded}))};toggleVMAFZeroesExpand=()=>{this.setState(s=>({vmafZeroesExpanded:!s.vmafZeroesExpanded}))};toggleVMAFValleysExpand=()=>{this.setState(s=>({vmafValleysExpanded:!s.vmafValleysExpanded}))};fetchTest=async()=>{const{original_video_id:s}=this.props.item.data;try{const e=(await H.admin.regressionVideos.search.query({filters:{videoId:s}})).data[0];this.setState({test:e})}catch(e){console.error(e)}};updateDescription=async(s,e=!1)=>{this.setState({test:{...this.state.test,description:s}}),e&&await H.admin.regressionVideos.update.mutate({id:this.state.test.id,description:s})};updateFilter=s=>{const{updateVideoFilter:e,updateFilter:n}=this.props;e&&n&&e("original_video_id",this.props.item?.data?.original_video_id||"",n.bind(this,s))};rerunTest=async()=>{const{id:s}=this.props.item.data;try{this.setState({submitting:!0}),await H.admin.videoTest.run.mutate({id:s}),this.setState({submitting:!1})}catch(e){console.error(e)}};updateTest=async()=>{const{original_video_id:s,video_id:e}=this.props.item.data;try{if(!window.confirm(`Update test: ${s} -> ${e}`))return;const n=(await H.admin.regressionVideos.search.query({filters:{videoId:s}})).data[0];n&&await H.admin.regressionVideos.update.mutate({id:n.id,videoId:e,isDisabled:n.isDisabled,description:n.description})}catch(n){console.error(n)}};toggleDisableTest=async()=>{const{original_video_id:s,video_id:e}=this.props.item.data;try{if(!window.confirm(`Update test: ${s} -> ${e}`))return;const n=(await H.admin.regressionVideos.search.query({filters:{videoId:s}})).data[0],a={...n,isDisabled:!n?.isDisabled};this.setState({test:a}),n&&await H.admin.regressionVideos.update.mutate({id:n?.id,videoId:n?.videoId,isDisabled:a.isDisabled,description:a.description})}catch(n){console.error(n)}};scrubPosition=s=>{const e=s.currentTarget.value;this.testVideo&&(this.testVideo.currentTime=e),this.originalVideo&&(this.originalVideo.currentTime=e)};toggleSync=s=>{this.setState({sync:s.currentTarget.checked})};changePlayback=s=>{this.changePlaybackTimeout&&clearTimeout(this.changePlaybackTimeout);const e=Number(s.currentTarget.value)||1;this.setState({playbackRate:s.currentTarget.value}),this.changePlaybackTimeout=setTimeout(()=>{this.setState({videoSettings:{...this.state.videoSettings,playbackRate:e}})},500)};setupEvents=s=>{s.onloadedmetadata=()=>{this.scrub&&this.scrub.setAttribute("max",`${s.duration}`),s.dispatchEvent(this.event)},s.playbackRate=this.state.videoSettings.playbackRate,this.state.sync&&s.addEventListener("sync",this.sync)};syncHandler=s=>{const e=s.type,{originalVideo:n,testVideo:a}=this;if(!(n&&a))return;const{currentTime:o}=n;this.scrub&&this.scrub.setAttribute("value",`${o}`),this.state.sync&&(e==="seeking"&&(a.currentTime=o),(e==="play"||e==="pause")&&(a[e](),a.currentTime=o,n.currentTime=o))};sync=()=>{const{originalVideo:s,testVideo:e}=this;
223s&&e&&this.events.forEach(n=>{s.addEventListener(n,this.syncHandler)})};seek=s=>{const{originalVideo:e,testVideo:n}=this;e&&n&&(n.currentTime=s,e.currentTime=s)};handleReviewChange(s,e){this.setState({review:{...this.state.review,[e]:s.target.value}})}makeVideoURL=(s,e=!1)=>{let n=`/videos/${s}`;return e&&(n+="/debug"),n};secondsToTimestamp(s){return new Date(s*1e3).toISOString().substr(11,8)}renderMismatches(s){return s.map(e=>{const n=Object.keys(e)[0];if(n){let a=e[n];return typeof a=="object"&&(a=JSON.stringify(a,null,2)),(0,t.jsx)(Va,{toggleKey:n,toggleVal:a},n)}return null})}renderRow(s){return(0,t.jsx)("div",{className:"column",children:(0,t.jsx)("div",{className:"flex-row",role:"rowgroup",children:s.columns.map((e,n)=>(0,t.jsx)("div",{className:"flex-cell",style:e.style||{},children:this.renderCell(e)},n))})})}renderCell(s){const{data:e}=this.props.item,{key:n}=s,a=e[n];if(s.renderCell)return s.renderCell(a,this.props.item,s);switch(n){case"actions":{const o=this.props.item.props.expanded?"Collapse":"Expand";return(0,t.jsx)("button",{type:"button",onClick:this.toggleExpand,children:o})}case"video_id":case"original_video_id":return(0,t.jsx)("a",{href:`/videos/${a}/debug`,target:"_blank",rel:"noopener noreferrer",children:a});case"reviewed_by":return(0,t.jsx)("span",{children:e.reviewed_by?"True":"False"});case"build_duration":case"original_build_duration":return typeof a=="number"?(0,t.jsx)("span",{children:a.toFixed(2)}):(0,t.jsx)("span",{children:a});case"status":{let o="";e.error&&e.error.subcategory&&(o=e.error.subcategory);let i="#00ff00";switch(e.status){case"valid":i="#00ff00";break;case"failed":i="#ff0000";break;default:i="#FFA500"}return(0,t.jsx)("div",{style:{width:"100%",height:"100%",backgroundColor:i},children:o||e.status})}default:return JSON.stringify(e[n])}}renderVMAF(s){if(!s)return!1;if(typeof s=="string")return(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{children:"VMAF"}),s]});try{const e=["min","max","mean","harmonic_mean"],{vmaf:n,...a}=s.pooled_metrics;return(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{children:"VMAF Summary"}),(0,t.jsx)("table",{children:(0,t.jsxs)("tbody",{children:[(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{}),e.map(o=>(0,t.jsx)("th",{children:o},o))]}),(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"vmaf"}),Object.values(n).map(o=>(0,t.jsx)("th",{children:o},o))]}),this.state.vmafExpanded&&Object.entries(a).map(o=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:o[0]}),Object.values(o[1]).map(i=>(0,t.jsx)("th",{children:i},i))]},o))]})}),(0,t.jsx)("button",{type:"button",onClick:this.toggleVMAFExpand,children:this.state.vmafExpanded?"Collapse":"Expand"}),!!s.parsed_valleys?.length&&(0,t.jsx)("h4",{children:"VMAF Valleys"}),(0,t.jsx)("button",{type:"button",onClick:this.toggleVMAFValleysExpand,children:this.state.vmafValleysExpanded?"Collapse":"Expand"}),this.state.vmafValleysExpanded&&s.parsed_valleys?.map(([o,i])=>{const l=o/30,r=i/30;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{children:["Frame Interval: ",o," - ",i]}),(0,t.jsxs)("div",{children:["Timestamp Interval:"," ",(0,t.jsx)("button",{style:{cursor:"pointer"},onClick:()=>this.seek(l),type:"button",children:this.secondsToTimestamp(l)})," ","-"," ",(0,t.jsx)("button",{style:{cursor:"pointer"},onClick:()=>this.seek(r),type:"button",children:this.secondsToTimestamp(r)})]})]},`${o}:${i}`)}),!!s.parsed_zeroes?.length&&(0,t.jsx)("h4",{children:"VMAF Zeroes"}),(0,t.jsx)("button",{type:"button",onClick:this.toggleVMAFZeroesExpand,children:this.state.vmafZeroesExpanded?"Collapse":"Expand"}),this.state.vmafZeroesExpanded&&s.parsed_zeroes?.map(o=>{const i=o/30;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{children:["Frame: ",o]}),(0,t.jsxs)("div",{children:["Timestamp:"," ",(0,t.jsx)("button",{style:{cursor:"pointer"},onClick:()=>this.seek(i),type:"button",children:this.secondsToTimestamp(i)})]})]},o)})]})}catch{return(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{children:"VMAF"}),(0,t.jsx)(Va,{toggleKey:"VMAF JSON",toggleVal:JSON.stringify(s,null,2)})]})}}renderExpandedReview(){const{data:s}=this.props.item,{saving:e,error:n,submitting:a}=this.state;return(0,t.jsxs)("div",{className:"expanded-review",children:[(0,t.jsx)("h3",{children:"Review"}),(0,t.jsx)(be,{to:`/admin/process_video_jobs?filters[video_id]=${s.video_id}`,children:"Go to Process Video Job"}),s.error&&(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{children:"Errors: "}),(0,t.jsx)("div",{className:"error-message",children:(0,t.jsx)(Va,{toggleKey:"Error JSON",toggleVal:JSON.stringify(s.error,null,2)})})]}),(0,t.jsx)("h4",{children:"Mismatches:"}),(0,t.jsx)("code",{children:this.renderMismatches(s.mismatches)}),this.renderVMAF(s.vmaf),(0,t.jsxs)("form",{onSubmit:this.reviewVideo,children:[(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Notes:"}),(0,t.jsx)("textarea",{name:"notes",value:this.state.review.notes,onChange:o=>this.handleReviewChange(o,"notes")})]}),(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Status:"}),(0,t.jsxs)("label",{children:["Valid:",(0,t.jsx)("input",{type:"radio",name:"status",value:"valid",checked:this.state.review.status==="valid",onChange:o=>this.handleReviewChange(o,"status")})]}),(0,t.jsxs)("label",{children:["Invalid:",(0,t.jsx)("input",{type:"radio",name:"status",value:"invalid",checked:this.state.review.status==="invalid",onChange:o=>this.handleReviewChange(o,"status")})]}),(0,t.jsxs)("label",{children:["Failed:",(0,t.jsx)("input",{type:"radio",name:"status",value:"failed",checked:this.state.review.status==="failed",onChange:o=>this.handleReviewChange(o,"status")})]})]}),!e&&(0,t.jsx)("button",{type:"submit",children:"Update Review"}),n&&(0,t.jsx)("div",{className:"error",children:JSON.stringify(n,null,2)})]}),(0,t.jsx)("h4",{children:"Actions"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("button",{type:"button",onClick:this.updateFilter,children:"Filter for Test ID"}),a?(0,t.jsx)("button",{type:"button",disabled:!0,children:"Submitting..."}):(0,t.jsx)("button",{type:"button",onClick:this.rerunTest,children:"Re-run Test"})]}),(0,t.jsx)("div",{children:"Replace the test's original video ID with the test video ID"}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",onClick:this.updateTest,children:"Update Test"})}),(0,t.jsx)("br",{}),(0,t.jsx)("div",{children:"Toggle whether test will be run n nightly builds"}),(0,t.jsx)("div",{children:(0,t.jsx)("button",{type:"button",onClick:this.toggleDisableTest,children:this.state?.test?.isDisabled?"Enable Test":"Disable Test"})}),(0,t.jsx)("br",{}),(0,t.jsx)("legend",{children:"Test Description:"}),(0,t.jsx)("textarea",{name:"description",value:this.state.test?.description,onChange:o=>this.updateDescription(o.target.value)}),(0,t.jsx)("button",{type:"button",onClick:()=>this.updateDescription(this.state.test?.description,!0),children:"Update Description"})]})}renderExpanded(){const{data:s,props:e}=this.props.item,{playbackRate:n}=this.state;return e.expanded===!0?(0,t.jsx)("div",{className:"flex-row rowspan",children:(0,t.jsxs)("div",{className:"expanded-row",children:[(0,t.jsxs)("div",{className:"compare-container",children:[(0,t.jsxs)("div",{className:"flex-container",children:[(0,t.jsxs)("div",{className:"video-container",children:[(0,t.jsx)("h3",{children:"Original"}),(0,t.jsx)("div",{children:s.original_video_id}),(0,t.jsx)("a",{href:this.makeVideoURL(s.original_video_id),target:"_blank",rel:"noopener noreferrer",children:"Final Video Page"}),(0,t.jsx)("a",{href:this.makeVideoURL(s.original_video_id,!0),target:"_blank",rel:"noopener noreferrer",children:"Debug Page"}),(0,t.jsx)("div",{className:"video-wrapper",children:(0,t.jsx)("video",{ref:a=>{this.originalVideo=a,a&&this.setupEvents(a)},src:s.original_video_url,className:"pull-right",controls:!0})})]}),(0,t.jsxs)("div",{className:"video-container",children:[(0,t.jsx)("h3",{children:"Test"}),(0,t.jsx)("div",{children:s.video_id}),(0,t.jsx)("a",{href:this.makeVideoURL(s.video_id),target:"_blank",rel:"noopener noreferrer",children:"Final Video Page"}),(0,t.jsx)("a",{href:this.makeVideoURL(s.video_id,!0),target:"_blank",rel:"noopener noreferrer",children:"Debug Page"}),(0,t.jsx)("div",{className:"video-wrapper",children:(0,t.jsx)("video",{ref:a=>{this.testVideo=a,a&&this.setupEvents(a)},src:s.video_url,controls:!0})})]})]}),(0,t.jsxs)("div",{className:"sync-controls",children:[(0,t.jsxs)("div",{children:["Sync :",(0,t.jsx)("input",{type:"checkbox",value:"sync",defaultChecked:!0,onChange:this.toggleSync})]}),(0,t.jsxs)("div",{children:["Playback Rate:",(0,t.jsx)("input",{type:"input",value:n,onChange:this.changePlayback})]}),(0,t.jsx)("div",{children:(0,t.jsx)("input",{ref:a=>{this.scrub=a},type:"range",min:"0",onChange:this.scrubPosition})})]})]}),this.renderExpandedReview()]})}):null}render(){const{item:s}=this.props;return(0,t.jsxs)("div",{className:"flex-table row",role:"rowgroup",children:[this.renderRow(s),this.renderExpanded()]},s.id)}},JZ=GZ,zZ=Q(Qt()),Ui={video_id:"",original_video_id:"",status:"",reviewed:"",label:"",created_at:"",batch_id:""},YZ=[{key:"actions",name:"Actions",style:{flex:"0.5 0 0"}},{key:"status",name:"Status",style:{flex:"0.5 0 0"}},{key:"reviewed_by",name:"Reviewed",style:{flex:"0.4 0 0"}},{key:"created_at",name:"Created At",style:{flex:"1.2 0 0"},renderCell:ds.filterDate},{key:"last_succeeded_at",name:"Last succeeded",style:{flex:"1.2 0 0"},renderCell:ds.filterDate},{key:"label",name:"Label",style:{flex:"1.5 0 0"}},{key:"build_duration",name:"Test Build Duration",style:{flex:"0.5 0 0"}},{key:"original_build_duration",name:"Original Build Duration",style:{flex:"0.5 0 0"}},{key:"original_video_id",name:"Original Video ID",style:{flex:"1.5 0 0"}},{key:"video_id",name:"Video ID",style:{flex:"1.5 0 0"}},{key:"id",name:"Video Test ID",style:{flex:"1.5 0 0"}}],QZ=()=>{const s=ys(k=>k.currentUser),e=zs(),n=tt(),[a,o]=(0,f.useState)(!0),[i,l]=(0,f.useState)(Ui),[r,d]=(0,f.useState)({}),[c,m]=(0,f.useState)({data:[],meta:{per_page:20,page:1}}),[h,p]=(0,f.useState)(""),[u,g]=(0,f.useState)({}),[_,v]=(0,f.useState)(!1),[b,j]=(0,f.useState)(null),[x,S]=(0,f.useState)(null),C=(0,f.useCallback)(()=>{const k=zZ.default.parse(e.search,{ignoreQueryPrefix:!0}).filters||{},T={...k};if(k.created_at){const E="YYYY-MM-DD h:mm:ss a",O=ot(new Date(k.created_at));O.isValid()&&(k.created_at=O.format(E))}l({...Ui,...k}),d(T)},[e.search]),y=(0,f.useCallback)(()=>{H.admin.regressionVideos.totalActiveTests.query().then(k=>{S(k.total)}).catch(k=>{console.error("ERROR: ",k)})},[]);(0,f.useEffect)(()=>{C(),y()},[]);const N=(0,f.useCallback)(k=>{o(!0),H.admin.videoTest.search.query({filters:k.filters,page:k.page,per_page:k.per_page}).then(T=>{m({data:T.data.map(E=>({key:E.id,data:E,props:{expanded:!1}})),meta:T.meta})}).catch(T=>{console.error("ERROR: ",T)}).finally(()=>{o(!1)})},[]),w=(0,f.useCallback)((k,T)=>{const E=c.data,O=E.findIndex(q=>q.key===k);O===-1||m({...c,data:[...E.slice(0,O),{...E[O],...T},...E.slice(O+1)]})},[c]),A=(0,f.useCallback)(k=>{const{props:T}=k,E=!T.expanded;w(k.key,{props:{...T,expanded:E}})},[w]),I=(0,f.useCallback)(k=>{k.preventDefault();let T=i.created_at;if(i.created_at){const E=ot(new Date(i.created_at));E.isValid()&&(T=E.toISOString())}d({...i,created_at:T})},[i]),D=(k,T,E)=>{l(O=>({...O,[k]:T})),E&&E()},L=(0,f.useCallback)((k,T)=>(0,t.jsx)(JZ,{item:k,toggleExpand:A,updateItem:w,updateVideoFilter:D,updateFilter:I,currentUser:s},k.data.id),[s,A,I,w]),$=(0,f.useCallback)(async()=>{v(!0);try{g(await H.admin.videoTest.getRunStats.query({label:h}))}catch(k){console.error("Error getting run stats",k),Ss({description:"Error getting run stats"})}v(!1)}
223,[h]),R=(0,f.useCallback)(async k=>{if(window.confirm(`Re-run all ${u[k]} ${k} runs for label "${h}"?`)){j(k);try{const T=await H.admin.videoTest.runAllByStatus.mutate({label:h,status:k}),E=T.failed>0?`, ${T.failed} failed to queue`:"";n(He({type:T.failed>0?"warning":"success",description:`Queued ${T.count} ${k} run(s) for label "${h}"${E}`})),await $()}catch(T){console.error(`Error re-running all ${k} runs`,T),Ss({description:`Error re-running all ${k} runs`})}j(null)}},[h,u,$,n]),P=(0,f.useCallback)(()=>(0,t.jsxs)("div",{className:"flex-container",children:[(0,t.jsxs)("form",{onSubmit:I,className:"filter-box",children:[(0,t.jsxs)("fieldset",{children:[(0,t.jsx)("legend",{children:"Filter"}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Created At: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:i.created_at,onChange:k=>{const{value:T}=k.currentTarget;D("created_at",T)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{className:"level-left",children:"Label: "}),(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:i.label,onChange:k=>{const{value:T}=k.currentTarget;D("label",T)}}),(0,t.jsx)("div",{style:{fontSize:"9px"},children:'* Regex Ex: "regression.*"'})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Video ID: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:i.video_id,onChange:k=>{const{value:T}=k.currentTarget;D("video_id",T)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Batch ID: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:i.batch_id,onChange:k=>{const{value:T}=k.currentTarget;D("batch_id",T)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Original Video ID: "}),(0,t.jsx)("input",{type:"text",style:{width:"200px"},value:i.original_video_id,onChange:k=>{const{value:T}=k.currentTarget;D("original_video_id",T)}})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Status: "}),(0,t.jsxs)("select",{style:{width:"200px"},value:i.status,onChange:k=>{const{value:T}=k.currentTarget;D("status",T)},children:[(0,t.jsx)("option",{value:"",children:"All"}),(0,t.jsx)("option",{value:"running",children:"Running"}),(0,t.jsx)("option",{value:"valid",children:"Valid"}),(0,t.jsx)("option",{value:"invalid",children:"Invalid"}),(0,t.jsx)("option",{value:"failed",children:"Failed"})]})]}),(0,t.jsxs)("label",{className:"level",children:[(0,t.jsx)("span",{children:"Reviewed: "}),(0,t.jsxs)("select",{style:{width:"200px"},value:i.reviewed,onChange:k=>{const{value:T}=k.currentTarget;D("reviewed",T)},children:[(0,t.jsx)("option",{value:"",children:"All"}),(0,t.jsx)("option",{value:"true",children:"True"}),(0,t.jsx)("option",{value:"false",children:"False"})]})]}),(0,t.jsx)("div",{className:"level",children:(0,t.jsxs)("div",{className:"level-right",children:[(0,t.jsx)("button",{type:"submit",disabled:a,children:"Filter"})," "]})})]}),(0,t.jsxs)("div",{children:["Total Results: ",c.meta.total]})]}),(0,t.jsxs)("fieldset",{className:"run-stats-box",children:[(0,t.jsx)("legend",{children:"Run Stats"}),(0,t.jsxs)("div",{children:["Run Label:"," ",(0,t.jsx)("input",{type:"text",value:h,onChange:k=>{p(k.target.value),g({})},style:{width:"80%"}}),(0,t.jsx)("div",{style:{fontSize:"9px"},children:'* Nightly run labels follow the format of "regression-nightly-YYYY-MM-DD"'})]}),(0,t.jsxs)("div",{children:["Total Runs: ",u.total]}),(0,t.jsxs)("div",{children:["Valid Runs: ",u.valid]}),(0,t.jsxs)("div",{children:["Invalid Runs: ",u.invalid]}),(0,t.jsxs)("div",{children:["Failed Runs: ",u.failed]}),(0,t.jsxs)("div",{children:["In Progress Runs: ",u.running]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("button",{onClick:$,disabled:_,children:"Update"}),_&&(0,t.jsx)(it,{})]}),(0,t.jsxs)("div",{style:{marginTop:"8px"},children:[(0,t.jsx)("button",{onClick:()=>R(Eo.INVALID),disabled:!h||!u.invalid||!!b,children:"Re-run All Invalid"})," ",(0,t.jsx)("button",{onClick:()=>R(Eo.FAILED),disabled:!h||!u.failed||!!b,children:"Re-run All Failed"}),b&&(0,t.jsx)(it,{})]})]})]}),[I,i,c,h,$,u,_,R,b,a]);return(0,t.jsxs)("div",{className:"container video-validation",children:[(0,t.jsx)(be,{to:"/admin",children:"Back to Admin"}),(0,t.jsxs)("div",{className:"header",children:[(0,t.jsx)("h2",{className:"headerText",children:"Video Validation"}),(0,t.jsx)("div",{className:"description",children:"Compare Video exports of previously exported videos to validate they are the same."}),(0,t.jsxs)("div",{className:"description",children:["Total Active Regression Tests: ",x]})]}),(0,t.jsx)(da,{data:c,columns:YZ,filters:r,listData:N,loading:a,renderRow:L,renderSectionHeader:P})]})},XZ=f.memo(QZ);
223const eW="1001",tW="1000",sW="58px",nW="ViewTeam-module_container_ALljb",aW="ViewTeam-module_textContainer_-RnQ7",oW="ViewTeam-module_warning_480Al",iW="ViewTeam-module_header_fVwFw",lW="ViewTeam-module_sectionHeader_hu8d2",rW="ViewTeam-module_subheader_8Sqca",dW="ViewTeam-module_section_uMRHy",cW="ViewTeam-module_row_gL4lV",uW="ViewTeam-module_rowLeft_fLbYw",mW="ViewTeam-module_picture_T7Dv9",pW="ViewTeam-module_link_WGZZY",hW="ViewTeam-module_table_mC9z9",fW="ViewTeam-module_thead_9IbBC",xW="ViewTeam-module_trHead_UHbPi",gW="ViewTeam-module_tbody_7Zjno",vW="ViewTeam-module_trBody_uWOPA",_W="ViewTeam-module_td_01IXl",jW="ViewTeam-module_limitTr_Ci8Rt",bW="ViewTeam-module_planDataContainer_uMx5R",yW="ViewTeam-module_planTier_gfrty",SW="ViewTeam-module_stripeId_re5Ac",CW="ViewTeam-module_title_iZhUl",NW="ViewTeam-module_teamNotFound_9zMsT",wW="ViewTeam-module_headerRow_JUOXf",AW="ViewTeam-module_subscriptionNotFound_7hfdq",IW="ViewTeam-module_teamDetails_fl947",TW="ViewTeam-module_usageRow_9e6N3",kW="ViewTeam-module_left_1Fsmy",RW="ViewTeam-module_rightHalf_yYFJa",$W="ViewTeam-module_button_3-QW1",PW="ViewTeam-module_buttonDisabled_P-9Hg",EW="ViewTeam-module_gold_f-7li",LW="ViewTeam-module_subscriptionRow_aA4ux",BW="ViewTeam-module_marginTop_ok--Y",DW="ViewTeam-module_settingUpdateRow_bTRmd",MW="ViewTeam-module_inputActive_jvhl3",FW="ViewTeam-module_disabled_2CCku",OW="ViewTeam-module_dark_0qaR3",qW="ViewTeam-module_region_jqaV9",VW="ViewTeam-module_customLimitsGrid_af2b5",HW="ViewTeam-module_customLimitControlGroup_DKMIS",UW="ViewTeam-module_customLimitTitle_TAjpq",ZW="ViewTeam-module_leftAlign_2Byhk",WW="ViewTeam-module_sectionNav_ePx9o";var Se={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:eW,paywallBgZIndex:tW,collapsedMediaSidebarWidth:sW,container:nW,textContainer:aW,warning:oW,header:iW,sectionHeader:lW,subheader:rW,section:dW,row:cW,rowLeft:uW,picture:mW,link:pW,table:hW,thead:fW,trHead:xW,tbody:gW,trBody:vW,td:_W,limitTr:jW,planDataContainer:bW,planTier:yW,stripeId:SW,title:CW,teamNotFound:NW,headerRow:wW,subscriptionNotFound:AW,teamDetails:IW,usageRow:TW,left:kW,rightHalf:RW,button:$W,buttonDisabled:PW,gold:EW,subscriptionRow:LW,marginTop:BW,settingUpdateRow:DW,inputActive:MW,disabled:FW,dark:OW,region:qW,customLimitsGrid:VW,customLimitControlGroup:HW,customLimitTitle:UW,leftAlign:ZW,sectionNav:WW},KW=()=>{const s=tt(),[e,n]=(0,f.useState)(""),[a,o]=(0,f.useState)(""),[i,l]=(0,f.useState)(""),[r,d]=(0,f.useState)(""),[c,m]=(0,f.useState)(""),[h,p]=(0,f.useState)(""),[u,g]=(0,f.useState)(""),[_,v]=(0,f.useState)(Ha.Editor),b=async()=>{if(!Po(a)){s(He({description:"Please input a valid email address.",type:"error"}));return}const{userId:y,teamId:N}=await H.admin.users.createUserAndTeam.mutate({email:a,userName:e,teamName:i});s(He({description:"User and team created.",type:"success"})),m(y),d(N)},j=async()=>{if(!Po(h)){s(He({description:"Please input a valid email address.",type:"error"}));return}if(!u||!u.includes(" ")){s(He({description:"Please enter a full name.",type:"error"}));return}try{await H.admin.users.addUserToTeam.mutate({email:h,name:u,teamId:r}),s(He({description:"User added. You should see the team page update after refresh.",type:"success"}))}catch(y){Ue({description:"Error adding user. Please check the email is correct.",error:y})}finally{p(""),g("")}},x=()=>(0,t.jsxs)("div",{className:Se.section,children:[(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"Admin Email:"})," ",(0,t.jsx)("input",{onChange:y=>o(y.target.value),placeholder:"Required"})]}),(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"Admin Name:"})," ",(0,t.jsx)("input",{onChange:y=>n(y.target.value),placeholder:"Required"})]}),(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"Team Name:"})," ",(0,t.jsx)("input",{onChange:y=>l(y.target.value),placeholder:"Optional, will default to My Workspace"})]}),(0,t.jsx)("div",{className:Se.rowLeft,children:(0,t.jsx)("button",{type:"button",onClick:b,children:"Create team with admin"})})]}),S=()=>(0,t.jsxs)("div",{className:Se.section,children:[(0,t.jsx)("div",{className:`${Se.rowLeft} ${Se.sectionHeader}`,children:"⨠New team and admin created"}),(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"New User ID:"}),(0,t.jsx)(be,{to:`/admin/${c}`,target:"_blank",children:c}),"(opens in new tab)"]}),(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"New Team ID:"})," ",(0,t.jsx)(be,{to:`/admin/team/${r}`,target:"_blank",children:r}),"(opens in new tab)"]})]}),C=()=>(0,t.jsxs)("div",{className:Se.section,children:[(0,t.jsx)("div",{className:`${Se.rowLeft} ${Se.sectionHeader}`,children:"ð¥ Add users to team"}),(0,t.jsx)("div",{className:`${Se.rowLeft} ${Se.subheader}`,children:(0,t.jsx)("i",{children:"If user does not have a Kapwing account, we create one. If user already exists, we use their existing account and name."})}),(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"Team User Email:"})," ",(0,t.jsx)("input",{onChange:y=>p(y.target.value),value:h,placeholder:"Required"})]}),(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"Team User Name:"})," ",(0,t.jsx)("input",{onChange:y=>g(y.target.value),value:u,placeholder:"Required"})]}),(0,t.jsxs)("div",{className:Se.rowLeft,children:[(0,t.jsx)("strong",{children:"Role: "})," ",(0,t.jsxs)("select",{onChange:y=>{v(Number(y.target.value))},value:_,children:[(0,t.jsx)("option",{}),Object.entries(Ha).map(([y,N])=>(0,t.jsx)("option",{value:N,children:y},N))]})]}),(0,t.jsx)("div",{className:Se.rowLeft,children:(0,t.jsx)("button",{type:"button",onClick:j,children:"Add user to team"})})]});return(0,t.jsxs)("div",{className:Se.container,children:[(0,t.jsx)(vo,{}),(0,t.jsxs)("div",{className:Se.textContainer,children:[(0,t.jsx)("span",{className:Se.title,children:"Create a team"}),(0,t.jsx)("div",{className:`${Se.row} ${Se.header}`,children:(0,t.jsxs)("i",{children:["Use this tool to create a team from scratch for ",(0,t.jsx)("strong",{children:"new"})," ","users to Kapwing."]})}),(0,t.jsx)("div",{className:Se.subheader,children:(0,t.jsx)("i",{children:"If the admin of the team you want to create already has a Kapwing account, it is recommended to visit /admin/:userId, act as the user, and create the Workspace that way."})})]}),!r&&x(),r&&(0,t.jsxs)(t.Fragment,{children:[S(),C()]})]})},GW=f.memo(KW),JW=4*(3600*1e3);function zW(s){if(s.state!=="pending")return!1;const e=typeof s.createdAt=="string"?new Date(s.createdAt):s.createdAt;return Date.now()-e.getTime()>JW}function YW(s){return s.state==="completed"?!0:s.state==="pending"?!zW(s):!1}function QW(s){return s.filter(YW).reduce((e,n)=>(Ad(n.usageCategory)&&(e[n.usageCategory]+=n.amount),e),vl())}function XW(s,e){return Object.keys(s).reduce((n,a)=>{const o=a;return n[o]=(s[o]||0)+(e[o]||0),n},vl())}function eK({ledger:s,limitsUsage:e}){return XW({CREDITS:0,STORAGE:0,TRANSCRIBE:e.transcribeUsage,TRANSLATE:e.monthlyTranslateUsage,AI_CREDITS:e.monthlyAICreditsUsage,TTS:e.monthlyTTSUsage,LIP_SYNC:e.monthlyLipSyncUsage,CLONED_VOICES:e.TTSVoiceClones??0,ENHANCE_IMAGE:e.imageEnhancements??0,REPURPOSE_USES:e.repurposeStudioUses??0,EXAMPLE_OLD_CATEGORY:0},QW(s))}const tK=(s,e)=>{const n=Zc(),[a,o]=(0,f.useState)(!1),[i,l]=(0,f.useState)(),[r,d
223]=(0,f.useState)(),c=(0,f.useCallback)(async()=>{if(s){o(!0);try{l(await dl(s,{params:{query:e},signal:n.signal})),o(!1)}catch(m){d(zd(m)??"An error occurred"),o(!1)}}},[s,n.signal,e]);return(0,f.useEffect)(()=>{c()},[c]),{isLoading:a,data:i,error:r,refetch:(0,f.useCallback)(async()=>{a||await c()},[a,c])}};const sK="1001",nK="1000",aK="58px",oK="AdminSSOSettings-module_header_6KSpO",iK="AdminSSOSettings-module_title_853nI",lK="AdminSSOSettings-module_chevron_-bByf",rK="AdminSSOSettings-module_settingsWrapper_x5jMj",dK="AdminSSOSettings-module_wrapper_E5VZh",cK="AdminSSOSettings-module_section_eeo2-",uK="AdminSSOSettings-module_sectionLabel_t5YKT",mK="AdminSSOSettings-module_sectionValue_gBm2h",pK="AdminSSOSettings-module_sectionActionButton_8H59F",hK="AdminSSOSettings-module_sectionEditing_NsqEd",fK="AdminSSOSettings-module_buttonSection_Az5ad",xK="AdminSSOSettings-module_checkIcon_O3VA5",gK="AdminSSOSettings-module_checked_GvrKE",vK="AdminSSOSettings-module_unchecked_CiC-b";var Fe={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:sK,paywallBgZIndex:nK,collapsedMediaSidebarWidth:aK,header:oK,title:iK,chevron:lK,settingsWrapper:rK,wrapper:dK,section:cK,sectionLabel:uK,sectionValue:mK,sectionActionButton:pK,sectionEditing:hK,buttonSection:fK,checkIcon:xK,checked:gK,unchecked:vK},_K=Q(ie());const jK=f.memo(s=>{const e=(0,_K.c)(61),{team:n}=s,a=tt(),{data:o,refetch:i}=tK(`/api/v1/sso/admin/${n._id}`),[l,r]=(0,f.useState)(!0),[d,c]=(0,f.useState)(!1),[m,h]=(0,f.useState)(!1),[p,u]=(0,f.useState)(""),[g,_]=(0,f.useState)(ks.AZURE),[v,b]=(0,f.useState)(""),[j,x]=(0,f.useState)(""),[S,C]=(0,f.useState)(!1);let y;e[0]!==o?.config||e[1]!==o?.domain||e[2]!==o?.forceSSO||e[3]!==o?.identityProvider?(y=function(){o?.identityProvider&&_(o?.identityProvider),b(o?.config.loginUrl||""),x(o?.config.cert||""),C(!!o?.forceSSO),u(o?.domain||"")},e[0]=o?.config,e[1]=o?.domain,e[2]=o?.forceSSO,e[3]=o?.identityProvider,e[4]=y):y=e[4];const N=o?.identityProvider,w=o?.forceSSO,A=o?.domain,I=o?.config.loginUrl,D=o?.config.cert;let L;e[5]!==N||e[6]!==w||e[7]!==A||e[8]!==I||e[9]!==D?(L=[N,w,A,I,D],e[5]=N,e[6]=w,e[7]=A,e[8]=I,e[9]=D,e[10]=L):L=e[10],(0,f.useEffect)(y,L);let $;e[11]===Symbol.for("react.memo_cache_sentinel")?($=()=>{c(bK),h(!1)},e[11]=$):$=e[11];const R=$;let P;e[12]!==j||e[13]!==a||e[14]!==p||e[15]!==S||e[16]!==g||e[17]!==v||e[18]!==i||e[19]!==n._id?(P=async()=>{h(!0);const B={domain:p,identityProvider:g,forceSSO:S,config:{loginUrl:v,cert:j}};try{await Ua(`/api/v1/sso/admin/${n._id}`,{body:B})}catch(oe){a(He({type:"error",description:oe.message}))}await i(),h(!1),c(!1)},e[12]=j,e[13]=a,e[14]=p,e[15]=S,e[16]=g,e[17]=v,e[18]=i,e[19]=n._id,e[20]=P):P=e[20];const k=P,T=`https://www.kapwing.com/api/v1/sso/${o?.teamId}/consume`;let E;e[21]!==a||e[22]!==T?(E=()=>{Fo(T),a(He({type:"success",description:`Copied "${T}"`}))},e[21]=a,e[22]=T,e[23]=E):E=e[23];const O=E,q=`kapwing.com/${o?.teamId}`;let J;e[24]!==a||e[25]!==q?(J=()=>{Fo(q),a(He({type:"success",description:`Copied "${q}"`}))},e[24]=a,e[25]=q,e[26]=J):J=e[26];const K=J;let z;e[27]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{r(yK)},e[27]=z):z=e[27];const Y=z;let me;e[28]!==a||e[29]!==p||e[30]!==i||e[31]!==n._id?(me=async()=>{h(!0);try{await Ua(`/api/v1/sso/admin/${n._id}`,{body:{domain:p}})}catch(B){a(He({type:"error",description:B.message}))}await i(),h(!1)},e[28]=a,e[29]=p,e[30]=i,e[31]=n._id,e[32]=me):me=e[32];const X=me;if(!po(n.planTier).hasPermission(Md.SSO_LOGIN))return null;let te;e[33]===Symbol.for("react.memo_cache_sentinel")?(te=(0,t.jsx)("div",{className:Fe.title,children:"Single Sign-On"}),e[33]=te):te=e[33];let ae;e[34]!==l?(ae=(0,t.jsxs)("div",{className:Fe.header,onClick:Y,children:[te,(0,t.jsx)("div",{className:Fe.chevron,children:l?(0,t.jsx)(Sr,{}):(0,t.jsx)(Ir,{})})]}),e[34]=l,e[35]=ae):ae=e[35];let G;e[36]!==o||e[37]!==p||e[38]!==X||e[39]!==l||e[40]!==m?(G=!l&&!o&&(0,t.jsx)("div",{className:Fe.wrapper,children:(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Domain:"}),(0,t.jsx)("div",{className:Fe.sectionValue,children:(0,t.jsx)("input",{value:p,placeholder:"example.com",onChange:B=>u(B.target.value)})}),(0,t.jsx)(Ws,{onClick:X,loading:m,disabled:!p,small:!0,children:"Create SSO Configuration"})]})}),e[36]=o,e[37]=p,e[38]=X,e[39]=l,e[40]=m,e[41]=G):G=e[41];let se;e[42]!==j||e[43]!==o||e[44]!==p||e[45]!==d||e[46]!==q||e[47]!==S||e[48]!==K||e[49]!==O||e[50]!==k||e[51]!==l||e[52]!==g||e[53]!==m||e[54]!==v||e[55]!==T?(se=!l&&o&&(0,t.jsxs)("div",{className:Fe.wrapper,children:[(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Identity Provider:"}),!d&&(0,t.jsx)("div",{className:Fe.sectionValue,children:o.identityProvi
223der}),d&&(0,t.jsx)("div",{className:Fe.sectionEditing,children:(0,t.jsxs)("select",{value:g,onChange:B=>_(B.target.value),children:[(0,t.jsx)("option",{}),(0,t.jsx)("option",{value:ks.AZURE,children:ks.AZURE}),(0,t.jsx)("option",{value:ks.GOOGLE,children:ks.GOOGLE}),(0,t.jsx)("option",{value:ks.OKTA,children:ks.OKTA})]})})]}),(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Domain:"}),!d&&(0,t.jsx)("div",{className:Fe.sectionValue,children:o.domain}),d&&(0,t.jsx)("div",{className:Fe.sectionEditing,children:(0,t.jsx)("input",{value:p,placeholder:"example.com",onChange:B=>u(B.target.value)})})]}),(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Entity ID:"}),!d&&(0,t.jsxs)("div",{className:Fe.sectionValue,children:[(0,t.jsx)("div",{children:q}),(0,t.jsx)("div",{className:Fe.sectionActionButton,children:(0,t.jsx)(Ws,{onClick:K,small:!0,children:"Copy"})})]}),d&&(0,t.jsx)("div",{className:Fe.sectionEditing,children:(0,t.jsx)("input",{value:q,disabled:!0})})]}),(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Reply URL (ACS URL):"}),!d&&(0,t.jsxs)("div",{className:Fe.sectionValue,children:[(0,t.jsx)("div",{children:T}),(0,t.jsx)("div",{className:Fe.sectionActionButton,children:(0,t.jsx)(Ws,{onClick:O,small:!0,children:"Copy"})})]}),d&&(0,t.jsx)("div",{className:Fe.sectionEditing,children:(0,t.jsx)("input",{value:T,disabled:!0})})]}),(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Login URL:"}),!d&&(0,t.jsx)("div",{className:Fe.sectionValue,children:o.config.loginUrl}),d&&(0,t.jsx)("div",{className:Fe.sectionEditing,children:(0,t.jsx)("input",{value:v,onChange:B=>b(B.target.value)})})]}),(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Cert:"}),!d&&(0,t.jsxs)("div",{className:Fe.sectionValue,children:[o.config.cert?.substring(0,25),o.config.cert&&(0,t.jsx)("span",{children:"..."})]}),d&&(0,t.jsx)("div",{className:Fe.sectionEditing,children:(0,t.jsx)("textarea",{value:j,onChange:B=>x(B.target.value)})})]}),(0,t.jsxs)("div",{className:Fe.section,children:[(0,t.jsx)("div",{className:Fe.sectionLabel,children:"Force SSO:"}),!d&&(0,t.jsx)("div",{className:Fe.sectionValue,children:o.forceSSO?(0,t.jsxs)("div",{children:["Users must sign in with SSO",(0,t.jsx)("span",{className:`${Fe.checkIcon} ${Fe.checked}`,children:(0,t.jsx)(Kr,{})})]}):(0,t.jsxs)("div",{children:["Users can sign in with email and password",(0,t.jsx)("span",{className:`${Fe.checkIcon} ${Fe.unchecked}`,children:(0,t.jsx)(Fr,{})})]})}),d&&(0,t.jsx)("input",{type:"checkbox",checked:!!S,onChange:B=>C(B.target.checked)})]}),(0,t.jsxs)("div",{className:Fe.buttonSection,children:[d&&(0,t.jsx)(Ws,{onClick:k,small:!0,loading:m,children:"Save"}),(0,t.jsx)(Ws,{onClick:R,small:!0,overrideColor:d?"gray":void 0,children:d?"Cancel":"Edit"})]})]}),e[42]=j,e[43]=o,e[44]=p,e[45]=d,e[46]=q,e[47]=S,e[48]=K,e[49]=O,e[50]=k,e[51]=l,e[52]=g,e[53]=m,e[54]=v,e[55]=T,e[56]=se):se=e[56];let U;return e[57]!==ae||e[58]!==G||e[59]!==se?(U=(0,t.jsxs)("div",{className:Fe.settingsWrapper,children:[ae,G,se]}),e[57]=ae,e[58]=G,e[59]=se,e[60]=U):U=e[60],U});function bK(s){return!s}function yK(s){return!s}const SK=()=>{if(typeof document>"u")return!1;try{const{domain:s}=document;return s.endsWith(".kapwing-dev.com")||s.startsWith("kapwing-dev")&&s.endsWith(".herokuapp.com")||s.startsWith("localhost")&&["3000","4000","5000"].includes(window.location.port)||s.startsWith("192.")||s.startsWith("10.0.")||s.startsWith("10.1.")}catch{return!1}};const CK="1001",NK="1000",wK="58px",AK="TeamStripeTesting-module_container_LNxsh",IK="TeamStripeTesting-module_header_y9Rvr",TK="TeamStripeTesting-module_subheader_-gfmB",kK="TeamStripeTesting-module_body_ssmQ-";var zn={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:CK,paywallBgZIndex:NK,collapsedMediaSidebarWidth:wK,container:AK,header:IK,subheader:TK,body:kK},RK=Q(ie()),$K=s=>{const e=(0,RK.c)(10),{team:n}=s,[a,o]=(0,f.useState)();if(!n)return null;const i=!n.stripeId;let l;e[0]!==n._id?(l=async()=>{const{testClockUrl:u}=await H.payment.attachTestClock.mutate({teamId:n._id});o(u)},e[0]=n._id,e[1]=l):l=e[1];const r=l;if(!SK||!a&&!i)return null;let d,c;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("div",{className:zn.header,children:"Test clock"}),c=(0,t.jsx)("div",{className:zn.subheader,children:"Use this section to create a Stripe test clock and attach it to this specific team. This is useful if you want to test what happens to a team's subscription."}),e[2]=d,e[3]=c):(d=e[2],c=e[3]);const m=a&&`Test Clock: ${a}`;let h;e[4]!==r||e[5]!==i?(h=i&&(0,t.jsx)("button",{type:"button",onClick:r,children:"Attach Test Clock"}),e[4]=r,e[5]=i,e[6]=h):h=e[6];let p;
223return e[7]!==m||e[8]!==h?(p=(0,t.jsxs)("div",{className:zn.container,children:[d,c,(0,t.jsxs)("div",{className:zn.body,children:[m,h]})]}),e[7]=m,e[8]=h,e[9]=p):p=e[9],p},PK=f.memo($K),pr=Q(ie()),EK=s=>{const e=(0,pr.c)(21),{teamUser:n}=s;let a=n.firstName,o=n.lastName;if(!n.firstName&&!n.lastName&&n.name&&n.name.length>3){let _;e[0]!==n.name?(_=n.name.split(" "),e[0]=n.name,e[1]=_):_=e[1];const v=_;v[0]&&(a=v[0]),v[1]&&(o=v[1])}let i;e[2]!==a?(i=(0,t.jsx)("td",{children:a}),e[2]=a,e[3]=i):i=e[3];const l=o||n.name;let r;e[4]!==l?(r=(0,t.jsx)("td",{children:l}),e[4]=l,e[5]=r):r=e[5];let d;e[6]!==n.email?(d=(0,t.jsx)("td",{children:n.email}),e[6]=n.email,e[7]=d):d=e[7];const c=`/admin/${n.userId.toString()}`;let m;e[8]!==n.userId?(m=n.userId.toString(),e[8]=n.userId,e[9]=m):m=e[9];let h;e[10]!==c||e[11]!==m?(h=(0,t.jsx)("td",{children:(0,t.jsx)(be,{to:c,children:m})}),e[10]=c,e[11]=m,e[12]=h):h=e[12];const p=n.role===Ha.Admin?"Admin":"Editor";let u;e[13]!==p?(u=(0,t.jsx)("td",{children:p}),e[13]=p,e[14]=u):u=e[14];let g;return e[15]!==i||e[16]!==r||e[17]!==d||e[18]!==h||e[19]!==u?(g=(0,t.jsxs)("tr",{children:[i,r,d,h,u]}),e[15]=i,e[16]=r,e[17]=d,e[18]=h,e[19]=u,e[20]=g):g=e[20],g};const LK=f.memo(s=>{const e=(0,pr.c)(4),{teamUsers:n}=s;if(!n)return null;let a;e[0]!==n?(a=n.map(BK),e[0]=n,e[1]=a):a=e[1];let o;return e[2]!==a?(o=(0,t.jsx)(t.Fragment,{children:a}),e[2]=a,e[3]=o):o=e[3],o});function BK(s){return(0,t.jsx)(EK,{teamUser:s},s._id.toString())}const DK="1001",MK="1000",FK="58px",OK="AdminUpgradeTeam-module_container_X85-q",qK="AdminUpgradeTeam-module_textContainer_ApvDW",VK="AdminUpgradeTeam-module_warning_gCdtg",HK="AdminUpgradeTeam-module_header_fpnku",UK="AdminUpgradeTeam-module_sectionHeader_lFBwm",ZK="AdminUpgradeTeam-module_subheader_rZuxG",WK="AdminUpgradeTeam-module_section_-OlHw",KK="AdminUpgradeTeam-module_row_bXDkG",GK="AdminUpgradeTeam-module_rowLeft_N-3f-",JK="AdminUpgradeTeam-module_picture_Nan5Y",zK="AdminUpgradeTeam-module_link_gGQLw",YK="AdminUpgradeTeam-module_table_0k3-U",QK="AdminUpgradeTeam-module_thead_Xz5Q8",XK="AdminUpgradeTeam-module_trHead_O038d",eG="AdminUpgradeTeam-module_tbody_qDvIX",tG="AdminUpgradeTeam-module_trBody_X0coF",sG="AdminUpgradeTeam-module_td_P007G",nG="AdminUpgradeTeam-module_limitTr_n0-cV",aG="AdminUpgradeTeam-module_planDataContainer_wTs2B",oG="AdminUpgradeTeam-module_planTier_i9Zz8",iG="AdminUpgradeTeam-module_stripeId_hUSCc",lG="AdminUpgradeTeam-module_title_92hgq",rG="AdminUpgradeTeam-module_teamNotFound_jF8C8",dG="AdminUpgradeTeam-module_headerRow_KoVoI",cG="AdminUpgradeTeam-module_subscriptionNotFound_8dOql",uG="AdminUpgradeTeam-module_teamDetails_Jo9kY",mG="AdminUpgradeTeam-module_usageRow_NfEX0",pG="AdminUpgradeTeam-module_left_ARqz8",hG="AdminUpgradeTeam-module_rightHalf_og01J",fG="AdminUpgradeTeam-module_button_V3e0A",xG="AdminUpgradeTeam-module_buttonDisabled_i5mq7",gG="AdminUpgradeTeam-module_gold_QZg4q",vG="AdminUpgradeTeam-module_subscriptionRow_JgbKM",_G="AdminUpgradeTeam-module_marginTop_Us0yu",jG="AdminUpgradeTeam-module_settingUpdateRow_GhlE4",bG="AdminUpgradeTeam-module_inputActive_dcVRH",yG="AdminUpgradeTeam-module_disabled_A6GH4",SG="AdminUpgradeTeam-module_dark_-G-v-",CG="AdminUpgradeTeam-module_region_oUU56",NG="AdminUpgradeTeam-module_customLimitsGrid_ZNxm3",wG="AdminUpgradeTeam-module_customLimitControlGroup_f7g0k",AG="AdminUpgradeTeam-module_customLimitTitle_L5xau",IG="AdminUpgradeTeam-module_leftAlign_HIZYw",TG="AdminUpgradeTeam-module_sectionNav_orU3u",kG="AdminUpgradeTeam-module_planSelection_Xft2H";var Sn={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:DK,paywallBgZIndex:MK,collapsedMediaSidebarWidth:FK,container:OK,textContainer:qK,warning:VK,header:HK,sectionHeader:UK,subheader:ZK,section:WK,row:KK,rowLeft:GK,picture:JK,link:zK,table:YK,thead:QK,trHead:XK,tbody:eG,trBody:tG,td:sG,limitTr:nG,planDataContainer:aG,planTier:oG,stripeId:iG,title:lG,teamNotFound:rG,headerRow:dG,subscriptionNotFound:cG,teamDetails:uG,usageRow:mG,left:pG,rightHalf:hG,button:fG,buttonDisabled:xG,gold:gG,subscriptionRow:vG,marginTop:_G,settingUpdateRow:jG,inputActive:bG,disabled:yG,dark:SG,region:CG,customLimitsGrid:NG,customLimitControlGroup:wG,customLimitTitle:AG,leftAlign:IG,sectionNav:TG,planSelection:kG},RG=Q(ie()),$G=f.memo(s=>
223{const e=(0,RG.c)(16),{team:n,refetchSubscription:a}=s,[o,i]=(0,f.useState)(!1),[l,r]=(0,f.useState)(!1);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i(!1),e[0]=d):d=e[0];const c=d;let m;e[1]!==a||e[2]!==n?(m=async x=>{r(!0);const S=po(x).name;if(window.confirm(`Are you sure you want to upgrade this team manually? This will set this team workspace to ${S}, and this team will be ${S} for free, with no billing information attached.`))try{await Mc(n._id,x),a(),i(!1)}catch(C){console.error(C)}r(!1)},e[1]=a,e[2]=n,e[3]=m):m=e[3];const h=m;let p;e[4]!==h?(p=()=>(0,t.jsxs)(un,{unsetCancelModal:c,children:[(0,t.jsx)("div",{className:Sn.title,children:"Select the plan tier to upgrade to:"}),Object.values(ho).filter(EG).map(x=>(0,t.jsx)("div",{onClick:()=>h(x),className:Sn.planSelection,children:(0,t.jsx)(_o,{overridePlan:x})},x))]}),e[4]=h,e[5]=p):p=e[5];const u=p;let g;e[6]!==l?(g=()=>(0,t.jsx)("div",{className:Sn.rightHalf,children:l?(0,t.jsx)("div",{className:Sn.buttonDisabled,children:"Upgrading ..."}):(0,t.jsx)("div",{className:Sn.button,onClick:()=>i(!0),children:"Upgrade this team manually"})}),e[6]=l,e[7]=g):g=e[7];const _=g;let v;e[8]!==u||e[9]!==o?(v=o&&u(),e[8]=u,e[9]=o,e[10]=v):v=e[10];let b;e[11]!==_?(b=_(),e[11]=_,e[12]=b):b=e[12];let j;return e[13]!==v||e[14]!==b?(j=(0,t.jsxs)(t.Fragment,{children:[v,b]}),e[13]=v,e[14]=b,e[15]=j):j=e[15],j}),PG=$G;function EG(s){return s!==ho.Free}var LG=Q(ie());const BG=f.memo(s=>{const e=(0,LG.c)(30),{team:n,refetch:a}=s,{subscription:o}=cl(n._id),[i,l]=(0,f.useState)(!1);let r;e[0]!==a||e[1]!==n._id?(r=async()=>{if(l(!0),window.confirm("Are you sure you want to downgrade this team manually? This will set this team workspace to Free. This WILL NOT affect Stripe, which means if this team has an active subscription, it WILL NOT be cancelled. If you want to cancel a subscription or delete a customer, please do it through Stripe instead."))try{await Xc(n._id),a()}catch(C){console.error(C)}l(!1)},e[0]=a,e[1]=n._id,e[2]=r):r=e[2];const d=r;let c;e[3]!==d||e[4]!==i||e[5]!==a||e[6]!==n?(c=()=>{const{planTier:C}=n;return C!==ho.Free?(0,t.jsx)("div",{className:Se.rightHalf,children:i?(0,t.jsx)("div",{className:Se.buttonDisabled,children:"Downgrading ..."}):(0,t.jsx)("div",{className:Se.button,onClick:d,children:"Reset this team to Free"})}):(0,t.jsx)(PG,{team:n,refetchSubscription:a})},e[3]=d,e[4]=i,e[5]=a,e[6]=n,e[7]=c):c=e[7];const m=c;let h;e[8]!==m||e[9]!==o||e[10]!==n?(h=()=>{const{interval:C}=ec(o),y=xc({interval:C});return(0,t.jsxs)("div",{className:Se.planDataContainer,children:[(0,t.jsxs)("div",{className:Se.left,children:[(0,t.jsxs)("div",{className:Se.section,children:[(0,t.jsx)("strong",{children:"Plan Tier:"}),"Â ",(0,t.jsx)(_o,{overrideTeam:n})]}),o&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:Se.section,children:[(0,t.jsx)("strong",{children:"Payment Term:"}),"Â ",y]}),(0,t.jsxs)("div",{className:Se.section,children:[(0,t.jsx)("strong",{children:"Upgraded at:"}),"Â ",n.upgradedAt&&ot(new Date(n.upgradedAt)).format("MMM D, YYYY, h:mma")]})]}),o?.cancel_at_period_end||n.downgradedAt&&(0,t.jsxs)("div",{className:Se.section,children:[(0,t.jsx)("strong",{children:"Downgraded at:"}),"Â ",ot(new Date(n.downgradedAt)).format("MMM D, YYYY, h:mma")]})]}),m()]})},e[8]=m,e[9]=o,e[10]=n,e[11]=h):h=e[11];const p=h;let u;e[12]!==n?(u=(0,t.jsx)(jl,{team:n,className:Se.picture}),e[12]=n,e[13]=u):u=e[13];let g;e[14]!==n.name?(g=(0,t.jsx)("b",{children:n.name}),e[14]=n.name,e[15]=g):g=e[15];let _;e[16]!==g||e[17]!==n._id?(_=(0,t.jsxs)("div",{className:Se.header,children:[g," (",n._id,")"]}),e[16]=g,e[17]=n._id,e[18]=_):_=e[18];const v=`${gl}/teams/${encodeURIComponent(n._id)}`;let b;e[19]!==v?(b=(0,t.jsx)("a",{className:Se.link,href:v,target:"_blank",rel:"noopener noreferrer",children:"View team in Media Forge admin"}),e[19]=v,e[20]=b):b=e[20];let j;e[21]!==u||e[22]!==_||e[23]!==b?(j=(0,t.jsxs)("div",{className:Se.headerRow,children:[u,_,b]}),e[21]=u,e[22]=_,e[23]=b,e[24]=j):j=e[24];let x;e[25]!==p?(x=p(),e[25]=p,e[26]=x):x=e[26];let S;return e[27]!==x||e[28]!==j?(S=(0,t.jsxs)(t.Fragment,{children:[j,x]}),e[27]=x,e[28]=j,e[29]=S):S=e[29],S});const DG="1001",MG="1000",FG="58px",OG="StripeId-module_background_oC-Hg",qG="StripeId-module_container_UGCWU",VG="StripeId-module_header_Ea4QS",HG="Str
223ipeId-module_close_xUIKL",UG="StripeId-module_description_3Rvyn",ZG="StripeId-module_selectContainer_7ImPH",WG="StripeId-module_selectLabel_FnTkk",KG="StripeId-module_select_0fo8u",GG="StripeId-module_submitContainer_cHBgY",JG="StripeId-module_submit_gqwvO",zG="StripeId-module_submitDisabled_G06us",YG="StripeId-module_pricing_WKBM5",QG="StripeId-module_loader_fcPzV",XG="StripeId-module_spin_fhXUA",eJ="StripeId-module_pricingInfo_7-42R",tJ="StripeId-module_pricingInfoRow_NLIIe",sJ="StripeId-module_pricingInfoHalf_i01ns",nJ="StripeId-module_newPlanHalf_RShm-",aJ="StripeId-module_pendingCancellationText_JHyYm",oJ="StripeId-module_pricingInfoSubheader_rZDOu",iJ="StripeId-module_pricingInfoText_rMCMj",lJ="StripeId-module_nextBill_Wkhpo",rJ="StripeId-module_arrow_ouZhG",dJ="StripeId-module_dueToday_v3NP9",cJ="StripeId-module_input_bsTyb";var Jt={workspacePopoverZIndex:"18",popoverZIndex:"14",paywallZIndex:DG,paywallBgZIndex:MG,collapsedMediaSidebarWidth:FG,background:OG,container:qG,header:VG,close:HG,description:UG,selectContainer:ZG,selectLabel:WG,select:KG,submitContainer:GG,submit:JG,submitDisabled:zG,pricing:YG,loader:QG,spin:XG,pricingInfo:eJ,pricingInfoRow:tJ,pricingInfoHalf:sJ,newPlanHalf:nJ,pendingCancellationText:aJ,pricingInfoSubheader:oJ,pricingInfoText:iJ,nextBill:lJ,arrow:rJ,dueToday:dJ,input:cJ},uJ=Q(ie()),mJ=s=>{const e=(0,uJ.c)(31),{onClose:n,team:a,refetch:o}=s,[i,l]=(0,f.useState)(!1),[r,d]=(0,f.useState)("");let c;e[0]!==n?(c=D=>{D.key==="Escape"&&n()},e[0]=n,e[1]=c):c=e[1];const m=c;let h,p;e[2]!==m?(h=()=>(document.addEventListener("keydown",m,!1),()=>{document.removeEventListener("keydown",m,!1)}),p=[m],e[2]=m,e[3]=h,e[4]=p):(h=e[3],p=e[4]),(0,f.useEffect)(h,p);let u;e[5]!==r||e[6]!==n||e[7]!==o||e[8]!==a._id?(u=async()=>{l(!0);try{await Kc(r,a._id),o(),l(!1),n()}catch(D){const L=D;console.error(L),Ue({description:"An error occurred while updating the Stripe Id.",error:L}),l(!1)}},e[5]=r,e[6]=n,e[7]=o,e[8]=a._id,e[9]=u):u=e[9];const g=u;let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=D=>{d(D.currentTarget.value)},e[10]=_):_=e[10];const v=_;let b;e[11]!==g||e[12]!==i?(b=()=>i?(0,t.jsxs)("div",{className:Jt.submitDisabled,children:[(0,t.jsx)("span",{children:"Updating stripeId ... "}),(0,t.jsx)("div",{className:Jt.loader})]}):(0,t.jsx)("div",{className:Jt.submit,onClick:g,children:"Update Stripe ID"}),e[11]=g,e[12]=i,e[13]=b):b=e[13];const j=b;let x;e[14]!==n?(x=(0,t.jsx)("div",{className:Jt.background,onClick:n}),e[14]=n,e[15]=x):x=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=(0,t.jsx)(io,{}),e[16]=S):S=e[16];let C;e[17]!==n?(C=(0,t.jsxs)("div",{className:Jt.header,children:["Add Stripe ID to Team",(0,t.jsx)("div",{className:Jt.close,onClick:n,children:S})]}),e[17]=n,e[18]=C):C=e[18];let y;e[19]!==a.name?(y=(0,t.jsxs)("div",{className:Jt.description,children:["Use this form to add a Stripe customer ID to"," ",(0,t.jsx)("strong",{children:a.name}),". Only use this form for broken legacy states."]}),e[19]=a.name,e[20]=y):y=e[20];let N;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)("input",{className:Jt.input,placeholder:"cus_ABCXYZ123",type:"text",onChange:v}),e[21]=N):N=e[21];let w;e[22]!==j?(w=(0,t.jsx)("div",{className:Jt.submitContainer,children:j()}),e[22]=j,e[23]=w):w=e[23];let A;e[24]!==y||e[25]!==w||e[26]!==C?(A=(0,t.jsxs)("div",{className:Jt.container,children:[C,y,N,w]}),e[24]=y,e[25]=w,e[26]=C,e[27]=A):A=e[27];let I;return e[28]!==A||e[29]!==x?(I=(0,t.jsxs)(t.Fragment,{children:[x,A]}),e[28]=A,e[29]=x,e[30]=I):I=e[30],I},pJ=f.memo(mJ);const hJ="CustomLimitsControls-module_container_795ys",fJ="CustomLimitsControls-module_customLimitsGrid_0dpYt",xJ="CustomLimitsControls-module_customLimitControlGroup_2d1-r",gJ="CustomLimitsControls-module_customLimitTitle_tU4i-",vJ="CustomLimitsControls-module_applyLimitsButton_vtQpF";var Ms={container:hJ,customLimitsGrid:fJ,customLimitControlGroup:xJ,customLimitTitle:gJ,applyLimitsButton:vJ},_J=Q(ie());function jJ(s){const e=(0,_J.c)(21),{team:n,refetch:a}=s;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];const[i,l]=(0,f.useState)(o);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r={},e[1]=r):r=e[1];const[d,c]=(0,f.useState)(r),[m,h]=(0,f.useState)(!1);let p,u,g,_;if(e[2]!==i||e[3]!==d||e[4]!==a||e[5]!==n){const S=cu(n);p=async()=>{h(!0);try{const C=Object.fromEntries(Object.entries(i).map(bJ).filter(N=>{const[w,A]=N,I=w,D=n.customTeamLimits?.usageType?.[I]?.limit,L=nn[I]?.tier[n.planTier]?.limit;return!(A===D||A===L&&D===void 0)})),y=Object.fromEntries(Object.entries(d).filter(N=>{const[w,A]=N,I=w,D=n.customTeamLimits?.usageType?.[I]?.overageRate,L=nn[I]?.overageCost;return!(A===D||A===L&&D===void 0)}));await H.admin.teams.setCustomLimits.mutate({teamId:n._id,customLimits:C,customOverageRates:y}),l({}),c({}),await a()}catch(C){Ue({description:"An error occurred while saving custom limits.",error:C})}h(!1)},_=Ms.container,u=Ms.customLimitsGrid,g=Object.entries(nn).map(C=>{const[y,N]=C,w=y,A=w===mo.STORAGE;if(!(A||nn[w].tier[n.planTier]?.resetPeriod!==Bd.NEVER))return null;const I=S[w],D=A?i[y]??(I!==void 0?xu(I):""):i[y]??I??"",L=d[y]??n.customTeamLimits?.usageType?.[w]?.overageRate??N.overageCost;return(0,t.jsxs)(f.Fragment,{children:[(0,t.jsxs)("div",{className:Ms.customLimitControlGroup,children:[(0,t.jsx)("div",{className:Ms.customLimitTitle,children:A?`${N.label} (GB)`:N.name}),(0,t.jsx)("input",{type:"number",value:D,onChange:$=>l({...i,[y]:Number($.target.value)})})]}),(0,t.jsxs)("div",{className:Ms.customLimitControlGroup,children:[(0,t.jsxs)("div",{className:Ms.customLimitTitle,children:["Additional price per ",N.unit]}),N.overageCost?(0,t.jsx)("input",{type:"number",value:L??"",onChange:$=>
223c({...d,[y]:Number($.target.value)})}):(0,t.jsx)("div",{children:"No overage"})]})]},y)}),e[2]=i,e[3]=d,e[4]=a,e[5]=n,e[6]=p,e[7]=u,e[8]=g,e[9]=_}else p=e[6],u=e[7],g=e[8],_=e[9];let v;e[10]!==u||e[11]!==g?(v=(0,t.jsx)("div",{className:u,children:g}),e[10]=u,e[11]=g,e[12]=v):v=e[12];const b=m?"Saving...":"Save";let j;e[13]!==p||e[14]!==m||e[15]!==b?(j=(0,t.jsx)("div",{className:Ms.applyLimitsButton,children:(0,t.jsx)(Xs,{onClick:p,isLoading:m,label:b,width:"small"})}),e[13]=p,e[14]=m,e[15]=b,e[16]=j):j=e[16];let x;return e[17]!==_||e[18]!==v||e[19]!==j?(x=(0,t.jsx)("div",{children:(0,t.jsxs)("div",{className:_,children:[v,j]})}),e[17]=_,e[18]=v,e[19]=j,e[20]=x):x=e[20],x}function bJ(s){const[e,n]=s;return[e,e===mo.STORAGE?mu(n):n]}const yJ="Drawer-module_root_aNlHy",SJ="Drawer-module_backdrop_jtZuk",CJ="Drawer-module_backdropHidden_tcVQr",NJ="Drawer-module_panel_zGSSI",wJ="Drawer-module_right_z4itr",AJ="Drawer-module_left_Fr2-z",IJ="Drawer-module_top_1YBpj",TJ="Drawer-module_bottom_Uyl2p",kJ="Drawer-module_slideInRight_AFF3w",RJ="Drawer-module_slideInLeft_UFrjT",$J="Drawer-module_slideInTop_pmyDt",PJ="Drawer-module_slideInBottom_90tXc",EJ="Drawer-module_content_vE8BU";var Fs={root:yJ,backdrop:SJ,backdropHidden:CJ,panel:NJ,right:wJ,left:AJ,top:IJ,bottom:TJ,slideInRight:kJ,slideInLeft:RJ,slideInTop:$J,slideInBottom:PJ,content:EJ},LJ=Q(ie());const hr=s=>{const e=(0,LJ.c)(22),{open:n,onClose:a,anchor:o,width:i,children:l}=s,r=o===void 0?"right":o,[d,c]=(0,f.useState)(n),[m,h]=(0,f.useState)(!1);let p,u;e[0]!==n?(p=()=>
223{if(n)c(!0),setTimeout(()=>h(!0),100);else{h(!1);const L=setTimeout(()=>c(!1),300);return()=>clearTimeout(L)}},u=[n],e[0]=n,e[1]=p,e[2]=u):(p=e[1],u=e[2]),(0,f.useEffect)(p,u);let g,_;if(e[3]!==a||e[4]!==n?(g=()=>{const L=$=>{$.key==="Escape"&&a()};if(n)return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},_=[n,a],e[3]=a,e[4]=n,e[5]=g,e[6]=_):(g=e[5],_=e[6]),(0,f.useEffect)(g,_),!d)return null;const v=Fs[r],b=m?Fs[`slideIn${BJ(r)}`]:"",j=r==="left"||r==="right"?i??i:"320px",x=r==="top"||r==="bottom"?"250px":void 0;let S;e[7]!==j||e[8]!==x?(S={width:j,height:x},e[7]=j,e[8]=x,e[9]=S):S=e[9];const C=S,y=`${Fs.backdrop} ${m?"":Fs.backdropHidden}`;let N;e[10]!==a||e[11]!==y?(N=(0,t.jsx)("div",{className:y,onClick:a}),e[10]=a,e[11]=y,e[12]=N):N=e[12];const w=`${Fs.panel} ${v} ${b}`;let A;e[13]!==l?(A=(0,t.jsx)("div",{className:Fs.content,children:l}),e[13]=l,e[14]=A):A=e[14];let I;e[15]!==C||e[16]!==w||e[17]!==A?(I=(0,t.jsx)("div",{className:w,style:C,children:A}),e[15]=C,e[16]=w,e[17]=A,e[18]=I):I=e[18];let D;return e[19]!==N||e[20]!==I?(D=(0,t.jsxs)("div",{className:Fs.root,children:[N,I]}),e[19]=N,e[20]=I,e[21]=D):D=e[21],D};function BJ(s){return s.charAt(0).toUpperCase()+s.slice(1)}var DJ=Q(ie());const Zi=f.memo(s=>{const e=(0,DJ.c)(16),{folder:n}=s;let a;e[0]!==n.type?(a=()=>{switch(n.type){case To.team:return"Team";case To.personal:return"Personal";default:return"Unknown"}},e[0]=n.type,e[1]=a):a=e[1];const o=a;let i;e[2]!==n.name?(i=(0,t.jsx)("td",{children:n.name}),e[2]=n.name,e[3]=i):i=e[3];const l=o();let r;e[4]!==l?(r=(0,t.jsx)("td",{children:l}),e[4]=l,e[5]=r):r=e[5];const d=`/admin/${n.creatorId}`;let c;e[6]!==n.creatorId||e[7]!==d?(c=(0,t.jsx)("td",{children:(0,t.jsx)(be,{to:d,children:n.creatorId})}),e[6]=n.creatorId,e[7]=d,e[8]=c):c=e[8];let m;e[9]!==n._id?(m=(0,t.jsx)("td",{children:n._id}),e[9]=n._id,e[10]=m):m=e[10];let h;return e[11]!==i||e[12]!==r||e[13]!==c||e[14]!==m?(h=(0,t.jsxs)("tr",{children:[i,r,c,m]}),e[11]=i,e[12]=r,e[13]=c,e[14]=m,e[15]=h):h=e[15],h}),MJ="TeamFolders-module_container_-PzQK",FJ="TeamFolders-module_table_C7ES3",OJ="TeamFolders-module_thead_l6PZ6",qJ="TeamFolders-module_trHead_nwcm2",VJ="TeamFolders-module_tbody_sxtVo",HJ="TeamFolders-module_toggleButton_-Ql-t",UJ="TeamFolders-module_sortable_yANUt",ZJ="TeamFolders-module_sortContent_bs3Zv",WJ="TeamFolders-module_sortArrow_D0v5T",KJ="TeamFolders-module_drawerContent_l5LWE",GJ="TeamFolders-module_drawerHeader_1LJAC",JJ="TeamFolders-module_applyLimitsButton_XLbR-";var Ye={container:MJ,table:FJ,thead:OJ,trHead:qJ,tbody:VJ,toggleButton:HJ,sortable:UJ,sortContent:ZJ,sortArrow:WJ,drawerContent:KJ,drawerHeader:GJ,applyLimitsButton:JJ},Wi=5;function zJ({teamFolders:s}){const[e,n]=(0,f.useState)({column:"name",direction:"asc"}),a=c=>{n(m=>m.column===c?{column:c,direction:m.direction==="asc"?"desc":"asc"}:{column:c,direction:"asc"})},o=(0,f.useMemo)(()=>[...s].sort((c,m)=>{const h=c[e.column]??"",p=m[e.column]??"";return typeof h=="string"&&typeof p=="string"?e.direction==="asc"?h.localeCompare(p):p.localeCompare(h):0}),[s,e]),i=o.slice(0,Wi),l=c=>e.column!==c?null:(0,t.jsx)("span",{className:Ye.sortArrow,children:e.direction==="asc"?"â²":"â¼"}
223),[r,d]=(0,f.useState)(!1);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:Ye.container,children:[(0,t.jsxs)("table",{className:Ye.table,children:[(0,t.jsx)("thead",{className:Ye.thead,children:(0,t.jsxs)("tr",{className:Ye.trHead,children:[(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("name"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["Folder Name ",l("name")]})}),(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("type"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["Folder Type ",l("type")]})}),(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("creatorId"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["Creator ID ",l("creatorId")]})}),(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("_id"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["ID ",l("_id")]})})]})}),(0,t.jsx)("tbody",{className:Ye.tbody,children:i.map(c=>(0,t.jsx)(Zi,{folder:c},c._id))})]}),s.length>Wi&&(0,t.jsx)("div",{className:Ye.applyLimitsButton,children:(0,t.jsx)(Xs,{onClick:()=>d(!0),label:"View all folders",width:"small"})})]}),(0,t.jsx)(hr,{anchor:"right",open:r,onClose:()=>d(!1),children:(0,t.jsxs)("div",{className:Ye.drawerContent,children:[(0,t.jsxs)("div",{className:Ye.drawerHeader,children:[(0,t.jsx)("div",{children:(0,t.jsx)(rs,{onClick:()=>d(!1),label:(0,t.jsx)(Gi,{}),color:"primary",width:"small"})}),(0,t.jsx)("h2",{children:"Team Folders"})]}),(0,t.jsxs)("table",{className:Ye.table,children:[(0,t.jsx)("thead",{className:Ye.thead,children:(0,t.jsxs)("tr",{className:Ye.trHead,children:[(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("name"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["Folder Name ",l("name")]})}),(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("type"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["Folder Type ",l("type")]})}),(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("creatorId"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["Creator ID ",l("creatorId")]})}),(0,t.jsx)("th",{className:Ye.sortable,onClick:()=>a("_id"),children:(0,t.jsxs)("span",{className:Ye.sortContent,children:["ID ",l("_id")]})})]})}),(0,t.jsx)("tbody",{className:Ye.tbody,children:o.map(c=>(0,t.jsx)(Zi,{folder:c},c._id))})]})]})})]})}const YJ="TeamLimitsHighlights-module_limitTrigger_0BAGC",QJ="TeamLimitsHighlights-module_limitName_-AnbE",XJ="TeamLimitsHighlights-module_limitStats_Tsb3F",ez="TeamLimitsHighlights-module_deducted_cHMh-",tz="TeamLimitsHighlights-module_refunded_f3wS2",sz="TeamLimitsHighlights-module_drawerContent_N3p31";var Os={limitTrigger:YJ,limitName:QJ,limitStats:XJ,deducted:ez,refunded:tz,drawerContent:sz};const nz="TeamLimitsLedger-module_ledgerTitle_V5lyE",az="TeamLimitsLedger-module_tableWrapper_Rz-Gd",oz="TeamLimitsLedger-module_table_nRd9E",iz="TeamLimitsLedger-module_metricGrid_BdvWE",lz="TeamLimitsLedger-module_metricCard_cUHBD",rz="TeamLimitsLedger-module_metricLabel_GC5pA",dz="TeamLimitsLedger-module_metricValue_8fOwq",cz="TeamLimitsLedger-module_refunded_wXewy",uz="TeamLimitsLedger-module_deducted_hvZNU",mz="TeamLimitsLedger-module_expandButton_Zf2VO",pz="TeamLimitsLedger-module_extraFields_4vGyw";var Ot={ledgerTitle:nz,tableWrapper:az,table:oz,metricGrid:iz,metricCard:lz,metricLabel:rz,metricValue:dz,refunded:cz,deducted:uz,expandButton:mz,extraFields:pz},hz=Q(ie());function fz(s){const e=(0,hz.c)(42),{limitsLedger:n,limitName:a,totalUsage:o,totalRefunded:i}=s,l=a.charAt(0).toUpperCase()+a.slice(1);let r,d,c,m,h,p;if(e[0]!==a||e[1]!==l||e[2]!==n||e[3]!==i||e[4]!==o){const b=[...n].sort(xz);e[11]!==l?(h=(0,t.jsx)("h2",{className:Ot.ledgerTitle,children:l}),e[11]=l,e[12]=h):h=e[12];let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)("p",{className:Ot.metricLabel,children:"Total Usage"}),e[13]=j):j=e[13];let x;e[14]!==o?(x=Nn(o,.01),e[14]=o,e[15]=x):x=e[15];let S;e[16]!==x?(S=(0,t.jsxs)("div",{className:Ot.metricCard,children:[j,(0,t.jsx)("p",{className:Ot.metricValue,children:x})]}),e[16]=x,e[17]=S):S=e[17];let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=(0,t.jsx)("p",{className:Ot.metricLabel,children:"Total Refunded"}),e[18]=C):C=e[18];let y;e[19]!==i?(y=Nn(i,.01),e[19]=i,e[20]=y):y=e[20];let N;e[21]!==y?(N=(0,t.jsxs)("div",{className:Ot.metricCard,children:[C,(0,t.jsx)("p",{className:`${Ot.metricValue} ${Ot.refunded}`,children:y})]}),e[21]=y,e[22]=N):N=e[22],e[23]!==N||e[24]!==S?(p=(0,t.jsxs)("div",{className:Ot.metricGrid,children:[S,N]}),e[23]=N,e[24]=S,e[25]=p):p=e[25],m=Ot.tableWrapper,d=Ot.table,e[26]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{children:"Date"}),(0,t.jsx)("th",{children:"Usage"}),(0,t.jsx)("th",{children:"Origin"}),(0,t.jsx)("th",{children:"Useful Ids"}),(0,t.jsx)("th",{children:"User Id"})]})}),e[26]=c):c=e[26];let w;e[27]!==a?(w=(A,I)=>{const D=ot(A.createdAt).format("YYYY-MM-DD HH:mm:ss"),L=`${a}_${D}_${I}`,$=A.state!=="completed",R=Nn(A.amount,.01),P=$?`0 (failed charge of ${R})`:R;return(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{children:D}),(0,t.jsx)("td",{style:{color:A.amount<0?"red":void 0},children:P}),(0,t.jsx)("td",{children:A.source}),(0,t.jsx)("td",{children:JSON.stringify(A.relevantIds)}),(0,t.jsx)("td",{children:A.userId})]},L)},e[27]=a,e[28]=w):w=e[28],r=b.map(w),e[0]=a,e[1]=l,e[2]=n,e[3]=i,e[4]=o,e[5]=r,e[6]=d,e[7]=c,e[8]=m,e[9]=h,e[10]=p}else r=e[5],d=e[6],c=e[7],m=e[8],h=e[9],p=e[10];let u;e[29]!==r?(u=(0,t.jsx)("tbody",{children:r}),e[29]=r,e[30]=u):u=e[30];let g;e[31]!==d||e[32]!==c||e[33]!==u?(g=(0,t.jsxs)("table",{className:d,children:[c,u]}),e[31]=d,e[32]=c,e[33]=u,e[34]=g):g=e[34];let _;e[35]!==m||e[36]!==g?(_=(0,t.jsx)("div",{className:m,children:g}),e[35]=m,e[36]=g,e[37]=_):_=e[37];let v;
223return e[38]!==h||e[39]!==p||e[40]!==_?(v=(0,t.jsxs)("div",{children:[h,p,_]}),e[38]=h,e[39]=p,e[40]=_,e[41]=v):v=e[41],v}function xz(s,e){const n=ot(s.createdAt);return ot(e.createdAt).diff(n)}var gz=Q(ie());function vz(s){const e=(0,gz.c)(44),{limit:n,totalUsage:a,totalRefunded:o,limitsLedger:i,openLimit:l,setOpenLimit:r}=s,d=l===n;let c;e[0]!==n||e[1]!==r?(c=()=>r(n),e[0]=n,e[1]=r,e[2]=c):c=e[2];let m;e[3]!==n||e[4]!==r?(m=A=>A.key==="Enter"&&r(n),e[3]=n,e[4]=r,e[5]=m):m=e[5];let h;e[6]!==n?(h=(0,t.jsx)("div",{className:Os.limitName,children:(0,t.jsx)("span",{className:Os.limitName,children:n})}),e[6]=n,e[7]=h):h=e[7];let p;e[8]!==a?(p=Nn(a,.01),e[8]=a,e[9]=p):p=e[9];let u;e[10]!==p?(u=(0,t.jsx)("div",{className:Os.limitStats,children:(0,t.jsxs)("span",{children:["Total Usage:"," ",(0,t.jsx)("strong",{children:p})]})}),e[10]=p,e[11]=u):u=e[11];let g;e[12]!==o?(g=Nn(o,.01),e[12]=o,e[13]=g):g=e[13];let _;e[14]!==g?(_=(0,t.jsx)("div",{className:Os.limitStats,children:(0,t.jsxs)("span",{children:["Total Refunded:"," ",(0,t.jsx)("strong",{className:Os.refunded,children:g})]})}),e[14]=g,e[15]=_):_=e[15];let v;e[16]!==c||e[17]!==m||e[18]!==h||e[19]!==u||e[20]!==_?(v=(0,t.jsxs)("div",{className:Os.limitTrigger,onClick:c,role:"button",tabIndex:0,onKeyDown:m,children:[h,u,_]}),e[16]=c,e[17]=m,e[18]=h,e[19]=u,e[20]=_,e[21]=v):v=e[21];let b;e[22]!==r?(b=()=>r(null),e[22]=r,e[23]=b):b=e[23];let j;e[24]!==r?(j=()=>r(null),e[24]=r,e[25]=j):j=e[25];let x;e[26]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)(Gi,{}),e[26]=x):x=e[26];let S;e[27]!==j?(S=(0,t.jsx)("div",{children:(0,t.jsx)(rs,{onClick:j,label:x,color:"primary",width:"small"})}),e[27]=j,e[28]=S):S=e[28];let C;e[29]!==n||e[30]!==i||e[31]!==o||e[32]!==a?(C=(0,t.jsx)(fz,{limitsLedger:i,limitName:n,totalUsage:a,totalRefunded:o}),e[29]=n,e[30]=i,e[31]=o,e[32]=a,e[33]=C):C=e[33];let y;e[34]!==S||e[35]!==C?(y=(0,t.jsxs)("div",{className:Os.drawerContent,children:[S,C]}),e[34]=S,e[35]=C,e[36]=y):y=e[36];let N;e[37]!==d||e[38]!==y||e[39]!==b?(N=(0,t.jsx)(hr,{anchor:"right",open:d,onClose:b,width:"800px",children:y}),e[37]=d,e[38]=y,e[39]=b,e[40]=N):N=e[40];let w;return e[41]!==N||e[42]!==v?(w=(0,t.jsxs)("div",{children:[v,N]}),e[41]=N,e[42]=v,e[43]=w):w=e[43],w}const _z="TeamLimitsSection-module_container_qgmz7",jz="TeamLimitsSection-module_limitsContainer_1zHx2",bz="TeamLimitsSection-module_drawerTrigger_PXoKp",yz="TeamLimitsSection-module_drawerContent_MD0ex",Sz="TeamLimitsSection-module_buttonWrapper_YBSlG";var Ki={container:_z,limitsContainer:jz,drawerTrigger:bz,drawerContent:yz,buttonWrapper:Sz},Cz=Q(ie());function fr(s){const e=(0,Cz.c)(10),{consumption:n,ledger:a,metadata:o}=s;let i;e[0]!==a?(i=a===void 0?[]:a,e[0]=a,e[1]=i):i=e[1];const l=i,[r,d]=(0,f.useState)(null);let c;e[2]!==l||e[3]!==o?(c=Object.keys(mo).map(p=>{const u=nn[p].dbKey,g=o&&u&&u in o?o[u]:[],_=[...l.filter(v=>v.usageCategory===p),...g.map(v=>({amount:v.usage,createdAt:v.usedOn,id:v.usedOn,initialAmount:v.usage,relevantIds:{videoId:v.context?.videoId,workflowId:v.context?.workflowId},source:v.origin+v.usedBy,state:"completed",usageCategory:p,userId:v.userId??"unknown"}))];return[p,{ledgerEntries:_,totalRefunded:g.filter(Tz).reduce(Iz,0)+_.filter(Az).reduce(wz,0)}]}).filter(Nz),e[2]=l,e[3]=o,e[4]=c):c=e[4];const m=c;if(!m.length){let p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)("div",{children:"No limits usage so far"}),e[5]=p):p=e[5],p}let h;return e[6]!==n||e[7]!==m||e[8]!==r?(h=(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("div",{className:Ki.container,children:(0,t.jsx)("div",{className:Ki.limitsContainer,children:m.map(p=>{const[u,g]=p,{ledgerEntries:_,totalRefunded:v}=g;return(0,t.jsx)("div",{children:(0,t.jsx)(vz,{limit:u,totalUsage:n[u],limitsLedger:_,totalRefunded:v,openLimit:r,setOpenLimit:d})},u)})})})}),e[6]=n,e[7]=m,e[8]=r,e[9]=h):h=e[9],h}function Nz(s){const[,e]=s,{ledgerEntries:n}=e;return n.length>0}function wz(s,e){return s+e.amount}function Az(s){return s.state!=="completed"}function Iz(s,e){return s+Math.abs(e.usage)}function Tz(s){return s.usage<0}var kz=Q(ie()),Rz=Q(cn()),$z=s=>{const e=(0,kz.c)(73),{match:n}=s,{params:a}=n,{teamId:o}=a,i=tt(),[l,r]=(0,f.useState)(!1),[d,c]=(0,f.useState)(!1),[m,h]=(0,f.useState)(!1);let p;e[0]!==o?(p=Ut.team.get.queryOptions({teamId:o}),e[0]=o,e[1]=p):p=e[1];const{isLoading:u,data:g,refetch:_}=Gs(p),{subscription:v,loadingSubscription:b,refetch:j}=cl(o);let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[2]=x):x=e[2];
223const[S,C]=(0,f.useState)(x),[y,N]=(0,f.useState)(g?.emailDomain||""),[w,A]=(0,f.useState)(!0),[I,D]=(0,f.useState)(!1);let L;e[3]!==j||e[4]!==_?(L=()=>Promise.all([_(),j()]).then(Ez),e[3]=j,e[4]=_,e[5]=L):L=e[5];const $=L,R=_c();let P,k;e[6]!==o?(P=()=>{(async function(){C(await Lc({teamId:o}))})()},k=[o],e[6]=o,e[7]=P,e[8]=k):(P=e[7],k=e[8]),(0,f.useEffect)(P,k);const[T,E]=(0,f.useState)();let O,q;e[9]!==o?(O=function(){o&&(async()=>{try{E(await H.admin.teams.pastCycleInfo.query({teamId:o}))}catch(ee){console.error(ee)}})()},q=[o],e[9]=o,e[10]=O,e[11]=q):(O=e[10],q=e[11]),(0,f.useEffect)(O,q);let J;e[12]!==g?.emailDomain?(J=()=>{A(!1),N(g?.emailDomain||"")},e[12]=g?.emailDomain,e[13]=J):J=e[13];const K=g?.emailDomain;let z;e[14]!==u||e[15]!==K?(z=[u,K],e[14]=u,e[15]=K,e[16]=z):z=e[16],(0,f.useEffect)(J,z);let Y;e[17]!==$||e[18]!==g?(Y=async()=>{if(g&&window.confirm(`Are you sure? This will remove the stripe ID from team: ${g.name}`)){c(!0);try{await Ec(g._id),$(),c(!1)}catch(pe){const ee=pe;console.error(ee),Ue({description:"An error occurred while removing the Stripe Id.",error:ee}),c(!1)}}},e[17]=$,e[18]=g,e[19]=Y):Y=e[19];const me=Y;let X;e[20]!==i||e[21]!==y||e[22]!==o?(X=async()=>{if(A(!0),!/^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(y)){Ss({description:"Please enter a valid domain."}),A(!1);return}await H.admin.teams.updateDomain.mutate({domain:y,teamId:o}),N(y),A(!1),D(!1),i(He({description:"Email updated!",type:"success"}))},e[20]=i,e[21]=y,e[22]=o,e[23]=X):X=e[23];const te=X;let ae;e[24]!==I||e[25]!==te?(ae=()=>{I?te():D(!0)},e[24]=I,e[25]=te,e[26]=ae):ae=e[26];const G=ae;let se;e[27]!==$||e[28]!==g?(se=async()=>{if(h(!0),!g){Ss({description:"An error occurred while resetting team limits. No team id."}),h(!1);return}if(window.confirm("Are you sure you want to reset this team's limits? This will set all team usage to 0, enabling them to use features additionally without upgrading to Enterprise. This should be reserved for correcting team data."))try{await H.admin.teams.resetLimits.mutate({teamId:g._id}),$()}catch(pe){console.error(pe)}h(!1)},e[27]=$,e[28]=g,e[29]=se):se=e[29];const U=se;let B;e[30]!==T||e[31]!==g?(B=()=>!T||!g?null:(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{children:"Each start date is when we refreshed a user's limits. This can happen mid-cycle. For example, 10-15-2024 would mean the user's first activity in October was on the 15th. The limit cycle represented would still be from the 1st to the 31st though."}),(0,t.jsx)("p",{children:"If a user has a long period of inactivity, we may not have entries for every billing cycle. Dev cycles are 30 minutes and prod cycles are 1 month."}),(0,t.jsx)("p",{children:"These times below are in your local timezone. Resets happen based on UTC. This might mean you see resets like 10-31-24 but this actually represents the start of the November billing cycle."})]}),T.map(Bz)]}),e[30]=T,e[31]=g,e[32]=B):B=e[32];const oe=B;let de;e[33]===Symbol.for("react.memo_cache_sentinel")?(de=function(ee){const xe=document.getElementById(ee);xe&&xe.scrollIntoView({behavior:"smooth"})},e[33]=de):de=e[33];const ye=de;let Le,Ne,Be,le;if(e[34]!==y||e[35]!==I||e[36]!==G||e[37]!==me||e[38]!==U||e[39]!==R||e[40]!==u||e[41]!==d||e[42]!==w||e[43]!==m||e[44]!==b||e[45]!==$||e[46]!==oe||e[47]!==v||e[48]!==g||e[49]!==S){const pe=()=>{if(u||b)return(0,t.jsx)(it,{text:"Looking up team and subscription..."});if(!g)return(0,t.jsx)("div",{className:Se.teamNotFound,children:"404 - a team for this ID cannot be found. Are you sure you tried a team ID and not a folder ID or user ID?"});const{consumption:V}=g.currentConsumption;return(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:Se.container,children:[(0,t.jsx)(BG,{team:g,refetch:$}),(0,t.jsxs)("div",{className:Se.settingUpdateRow,children:[(0,t.jsx)("strong",{children:"Team email domain:"})," ",(0,t.jsx)("div",{children:(0,t.jsx)("input",{type:"text",value:w?"loading...":y,onChange:Ie=>N(Ie.target.value),readOnly:!I||w,className:I?Se.inputActive:Se.disabled})}),(0,t.jsx)(Ga,{buttonText:I?"Update":"Edit",className:w?Se.buttonDisabled:Se.button,onClick:G})]}),we(),(0,t.jsx)(jK,{team:g}),(0,t.jsxs)("nav",{className:Se.sectionNav,children:[(0,t.jsx)("button",{onClick:()=>ye("team-users"),children:"Team users"}),(0,t.jsx)("button",{onClick:()=>ye("team-folders"),children:"Team folders"}),(0,t.jsx)("button",{onClick:()=>ye("custom-limits"),children:"Custom limits"}),(0,t.jsx)("button",{onClick:()=>ye("limits-section"),children:"Limit usage"}),(0,t.jsx)("button",{onClick:()=>ye("past-cycles"),children:"Past billing cycles"})]}),(0,t.jsx)("div",{id:"team-users",children:ve()}),(0,t.jsxs)("div",{id:"team-folders",children:[(0,t.jsx)("h2",{children:"Team folders"}),(0,t.jsx)(zJ,{teamFolders:S})]}),(0,t.jsxs)("div",{id:"custom-limits",children:[(0,t.jsx)("h2",{children:"Custom limits"}),(0,t.jsx)(jJ,{team:g,refetch:$})]}),(0,t.jsxs)("div",{id:"limits-section",children:[(0,t.jsx)("h2",{children:"Limit usage"}),(0,t.jsx)(fr,{metadata:g?.limitsWithMetadata,ledger:g?.limitsLedger,consumption:V})]}),(0,t.jsxs)("div",{id:"past-cycles",children:[(0,t.jsx)("h2",{children:"Past billing cycles"}),oe()]})]})})};let ee;e[54]!==R?(ee=()=>R&&(0,t.jsx)("div",{className:Se.textContainer,children:"You're currently on dev or localhost. Stripe data may not show properly for production customer data."}),e[54]=R,e[55]=ee):ee=e[55];const xe=ee,ve=()=>(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{children:"Team users"}),(0,t.jsxs)("table",{className:Se.table,children:[(0,t.jsx)("thead",{className:Se.thead,children:(0,t.jsxs)("tr",{className:Se.trHead,children:[(0,t.jsx)("th",{children:"First Name"}),(0,t.jsx)("th",{children:"Last Name"}),(0,t.jsx)("th",{children:"Email"}),(0,t.jsx)("th",{children:"User Id"}),(0,t.jsx)("th",{children:"Role"})]})}),(0,t.jsx)("tbody",{className:Se.tbody,children:(0,t.jsx)(LK,{teamUsers:g?.users})})]})]}),we=()=>{if(!g)return null;if(b)return(0,t.jsx)("div",{className:`${Se.row} ${Se.subheader}`,children:"Loading subscription and customer information..."});if(!v){const ke=nl(g);return(0,t.jsxs)("div",{className:Se.subscriptionRow,children:[(0,t.jsxs)("div",{className:Se.subscriptionNotFound,children:["No subscription and/or customer found for this team."," ",(0,t.jsx)("span",{children:ke.isPaid?(0,t.jsx)("span",{className:Se.gold,children:"This team may have been manually upgraded."}):null})]}),(0,t.jsx)("div",{className:Se.button,onClick:()=>{r(!0)},children:"Add a stripe ID to this team"})]})}const V=g?.users.length,{consumption:Ie}=g.currentConsumption;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:Se.subscriptionRow,children:[xe(),(0,t.jsx)("div",{children:"Â "}),d?(0,t.jsx)("div",{className:Se.buttonDisabled,children:"Removing stripe ID..."}):(0,t.jsx)("div",{className:Se.button,onClick:me,children:"Remove stripe ID from team"})]}),(0,t.jsxs)("div",{className:Se.teamDetails,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Total Users:"})," ",V]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Paid Seats:"})," ",(0,t.jsx)("span",{children:v.quantity||"-"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Created:"})," ",ot(new Date(g.createdAt)).format("MMM D, YYYY, h:mma")]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Stripe ID:"})," ",(0,t.jsx)("a",{href:`https://dashboard.stripe.com/customers/${g.stripeId}`,target:"_blank",rel:"noopener noreferrer",children:g.stripeId})]})]}),(0,t.jsx)("strong",{children:"Feature Usage this Month"}),(0,t.jsxs)("div",{className:Se.teamDetails,children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"AI Credits:"})," ",(0,t.jsx)("span",{children:Ie.AI_CREDITS})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Translate:"})," ",(0,t.jsx)("span",{children:Ie.TRANSLATE})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Transcribe:"})," ",(0,t.jsx)("span",{children:Ie.TRANSCRIBE})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Text to Speech:"})," ",(0,t.jsx)("span",{children:Ie.TTS})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Lip Sync:"})," ",(0,t.jsx)("span",{children:Ie.LIP_SYNC})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("strong",{children:"Last Reset:"})," ",g?.limits?.lastReset&&ot(new Date(g.limits.lastReset)).format("MMM D, YYYY, h:mma")]}),(0,t.jsx)("div",{children:(0,t.jsx)(rs,{color:"danger",label:"Reset all team limits",isLoading:m,onClick:U})})]})]})};let re;e[56]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{r(!1)},e[56]=re):re=e[56],Le=re,Ne=Se.container,e[57]===Symbol.for("react.memo_cache_sentinel")?(Be=(0,t.jsx)(vo,{}),e[57]=Be):Be=e[57],le=pe(),e[34]=y,e[35]=I,e[36]=G,e[37]=me,e[38]=U,e[39]=R,e[40]=u,e[41]=d,e[42]=w,e[43]=m,e[44]=b,e[45]=$,e[46]=oe,e[47]=v,e[48]=g,e[49]=S,e[50]=Le,e[51]=Ne,e[52]=Be,e[53]=le}else Le=e[50],Ne=e[51],Be=e[52],le=e[53];let he;e[58]!==g?(he=(0,t.jsx)(PK,{team:g}),e[58]=g,e[59]=he):he=e[59];let ge;e[60]!==Ne||e[61]!==Be||e[62]!==le||e[63]!==he?(ge=(0,t.jsxs)("div",{className:Ne,children:[Be,le,he]}
223),e[60]=Ne,e[61]=Be,e[62]=le,e[63]=he,e[64]=ge):ge=e[64];let je;e[65]!==Le||e[66]!==$||e[67]!==l||e[68]!==g?(je=l&&g?(0,t.jsx)(pJ,{team:g,refetch:$,onClose:Le}):null,e[65]=Le,e[66]=$,e[67]=l,e[68]=g,e[69]=je):je=e[69];let ue;return e[70]!==ge||e[71]!==je?(ue=(0,t.jsxs)(t.Fragment,{children:[ge,je]}),e[70]=ge,e[71]=je,e[72]=ue):ue=e[72],ue},Pz=f.memo(Qs($z));function Ez(){}function Lz(s){const[e,n]=s;return(0,t.jsxs)("tr",{className:Se.usageRow,children:[(0,t.jsx)("td",{children:e}),(0,t.jsx)("td",{children:String(n)})]},e)}function Bz(s){const e=new Date(s.cycleStart),n=eK({limitsUsage:s.usage,ledger:s.limitsLedger??[]}),a=Object.entries(s.enforcedLimits).reduce((o,i)=>{const[l,r]=i,d=l;if(typeof r!="number")return o;const c=n[d]-r;return c<=0?o:{...o,[d]:c}},{});return(0,t.jsxs)(Pu,{level:0,title:`Billing cycle starting on ${e.toLocaleDateString()} at ${e.toLocaleTimeString()}`,children:[(0,t.jsxs)("div",{className:Se.marginTop,children:[(0,t.jsx)("h3",{children:"Enforced limits"}),(0,t.jsx)("table",{className:Se.table,children:(0,t.jsx)("tbody",{className:Se.tbody,children:Object.entries(s.enforcedLimits).map(Lz)})})]}),(0,t.jsxs)("div",{className:Se.marginTop,children:[(0,t.jsx)("h3",{children:"Excess usage"}),(0,Rz.isEmpty)(a)?(0,t.jsx)("div",{children:"No excess usage"}):(0,t.jsxs)("table",{className:Se.table,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:Se.usageRow,children:[(0,t.jsx)("th",{children:"Category"}),(0,t.jsx)("th",{children:"Excess usage"}),(0,t.jsx)("th",{children:"Negotiated rate"}),(0,t.jsx)("th",{children:"Cost"})]})}),(0,t.jsx)("tbody",{className:Se.tbody,children:Object.entries(a).map(o=>{const[i,l]=o;if(!Td(i))return null;const r=s.customBillingInfo?.usageType?.[i]?.overageRate??nn[i].overageCost;return(0,t.jsxs)("tr",{className:Se.usageRow,children:[(0,t.jsx)("td",{width:"25%",children:i}),(0,t.jsx)("td",{width:"25%",children:String(l)}),(0,t.jsx)("td",{width:"25%",children:String(r)}),(0,t.jsx)("td",{width:"25%",children:String(l*(r??0))})]},i)})})]})]}),(0,t.jsx)("div",{className:Se.marginTop,children:(0,t.jsx)(fr,{metadata:s.usageWithMetadata,ledger:s.limitsLedger,consumption:n})}),(0,t.jsx)("div",{className:Se.marginTop})]},String(s._id))}var Dz=Q(ie()),Mz=()=>{const s=(0,Dz.c)(52);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(Qc,{}),s[0]=e):e=s[0];let n;s[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(Te,{path:"/debug/assetSearch",element:(0,t.jsx)(g5,{})}),s[1]=n):n=s[1];let a;s[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(Te,{path:"/debug/assetSearch/broll/:id",element:(0,t.jsx)(A5,{})}),s[2]=a):a=s[2];let o;s[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(Te,{path:"/edu/*",element:(0,t.jsx)(gf,{})}),s[3]=o):o=s[3];let i;s[4]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(Te,{path:"/personas",element:(0,t.jsx)(C9,{})}),s[4]=i):i=s[4];let l;s[5]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(Te,{path:"/tools",element:(0,t.jsx)(sb,{})}),s[5]=l):l=s[5];let r;s[6]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Te,{path:"/ai/tools",element:(0,t.jsx)(Cb,{})}),s[6]=r):r=s[6];let d;s[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(Te,{path:"/ai/helpbot",element:(0,t.jsx)(rb,{})}),s[7]=d):d=s[7];let c;s[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(Te,{path:"/flags",element:(0,t.jsx)(N7,{})}),s[8]=c):c=s[8];let m;s[9]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(Te,{path:"/flags/mcp",element:(0,t.jsx)(iO,{})}),s[9]=m):m=s[9];let h;s[10]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(Te,{path:"/validation",element:(0,t.jsx)(XZ,{})}),s[10]=h):h=s[10];let p;s[11]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(Te,{path:"/export-speed",element:(0,t.jsx)(MF,{})}),s[11]=p):p=s[11];let u;s[12]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(Te,{path:"/regression",element:(0,t.jsx)(tV,{})}),s[12]=u):u=s[12];let g;s[13]===Symbol.for("react.memo_cache_sentinel")?(g=(0,t.jsx)(Te,{path:"/dubbing",element:(0,t.jsx)(PM,{})}),s[13]=g):g=s[13];let _;s[14]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsx)(Te,{path:"/dubbing/:workflowId",element:(0,t.jsx)(KM,{})}),s[14]=_):_=s[14];let v;s[15]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)(Te,{path:"/process_video_jobs/*",element:(0,t.jsx)(Sq,{})}),s[15]=v):v=s[15];let b;s[16]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)(Te,{path:"/tasks/*",element:(0,t.jsx)(bO,{})}),s[16]=b):b=s[16];let j;s[17]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(Te,{path:"/k2-license-keys",element:(0,t.jsx)(YO,{})}),s[17]=j):j=s[17];let x;s[18]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)(Te,{path:"/dev-machines",element:(0,t.jsx)(t8,{})}),s[18]=x):x=s[18];let S;s[19]===Symbol.for("react.memo_cache_sentinel")?(S=(0,t.jsx)(Te,{path:"/qualified-domains",element:(0,t.jsx)(TL,{})}),s[19]=S):S=s[19];let C;s[20]===Symbol.for("react.memo_cache_sentinel")?(C=(0,t.jsx)(Te,{path:"/speakerFocus",element:(0,t.jsx)(xV,{})}),s[20]=C):C=s[20];let y;s[21]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsx)(Te,{path:"/speakerFocus/asset/:assetId",element:(0,t.jsx)(xU,{})}),s[21]=y):y=s[21];let N;s[22]===Symbol.for("react.memo_cache_sentinel")?(N=(0,t.jsx)(Te,{path:"/templates/new",element:(0,t.jsx)(Lx,{})}),s[22]=N):N=s[22];let w;s[23]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)(Te,{path:"/templates/edit",element:(0,t.jsx)(Kf,{})}),s[23]=w):w=s[23];let A;s[24]===Symbol.for("react.memo_cache_sentinel")?(A=(0,t.jsx)(Te,{path:"/templates/update",element:(0,t.jsx)(Yn,{to:"/admin/templates/edit"})}),s[24]=A):A=s[24];let I;s[25]===Symbol.for("react.memo_cache_sentinel")?(I=(0,t.jsx)(Te,{path:"/templates/delete",element:(0,t.jsx)(zU,{})}),s[25]=I):I=s[25];let D;s[26]===Symbol.for("react.memo_cache_sentinel")?(D=(0,t.jsx)(Te,{path:"/templates/migrate",element:(0,t.jsx)(ax,{})}),s[26]=D):D=s[26];let L;s[27]===Symbol.for("react.memo_cache_sentinel")?(L=(0,t.jsx)(Te,{path:"/templates/migrate-single-media",element:(0,t.jsx)(lx,{})}),s[27]=L):L=s[27];let $;s[28]===Symbol.for("react.memo_cache_sentinel")?($=(0,t.jsx)(Te,{path:"/templates",element:(0,t.jsx)(Yn,{to:"/admin/templates/1"})}),s[28]=$):$=s[28];let R;s[29]===Symbol.for("react.memo_cache_sentinel")?(R=(0,t.jsx)(Te,{path:"/templates/:pageNumber",element:(0,t.jsx)(vg,{})}),s[29]=R):R=s[29];let P;s[30]===Symbol.for("react.memo_cache_sentinel")?(P=(0,t.jsx)(Te,{path:"/tts-voices",element:(0,t.jsx)(ZZ,{})}),s[30]=P):P=s[30];let k;s[31]===Symbol.for("react.memo_cache_sentinel")?(k=(0,t.jsx)(Te,{path:"/react-compiler",element:(0,t.jsx)($j,{})}),s[31]=k):k=s[31];let T;s[32]===Symbol.for("react.memo_cache_sentinel")?(T=(0,t.jsx)(Te,{path:"/upload",element:(0,t.jsx)(dv,{})}),s[32]=T):T=s[32];let E;s[33]===Symbol.for("react.memo_cache_sentinel")?(E=(0,t.jsx)(Te,{path:"/blocked-accounts",element:(0,t.jsx)(Kh,{})}),s[33]=E):E=s[33];let O;s[34]===Symbol.for("react.memo_cache_sentinel")?(O=(0,t.jsx)(Te,{path:"/emailScheduler",element:(0,t.jsx)(_h,{})}),s[34]=O):O=s[34];let q;s[35]===Symbol.for("react.memo_cache_sentinel")?(q=(0,t.jsx)(Te,{path:"/product-notifications",element:(0,t.jsx)(Yq,{})}),s[35]=q):q=s[35];let J;s[36]===Symbol.for("react.memo_cache_sentinel")?(J=(0,t.jsx)(Te,{path:"/team/create",element:(0,t.jsx)(GW,{})}),s[36]=J):J=s[36];let K;s[37]===Symbol.for("react.memo_cache_sentinel")?(K=(0,t.jsx)(Te,{path:"/team/:teamId",element:(0,t.jsx)(Pz,{})}),s[37]=K):K=s[37];let z;s[38]===Symbol.for("react.memo_cache_sentinel")?(z=(0,t.jsx)(Te,{path:"/nps",element:(0,t.jsx)(d9,{})}),s[38]=z):z=s[38];let Y;s[39]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,t.jsx)(Te,{path:"/repurpose",element:(0,t.jsx)(pV,{})}),s[39]=Y):Y=s[39];let me;s[40]===Symbol.for("react.memo_cache_sentinel")?(me=(0,t.jsx)(Te,{path:"/performance-reports",element:(0,t.jsx)(h9,{})}),s[40]=me):me=s[40];let X;s[41]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(Te,{path:"/stock-kai-characters",element:(0,t.jsx)(OU,{})}),s[41]=X):X=s[41];let te;s[42]===Symbol.for("react.memo_cache_sentinel")?(te=(0,t.jsx)(Te,{path:"/compare/translation",element:(0,t.jsx)(qL,{})}),s[42]=te):te=s[42];let ae;s[43]===Symbol.for("react.memo_cache_sentinel")?(ae=(0,t.jsx)(Te,{path:"/translation-pairs",element:(0,t.jsx)(lZ,{})}),s[43]=ae):ae=s[43];let G;s[44]===Symbol.for("react.memo_cache_sentinel")?(G=(0,t.jsx)(Te,{path:"/:identifier",element:(0,t.jsx)(kj,{})}),s[44]=G):G=s[44];let se;s[45]===Symbol.for("react.memo_cache_sentinel")?(se=(0,t.jsx)(Te,{path:"/",element:(0,t.jsx)(uh,{})}),s[45]=se):se=s[45];let U;s[46]===Symbol.for("react.memo_cache_sentinel")?(U=(0,t.jsx)(Te,{path:"custom-kais",element:(0,t.jsx)(nD,{})}),s[46]=U):U=s[46];let B;s[47]===Symbol.for("react.memo_cache_sentinel")?(B=(0,t.jsx)(Te,{path:"/ai-evaluation/*",element:(0,t.jsx)(yC,{})}),s[47]=B):B=s[47];let oe;s[48]===Symbol.for("react.memo_cache_sentinel")?(oe=(0,t.jsx)(Te,{path:"/ai/prompt-comparison/:jobId?",element:(0,t.jsx)(UA,{})}),s[48]=oe):oe=s[48];let de;s[49]===Symbol.for("react.memo_cache_sentinel")?(de=(0,t.jsx)(Te,{path:"/ai/prompt-comparison-runs/:runId?",element:(0,t.jsx)(WE,{})}),s[49]=de):de=s[49];let ye;s[50]===Symbol.for("react.memo_cache_sentinel")?(ye=(0,t.jsx)(Te,{path:"/ai/prompt-comparison-request-bank",element:(0,t.jsx)(e3,{})}),s[50]=ye):ye=s[50];let Le;return s[51]===Symbol.for("react.memo_cache_sentinel")?(Le=(0,t.jsxs)("div",{className:"admin",children:[e,(0,t.jsx)("div",{className:"all-videos-container",children:(0,t.jsxs)(Bn,{children:[n,a,o,i,l,r,d,c,m,h,p,u,g,_,v,b,j,x,S,C,y,N,w,A,I,D,L,$,R,P,k,T,E,O,q,J,K,z,Y,me,X,te,ae,G,se,U,B,oe,de,ye,(0,t.jsx)(Te,{path:"/ai/prompt-comparison-request-import",element:(0,t.jsx)(t4,{})})]})}),(0,t.jsx)($c,{})]}),s[51]=Le):Le=s[51],Le},Fz=Mz,Oz=Q(ie()),qz=()=>{const s=(0,Oz.c)(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(Gc,{children:(0,t.jsx)(Fz,{})}),s[0]=e):e=s[0],e},lY=qz;export{lY as default}; 224 225//# sourceMappingURL=AdminContainer-Naa597Pu.js.map
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.