videobook 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/chat-router.js +1 -1
- package/dist/guides/seedance_2_prompting_guide.md +1 -1
- package/dist/image-edit-models.js +1 -0
- package/dist/jobs/generate-media.js +18 -6
- package/dist/jobs/run-notebook.js +23 -4
- package/dist/media/adapters/fal.js +7 -0
- package/dist/media/catalog.js +4 -2
- package/dist/media/cost.js +2 -2
- package/dist/media/refs.js +13 -0
- package/dist/media/request.js +7 -0
- package/dist/media/seedance-edit.js +9 -0
- package/dist/provider-usage.js +3 -1
- package/dist/tools/estimate-cost.js +4 -1
- package/dist/tools/generate-media.js +2 -1
- package/dist/tools/reconcile-project-work.js +2 -1
- package/package.json +14 -14
- package/ui/assets/{alive-captions-DPEr1nKM.js → alive-captions-C48o6dfv.js} +1 -1
- package/ui/assets/confirm-bodies-aq6Az8Md.js +1 -0
- package/ui/assets/{fullscreen-B7nw4YbE.js → fullscreen-4m0qtZ7w.js} +1 -1
- package/ui/assets/{goal-ui-DK-xTCK0.js → goal-ui-2pUWP_B2.js} +2 -2
- package/ui/assets/{index-kS1905s5.js → index-DmDH4gYr.js} +2 -2
- package/ui/assets/{inspector-MlzQbTVo.js → inspector-CnKySYc5.js} +1 -1
- package/ui/assets/{jobs-ui-CoinOWx0.js → jobs-ui-lRoS1MbL.js} +1 -1
- package/ui/assets/{music-video-Cbe80kmQ.js → music-video-BQnnPp-X.js} +1 -1
- package/ui/assets/ui-OHFUngrc.js +2 -0
- package/ui/assets/{vendor-flow-BXbeWxW7.js → vendor-flow-zBavaNEW.js} +1 -1
- package/ui/assets/{vendor-mcp-BTlEJcHV.js → vendor-mcp-DQ7EusT9.js} +1 -1
- package/ui/assets/vendor-yctIZ9Dz.js +19 -0
- package/ui/assets/{videobook-Qlp9HQFu.js → videobook-DZ58pKW5.js} +12 -12
- package/ui/index.html +11 -11
- package/ui/assets/confirm-bodies-D8ouHXKy.js +0 -1
- package/ui/assets/ui-xo_Y1yQg.js +0 -2
- package/ui/assets/vendor-DfTCWgKm.js +0 -19
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as C,j as t,c as Y,d as ma,b as hs}from"./vendor-react-Dj7D1fD4.js";import{b as Vt,E as os,F as al,G as fa,H as rl,I as pa,J as ol,K as ha,L as ba,n as ti,O as xa,P as ga,Q as cs,R as cl,U as ya,V as ja}from"./vendor-yctIZ9Dz.js";import{x as va,p as ka,u as Sa,a as wa,i as Na,b as Ca,P as fn,c as $a,m as pn,d as dl,h as In,e as Ia,f as si,g as ul,r as gs,s as ml,j as ns,k as fl,l as pl,n as ni,o as li,q as ii,t as ai,v as Ra,w as Ma,y as Pa,z as Ta,A as Ea,B as Aa,C as Xt,D as Da,E as Fa,F as _a,G as La,H as za,I as Ba,J as hl,K as Oa,L as Ua,M as Ha,N as bl,O as hn,Q as Ka,R as Va,S as qa,T as bn,U as Wa,V as Xa,W as Ga,X as Ya,Y as xl,Z as Ja,_ as Qa,$ as Za,a0 as er,a1 as tr,a2 as sr,a3 as nr,a4 as lr,a5 as ir,a6 as Rn,a7 as ar,a8 as He,a9 as Ln,aa as _s,ab as rr,ac as or,ad as Bt,ae as ri,af as cr,ag as dr,ah as ur,ai as mr,aj as fr,ak as pr,al as oi,am as hr,an as br,ao as xr,ap as gr,aq as ci,ar as yr,as as jr,at as di,au as vr,av as kr,aw as Sr,ax as wr,ay as Nr,az as Cr,aA as $r,aB as Ir,aC as Rr,aD as Mr,aE as ui,aF as gl,aG as Pr,aH as Tr,aI as yl,aJ as Er,aK as Ar,aL as Dr,aM as Fr,aN as _r,aO as Lr,aP as jl,aQ as zr,aR as Br,aS as Or,aT as Ur,aU as xn,aV as vl,aW as ds,aX as Hr,aY as Kr,aZ as ws,a_ as gn,a$ as mi,b0 as fi,b1 as Vr,b2 as pi,b3 as qr,b4 as Wr,b5 as Xr,b6 as Gr,b7 as hi,b8 as Yr,b9 as Jr,ba as ls,bb as Mn,bc as js,bd as bi,be as Qr,bf as Zr,bg as eo,bh as to,bi as so,bj as no,bk as xi,bl as lo,bm as io,bn as ao,bo as gi,bp as ro,bq as oo,br as co,bs as uo,bt as mo,bu as fo,bv as kl,bw as po,bx as ho,by as bo,bz as xo,bA as go,bB as yo,bC as jo,bD as vo,bE as yi,bF as Sl,bG as us,bH as ko,bI as So,bJ as ji,bK as wo,bL as No,bM as Co,bN as $o,bO as Io,bP as Ro,bQ as Mo,bR as Po,bS as wl,bT as Nl,bU as To,bV as Eo,bW as Ao,bX as Ls,bY as Cl,bZ as Do,b_ as fs,b$ as Fo}from"./videobook-DZ58pKW5.js";import{X as dt,A as _o,a as ts,F as Ct,I as Qt,B as $s,b as zn,V as Lo,L as vi,C as Ns,M as ki,c as Jt,T as $l,W as Si,d as zo,S as Bo,e as Gs,E as Oo,R as Bn,f as is,g as Ys,h as On,H as Un,P as Uo,i as wi,D as Js,j as Ho,k as Ni,l as Ci,m as Zt,n as Hn,o as Ko,p as $i,N as Vo,q as qo,U as Wo,r as Ii,s as Xo,t as Ri,u as Go,v as Yo,w as Kn,x as Mi,Z as Jo,y as Qs,z as Vn,G as Il,J as ks,K as Qo,O as Rl,Q as yn,Y as qn,_ as Is,$ as Pi,a0 as Zo,a1 as Cs,a2 as ec,a3 as as,a4 as tc,a5 as sc,a6 as Ti,a7 as Ei,a8 as Ai,a9 as Di,aa as nc,ab as lc,ac as Fi,ad as ic,ae as ac,af as Pn,ag as rc,ah as oc}from"./vendor-icons-CGqhCIXV.js";import{u as cc,B as dc,V as _i,P as Ss,a as uc,H as jn}from"./vendor-flow-zBavaNEW.js";import{S as Tn,u as mc,i as Ml,I as fc,A as Wn,V as pc,b as hc,P as bc}from"./vendor-remotion-CH1HXrlc.js";const xc={tiktok:"https://www.tiktok.com/@account/video/…",instagram:"https://www.instagram.com/reel/…",youtube:"https://youtube.com/shorts/…",x:"https://x.com/account/status/…",other:"https://…"};function gc(l){return l instanceof Error?l.message:String(l)}function yc({post:l,disabled:e,className:s,onLink:n}){const[i,a]=C.useState(""),[o,r]=C.useState(()=>va(new Date().toISOString())),[c,d]=C.useState(!1),[u,f]=C.useState(null),m=e||c||!l.definition.source,b=async()=>{if(!(m||!i.trim()||!o)){d(!0),f(null);try{await n({url:i.trim(),posted_at:new Date(o).toISOString()})}catch(h){f(gc(h))}finally{d(!1)}}},p=h=>{h.key==="Enter"&&(h.preventDefault(),h.stopPropagation(),b())},g=`post-link-${l.id}`;return t.jsxs("div",{className:s??"post-link-field",role:"group","aria-labelledby":`${g}-heading`,children:[t.jsx("h3",{id:`${g}-heading`,children:ka(l)}),t.jsx("label",{htmlFor:`${g}-url`,children:"Post URL"}),t.jsx("input",{id:`${g}-url`,type:"url",value:i,disabled:m,spellCheck:!1,placeholder:xc[l.definition.platform],onChange:h=>a(h.target.value),onKeyDown:p}),t.jsx("label",{htmlFor:`${g}-at`,children:"Published at"}),t.jsx("input",{id:`${g}-at`,type:"datetime-local",value:o,disabled:m,onChange:h=>r(h.target.value),onKeyDown:p}),t.jsx("button",{type:"button",disabled:m||!i.trim()||!o,onClick:()=>{b()},children:c?"Saving link…":"Save published link"}),u&&t.jsx("small",{role:"alert",className:"post-error",children:u}),t.jsx("small",{children:"Locks the clip and caption to this publication. Add views and likes under Results afterwards."})]})}function Pl(){const l=new Date;return new Date(l.getTime()-l.getTimezoneOffset()*6e4).toISOString().slice(0,23)}function X1(l){const e=Y.c(186),{post:s,cells:n,asset:i,bookId:a,call:o,onRefresh:r,onSelectCell:c,onDeliver:d,onReviewX:u,onDelete:f}=l,m=Sa(o,a,r);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[p,g]=C.useState(b),h=p.platform??s.definition.platform,y=p.caption??s.definition.caption,x=p.credits??s.definition.credits,j=p.account??s.definition.account,v=p.notes??s.definition.notes,[k,w]=C.useState(""),[S,M]=C.useState(Pl);let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N={},e[1]=N):N=e[1];const[$,R]=C.useState(N),[I,P]=C.useState(null);wa(!!s.runtime.icloud?.completedAt,o,a,s.id,P);const T=I?.phase??null,D=I?.error;let A;e[2]!==T||e[3]!==D?(A=Na(T,D),e[2]=T,e[3]=D,e[4]=A):A=e[4];const F=A,E=!!(s.runtime.outbound||s.runtime.url||s.runtime.status==="scheduled");let z,_,L,B,H,q,U,K,ee,ne,V,re,W,Z;if(e[5]!==j||e[6]!==m||e[7]!==i||e[8]!==a||e[9]!==o||e[10]!==y||e[11]!==n||e[12]!==x||e[13]!==p||e[14]!==F||e[15]!==E||e[16]!==$||e[17]!==v||e[18]!==S||e[19]!==d||e[20]!==r||e[21]!==u||e[22]!==c||e[23]!==h||e[24]!==s||e[25]!==k){let le;e[40]!==s.definition.source?.cellId?(le=ke=>ke.id===s.definition.source?.cellId,e[40]=s.definition.source?.cellId,e[41]=le):le=e[41];const de=n.find(le),pe=s.runtime.metrics.at(-1),ue=h!==s.definition.platform||y!==s.definition.caption||x!==s.definition.credits||j!==s.definition.account;let me;e[42]!==m||e[43]!==s.id?(me=(ke,Oe)=>{const at=Oe===void 0?{}:Oe;return m.run(ke,{post_cell_id:s.id,...at})},e[42]=m,e[43]=s.id,e[44]=me):me=e[44];const fe=me;let xe;e[45]!==a||e[46]!==o||e[47]!==r||e[48]!==s.id?(xe=async ke=>{o&&(await o("link_post",{book_id:a,post_cell_id:s.id,...ke}),await r())},e[45]=a,e[46]=o,e[47]=r,e[48]=s.id,e[49]=xe):xe=e[49];const he=xe;V="post-inspector",re="Post details";let oe;e[50]!==s.definition.platform?(oe=t.jsxs("span",{className:"post-eyebrow",children:[s.definition.platform," publication"]}),e[50]=s.definition.platform,e[51]=oe):oe=e[51];let Q;e[52]!==s.address?(Q=t.jsxs("h2",{children:[s.address," · Post"]}),e[52]=s.address,e[53]=Q):Q=e[53];let te;e[54]!==oe||e[55]!==Q?(te=t.jsxs("div",{children:[oe,Q]}),e[54]=oe,e[55]=Q,e[56]=te):te=e[56];const be=`post-status post-status-${s.runtime.status}`;let ve;e[57]!==s.runtime.status?(ve=s.runtime.status.replaceAll("_"," "),e[57]=s.runtime.status,e[58]=ve):ve=e[58];let Ce;e[59]!==be||e[60]!==ve?(Ce=t.jsx("span",{className:be,children:ve}),e[59]=be,e[60]=ve,e[61]=Ce):Ce=e[61],e[62]!==te||e[63]!==Ce?(W=t.jsxs("div",{className:"post-heading",children:[te,Ce]}),e[62]=te,e[63]=Ce,e[64]=W):W=e[64],e[65]!==i?(Z=i?.mediaUrl&&(i.type==="image"?t.jsx("img",{className:"post-media",src:i.mediaUrl,alt:"Frozen publication media"}):t.jsx("video",{className:"post-media",src:i.mediaUrl,controls:!0,preload:"metadata",poster:i.thumbnailUrl??void 0})),e[65]=i,e[66]=Z):Z=e[66];const Se=de?t.jsxs("button",{type:"button",onClick:()=>c(de.id),children:["Source ",Vt(de.slot)," · ",de.label??de.type]}):s.definition.source?t.jsx("span",{children:"Source cell no longer on this canvas"}):t.jsx("span",{children:"Choose the finished clip this publication will represent."});let $e;e[67]!==s.definition.createdAt||e[68]!==s.definition.source?($e=s.definition.source&&t.jsx("small",{children:s.definition.source.revision?`Clip version saved ${new Date(s.definition.createdAt).toLocaleString()}`:"Historical media version unknown"}),e[67]=s.definition.createdAt,e[68]=s.definition.source,e[69]=$e):$e=e[69],e[70]!==Se||e[71]!==$e?(z=t.jsxs("div",{className:"post-source",children:[Se,$e]}),e[70]=Se,e[71]=$e,e[72]=z):z=e[72],e[73]!==m.busy||e[74]!==n||e[75]!==s.definition.source||e[76]!==fe||e[77]!==k?(_=!s.definition.source&&t.jsxs("form",{onSubmit:ke=>{ke.preventDefault(),fe("update_post",{source_cell_id:k})},children:[t.jsxs("label",{children:["Source clip",t.jsxs("select",{"aria-label":"Source clip",value:k,onChange:ke=>w(ke.target.value),required:!0,children:[t.jsx("option",{value:"",children:"Choose a finished image or video"}),n.filter(Nc).map(wc)]})]}),t.jsx("button",{disabled:m.busy||!k,children:"Save source version"})]}),e[73]=m.busy,e[74]=n,e[75]=s.definition.source,e[76]=fe,e[77]=k,e[78]=_):_=e[78];let Be;e[79]!==j||e[80]!==y||e[81]!==x||e[82]!==E||e[83]!==v||e[84]!==h||e[85]!==fe?(Be=ke=>{ke.preventDefault(),fe("update_post",E?{notes:v}:{platform:h,caption:y,credits:x,account:j,notes:v}).then(Oe=>{Oe&&g({})})},e[79]=j,e[80]=y,e[81]=x,e[82]=E,e[83]=v,e[84]=h,e[85]=fe,e[86]=Be):Be=e[86];let _e;e[87]!==p?(_e=ke=>g({...p,platform:ke.target.value}),e[87]=p,e[88]=_e):_e=e[88];let nt;e[89]===Symbol.for("react.memo_cache_sentinel")?(nt=$a.map(Sc),e[89]=nt):nt=e[89];let Ke;e[90]!==E||e[91]!==h||e[92]!==_e?(Ke=t.jsxs("label",{children:["Platform",t.jsx("select",{"aria-label":"Platform",disabled:E,value:h,onChange:_e,children:nt})]}),e[90]=E,e[91]=h,e[92]=_e,e[93]=Ke):Ke=e[93];let Xe;e[94]!==p?(Xe=ke=>g({...p,account:ke.target.value}),e[94]=p,e[95]=Xe):Xe=e[95];let qe;e[96]!==j||e[97]!==E||e[98]!==Xe?(qe=t.jsxs("label",{children:["Account",t.jsx("input",{value:j,disabled:E,placeholder:"@account",onChange:Xe})]}),e[96]=j,e[97]=E,e[98]=Xe,e[99]=qe):qe=e[99];let Fe;e[100]!==Ke||e[101]!==qe?(Fe=t.jsxs("div",{className:"post-fields",children:[Ke,qe]}),e[100]=Ke,e[101]=qe,e[102]=Fe):Fe=e[102];let Ve;e[103]!==p?(Ve=ke=>g({...p,caption:ke.target.value}),e[103]=p,e[104]=Ve):Ve=e[104];let Ze;e[105]!==y||e[106]!==E||e[107]!==Ve?(Ze=t.jsxs("label",{children:["Caption",t.jsx("textarea",{value:y,disabled:E,rows:4,onChange:Ve,placeholder:"What will this post say?"})]}),e[105]=y,e[106]=E,e[107]=Ve,e[108]=Ze):Ze=e[108];let Ge;e[109]!==p?(Ge=ke=>g({...p,credits:ke.target.value}),e[109]=p,e[110]=Ge):Ge=e[110];let et;e[111]!==x||e[112]!==E||e[113]!==Ge?(et=t.jsxs("label",{children:["Credits",t.jsx("textarea",{value:x,disabled:E,rows:2,onChange:Ge,placeholder:"Creator and source credits"})]}),e[111]=x,e[112]=E,e[113]=Ge,e[114]=et):et=e[114];let tt;e[115]!==p?(tt=ke=>g({...p,notes:ke.target.value}),e[115]=p,e[116]=tt):tt=e[116];let Re;e[117]!==v||e[118]!==tt?(Re=t.jsxs("label",{children:["Notes",t.jsx("textarea",{value:v,rows:2,onChange:tt,placeholder:"What worked? What would you change?"})]}),e[117]=v,e[118]=tt,e[119]=Re):Re=e[119];const Pe=m.busy||!o,Je=E?"Save notes":"Save draft";let De;e[120]!==Pe||e[121]!==Je?(De=t.jsx("button",{disabled:Pe,children:Je}),e[120]=Pe,e[121]=Je,e[122]=De):De=e[122],e[123]!==Be||e[124]!==Fe||e[125]!==Ze||e[126]!==et||e[127]!==Re||e[128]!==De?(L=t.jsxs("form",{onSubmit:Be,children:[Fe,Ze,et,Re,De]}),e[123]=Be,e[124]=Fe,e[125]=Ze,e[126]=et,e[127]=Re,e[128]=De,e[129]=L):L=e[129],e[130]!==m.error?(B=m.error&&t.jsx("p",{role:"alert",className:"post-error",children:m.error}),e[130]=m.error,e[131]=B):B=e[131],e[132]!==s.runtime.error?(H=s.runtime.error&&t.jsx("p",{role:"alert",className:"post-error",children:s.runtime.error}),e[132]=s.runtime.error,e[133]=H):H=e[133],e[134]!==m.busy||e[135]!==y||e[136]!==ue||e[137]!==d||e[138]!==u||e[139]!==s||e[140]!==fe?(q=!s.runtime.url&&t.jsxs("div",{className:"post-delivery",children:[t.jsx("h3",{children:"Deliver"}),t.jsx("p",{children:"Review the clip and caption, then save them where you will publish."}),t.jsx("button",{type:"button","aria-pressed":s.definition.delivery==="icloud",onClick:()=>d("icloud"),children:"Save to iPhone"}),t.jsx("button",{type:"button","aria-pressed":s.definition.delivery==="dropbox",onClick:()=>d("dropbox"),children:"Upload to Dropbox"}),s.definition.platform==="x"&&!s.runtime.xRequest&&!["scheduled","needs_reconciliation","posting"].includes(s.runtime.status)&&t.jsx("button",{type:"button",disabled:m.busy||!s.definition.source?.snapshotArtifactId||!y.trim()||ue,onClick:()=>{u(s)},children:"Review X post…"}),s.definition.platform==="x"&&s.runtime.xRequest&&s.runtime.status==="failed"&&t.jsx("button",{type:"button",disabled:m.busy,onClick:()=>{fe("post")},children:"Retry saved X post"}),ue&&t.jsx("small",{children:"Save your draft before delivering."}),s.runtime.scheduledFor&&t.jsxs("p",{children:["Scheduled for ",new Date(s.runtime.scheduledFor).toLocaleString()]})]}),e[134]=m.busy,e[135]=y,e[136]=ue,e[137]=d,e[138]=u,e[139]=s,e[140]=fe,e[141]=q):q=e[141],e[142]!==F||e[143]!==s.runtime.icloud?(U=s.runtime.icloud?.completedAt&&t.jsxs("div",{className:"post-receipt",children:[t.jsx("strong",{children:Ca(s.runtime.icloud.folder)}),F&&t.jsx("small",{children:F})]}),e[142]=F,e[143]=s.runtime.icloud,e[144]=U):U=e[144],e[145]!==s.runtime.dropbox?(K=s.runtime.dropbox&&t.jsxs("div",{className:"post-receipt",children:[t.jsx("strong",{children:s.runtime.dropbox.completedAt?"Dropbox files ready":"Dropbox upload saved"}),t.jsx("span",{children:s.runtime.dropbox.folder}),t.jsxs("small",{children:["Clip: ",s.runtime.dropbox.video.rev?"uploaded":`${s.runtime.dropbox.video.offset.toLocaleString()} bytes saved`," · Caption: ",s.runtime.dropbox.caption.rev?"uploaded":"pending"]})]}),e[145]=s.runtime.dropbox,e[146]=K):K=e[146],e[147]!==m.busy||e[148]!==o||e[149]!==ue||e[150]!==he||e[151]!==s?(ee=s.runtime.url?t.jsxs("div",{className:"post-receipt",children:[t.jsx("a",{href:s.runtime.url,target:"_blank",rel:"noreferrer",children:"Open published post ↗"}),t.jsx("span",{children:s.runtime.postedAt?new Date(s.runtime.postedAt).toLocaleString():"Publication time unknown"}),s.runtime.x?.replies.map(kc)]}):t.jsx(yc,{post:s,disabled:m.busy||!o||ue,className:"post-delivery post-link-field",onLink:he}),e[147]=m.busy,e[148]=o,e[149]=ue,e[150]=he,e[151]=s,e[152]=ee):ee=e[152],ne=s.runtime.url&&t.jsxs("div",{className:"post-results",children:[t.jsx("h3",{children:"Results"}),pe?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"post-metric-grid",children:fn.map(ke=>t.jsxs("div",{children:[t.jsx("strong",{children:pe.values[ke]?.toLocaleString()??"—"}),t.jsx("span",{children:ke})]},ke))}),t.jsxs("small",{children:["Observed ",new Date(pe.observedAt).toLocaleString()," · ",pe.source]}),pe.mediaViews!==void 0&&t.jsxs("p",{children:[pe.mediaViews.toLocaleString()," X media views · shared across posts using this media"]})]}):t.jsx("p",{children:"No observations yet. Unknown metrics appear as —."}),s.definition.platform==="x"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",disabled:m.busy,onClick:()=>{fe("refresh_post_metrics")},children:"Refresh now"}),t.jsx("small",{children:s.runtime.nextMetricAt?`Next check ${new Date(s.runtime.nextMetricAt).toLocaleString()}`:s.runtime.metricsPaused?"Automatic checks paused; reconnect X and refresh.":"Scheduled observations complete."}),s.runtime.metricsError&&t.jsx("p",{className:"post-error",children:s.runtime.metricsError})]}),t.jsxs("details",{onToggle:ke=>{ke.currentTarget.open&&M(Pl())},children:[t.jsx("summary",{children:"Add manual observation"}),t.jsxs("form",{onSubmit:ke=>{ke.preventDefault();const Oe={};for(const at of fn)$[at]?.trim()&&(Oe[at]=Number($[at]));fe("record_post_metrics",{observed_at:new Date(S).toISOString(),values:Oe})},children:[t.jsxs("label",{children:["Observed at",t.jsx("input",{type:"datetime-local",step:"0.001",required:!0,value:S,onChange:ke=>M(ke.target.value)})]}),t.jsx("div",{className:"post-metric-inputs",children:fn.map(ke=>t.jsxs("label",{children:[ke,t.jsx("input",{type:"number",min:"0",step:"1",placeholder:"Unknown",value:$[ke]??"",onChange:Oe=>R({...$,[ke]:Oe.target.value})})]},ke))}),t.jsx("button",{disabled:m.busy||!Object.values($).some(Boolean),children:"Save observation"})]})]}),s.runtime.metrics.length>0&&t.jsxs("details",{children:[t.jsxs("summary",{children:["Observation history (",s.runtime.metrics.length,")"]}),t.jsx("div",{className:"post-history",children:[...s.runtime.metrics].reverse().map(jc)})]})]}),e[5]=j,e[6]=m,e[7]=i,e[8]=a,e[9]=o,e[10]=y,e[11]=n,e[12]=x,e[13]=p,e[14]=F,e[15]=E,e[16]=$,e[17]=v,e[18]=S,e[19]=d,e[20]=r,e[21]=u,e[22]=c,e[23]=h,e[24]=s,e[25]=k,e[26]=z,e[27]=_,e[28]=L,e[29]=B,e[30]=H,e[31]=q,e[32]=U,e[33]=K,e[34]=ee,e[35]=ne,e[36]=V,e[37]=re,e[38]=W,e[39]=Z}else z=e[26],_=e[27],L=e[28],B=e[29],H=e[30],q=e[31],U=e[32],K=e[33],ee=e[34],ne=e[35],V=e[36],re=e[37],W=e[38],Z=e[39];let ie;e[153]!==s.definition.lineage.length?(ie=t.jsxs("summary",{children:["Idea → clip → post (",s.definition.lineage.length," source cells)"]}),e[153]=s.definition.lineage.length,e[154]=ie):ie=e[154];let J;if(e[155]!==n||e[156]!==c||e[157]!==s.definition.lineage){let le;e[159]!==n||e[160]!==c?(le=de=>{const pe=n.find(ue=>ue.id===de.cellId);return t.jsxs("div",{children:[pe?t.jsxs("button",{type:"button",onClick:()=>c(pe.id),children:[Vt(pe.slot)," · ",de.label??de.type]}):t.jsx("strong",{children:de.label??de.type}),de.prompt&&t.jsx("p",{children:de.prompt})]},de.cellId)},e[159]=n,e[160]=c,e[161]=le):le=e[161],J=s.definition.lineage.map(le),e[155]=n,e[156]=c,e[157]=s.definition.lineage,e[158]=J}else J=e[158];let G;e[162]!==J?(G=t.jsx("div",{className:"post-lineage",children:J}),e[162]=J,e[163]=G):G=e[163];let ce;e[164]!==ie||e[165]!==G?(ce=t.jsxs("details",{children:[ie,G]}),e[164]=ie,e[165]=G,e[166]=ce):ce=e[166];let ae;e[167]!==f?(ae=t.jsx("button",{type:"button",className:"post-delete",onClick:f,children:"Remove Post cell"}),e[167]=f,e[168]=ae):ae=e[168];let X;return e[169]!==z||e[170]!==_||e[171]!==L||e[172]!==B||e[173]!==H||e[174]!==q||e[175]!==U||e[176]!==K||e[177]!==ee||e[178]!==ne||e[179]!==ce||e[180]!==ae||e[181]!==V||e[182]!==re||e[183]!==W||e[184]!==Z?(X=t.jsxs("section",{className:V,"aria-label":re,children:[W,Z,z,_,L,B,H,q,U,K,ee,ne,ce,ae]}),e[169]=z,e[170]=_,e[171]=L,e[172]=B,e[173]=H,e[174]=q,e[175]=U,e[176]=K,e[177]=ee,e[178]=ne,e[179]=ce,e[180]=ae,e[181]=V,e[182]=re,e[183]=W,e[184]=Z,e[185]=X):X=e[185],X}function jc(l){return t.jsxs("p",{children:[t.jsxs("strong",{children:[new Date(l.observedAt).toLocaleString()," · ",l.source]}),t.jsx("span",{children:Object.entries(l.values).map(vc).join(" · ")})]},l.id??`${l.observedAt}-${l.source}`)}function vc(l){const[e,s]=l;return`${e}: ${s?.toLocaleString()??"—"}`}function kc(l){return t.jsx("a",{href:l.tweet_url,target:"_blank",rel:"noreferrer",children:"Open reply ↗"},l.tweet_id)}function Sc(l){return t.jsx("option",{value:l,children:l==="x"?"X":l},l)}function wc(l){return t.jsxs("option",{value:l.id,children:[Vt(l.slot)," · ",l.label??l.type]},l.id)}function Nc(l){return l.type!=="post"&&l.outputArtifactId&&["image","video","generate_image","generate_video","concat","splice","split_video"].includes(l.type)}const Li=C.createContext(null);function Cc(l){const e=Y.c(17),{label:s,shortcut:n,divider:i}=l,a=i===void 0?!0:i,o=C.useContext(Li);if(!o)return null;let r;e[0]!==a?(r=a&&t.jsx("span",{className:"composer-dock-close-divider","aria-hidden":"true"}),e[0]=a,e[1]=r):r=e[1];const c=s?"composer-dock-close composer-dock-close-labeled":"composer-dock-close",d=s??o.hideLabel,u=n?"Escape":void 0,f=`${s??o.hideLabel}${n?" (Esc)":""}`;let m;e[2]!==s?(m=s??t.jsx(dt,{size:14}),e[2]=s,e[3]=m):m=e[3];let b;e[4]!==n?(b=n&&t.jsx("kbd",{"aria-hidden":"true",children:"Esc"}),e[4]=n,e[5]=b):b=e[5];let p;e[6]!==o.hide||e[7]!==c||e[8]!==d||e[9]!==u||e[10]!==f||e[11]!==m||e[12]!==b?(p=t.jsxs("button",{type:"button",className:c,"data-composer-dock-hide":"","aria-label":d,"aria-keyshortcuts":u,title:f,onClick:o.hide,children:[m,b]}),e[6]=o.hide,e[7]=c,e[8]=d,e[9]=u,e[10]=f,e[11]=m,e[12]=b,e[13]=p):p=e[13];let g;return e[14]!==r||e[15]!==p?(g=t.jsxs(t.Fragment,{children:[r,p]}),e[14]=r,e[15]=p,e[16]=g):g=e[16],g}function zi(l){const e=Y.c(35),{label:s,targetSelector:n,edge:i,minimum:a,reserve:o,onResize:r}=l,c=o===void 0?0:o,d=C.useRef(null),u=C.useRef(null);let f;e[0]!==a?(f={height:a,min:a,max:a},e[0]=a,e[1]=f):f=e[1];const[m,b]=C.useState(f);let p,g;e[2]!==a||e[3]!==c||e[4]!==n?(p=()=>{const R=d.current?.closest(n);if(!R)return;const I=()=>{const T=parseFloat(getComputedStyle(R).maxHeight),D=c>0&&R.parentElement?R.parentElement.clientHeight-c:window.innerHeight,A=Math.max(0,Math.min(Number.isFinite(T)?T:D,D)),F={height:Math.round(R.getBoundingClientRect().height),min:Math.min(a,A),max:Math.round(A)};b(E=>E.height===F.height&&E.min===F.min&&E.max===F.max?E:F)},P=new ResizeObserver(I);return P.observe(R),R.parentElement&&P.observe(R.parentElement),I(),()=>P.disconnect()},g=[a,c,n],e[2]=a,e[3]=c,e[4]=n,e[5]=p,e[6]=g):(p=e[5],g=e[6]),C.useLayoutEffect(p,g);let h;e[7]!==r||e[8]!==m.max||e[9]!==m.min?(h=R=>r(Math.round(Math.max(m.min,Math.min(m.max,R)))),e[7]=r,e[8]=m.max,e[9]=m.min,e[10]=h):h=e[10];const y=h,x=i==="top"?-1:1,j=`pane-resize-handle pane-resize-handle-${i}`,v=`${m.height} pixels`;let k;e[11]!==m.height||e[12]!==n?(k=R=>{if(R.button!==0)return;R.preventDefault(),R.currentTarget.focus({preventScroll:!0}),R.currentTarget.setPointerCapture(R.pointerId);const I=d.current?.closest(n);u.current={y:R.clientY,height:I?Math.round(I.getBoundingClientRect().height):m.height}},e[11]=m.height,e[12]=n,e[13]=k):k=e[13];let w;e[14]!==x||e[15]!==y?(w=R=>{const I=u.current;I&&y(I.height+x*(R.clientY-I.y))},e[14]=x,e[15]=y,e[16]=w):w=e[16];let S,M;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=R=>{u.current=null,R.currentTarget.hasPointerCapture(R.pointerId)&&R.currentTarget.releasePointerCapture(R.pointerId)},M=()=>{u.current=null},e[17]=S,e[18]=M):(S=e[17],M=e[18]);let N;e[19]!==x||e[20]!==y||e[21]!==m.height||e[22]!==m.max||e[23]!==m.min?(N=R=>{["ArrowUp","ArrowDown","Home","End"].includes(R.key)&&(R.preventDefault(),R.stopPropagation(),R.key==="Home"?y(m.min):R.key==="End"?y(m.max):y(m.height+x*(R.key==="ArrowUp"?-24:24)))},e[19]=x,e[20]=y,e[21]=m.height,e[22]=m.max,e[23]=m.min,e[24]=N):N=e[24];let $;return e[25]!==s||e[26]!==m.height||e[27]!==m.max||e[28]!==m.min||e[29]!==N||e[30]!==j||e[31]!==v||e[32]!==k||e[33]!==w?($=t.jsx("div",{ref:d,className:j,role:"separator","aria-label":s,"aria-orientation":"horizontal","aria-valuemin":m.min,"aria-valuemax":m.max,"aria-valuenow":m.height,"aria-valuetext":v,tabIndex:0,"data-composer-focus":"preserve",onPointerDown:k,onPointerMove:w,onPointerUp:S,onLostPointerCapture:M,onKeyDown:N}),e[25]=s,e[26]=m.height,e[27]=m.max,e[28]=m.min,e[29]=N,e[30]=j,e[31]=v,e[32]=k,e[33]=w,e[34]=$):$=e[34],$}function Tl(l,e){const s=e.getBoundingClientRect(),n=12,i=s.top>window.innerHeight-s.bottom,a=Math.min(560,window.innerWidth-n*2);l.style.left=`${Math.max(n,Math.min(s.left,window.innerWidth-a-n))}px`,l.style.top=i?"auto":`${s.bottom+8}px`,l.style.bottom=i?`${window.innerHeight-s.top+8}px`:"auto",l.style.maxHeight=`${Math.max(0,(i?s.top:window.innerHeight-s.bottom)-n-8)}px`}function El(l){const e=Y.c(65),{call:s,active:n,onToggle:i}=l,a=n===void 0?!0:n,o=C.useId(),r=C.useRef(null),c=C.useRef(null);let d,u;e[0]!==a||e[1]!==s.expanded?(d=()=>{const q=c.current,U=r.current;if(!q||!U)return;if(!a){q.hidePopover();return}if(!s.expanded)return;const K=()=>Tl(q,U);K();const ee=new ResizeObserver(K);ee.observe(U);const ne=U.closest(".composer-history");return ne&&ee.observe(ne),window.addEventListener("resize",K),window.addEventListener("scroll",K,!0),()=>{ee.disconnect(),window.removeEventListener("resize",K),window.removeEventListener("scroll",K,!0)}},u=[a,s.expanded],e[0]=a,e[1]=s.expanded,e[2]=d,e[3]=u):(d=e[2],u=e[3]),C.useLayoutEffect(d,u);const f=`mcp-call mcp-call-${s.phase}`,m=s.tool,b=s.expanded;let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{className:"composer-history-kind mcp-call-channel",children:"ACTION"}),e[4]=p):p=e[4];let g;e[5]!==s.tool?(g=pn(s.tool),e[5]=s.tool,e[6]=g):g=e[6];let h;e[7]!==g?(h=t.jsx("span",{className:"composer-history-text mcp-call-name",children:g}),e[7]=g,e[8]=h):h=e[8];let y;e[9]!==s.phase?(y=s.phase==="running"&&t.jsxs("span",{className:"mcp-call-signal","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),e[9]=s.phase,e[10]=y):y=e[10];let x;e[11]!==s?(x=dl(s),e[11]=s,e[12]=x):x=e[12];let j;e[13]!==x?(j=t.jsx("span",{className:"mcp-call-state",children:x}),e[13]=x,e[14]=j):j=e[14];let v;e[15]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(_o,{className:"mcp-call-details-icon",size:14,"aria-hidden":"true"}),e[15]=v):v=e[15];let k;e[16]!==y||e[17]!==j?(k=t.jsxs("span",{className:"mcp-call-trail",children:[y,j,v]}),e[16]=y,e[17]=j,e[18]=k):k=e[18];let w;e[19]!==s.expanded||e[20]!==o||e[21]!==k||e[22]!==h?(w=t.jsxs("button",{ref:r,type:"button",className:"composer-history-entry mcp-call-head",popoverTarget:o,"aria-haspopup":"dialog","aria-controls":o,"aria-expanded":b,children:[p,h,k]}),e[19]=s.expanded,e[20]=o,e[21]=k,e[22]=h,e[23]=w):w=e[23];let S;e[24]!==s.tool?(S=pn(s.tool),e[24]=s.tool,e[25]=S):S=e[25];const M=`${S} details`;let N;e[26]===Symbol.for("react.memo_cache_sentinel")?(N=q=>{q.newState==="open"&&r.current&&Tl(q.currentTarget,r.current)},e[26]=N):N=e[26];let $;e[27]!==s.expanded||e[28]!==s.id||e[29]!==i?($=q=>{q.newState==="open"!==s.expanded&&i(s.id)},e[27]=s.expanded,e[28]=s.id,e[29]=i,e[30]=$):$=e[30];let R;e[31]!==s.tool?(R=pn(s.tool),e[31]=s.tool,e[32]=R):R=e[32];let I;e[33]!==R?(I=t.jsx("span",{children:R}),e[33]=R,e[34]=I):I=e[34];let P;e[35]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(dt,{size:14,"aria-hidden":"true"}),e[35]=P):P=e[35];let T;e[36]!==o?(T=t.jsx("button",{type:"button",popoverTarget:o,popoverTargetAction:"hide","aria-label":"Close action details",autoFocus:!0,children:P}),e[36]=o,e[37]=T):T=e[37];let D;e[38]!==I||e[39]!==T?(D=t.jsxs("header",{className:"mcp-call-popover-head",children:[I,T]}),e[38]=I,e[39]=T,e[40]=D):D=e[40];const A=s.tool;let F;e[41]!==s?(F=dl(s),e[41]=s,e[42]=F):F=e[42];let E;e[43]!==s.tool||e[44]!==F?(E=t.jsxs("p",{className:"mcp-call-what",children:[A," · ",F]}),e[43]=s.tool,e[44]=F,e[45]=E):E=e[45];let z;e[46]!==s.args?(z=s.args.length>0&&t.jsx("dl",{className:"mcp-call-args",children:s.args.map($c)}),e[46]=s.args,e[47]=z):z=e[47];let _;e[48]!==s.detail?(_=s.detail&&t.jsxs("p",{className:"mcp-call-out",children:[t.jsx("b",{"aria-hidden":"true",children:"→"}),t.jsx("span",{children:s.detail})]}),e[48]=s.detail,e[49]=_):_=e[49];let L;e[50]!==E||e[51]!==z||e[52]!==_?(L=t.jsxs("div",{className:"mcp-call-body",children:[E,z,_]}),e[50]=E,e[51]=z,e[52]=_,e[53]=L):L=e[53];let B;e[54]!==o||e[55]!==M||e[56]!==$||e[57]!==D||e[58]!==L?(B=t.jsxs("div",{ref:c,id:o,className:"mcp-call-popover",popover:"auto",role:"dialog","aria-label":M,onBeforeToggle:N,onToggle:$,onKeyDown:Ic,children:[D,L]}),e[54]=o,e[55]=M,e[56]=$,e[57]=D,e[58]=L,e[59]=B):B=e[59];let H;return e[60]!==s.tool||e[61]!==w||e[62]!==B||e[63]!==f?(H=t.jsxs("div",{className:f,"data-tool":m,children:[w,B]}),e[60]=s.tool,e[61]=w,e[62]=B,e[63]=f,e[64]=H):H=e[64],H}function $c(l){return t.jsxs(C.Fragment,{children:[t.jsx("dt",{children:l.name}),t.jsx("dd",{children:l.value})]},l.name)}function Ic(l){l.key==="Escape"&&l.stopPropagation()}const Bi=C.createContext(null),Al=28;function Rc(l){const e=Y.c(39),{rows:s,phase:n,voicePresent:i,open:a,onToggleCall:o,connected:r,onDetailsChange:c,children:d}=l,u=r===void 0?!0:r,f=C.useId(),b=C.useContext(Bi)?.captionId??f,p=C.useRef(null),g=C.useRef(!0),h=C.useRef(void 0),[y,x]=C.useState(!1);let j;e[0]!==d||e[1]!==n||e[2]!==s||e[3]!==i?(j=!d&&In(n,s.length,i),e[0]=d,e[1]=n,e[2]=s,e[3]=i,e[4]=j):j=e[4];const v=j;let k;e[5]!==v||e[6]!==c||e[7]!==a||e[8]!==s?(k=()=>{const T=p.current;if(c?.(a&&!!T?.querySelector(".chat-turn-details[open]")),v||!T||!a)return;const D=s.filter(Pc).at(-1)?.sequence;D!==h.current&&(g.current=!0),h.current=D,g.current&&(T.scrollTop=T.scrollHeight);const A=T.scrollHeight-T.scrollTop-T.clientHeight<Al;g.current=A,x(!A&&s.length>0)},e[5]=v,e[6]=c,e[7]=a,e[8]=s,e[9]=k):k=e[9];let w;if(e[10]!==d||e[11]!==v||e[12]!==c||e[13]!==a||e[14]!==s?(w=[d,v,c,a,s],e[10]=d,e[11]=v,e[12]=c,e[13]=a,e[14]=s,e[15]=w):w=e[15],C.useLayoutEffect(k,w),v)return null;const S=a?"true":"false",M=!a;let N;e[16]!==s.length?(N=T=>{const D=T.currentTarget,A=D.scrollHeight-D.scrollTop-D.clientHeight<Al;g.current=A,x(!A&&s.length>0)},e[16]=s.length,e[17]=N):N=e[17];let $;e[18]!==d||e[19]!==u||e[20]!==c||e[21]!==o||e[22]!==a||e[23]!==n||e[24]!==s?($=s.length===0&&!d?t.jsxs("p",{className:"composer-history-entry voice-captions-empty",children:[t.jsx("span",{className:"composer-history-kind",children:"STATUS"}),t.jsx("span",{children:Ia(n??"off")})]}):s.map(T=>t.jsx(Ec,{row:T,active:a,connected:u,onToggleCall:o,onDetailsChange:()=>c?.(!!p.current?.querySelector(".chat-turn-details[open]"))},Tc(T))),e[18]=d,e[19]=u,e[20]=c,e[21]=o,e[22]=a,e[23]=n,e[24]=s,e[25]=$):$=e[25];let R;e[26]!==b||e[27]!==d||e[28]!==M||e[29]!==N||e[30]!==$?(R=t.jsxs("div",{ref:p,id:b,className:"composer-history voice-captions","data-testid":"composer-history",hidden:M,"aria-label":"Message log",role:"log","aria-live":"off",onScroll:N,children:[$,d]}),e[26]=b,e[27]=d,e[28]=M,e[29]=N,e[30]=$,e[31]=R):R=e[31];let I;e[32]!==a||e[33]!==y?(I=a&&y&&t.jsx("button",{type:"button",className:"voice-captions-latest",onMouseDown:Mc,onClick:()=>{g.current=!0,x(!1);const T=p.current;T&&(T.scrollTop=T.scrollHeight)},children:"Latest"}),e[32]=a,e[33]=y,e[34]=I):I=e[34];let P;return e[35]!==I||e[36]!==S||e[37]!==R?(P=t.jsxs("div",{className:"composer-history-panel","data-history-open":S,children:[R,I]}),e[35]=I,e[36]=S,e[37]=R,e[38]=P):P=e[38],P}function Mc(l){return l.preventDefault()}function Pc(l){return l.kind==="caption"&&l.turn}function Tc(l){return l.kind==="status"?`status:${l.sequence}`:l.kind==="caption"?`caption:${l.caption.id}`:`call:${l.call.id}`}function Ec(l){const e=Y.c(65),{row:s,active:n,onToggleCall:i,connected:a,onDetailsChange:o}=l;if(s.kind==="call"){let p;return e[0]!==n||e[1]!==i||e[2]!==s.call?(p=t.jsx(El,{call:s.call,active:n,onToggle:i}),e[0]=n,e[1]=i,e[2]=s.call,e[3]=p):p=e[3],p}if(s.kind==="status"){let p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{className:"composer-history-kind",children:"STATUS"}),e[4]=p):p=e[4];let g;e[5]!==s.text?(g=t.jsx("span",{className:"composer-history-text",children:s.text}),e[5]=s.text,e[6]=g):g=e[6];let h;return e[7]!==s.goalId||e[8]!==g?(h=t.jsxs("p",{className:"composer-history-entry","data-role":"status","data-goal-id":s.goalId,children:[p,g]}),e[7]=s.goalId,e[8]=g,e[9]=h):h=e[9],h}const r=s.caption;if(s.turn){const p=s.turn;let g;e[10]!==a||e[11]!==p?(g=a&&si(p)&&p.status!=="review",e[10]=a,e[11]=p,e[12]=g):g=e[12];const h=g,y=p.id,x=p.status;let j;e[13]!==p.text?(j=t.jsx("p",{className:"chat-bubble chat-bubble-user","aria-label":"Your message",children:p.text}),e[13]=p.text,e[14]=j):j=e[14];let v;e[15]!==a||e[16]!==p?(v=ul(p,a),e[15]=a,e[16]=p,e[17]=v):v=e[17];const k=`Message activity: ${v}`;let w;e[18]!==h?(w=h&&t.jsxs("span",{className:"chat-working-dots","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),e[18]=h,e[19]=w):w=e[19];let S;e[20]!==a||e[21]!==p?(S=ul(p,a),e[20]=a,e[21]=p,e[22]=S):S=e[22];let M;e[23]!==S?(M=t.jsx("span",{children:S}),e[23]=S,e[24]=M):M=e[24];let N;e[25]!==w||e[26]!==M?(N=t.jsxs("span",{className:"chat-turn-status",role:"status","aria-live":"polite",children:[w,M]}),e[25]=w,e[26]=M,e[27]=N):N=e[27];let $;e[28]!==N||e[29]!==k?($=t.jsx("summary",{"aria-label":k,children:N}),e[28]=N,e[29]=k,e[30]=$):$=e[30];let R;e[31]!==p.work?(R=p.work.map(Ac),e[31]=p.work,e[32]=R):R=e[32];let I;e[33]!==n||e[34]!==i||e[35]!==s.calls?(I=s.calls?.map(F=>t.jsx(El,{call:F,active:n,onToggle:i},F.id)),e[33]=n,e[34]=i,e[35]=s.calls,e[36]=I):I=e[36];let P;e[37]!==R||e[38]!==I?(P=t.jsxs("div",{className:"chat-turn-work",children:[R,I]}),e[37]=R,e[38]=I,e[39]=P):P=e[39];let T;e[40]!==o||e[41]!==$||e[42]!==P?(T=t.jsxs("details",{className:"chat-turn-details",onToggle:o,children:[$,P]}),e[40]=o,e[41]=$,e[42]=P,e[43]=T):T=e[43];let D;e[44]!==p.reply?(D=p.reply&&t.jsx("p",{className:"chat-bubble chat-bubble-assistant","aria-label":"Copilot reply",children:p.reply}),e[44]=p.reply,e[45]=D):D=e[45];let A;return e[46]!==T||e[47]!==D||e[48]!==j||e[49]!==p.id||e[50]!==p.status?(A=t.jsxs("article",{className:"chat-turn","data-turn-id":y,"data-status":x,children:[j,T,D]}),e[46]=T,e[47]=D,e[48]=j,e[49]=p.id,e[50]=p.status,e[51]=A):A=e[51],A}const c=`composer-history-entry chat-bubble chat-bubble-${r.role}`,d=r.role==="user"?"YOU":"COPILOT";let u;e[52]!==d?(u=t.jsx("span",{className:"composer-history-kind",children:d}),e[52]=d,e[53]=u):u=e[53];let f;e[54]!==r.interrupted?(f=r.interrupted&&t.jsx("em",{children:" · interrupted"}),e[54]=r.interrupted,e[55]=f):f=e[55];let m;e[56]!==r.text||e[57]!==f?(m=t.jsxs("span",{className:"composer-history-text",children:[r.text,f]}),e[56]=r.text,e[57]=f,e[58]=m):m=e[58];let b;return e[59]!==r.final||e[60]!==r.role||e[61]!==c||e[62]!==u||e[63]!==m?(b=t.jsxs("p",{className:c,"data-final":r.final,"data-role":r.role,children:[u,m]}),e[59]=r.final,e[60]=r.role,e[61]=c,e[62]=u,e[63]=m,e[64]=b):b=e[64],b}function Ac(l){return t.jsxs("p",{children:[t.jsx("span",{children:l.label}),t.jsx("span",{children:l.detail??l.state})]},l.key)}function Dl(l){const e=Y.c(15),{dismissLabel:s,message:n,onDismiss:i,tone:a}=l,o=a==="error",r=`chat-bubble chat-bubble-assistant chat-feedback command-result ${o?"command-result-error":"command-result-ok"}`,c=o?"alert":"status",d=o?"ERROR":"STATUS";let u;e[0]!==d?(u=t.jsx("span",{className:"composer-history-kind",children:d}),e[0]=d,e[1]=u):u=e[1];let f;e[2]!==n?(f=t.jsx("span",{children:n}),e[2]=n,e[3]=f):f=e[3];let m;e[4]!==u||e[5]!==f?(m=t.jsxs("div",{className:"chat-feedback-content",children:[u,f]}),e[4]=u,e[5]=f,e[6]=m):m=e[6];let b;e[7]!==s||e[8]!==i?(b=i&&t.jsx("button",{type:"button",className:"command-result-dismiss","aria-label":s,onClick:i,children:t.jsx(dt,{size:12,"aria-hidden":"true"})}),e[7]=s,e[8]=i,e[9]=b):b=e[9];let p;return e[10]!==r||e[11]!==c||e[12]!==m||e[13]!==b?(p=t.jsxs("div",{className:r,role:c,"aria-live":"polite",children:[m,b]}),e[10]=r,e[11]=c,e[12]=m,e[13]=b,e[14]=p):p=e[14],p}function ps(l){const e=Y.c(7),{asset:s,kindHint:n,videoFrame:i}=l,a=i===void 0?!1:i,[o,r]=C.useState(null),c=s?.thumbnailUrl??(s?.type==="image"?s.mediaUrl:null),d=s?.type??n??"unknown",u=d==="audio"||n==="generate_audio"||n==="extract_audio",f=d==="video"||d==="final"||n==="generate_video"||n==="split_video"||n==="concat"||n==="splice",m=d==="image"||n==="generate_image",b=a&&f&&!c?s?.mediaUrl:null;let p;return e[0]!==u||e[1]!==o||e[2]!==b||e[3]!==m||e[4]!==c||e[5]!==f?(p=t.jsx("span",{className:"inspector-source-thumb","aria-hidden":"true",children:c&&c!==o?t.jsx("img",{src:c,alt:"",loading:"lazy",decoding:"async",onError:()=>r(c)}):b&&b!==o?t.jsx("video",{src:`${b}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata",onError:()=>r(b)}):u?t.jsx(ts,{size:16}):f?t.jsx(Ct,{size:16}):m?t.jsx(Qt,{size:16}):t.jsx($s,{size:15})}),e[0]=u,e[1]=o,e[2]=b,e[3]=m,e[4]=c,e[5]=f,e[6]=p):p=e[6],p}function Dc(l){const e=Y.c(8),{token:s,reference:n}=l,i=n?.asset,a=n?.type;let o;e[0]!==i||e[1]!==a?(o=t.jsx(ps,{asset:i,kindHint:a}),e[0]=i,e[1]=a,e[2]=o):o=e[2];let r;e[3]!==s?(r=t.jsx("span",{className:"composer-reference-address",children:s}),e[3]=s,e[4]=r):r=e[4];let c;return e[5]!==o||e[6]!==r?(c=t.jsxs(t.Fragment,{children:[o,r]}),e[5]=o,e[6]=r,e[7]=c):c=e[7],c}function zs(l){return ni(l.state.doc,l.state.selection.anchor,l.state.selection.head)}function Fl(l){return{class:"command-rich-input",role:"combobox","aria-label":"Videobook command input","aria-autocomplete":"list","aria-expanded":String(l.expanded),"aria-disabled":String(l.disabled),"data-workspace-action-surface":"slash","data-placeholder":l.placeholder,"data-empty":String(l.value.length===0),tabindex:l.disabled?"-1":"0",spellcheck:"false",autocapitalize:"none",...l.controls?{"aria-controls":l.controls}:{},...l.activeDescendant?{"aria-activedescendant":l.activeDescendant}:{}}}function Fc({ref:l,...e}){const[s]=C.useState({value:e.value,disabled:e.disabled}),n=C.useRef(null),i=C.useRef(null),a=C.useRef(e),o=C.useRef(e.session),r=C.useRef(!1),c=C.useRef(0),d=C.useRef(new Set);return C.useImperativeHandle(l,()=>({element:()=>i.current?.dom??null,selection:()=>i.current?zs(i.current):{start:0,end:0},select:()=>{const u=i.current;u&&u.dispatch(ml(u.state.tr,{start:0,end:ns(u.state.doc).length}))},setSelection:u=>{const f=i.current;if(!f)return;const m=u.start<zs(f).start?-1:1;f.dispatch(ml(f.state.tr,u,m).scrollIntoView())},replace:(u,f={start:u.length,end:u.length})=>{const m=i.current;m&&m.dispatch(os(gs(m.state.tr,u,f,a.current.rich!==!1)).scrollIntoView())}}),[]),C.useLayoutEffect(()=>{const u=n.current;if(!u)return;const f=a.current;let b=f.sessions.get(f.session)??al.create({schema:fl,doc:pl(f.value,f.rich!==!1),plugins:[fa(),rl({"Mod-z":ha,"Mod-Shift-z":ol,"Mod-y":ol}),rl(ba)]});ns(b.doc)!==f.value&&(b=b.apply(os(gs(b.tr,f.value,{start:f.value.length,end:f.value.length},f.rich!==!1))));const p=x=>{let j=String(x.attrs.token);const v=document.createElement("span");v.className="composer-reference-chip",v.contentEditable="false",v.setAttribute("role","img");const k=ma.createRoot(v),w=()=>{const S=a.current.references.get(j.toLowerCase()),M=S?li(S):"Unavailable reference",N=[j,S?.label,M].filter(Boolean).join(" · ");v.dataset.reference=j,v.setAttribute("aria-label",N),v.title=N,k.render(t.jsx(Dc,{token:j,reference:S}))};return w(),d.current.add(w),{dom:v,update(S){return S.type!==x.type?!1:(j=String(S.attrs.token),w(),!0)},ignoreMutation:S=>S.type!=="selection",destroy(){d.current.delete(w),queueMicrotask(()=>k.unmount())}}},g=x=>{const j=i.current;if(!j)return;if(!j.composing&&!r.current&&(x.docChanged||x.getMeta("normalizeReferences"))){const w=ni(x.doc,x.selection.anchor,x.selection.head);gs(x,ns(x.doc),w,a.current.rich!==!1)}const v=j.state;j.updateState(v.apply(x)),a.current.sessions.set(o.current,j.state);const k=zs(j);v.doc.eq(j.state.doc)?v.selection.eq(j.state.selection)||a.current.onSelectionChange(k):a.current.onChange(ns(j.state.doc),k)},h=(x,j,v)=>!j.clipboardData||x.state.selection.empty?!1:(j.preventDefault(),j.clipboardData.clearData(),j.clipboardData.setData("text/plain",ns(x.state.doc,x.state.selection.from,x.state.selection.to)),v&&!a.current.disabled&&x.dispatch(os(x.state.tr.deleteSelection())),!0),y=new pa({mount:u},{state:b,editable:()=>!a.current.disabled,attributes:Fl(f),dispatchTransaction:g,nodeViews:{reference:p},clipboardTextSerializer:x=>x.content.textBetween(0,x.content.size,"",j=>String(j.attrs.token??"")),handleKeyDown:(x,j)=>{if(j.isComposing||j.altKey||j.ctrlKey||j.metaKey||j.shiftKey||!x.state.selection.empty)return!1;const{$from:v}=x.state.selection,k=j.key==="Backspace";if(!k&&j.key!=="Delete")return!1;const w=k?v.nodeBefore:v.nodeAfter;if(w?.type.name!=="reference")return!1;const S=k?v.pos-w.nodeSize:v.pos;return x.dispatch(os(x.state.tr.delete(S,S+w.nodeSize)).scrollIntoView()),!0},handlePaste:(x,j)=>{if(!j.clipboardData)return!1;j.preventDefault();const v=j.clipboardData.getData("text/plain").replace(/\r\n?/gu,`
|
|
2
|
+
`);return x.dispatch(os(x.state.tr.insertText(v)).scrollIntoView()),!0},handleDOMEvents:{focus:()=>(a.current.onFocus(),!1),keydown:(x,j)=>(a.current.onKeyDown(j),j.defaultPrevented),copy:(x,j)=>h(x,j,!1),cut:(x,j)=>h(x,j,!0),compositionstart:()=>(r.current=!0,a.current.onCompositionChange(!0),!1),compositionend:()=>(r.current=!1,a.current.onCompositionChange(!1),window.cancelAnimationFrame(c.current),c.current=window.requestAnimationFrame(()=>{const x=i.current;x&&!x.composing&&x.dispatch(x.state.tr.setMeta("normalizeReferences",!0))}),!1)}});return i.current=y,()=>{window.cancelAnimationFrame(c.current),a.current.sessions.set(o.current,y.state),i.current=null,y.destroy()}},[]),C.useLayoutEffect(()=>{const u=i.current,f=a.current.references;if(a.current=e,!u)return;const m=o.current!==e.session;if(m){o.current.includes(":actions-")?e.sessions.delete(o.current):e.sessions.set(o.current,u.state);let p=e.sessions.get(e.session)??al.create({schema:fl,doc:pl(e.value,e.rich!==!1),plugins:u.state.plugins});ns(p.doc)!==e.value&&(p=p.apply(os(gs(p.tr,e.value,{start:e.value.length,end:e.value.length},e.rich!==!1)))),o.current=e.session,r.current=!1,u.updateState(p)}else if(!u.composing&&ns(u.state.doc)!==e.value){const b={start:e.value.length,end:e.value.length};u.updateState(u.state.apply(gs(u.state.tr,e.value,b,e.rich!==!1).setMeta("addToHistory",!1)))}if(u.setProps({attributes:Fl(e),editable:()=>!a.current.disabled}),m&&e.onSelectionChange(zs(u)),f!==e.references)for(const b of d.current)b()},[e]),t.jsx("div",{className:"command-editor-mount",children:t.jsx("div",{ref:n,role:"combobox","aria-label":"Videobook command input","aria-disabled":s.disabled,contentEditable:!s.disabled,suppressContentEditableWarning:!0,children:s.value})})}function _c(l){const e=Y.c(44),{actions:s,groups:n,group:i,context:a,loading:o,error:r,listId:c,selectedIndex:d,onGroupChange:u,onClose:f,onSelect:m}=l;let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("strong",{children:"Actions"}),e[0]=b):b=e[0];let p;e[1]!==u?(p=P=>u(P.target.value),e[1]=u,e[2]=p):p=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("option",{value:"",children:"All categories"}),e[3]=g):g=e[3];let h;e[4]!==n?(h=n.map(zc),e[4]=n,e[5]=h):h=e[5];let y;e[6]!==i||e[7]!==p||e[8]!==h?(y=t.jsxs("label",{children:["Category",t.jsxs("select",{"aria-label":"Action category",value:i,onChange:p,children:[g,h]})]}),e[6]=i,e[7]=p,e[8]=h,e[9]=y):y=e[9];const x=o?"Loading actions…":`${s.length} actions`;let j;e[10]!==x?(j=t.jsx("span",{role:"status",children:x}),e[10]=x,e[11]=j):j=e[11];let v;e[12]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(dt,{size:15}),e[12]=v):v=e[12];let k;e[13]!==f?(k=t.jsx("button",{type:"button","aria-label":"Close action search",onClick:f,children:v}),e[13]=f,e[14]=k):k=e[14];let w;e[15]!==y||e[16]!==j||e[17]!==k?(w=t.jsxs("header",{children:[b,y,j,k]}),e[15]=y,e[16]=j,e[17]=k,e[18]=w):w=e[18];let S;e[19]!==r?(S=r&&t.jsx("p",{role:"alert",children:r}),e[19]=r,e[20]=S):S=e[20];let M;if(e[21]!==s||e[22]!==a||e[23]!==c||e[24]!==m||e[25]!==d){let P;e[27]!==a||e[28]!==c||e[29]!==m||e[30]!==d?(P=(T,D)=>{const A=ii(T,a);return t.jsxs("button",{type:"button",role:"option",id:`${c}-option-${D}`,"aria-selected":D===d,className:D===d?"active":"","data-action-id":T.id,"data-command":T.command,onMouseDown:Lc,onClick:()=>m(T),children:[t.jsxs("span",{children:[t.jsx("strong",{children:T.title}),t.jsx("code",{children:T.command})]}),t.jsx("small",{children:T.description}),A&&t.jsx("small",{className:"composer-action-unavailable",children:A})]},T.id)},e[27]=a,e[28]=c,e[29]=m,e[30]=d,e[31]=P):P=e[31],M=s.map(P),e[21]=s,e[22]=a,e[23]=c,e[24]=m,e[25]=d,e[26]=M}else M=e[26];let N;e[32]!==s.length||e[33]!==o?(N=!o&&!s.length&&t.jsx("p",{children:"No matching actions. Try an operation, media type or command alias."}),e[32]=s.length,e[33]=o,e[34]=N):N=e[34];let $;e[35]!==c||e[36]!==M||e[37]!==N?($=t.jsxs("div",{id:c,role:"listbox","aria-label":"Available actions",className:"workspace-actions-list",children:[M,N]}),e[35]=c,e[36]=M,e[37]=N,e[38]=$):$=e[38];let R;e[39]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("p",{className:"composer-actions-help",children:"Choose an action to prepare its command. Submit when ready."}),e[39]=R):R=e[39];let I;return e[40]!==w||e[41]!==S||e[42]!==$?(I=t.jsxs("section",{className:"command-suggestions composer-actions-panel","aria-label":"Actions","data-workspace-action-surface":"launcher",children:[w,S,$,R]}),e[40]=w,e[41]=S,e[42]=$,e[43]=I):I=e[43],I}function Lc(l){return l.preventDefault()}function zc(l){return t.jsx("option",{children:l},l)}function ct(l){const e=Y.c(2),{size:s}=l,n=s===void 0?16:s;let i;return e[0]!==n?(i=t.jsx("span",{className:"busy-indicator","aria-hidden":"true",children:t.jsx(zn,{size:n})}),e[0]=n,e[1]=i):i=e[1],i}const Oi=C.createContext(null);function Bc(l){const e=Y.c(15),{voices:s,selectedVoiceId:n,playingVoiceId:i,disabled:a,onSelect:o,onTogglePreview:r}=l,c=a===void 0?!1:a;let d;if(e[0]!==c||e[1]!==o||e[2]!==r||e[3]!==i||e[4]!==n||e[5]!==s){let f;e[7]!==c||e[8]!==o||e[9]!==r||e[10]!==i||e[11]!==n?(f=m=>{const b=m.voiceId===n;return t.jsxs("div",{className:b?"speak-preview-voice selected":"speak-preview-voice",role:"option","aria-selected":b,"data-voice-id":m.voiceId,children:[t.jsxs("button",{type:"button",className:b?"active speak-preview-select":"speak-preview-select",disabled:c,onMouseDown:Uc,onClick:()=>o(m.voiceId),children:[t.jsx("strong",{children:m.name}),t.jsxs("span",{className:"speak-preview-badge",children:[m.source,m.category?` · ${m.category}`:""]})]}),m.previewUrl&&t.jsx("button",{type:"button",className:"speak-preview-play",disabled:c,onMouseDown:Oc,onClick:()=>r(m.voiceId,m.previewUrl),children:i===m.voiceId?"Pause":"Preview"})]},m.voiceId)},e[7]=c,e[8]=o,e[9]=r,e[10]=i,e[11]=n,e[12]=f):f=e[12],d=s.map(f),e[0]=c,e[1]=o,e[2]=r,e[3]=i,e[4]=n,e[5]=s,e[6]=d}else d=e[6];let u;return e[13]!==d?(u=t.jsx(t.Fragment,{children:d}),e[13]=d,e[14]=u):u=e[14],u}function Oc(l){return l.preventDefault()}function Uc(l){return l.preventDefault()}function Hc(l){const e=Y.c(32),{voices:s,selectedVoiceId:n,playingVoiceId:i,status:a,warning:o,loading:r,error:c,onSelect:d,onTogglePreview:u,onRefresh:f}=l;let m;if(e[0]!==n||e[1]!==s){let S;e[3]!==n?(S=M=>M.voiceId===n,e[3]=n,e[4]=S):S=e[4],m=s.find(S),e[0]=n,e[1]=s,e[2]=m}else m=e[2];const b=m;let p;e[5]!==r||e[6]!==s.length?(p=r&&s.length===0&&t.jsx("p",{className:"speak-preview-status",children:"Loading voices…"}),e[5]=r,e[6]=s.length,e[7]=p):p=e[7];let g;e[8]!==c?(g=c&&t.jsx("p",{className:"speak-preview-error",role:"alert",children:c}),e[8]=c,e[9]=g):g=e[9];const h=r?"Loading voices…":c?"Retry voices":s.length===0?"Load voices":"Refresh voices";let y;e[10]!==r||e[11]!==f||e[12]!==h?(y=t.jsx("button",{type:"button",className:"speak-preview-refresh",disabled:r,onMouseDown:Kc,onClick:f,children:h}),e[10]=r,e[11]=f,e[12]=h,e[13]=y):y=e[13];let x;e[14]!==d||e[15]!==u||e[16]!==i||e[17]!==n||e[18]!==s?(x=t.jsx(Bc,{voices:s,selectedVoiceId:n,playingVoiceId:i,onSelect:d,onTogglePreview:u}),e[14]=d,e[15]=u,e[16]=i,e[17]=n,e[18]=s,e[19]=x):x=e[19];let j;e[20]!==a||e[21]!==o?(j=(o||a==="fallback")&&o&&t.jsx("p",{className:"speak-preview-warning",children:o}),e[20]=a,e[21]=o,e[22]=j):j=e[22];const v=b?` · ${b.name}`:"";let k;e[23]!==v?(k=t.jsxs("p",{className:"speak-preview-hint",children:["↑↓ voice · tab select · ctrl+space preview · enter speak · esc close",v]}),e[23]=v,e[24]=k):k=e[24];let w;return e[25]!==p||e[26]!==g||e[27]!==y||e[28]!==x||e[29]!==j||e[30]!==k?(w=t.jsxs("div",{className:"command-suggestions speak-preview",role:"listbox","aria-label":"ElevenLabs voices","data-testid":"speak-command-preview",children:[p,g,y,x,j,k]}),e[25]=p,e[26]=g,e[27]=y,e[28]=x,e[29]=j,e[30]=k,e[31]=w):w=e[31],w}function Kc(l){return l.preventDefault()}function Vc(l){const e=Y.c(15),{feedback:s,onResumePlayback:n}=l,i=`chat-bubble chat-bubble-assistant chat-voice-activity${s.error?" chat-voice-error":""}`;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("span",{className:"composer-history-kind",children:"VOICE"}),e[0]=a):a=e[0];let o;e[1]!==s.busy||e[2]!==s.error||e[3]!==s.message?(o=s.message&&t.jsxs("p",{className:"chat-turn-status",role:s.error?"alert":"status",children:[s.busy&&t.jsxs("span",{className:"chat-working-dots","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),t.jsx("span",{children:s.message})]}),e[1]=s.busy,e[2]=s.error,e[3]=s.message,e[4]=o):o=e[4];let r;e[5]!==s.fallbackReason?(r=s.fallbackReason&&t.jsxs("details",{className:"voice-fallback",children:[t.jsx("summary",{children:"Using xAI · OpenAI unavailable"}),t.jsx("p",{children:s.fallbackReason})]}),e[5]=s.fallbackReason,e[6]=r):r=e[6];let c;e[7]!==s.playbackBlocked||e[8]!==n?(c=s.playbackBlocked&&t.jsxs("button",{className:"voice-resume",type:"button",onClick:n,children:[t.jsx(Lo,{size:14,"aria-hidden":"true"}),"Enable spoken replies"]}),e[7]=s.playbackBlocked,e[8]=n,e[9]=c):c=e[9];let d;return e[10]!==i||e[11]!==o||e[12]!==r||e[13]!==c?(d=t.jsxs("div",{className:i,"aria-label":"Voice activity",children:[a,o,r,c]}),e[10]=i,e[11]=o,e[12]=r,e[13]=c,e[14]=d):d=e[14],d}const qc='button[role="menuitemradio"]',_l=".composer-mode-cell-live";function Wc(l){return Array.from(l?.querySelectorAll(qc)??[])}function Xc(){const l=Y.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("span",{className:"composer-mode-meter","aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),l[0]=e):e=l[0],e}function Gc(l){const e=Y.c(26),{chatModels:s,selectedModel:n,modelSelectionDisabled:i,sending:a,context:o,voice:r,onModelChange:c,onToggleVoice:d}=l,u=C.useRef(null),f=C.useRef(null),[m,b]=C.useState(!1),[p,g]=C.useState(0),h=C.useId(),y=r?.meterRef,x=!!r?.active,j=r?.phase,v=!!r?.disabled,k=r?.message,w=r?.retrying,S=r?.pendingReview;let M;e[0]!==k||e[1]!==w||e[2]!==S||e[3]!==j?(M=ai({sending:!1,mcpRunning:0,voicePhase:j,voiceMessage:k,retrying:w,pendingReview:S}),e[0]=k,e[1]=w,e[2]=S,e[3]=j,e[4]=M):M=e[4];const N=M,$=r?.provider??r?.mode??"auto";let R;e[5]!==$?(R=Ea($),e[5]=$,e[6]=R):R=e[6];const I=R,P=r?.fallbackReason;let T;e[7]!==P||e[8]!==I||e[9]!==N.label?(T=[N.label,I,P].filter(Boolean),e[7]=P,e[8]=I,e[9]=N.label,e[10]=T):T=e[10];const D=T.join(" · "),A=Ra({chatModels:s,selectedModel:n,modelSelectable:!o,voiceMode:r?.mode??null}),F=Ma(A),E=F.length===0||i||a;let z;e[11]!==s||e[12]!==n?(z=s.find(X=>X.id===n)??s[0],e[11]=s,e[12]=n,e[13]=z):z=e[13];const _=z,L=o?o.label:_?.label??n,B=o?o.description:_?.description,H=()=>{u.current?.querySelector(_l)?.focus()},q=X=>{b(!1),H()};let U;e[14]!==m?(U=[m],e[14]=m,e[15]=U):U=e[15],C.useEffect(()=>{if(!m)return;const X=u.current,le=pe=>{X?.contains(pe.target)||b(!1)},de=pe=>{pe.key!=="Escape"||pe.defaultPrevented||(pe.preventDefault(),pe.stopPropagation(),b(!1),X?.querySelector(_l)?.focus())};return document.addEventListener("pointerdown",le),document.addEventListener("focusin",le),document.addEventListener("keydown",de,!0),()=>{document.removeEventListener("pointerdown",le),document.removeEventListener("focusin",le),document.removeEventListener("keydown",de,!0)}},U);const K=()=>{if(m){q();return}g(Pa(F)),b(!0)},ee=X=>{X.kind==="model"?c(X.model):r?.selectMode(X.mode),q()},ne=X=>{const le=Ta(F,p,X.key);le!==null&&(X.preventDefault(),g(le),Wc(f.current)[le]?.focus())},V={"aria-haspopup":"menu","aria-expanded":m,className:"composer-mode-cell composer-mode-cell-live",disabled:E,onClick:K},re="composer-mode-switch",W="group",Z="Input mode",ie=x?t.jsx("button",{type:"button",className:"composer-mode-cell composer-mode-cell-idle","aria-label":"Stop voice conversation","aria-pressed":!0,title:"Stop microphone and spoken replies",onClick:d,children:t.jsx($l,{size:14,"aria-hidden":"true"})}):t.jsxs("button",{...V,type:"button","aria-label":o?"Composer context":"Chat model",title:B,children:[o?t.jsx(Si,{size:13,"aria-hidden":"true"}):t.jsx($l,{size:14,"aria-hidden":"true"}),t.jsx("span",{className:"composer-mode-name",children:"TEXT"}),t.jsx("span",{className:"composer-mode-divider","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"composer-mode-engine",children:L}),!E&&t.jsx(Ns,{size:11,"aria-hidden":"true"})]}),J=r&&(x?t.jsxs("button",{...V,ref:y,type:"button","data-voice-phase":j,"aria-label":"Voice provider","aria-describedby":h,"aria-busy":j==="connecting",title:D,children:[j==="connecting"?t.jsx(vi,{className:"composer-mode-connecting",size:14,"aria-hidden":"true"}):t.jsx(Xc,{}),t.jsx("span",{className:"composer-mode-name",children:"VOICE"}),t.jsx("span",{className:"composer-mode-divider","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"composer-mode-engine",children:j==="connecting"?N.label:I}),!E&&t.jsx(Ns,{size:11,"aria-hidden":"true"})]}):t.jsx("button",{ref:y,type:"button",className:"composer-mode-cell composer-mode-cell-idle","data-voice-phase":j,"aria-label":"Start voice conversation","aria-describedby":h,"aria-pressed":!1,disabled:v||a,title:"Voice input + spoken replies",onClick:d,children:t.jsx(ki,{size:15,"aria-hidden":"true"})}));let G;e[16]!==r||e[17]!==N.label||e[18]!==h?(G=r&&t.jsx("span",{id:h,className:"sr-only",role:"status",children:N.label}),e[16]=r,e[17]=N.label,e[18]=h,e[19]=G):G=e[19];const ce=m&&t.jsx("ul",{ref:f,className:"composer-engine-menu",role:"menu","aria-label":"Chat model and voice provider",onKeyDown:ne,children:A.map(X=>[t.jsx("li",{role:"presentation",className:"composer-engine-group",children:X.label},`${X.id}-label`),...X.items.map(le=>{const de=`${le.id.replace(":","-")}-note`;return t.jsx("li",{role:"none",children:t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":le.checked,"aria-label":le.label,"aria-describedby":le.note?de:void 0,autoFocus:le.position===p,tabIndex:le.position===p?0:-1,className:"composer-engine-item",onClick:()=>ee(le.choice),children:[t.jsx("span",{className:"composer-engine-check","aria-hidden":"true",children:le.checked&&t.jsx(Jt,{size:13})}),t.jsxs("span",{className:"composer-engine-copy",children:[t.jsxs("span",{className:"composer-engine-head",children:[t.jsx("strong",{children:le.label}),le.detail&&t.jsx("small",{children:le.detail})]}),le.note&&t.jsx("small",{id:de,className:"composer-engine-note",children:le.note})]})]})},le.id)})])});let ae;return e[20]!==u||e[21]!==ie||e[22]!==J||e[23]!==G||e[24]!==ce?(ae=t.jsxs("div",{ref:u,className:re,role:W,"aria-label":Z,children:[ie,J,G,ce]}),e[20]=u,e[21]=ie,e[22]=J,e[23]=G,e[24]=ce,e[25]=ae):ae=e[25],ae}const Ll="videobook-command-composer-form",Yc=250;function G1({chatTurns:l=[],goalEvents:e=[],previewTurnId:s=null,connected:n=!0,onBeginTurn:i,children:a,commands:o,references:r,actions:c,actionContext:d,actionDiscovery:u,actionStatus:f,actionsDisabled:m,onOpenActions:b,onCloseActionSearch:p,onDismissComposer:g,dockOpen:h,onDockOpenChange:y,contextualContent:x=null,contextualHasHeader:j=!1,goalStatus:v=null,bookId:k,callTool:w,chatModels:S,disabled:M,hidden:N=!1,modelSelectionDisabled:$,connectionLabel:R,mcpCalls:I,mcpFlash:P,onToggleMcpCall:T,selectedModel:D,context:A=null,mentionAssets:F=[],inputSession:E=null,placeholder:z,portalTarget:_=null,pendingInput:L,notice:B,outcomeSlot:H="composer",onEnsureCatalog:q,onDismissNotice:U,onDismissPanel:K,onExecute:ee,onModelChange:ne,onStartVoice:V,onSendingChange:re,onCommandRowHeightChange:W,onHeightChange:Z,onSuccessfulExecute:ie,voiceCatalog:J,voice:G}){const[ce,ae]=C.useState(Aa),[X,le]=C.useState(()=>L??ce.get(E)??""),[de,pe]=C.useState(0),[ue,me]=C.useState(()=>L!==void 0&&!Xt(L)),[fe,xe]=C.useState(()=>Da()??""),he=Fa(),[oe,Q]=C.useState(!1),te=C.useRef(0),be=C.useRef(!1),[ve,Ce]=C.useState(!1),[Se,$e]=C.useState(null),[Be,_e]=C.useState(L),[nt,Ke]=C.useState(!1),[Xe,qe]=C.useState(E),Fe=C.useRef(null),Ve=C.useRef(null),Ze=C.useRef(null),[Ge,et]=C.useState(null);C.useLayoutEffect(()=>{const O=Ze.current,je=Ve.current;if(N||_||!O||!je||!W&&!Z)return;const we=()=>{const Kt=getComputedStyle(je);W?.(O.getBoundingClientRect().height+parseFloat(Kt.borderTopWidth)+parseFloat(Kt.borderBottomWidth)),Z?.(je.getBoundingClientRect().height)};we();const ze=new ResizeObserver(we);return ze.observe(O),ze.observe(je),()=>ze.disconnect()},[N,W,Z,_]);const[tt,Re]=C.useState(!1),Pe=h??tt,Je=C.useRef(Pe),De=O=>{h===void 0&&Re(O),y?.(O)},[ke]=C.useState(()=>new Map),[Oe,at]=C.useState({start:X.length,end:X.length}),[Et,At]=C.useState(u?.query??""),[$t,lt]=C.useState(""),[se,ye]=C.useState(u?.key),[Me,Ye]=C.useState(null),it=C.useId(),Ot=C.useId(),ut=C.useRef(E),kt=C.useRef(""),St=C.useRef([]),mt=C.useRef(-1),ft=C.useRef(""),rt=C.useRef(""),wt=G?.captions.filter(O=>O.role==="user"&&O.final).at(-1)?.id,It=C.useRef(null),Rt=C.useRef(!1),Le=C.useRef(null),Dt=C.useRef(0),[yt,jt]=C.useState(!0),[Ft,Ut]=C.useState(0),vt=C.useMemo(()=>_a(G?.captions??[],I,l,e),[l,e,I,G?.captions]),pt=La(vt),_t=za(vt),ht=Ba(G),Mt=H==="composer"&&B&&!l.some(O=>O.reply===B.message)?B:null,bt=H==="composer"&&Se&&Se.message!==B?.message?Se:null,xt=!!(ht||Mt||bt),Ee=JSON.stringify([ht,Mt,bt]),Ie=ai({sending:oe,mcpRunning:hl(I),voicePhase:G?.phase,voiceMessage:G?.message,retrying:G?.retrying,pendingReview:G?.pendingReview}),Ae=Ie.busy&&Ie.kind!=="connecting"&&Ie.kind!=="permission",Qe=!Ae&&P==="success",Te=!Ae&&P==="error",Ne=Oa({runningCalls:hl(I),voicePhase:G?.phase})||I.calls.some(O=>O.expanded)||l.some(si)||ve||!!(ht?.error||ht?.playbackBlocked)||Mt?.tone==="error"||bt?.ok===!1,Nt=C.useRef(pt),Lt=C.useRef(Ee);if(C.useLayoutEffect(()=>{ut.current=E},[E]),C.useEffect(()=>{Ua(ce,E,X===L?"":X)},[X,ce,E,L]),C.useEffect(()=>{(pt>Nt.current||xt&&Ee!==Lt.current)&&jt(!0),Nt.current=pt,Lt.current=Ee},[Ee,xt,pt]),C.useEffect(()=>Ha({open:yt,held:Ne,onClose:()=>jt(!1)}),[yt,Ne,_t,Ee]),C.useLayoutEffect(()=>{wt&&(rt.current="")},[wt]),C.useEffect(()=>{window.clearTimeout(Dt.current)},[E]),E!==Xe){const O=new Map(ce);O.set(Xe,X===Be?"":X),ae(O),qe(E),_e(L),Ke(!1),le(L??O.get(E)??""),$e(null),Ye(null),me(L!==void 0&&!Xt(L))}else if(L!==Be){const O=!X.trim()||X===Be;_e(L),G?.pendingReview||nt?Ke(L!==void 0):O&&le(L??""),me(L!==void 0&&!Xt(L))}u?.key!==se&&(ye(u?.key),At(u?.query??""),lt(""),pe(0));const ot=!u&&!A&&!ue&&Xt(X),Rs=G?.active&&!x&&!a&&!B&&!Se&&!u&&!ot&&pt<=Ft&&!(yt&&vt.length>0)&&!G.playbackBlocked&&!xt,ge=Pe&&!Rs,Pt=J?.voices??[],qt=bl(Pt,fe),Zs=he.stop;C.useEffect(()=>{ot||Zs()},[ot,Zs]);const Ms=()=>{J&&J.ensureLoaded().catch(()=>{})},Wt=O=>{!A&&Xt(O)&&Ms()},en=()=>{J&&J.refresh().catch(()=>{})},Ht=(O=!1)=>{bn(()=>Fe.current?.element()??null,()=>{O&&Fe.current?.select()})()},tn=()=>{me(!0),u&&p(!1),Ga({setOpen:De,stopVoice:G?.stop,pauseMedia:()=>hn(Ve.current)}),Ht()},Ps=()=>{if(G){if(G.active){G.stop(),Ht();return}G.disabled||oe||(he.stop(),hn(Ve.current),le(""),at({start:0,end:0}),Ke(!1),Ye(null),$e(null),me(!0),jt(!1),Ut(pt),mt.current=-1,ft.current="",u&&p(!1),U?.(),V?.(),De(!0),G.toggle(),Ht())}};C.useEffect(()=>{const O=Je.current;Je.current=Pe,!(!O||Pe)&&(he.stop(),G?.stop(),hn(Ve.current))},[Pe,he,G]);const st=C.useMemo(()=>({outcome:Se,notice:B??null,dismissOutcome:()=>$e(null),dismissNotice:()=>U?.()}),[B,U,Se]),Ue=C.useMemo(()=>{if(u||ue||Xt(X))return[];if(L&&/^\/(?:apply|cancel)(?:\s|$)/iu.test(X))return[];const O=X.match(/^\/([\w-]*)$/);if(O&&!A){const we=O[1].toLowerCase();return Ka(o,we).map(ze=>({value:`${ze.command} `,label:ze.command,description:ze.description,aliases:ze.aliases,type:"command"}))}const je=A?new Set(F.map(we=>we.artifactId)):void 0;return Va(r,X,Oe.start,Oe.end,je).map(we=>({value:we.token,label:we.token,description:li(we),type:"cell",reference:we}))},[u,o,A,ue,X,F,L,r,Oe]),We=C.useMemo(()=>qa(c,Et).filter(O=>!$t||O.group===$t),[$t,Et,c]),sn=C.useMemo(()=>[...new Set(c.map(O=>O.group))].sort(),[c]),es=Math.min(de,Math.max(0,We.length-1)),Ts=`${it}-actions`,nn=Me?.action.command===X.trim().split(/\s/u)[0]&&Me?.action.scope==="global"?m:M;C.useLayoutEffect(()=>{u&&bn(()=>Fe.current?.element()??null)()},[u,_]);const Zn=O=>{window.clearTimeout(Dt.current),$e(O),O.ok&&(Dt.current=window.setTimeout(()=>$e(null),3200))},Qi=async O=>{const je=[];let we=0;for(;;){const ze=await w("list_prompt_history",{book_id:O,surface:"chat",limit:Yc,offset:we}),Kt=lr(ze);if(je.push(...Kt.values),!Kt.hasMore)return je.reverse();const Tt=Kt.offset+Kt.values.length;if(Tt<=we)throw new Error("Prompt history pagination did not advance");we=Tt}},ln=async()=>{const O=k;if(!O)return;const je=Le.current;if(je?.bookId===O){await je.promise;return}if(rt.current===O)return;rt.current=O,St.current=[],mt.current=-1,ft.current="";const we=(async()=>{try{const ze=await Qi(O);rt.current===O&&(St.current=ze)}catch{rt.current===O&&(rt.current="")}})();Le.current={bookId:O,promise:we},await we,Le.current?.promise===we&&(Le.current=null)},Zi=()=>{A||(It.current!==k&&(It.current=k,q().catch(()=>{It.current===k&&(It.current=null)})),ln()),ot&&Ms()},ea=async(O,je)=>{St.current=[...St.current,O],mt.current=-1,k&&await w("record_prompt",{book_id:k,surface:"chat",prompt:O,params:{model:D}},{chat:je}).catch(()=>{})},el=async O=>{const je=O!==void 0,we=(O??X).trim();if(!we||be.current||nn||u||Rt.current)return;De(!0),je||Ke(!1);const ze=Me?.action.command===we.split(/\s/u)[0]?Me:null,Kt=E,Tt=i?.(we),rs=()=>Tt?Tt.isInScope():ut.current===Kt,da=te.current,il=()=>te.current===da&&ut.current===Kt;be.current=!0,Q(!0),jt(!0),$e(null),je||le(""),me(!0),re?.(!0);let dn=!1,un=!1;const ua=bn(()=>Fe.current?.element()??null,()=>{un&&Fe.current?.select()});try{if(!A||ze){if(await ln(),!rs())return;await ea(we,Tt)}if(!rs())return;const bs=!A&&Xt(we)?await J?.ensureLoaded():null;if(!rs())return;const Ds=bl(bs?.voices??Pt,fe),mn=er(we,Ds);mn?.speakVoiceId&&xl(mn.speakVoiceId);const Fs=await ee(we,{chat:Tt,...mn,...ze?{action:{id:ze.action.id,values:ze.values}}:{}});if(dn=!0,!rs()||Tt&&!Tt.isCurrent())return;Ye(null),(!Tt||!Fs.ok&&H==="sheet")&&Zn(Fs);const xs=tr(Fs,L);xs&&!je&&il()&&(le(xs.value),me(!Xt(xs.value)),Wt(xs.value),un=xs.select),Fs.ok&&ie()}catch(bs){const Ds={ok:!1,message:bs instanceof Error?bs.message:String(bs)};if(Tt?.finish(Ds),dn=!0,!rs())return;Tt||Zn(Ds),L!==void 0&&!je&&il()&&(le(L),me(!0),un=!0)}finally{dn||Tt?.finish({ok:!0,status:"cancelled",message:"Workspace changed before the command was sent."}),be.current=!1,Q(!1),re?.(!1),rs()&&(!Tt||Tt.isCurrent())&&ua()}},an=O=>{if(O.type==="command")Fe.current?.replace(O.value),me(!Xt(O.value)),Wt(O.value);else{const je=Fe.current?.selection()??Oe,we=Ja(X,O.value,je.start,je.end);if(!we)return;Fe.current?.replace(we.value,{start:we.caret,end:we.caret}),me(!0)}mt.current=-1,Ht()},rn=O=>{Ye({action:O,values:u?.values}),le(`${O.command} `),me(!0),pe(0),p(!0),Ht()},Es=()=>{p(!1),g||Ht()},tl=O=>{xe(O),xl(O),he.playingVoiceId&&he.playingVoiceId!==O&&he.stop()},ta=()=>{const O=Pt.find(je=>je.voiceId===qt);O?.previewUrl&&he.toggle(O.voiceId,O.previewUrl)},As=async O=>{const je=E;if(await ln(),je!==ut.current)return;const we=nr({values:St.current,cursor:mt.current,draft:ft.current,current:X,direction:O});we&&(mt.current=we.cursor,ft.current=we.draft,le(we.value),me(!0),Wt(we.value))},sl=(O,je=X)=>{const we=Fe.current?.selection()??Oe,ze=sr({value:je,selectionStart:we.start,selectionEnd:we.end,key:O.key,ctrlKey:O.ctrlKey,altKey:O.altKey,yankText:kt.current});return ze?(O.preventDefault(),ze.value===je?Fe.current?.setSelection({start:ze.selectionStart,end:ze.selectionEnd}):Fe.current?.replace(ze.value,{start:ze.selectionStart,end:ze.selectionEnd}),Wt(ze.value),ze.killedText!==void 0&&(kt.current=ze.killedText),!0):!1},sa=O=>{if(O.key==="Escape"){const je=document.querySelector(".mcp-call-popover:popover-open");if(je){O.preventDefault(),O.stopPropagation(),je.hidePopover();return}}if(Rt.current||O.isComposing||O.keyCode===229){O.key==="Enter"&&O.preventDefault();return}if(u){if(O.key==="Escape")O.preventDefault(),O.stopPropagation(),Es();else if(["ArrowDown","ArrowUp","Home","End"].includes(O.key)){O.preventDefault();const je=O.key==="Home"?0:O.key==="End"?We.length-1:(es+(O.key==="ArrowDown"?1:-1)+We.length)%Math.max(1,We.length);pe(Math.max(0,je)),document.getElementById(`${Ts}-option-${je}`)?.scrollIntoView({block:"nearest"})}else(O.key==="Enter"||O.key==="Tab"&&!O.shiftKey)&&We[es]?(O.preventDefault(),rn(We[es])):sl(O,Et);return}if(ot){const je=Qa(O,Pt,qt);if(je.type!=="ignore"&&O.preventDefault(),je.type==="select"){tl(je.voiceId);return}if(je.type==="toggle"){ta();return}if(je.type==="dismiss"){he.stop(),me(!0);return}}if(Ue.length>0){if(["ArrowDown","ArrowUp","Home","End"].includes(O.key)){O.preventDefault();const je=O.key==="Home"?0:O.key==="End"?Ue.length-1:(de+(O.key==="ArrowDown"?1:-1)+Ue.length)%Ue.length;pe(je),document.getElementById(`${it}-option-${je}`)?.scrollIntoView({block:"nearest"});return}if(O.key==="Tab"&&!O.shiftKey){O.preventDefault(),an(Ue[Math.min(de,Ue.length-1)]);return}if(O.key==="Enter"&&!Za(X,Ue)){O.preventDefault(),an(Ue[Math.min(de,Ue.length-1)]);return}if(O.key==="Escape"){O.preventDefault(),me(!0);return}}if(O.key==="Escape"&&ge&&cn&&yt&&!In(G?.phase,vt.length,!!G)){O.preventDefault(),jt(!1);return}if(O.key==="Escape"&&(K||g)){O.preventDefault(),K?K():g?.();return}if(!A&&O.ctrlKey&&O.key.toLowerCase()==="p"){O.preventDefault(),As(-1);return}if(!A&&O.ctrlKey&&O.key.toLowerCase()==="n"){O.preventDefault(),As(1);return}if(!A&&O.key==="ArrowUp"){O.preventDefault(),As(-1);return}if(!A&&O.key==="ArrowDown"){O.preventDefault(),As(1);return}sl(O)||O.key==="Enter"&&(O.preventDefault(),el())},ss=Xa(!!a),on=l.at(-1),nl=on!==void 0&&on.id===s,cn=!x||ss||nl,na=cn||xt,la=cn?x&&!ss&&nl?vt.filter(O=>O.kind==="caption"&&O.turn?.id===on.id):vt:[],ia=Ya({dockOpen:ge,panelHasHeader:j,reviewPriority:ss}),aa=!xt&&In(G?.phase,vt.length,!!G),ra={captionId:Ot},oa={hide:tn,hideLabel:Wa},ca=xt?t.jsxs(t.Fragment,{children:[Mt&&t.jsx(Dl,{message:Mt.message,tone:Mt.tone,dismissLabel:"Dismiss notice",onDismiss:U}),bt&&t.jsx(Dl,{message:bt.message,tone:bt.ok?"info":"error",dismissLabel:"Dismiss error",onDismiss:bt.ok?void 0:()=>$e(null)}),ht&&G&&t.jsx(Vc,{feedback:ht,onResumePlayback:G.resumePlayback})]}):null,ll=t.jsx(Oi.Provider,{value:st,children:t.jsx(Li.Provider,{value:oa,children:t.jsx(Bi.Provider,{value:ra,children:t.jsxs("section",{ref:Ve,className:"command-composer","data-composer-focus":"return","data-dock-open":ge?"true":"false","data-resizable-review":ss&&ge?"true":void 0,style:Ge===null?void 0:{"--composer-review-height":`${Ge}px`},"data-voice-phase":G?.phase,hidden:N,onKeyDown:O=>{!u||O.key!=="Escape"||O.defaultPrevented||O.nativeEvent.isComposing||(O.preventDefault(),O.stopPropagation(),Es())},children:[ss&&ge&&t.jsx(zi,{label:"Resize review pane",targetSelector:".command-composer",edge:"top",minimum:280,onResize:et}),ge&&!ia&&t.jsxs("div",{className:"command-composer-dock-bar",children:[aa&&t.jsx("span",{className:"command-composer-dock-title",children:"chat"}),t.jsx(Cc,{})]}),t.jsxs("div",{className:"command-composer-dock-body",hidden:!ge,inert:ge?void 0:!0,children:[x&&t.jsx("div",{className:"command-composer-contextual",hidden:ss,inert:ss?!0:void 0,children:x}),!N&&!A&&a,u&&t.jsx(_c,{actions:We,groups:sn,group:$t,context:d,loading:f.loading,error:f.error,listId:Ts,selectedIndex:es,onGroupChange:O=>{lt(O),pe(0),Ht()},onClose:Es,onSelect:rn}),!N&&na&&t.jsx(Rc,{rows:la,connected:n,onDetailsChange:Ce,phase:G?.phase,voicePresent:!!G,open:yt&&ge,onToggleCall:T,children:ca})]}),t.jsxs("form",{ref:Ze,id:Ll,className:`command-line-shell ${Ae?"command-line-shell-transmitting":""} ${Qe?"command-line-shell-success":""} ${Te?"command-line-shell-error":""}`,"aria-busy":Ae,onSubmit:O=>{if(O.preventDefault(),u&&We[es])rn(We[es]);else{const je=O.nativeEvent.submitter,we=je?.getAttribute("form")===Ll||!je&&document.activeElement?.closest(".confirm-sheet"),ze=L!==void 0&&we&&!/^\/apply(?:\s|$)/iu.test(X);el(ze?L:void 0)}},children:[ot&&t.jsx(Hc,{voices:Pt,selectedVoiceId:qt,playingVoiceId:he.playingVoiceId,status:J?.status??"fallback",warning:J?.warning??null,loading:J?.loading??!1,error:J?.error??null,onSelect:tl,onTogglePreview:(O,je)=>{G?.stop(),he.toggle(O,je)},onRefresh:en}),!ot&&Ue.length>0&&t.jsx("div",{className:"command-suggestions",id:`${it}-list`,role:"listbox","aria-label":"Command suggestions",children:Ue.map((O,je)=>t.jsx("button",{type:"button",role:"option",id:`${it}-option-${je}`,"aria-selected":je===de,className:`${je===de?"active ":""}${O.type==="cell"?"composer-reference-suggestion":"command-command-suggestion"}`,onMouseDown:we=>we.preventDefault(),onClick:()=>an(O),children:O.type==="cell"?t.jsxs(t.Fragment,{children:[t.jsx(ps,{asset:O.reference.asset,kindHint:O.reference.type}),t.jsxs("span",{className:"composer-reference-copy",children:[t.jsx("strong",{children:O.label}),O.reference.label&&t.jsx("span",{children:O.reference.label}),t.jsx("small",{children:O.description})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("strong",{children:O.label}),t.jsx("span",{children:O.description})]})},`${O.type}:${O.label}`))}),t.jsx("div",{className:"command-actions-controls",children:t.jsx("button",{type:"button",className:"command-actions-toggle","aria-label":"Open actions","aria-expanded":!!u,"data-workspace-action-surface":"button","aria-keyshortcuts":"Control+Shift+K Meta+Shift+K",disabled:m||oe,onClick:u?Es:b,children:t.jsx(zo,{size:14,"aria-hidden":"true"})})}),t.jsx(Fc,{ref:Fe,value:u?Et:X,session:`${E??"chat"}:${u?`actions-${u.key}`:"draft"}`,sessions:ke,references:r,disabled:u?m:nn,rich:!u,placeholder:u?"Search actions by name, operation or alias…":M?R:z??"Type a message or /command…",expanded:!!u||!ot&&Ue.length>0,controls:u?Ts:!ot&&Ue.length>0?`${it}-list`:void 0,activeDescendant:u&&We[es]?`${Ts}-option-${es}`:!ot&&Ue[de]?`${it}-option-${de}`:void 0,onFocus:Zi,onCompositionChange:O=>{Rt.current=O},onSelectionChange:at,onChange:(O,je)=>{if(at(je),pe(0),u){At(O);return}te.current+=1,le(O),me(!1),mt.current=-1,Wt(O)},onKeyDown:sa}),v,t.jsx(Gc,{chatModels:S,selectedModel:D,modelSelectionDisabled:$,sending:oe,context:A,voice:G,onModelChange:ne,onToggleVoice:Ps}),t.jsx("button",{type:"submit",className:"command-send",disabled:u?m||We.length===0||f.loading:nn||oe||!X.trim(),"aria-label":u?"Prepare action":"Send command",children:oe?t.jsx(ct,{size:14}):t.jsx(Bo,{size:14})}),Ae&&t.jsx("span",{className:"command-transmit-scan","aria-hidden":"true"})]})]})})})});return _?hs.createPortal(ll,_):ll}function Jc(l){const e=Y.c(13),{task:s}=l,[n,i]=C.useState(null);let a;e[0]!==s.model||e[1]!==s.provider?(a=ir(s.provider,s.model),e[0]=s.model,e[1]=s.provider,e[2]=a):a=e[2];const o=a;if(!o)return null;const r=s.provider==="fal"?"fal requests":"Kie logs";let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Oo,{size:12,"aria-hidden":"true"}),e[3]=c):c=e[3];let d;e[4]!==r||e[5]!==o?(d=t.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:[r,c]}),e[4]=r,e[5]=o,e[6]=d):d=e[6];let u;e[7]!==n||e[8]!==s.taskId?(u=s.taskId&&t.jsxs(t.Fragment,{children:[t.jsx("code",{title:s.taskId,children:s.taskId}),t.jsx("button",{type:"button","aria-label":"Copy provider request ID",title:"Copy provider request ID",onClick:async()=>{try{await navigator.clipboard.writeText(s.taskId),i(s.taskId)}catch{i(null)}},children:n===s.taskId?"Copied":t.jsx(Gs,{size:12,"aria-hidden":"true"})})]}),e[7]=n,e[8]=s.taskId,e[9]=u):u=e[9];let f;return e[10]!==d||e[11]!==u?(f=t.jsxs("div",{className:"provider-task-link",children:[d,u]}),e[10]=d,e[11]=u,e[12]=f):f=e[12],f}function Qc(l,e){return l===e?!0:!l||!e?!1:l.sourceLeftX===e.sourceLeftX&&l.sourceRightX===e.sourceRightX&&l.sourceBottomY===e.sourceBottomY&&l.targetCenterX===e.targetCenterX&&l.targetLeftX===e.targetLeftX&&l.targetTopY===e.targetTopY&&l.targetHeight===e.targetHeight}const Y1=C.memo(function(e){const s=Y.c(20),{source:n,sourceX:i,sourceY:a,target:o,data:r}=e;let c;s[0]!==n||s[1]!==o?(c=x=>{const j=x.nodeLookup.get(n),v=x.nodeLookup.get(o);if(!j||!v)return null;const k=j.internals?.positionAbsolute??j.position,w=v.internals?.positionAbsolute??v.position,S=j.measured?.width??He.squareSize,M=j.measured?.height??He.squareSize,N=v.measured?.width??He.squareSize,$=v.measured?.height??He.squareSize;return{sourceLeftX:k.x,sourceRightX:k.x+S,sourceBottomY:k.y+M,targetCenterX:w.x+N/2,targetLeftX:w.x,targetTopY:w.y,targetHeight:$}},s[0]=n,s[1]=o,s[2]=c):c=s[2];const d=cc(c,Qc);if(!r||!d)return null;const u=Rn[r.targetPortIndex]??Rn[1],f=r.targetSide==="left"?d.targetLeftX:d.targetCenterX,m=r.targetSide==="left"?d.targetTopY+d.targetHeight*u:d.targetTopY;let b;s[3]!==d||s[4]!==r||s[5]!==i||s[6]!==a||s[7]!==f||s[8]!==m?(b=ar({sourceX:i,sourceY:a,targetX:f,targetY:m,...d},r),s[3]=d,s[4]=r,s[5]=i,s[6]=a,s[7]=f,s[8]=m,s[9]=b):b=s[9];const p=b;let g;s[10]!==p||s[11]!==e.id||s[12]!==e.style?(g=t.jsx(dc,{id:e.id,path:p,interactionWidth:18,style:e.style}),s[10]=p,s[11]=e.id,s[12]=e.style,s[13]=g):g=s[13];let h;s[14]!==f||s[15]!==m?(h=t.jsx("circle",{className:"bus-river-entry-dot",cx:f,cy:m,r:2.5}),s[14]=f,s[15]=m,s[16]=h):h=s[16];let y;return s[17]!==g||s[18]!==h?(y=t.jsxs(t.Fragment,{children:[g,h]}),s[17]=g,s[18]=h,s[19]=y):y=s[19],y}),Bs=10;function Zc(l){const e=He.columnCount*He.columnPitch-He.gap,s=l.rowCount*He.rowPitch-He.gap,n=He.originX-Bs,i=He.originY+l.startRow*He.rowPitch-Bs;return{width:e+Bs*2,height:s+Bs*2,transform:`translate(${n}px, ${i}px)`}}function J1(l){const e=Y.c(33),{sections:s,metrics:n,occupiedSlots:i,previewSlot:a,mediaDropActive:o,mediaDropSlot:r,reviewRoles:c}=l;let d;e[0]!==a?(d=a?Ln(a):null,e[0]=a,e[1]=d):d=e[1];const u=d;let f;e[2]!==i?(f=new Set(i.map(_s)),e[2]=i,e[3]=f):f=e[3];const m=f;let b;e[4]!==r?(b=r?_s(r):null,e[4]=r,e[5]=b):b=e[5];const p=b;let g;e[6]!==n.height||e[7]!==n.width?(g={width:n.width,height:n.height},e[6]=n.height,e[7]=n.width,e[8]=g):g=e[8];let h;e[9]!==s?(h=s.map(ed),e[9]=s,e[10]=h):h=e[10];let y;if(e[11]!==o||e[12]!==p||e[13]!==n.columnCount||e[14]!==n.minColumn||e[15]!==n.rowCount||e[16]!==m||e[17]!==c){let v;e[19]!==o||e[20]!==p||e[21]!==n.columnCount||e[22]!==n.minColumn||e[23]!==m||e[24]!==c?(v=(k,w)=>Array.from({length:n.columnCount},(S,M)=>{const N=n.minColumn+M,$={row:w,column:N},R=_s($),I=m.has(R),P=o&&!I,T=P&&R===p,D=I?void 0:c.get(ti($)),F=`notebook-grid-square${!I&&(M===0||m.has(_s({row:w,column:N-1})))?" notebook-grid-square-run-start":""}${P?" notebook-grid-square-dropzone":""}${T?" notebook-grid-square-drop-target":""}${D?` notebook-grid-square-review notebook-review-${D}`:""}`;return t.jsx("span",{className:F,style:{width:He.squareSize,height:He.squareSize,transform:`translate(${He.originX+M*He.columnPitch}px, ${He.originY+w*He.rowPitch}px)`},children:t.jsx("span",{className:"notebook-grid-square-label",children:Vt($)})},R)}),e[19]=o,e[20]=p,e[21]=n.columnCount,e[22]=n.minColumn,e[23]=m,e[24]=c,e[25]=v):v=e[25],y=Array.from({length:n.rowCount},v),e[11]=o,e[12]=p,e[13]=n.columnCount,e[14]=n.minColumn,e[15]=n.rowCount,e[16]=m,e[17]=c,e[18]=y}else y=e[18];let x;e[26]!==u?(x=u&&t.jsx("div",{className:"notebook-grid-preview",style:{width:He.squareSize,height:He.squareSize,transform:`translate(${u.x}px, ${u.y}px)`}}),e[26]=u,e[27]=x):x=e[27];let j;return e[28]!==g||e[29]!==h||e[30]!==y||e[31]!==x?(j=t.jsx(_i,{children:t.jsxs("div",{className:"notebook-grid-board",style:g,children:[h,y,x]})}),e[28]=g,e[29]=h,e[30]=y,e[31]=x,e[32]=j):j=e[32],j}function ed(l){const e=l.family??"mixed";return t.jsx("div",{className:`notebook-lane notebook-lane-${e}${l.kind==="starter"?" notebook-lane-starter":""}${l.kind==="mixed"?" notebook-lane-mixed":""}`,"data-lane-caption":l.caption,"data-lane-family":e,"data-lane-kind":l.kind,"data-lane-row-count":l.rowCount,"data-lane-start-row":l.startRow,style:Zc(l)},`lane-${l.startRow}-${e}`)}const zt={width:240,height:156,pitch:4,minimumBarHeight:4};function td(l){const e=Y.c(17),{peaks:s,progress:n}=l,i=C.useId();let a;if(e[0]!==i){let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=/[^a-zA-Z0-9]/g,e[2]=g):g=e[2],a=i.replace(g,""),e[0]=i,e[1]=a}else a=e[1];const o=`played${a}`;let r;e[3]!==s?(r=rr(s,zt),e[3]=s,e[4]=r):r=e[4];const c=r,d=Math.min(1,Math.max(0,n)),u=zt.width*d;if(!c){let g;return e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Ui,{}),e[5]=g):g=e[5],g}let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("path",{className:"cell-waveform-midline",d:`M0 ${zt.height/2}h${zt.width}`}),e[6]=f):f=e[6];let m;e[7]!==c?(m=t.jsx("path",{className:"cell-waveform-bars",d:c}),e[7]=c,e[8]=m):m=e[8];let b;e[9]!==o||e[10]!==c||e[11]!==d||e[12]!==u?(b=d>0&&t.jsxs(t.Fragment,{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:o,children:t.jsx("rect",{x:"0",y:"0",width:u,height:zt.height})})}),t.jsx("g",{clipPath:`url(#${o})`,children:t.jsx("path",{className:"cell-waveform-played",d:c})}),t.jsx("path",{className:"cell-waveform-playhead",d:`M${u} 8V${zt.height-8}`})]}),e[9]=o,e[10]=c,e[11]=d,e[12]=u,e[13]=b):b=e[13];let p;return e[14]!==m||e[15]!==b?(p=t.jsxs("svg",{className:"cell-waveform",viewBox:`0 0 ${zt.width} ${zt.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:[f,m,b]}),e[14]=m,e[15]=b,e[16]=p):p=e[16],p}function Ui(){const l=Y.c(2);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=or(zt),l[0]=e):e=l[0];const s=e;let n;return l[1]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsxs("svg",{className:"cell-waveform cell-waveform-pending",viewBox:`0 0 ${zt.width} ${zt.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:[t.jsx("path",{className:"cell-waveform-midline",d:`M0 ${zt.height/2}h${zt.width}`}),t.jsx("path",{className:"cell-waveform-bars",d:s})]}),l[1]=n):n=l[1],n}function sd(l){const e=Y.c(20),{asset:s,eager:n}=l,i=n===void 0?!1:n,[a,o]=C.useState(!1),[r,c]=C.useState(!1),[d,u]=C.useState(i),f=C.useRef(null),m=s.type==="video"||s.type==="final",b=s.thumbnailUrl??(s.type==="image"?s.mediaUrl:null),p=`${b??""}:${s.mediaUrl??""}:${s.type}:${i}`,[g,h]=C.useState(p);g!==p&&(h(p),o(!1),c(!1),u(i));const y=!!(b&&!a),x=m&&!!s.mediaUrl&&!y;let j,v;if(e[0]!==i||e[1]!==x||e[2]!==d?(j=()=>{if(!x||d)return;if(i||typeof IntersectionObserver>"u"){const $=window.requestAnimationFrame(()=>u(!0));return()=>window.cancelAnimationFrame($)}const M=f.current;if(!M)return;const N=new IntersectionObserver($=>{$.some(nd)&&(u(!0),N.disconnect())},{root:M.closest(".media-library-results"),rootMargin:"96px 0px"});return N.observe(M),()=>N.disconnect()},v=[i,x,d],e[0]=i,e[1]=x,e[2]=d,e[3]=j,e[4]=v):(j=e[3],v=e[4]),C.useEffect(j,v),y&&b){let M;e[5]===Symbol.for("react.memo_cache_sentinel")?(M=()=>o(!0),e[5]=M):M=e[5];let N;return e[6]!==b?(N=t.jsx("img",{src:b,alt:"",loading:"lazy",decoding:"async",onError:M}),e[6]=b,e[7]=N):N=e[7],N}if(m&&s.mediaUrl){let M;return e[8]!==s.duration||e[9]!==s.mediaUrl||e[10]!==d||e[11]!==r?(M=t.jsx("span",{ref:f,className:"media-library-asset-preview",children:d&&!r?t.jsx("video",{src:s.mediaUrl,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true",onError:()=>c(!0)}):t.jsxs(t.Fragment,{children:[t.jsx(Ct,{size:28}),s.duration!==null&&t.jsx("small",{children:Bt(s.duration)})]})}),e[8]=s.duration,e[9]=s.mediaUrl,e[10]=d,e[11]=r,e[12]=M):M=e[12],M}let k;e[13]!==s.type?(k=s.type==="audio"?t.jsx(ts,{size:28}):t.jsx(Ct,{size:28}),e[13]=s.type,e[14]=k):k=e[14];let w;e[15]!==s.duration?(w=s.duration!==null&&t.jsx("small",{children:Bt(s.duration)}),e[15]=s.duration,e[16]=w):w=e[16];let S;return e[17]!==k||e[18]!==w?(S=t.jsxs("span",{className:"media-library-asset-placeholder",children:[k,w]}),e[17]=k,e[18]=w,e[19]=S):S=e[19],S}function nd(l){return l.isIntersecting}function vn(l){return l!==null&&Number.isFinite(l)&&l>0}function ld(l){const e=Y.c(11),{className:s,width:n,height:i,durationSeconds:a,fallbackLabel:o}=l,r=vn(n)&&vn(i)?`${n}×${i}`:o??null;let c;e[0]!==a?(c=vn(a)?Bt(a):null,e[0]=a,e[1]=c):c=e[1];const d=c;if(!r&&!d)return null;const u=`notebook-media-metadata ${s}`;let f;e[2]!==r?(f=r&&t.jsx("span",{children:r}),e[2]=r,e[3]=f):f=e[3];let m;e[4]!==d||e[5]!==a?(m=d&&t.jsx("time",{dateTime:`PT${a}S`,"aria-label":`Duration ${d}`,children:d}),e[4]=d,e[5]=a,e[6]=m):m=e[6];let b;return e[7]!==u||e[8]!==f||e[9]!==m?(b=t.jsxs("span",{className:u,children:[f,m]}),e[7]=u,e[8]=f,e[9]=m,e[10]=b):b=e[10],b}const id=/("(?:\\.|[^"\\])*")(?=\s*:)|("(?:\\.|[^"\\])*")|\b(true|false)\b|\b(null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function ad(l){const e=JSON.stringify(l,null,2)??"null",s=[];let n=0;for(const i of e.matchAll(id)){const a=i.index;a>n&&s.push({kind:"punctuation",value:e.slice(n,a)}),s.push({kind:i[1]?"key":i[2]?"string":i[3]?"boolean":i[4]?"null":"number",value:i[0]}),n=a+i[0].length}return n<e.length&&s.push({kind:"punctuation",value:e.slice(n)}),s}function rd(l){if(!l.startsWith('"')||!l.endsWith('"')||l.length<2)return null;try{const e=JSON.parse(l);return typeof e=="string"?e:null}catch{return null}}function od(l){const e=Y.c(23),{asset:s}=l,n=C.useId(),i=C.useRef(null),a=C.useRef(null),o=s.type==="video"||s.type==="final",r=s.mediaUrl??(s.type==="image"?s.thumbnailUrl:null);if(!r||!o&&s.type!=="image"&&s.type!=="audio"){let v;return e[0]!==s?(v=t.jsx(ps,{asset:s}),e[0]=s,e[1]=v):v=e[1],v}let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{const v=i.current,k=a.current;if(!v||!k)return;v.showPopover();const w=k.getBoundingClientRect(),S=v.getBoundingClientRect(),M=w.right+S.width<=window.innerWidth-12?w.right:Math.max(12,w.left-S.width);v.style.left=`${M}px`,v.style.top=`${Math.max(12,Math.min(w.top,window.innerHeight-S.height-12))}px`},e[2]=c):c=e[2];const d=c;let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>i.current?.hidePopover(),e[3]=u):u=e[3];const f=u;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=v=>{v.currentTarget.contains(document.activeElement)||f()},e[4]=m):m=e[4];let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=v=>{v.currentTarget.contains(v.relatedTarget)||f()},e[5]=b):b=e[5];const p=`Preview source ${o?"video":s.type}`;let g;e[6]!==s?(g=t.jsx(ps,{asset:s,videoFrame:!0}),e[6]=s,e[7]=g):g=e[7];let h;e[8]!==n||e[9]!==p||e[10]!==g?(h=t.jsx("button",{ref:a,type:"button",className:"json-media-trigger","aria-label":p,"aria-controls":n,onClick:d,children:g}),e[8]=n,e[9]=p,e[10]=g,e[11]=h):h=e[11];let y;e[12]!==s.thumbnailUrl||e[13]!==s.type||e[14]!==r||e[15]!==o?(y=s.type==="image"?t.jsx("img",{src:r,alt:"Source image preview",loading:"lazy",decoding:"async"}):o?t.jsx("video",{src:r,poster:s.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"none","aria-label":"Source video"}):t.jsx("audio",{src:r,controls:!0,preload:"none","aria-label":"Source audio"}),e[12]=s.thumbnailUrl,e[13]=s.type,e[14]=r,e[15]=o,e[16]=y):y=e[16];let x;e[17]!==n||e[18]!==y?(x=t.jsx("span",{id:n,ref:i,popover:"auto",className:"json-media-popover",onToggle:cd,children:y}),e[17]=n,e[18]=y,e[19]=x):x=e[19];let j;return e[20]!==h||e[21]!==x?(j=t.jsxs("span",{className:"json-media-preview",onMouseEnter:d,onMouseLeave:m,onFocus:d,onBlur:b,children:[h,x]}),e[20]=h,e[21]=x,e[22]=j):j=e[22],j}function cd(l){l.newState==="closed"&&l.currentTarget.querySelectorAll("video, audio").forEach(dd)}function dd(l){l instanceof HTMLMediaElement&&l.pause()}const ud=/\.(?:png|jpe?g|webp|gif|avif)$/i,md=/\.(?:mp4|mov|webm|m4v)$/i;function fd(l){if(!/^https?:\/\//i.test(l))return;let e;try{e=new URL(l).pathname}catch{return}const s=ud.test(e)?"image":md.test(e)?"video":null;return s?{artifactId:l,type:s,mediaUrl:l}:void 0}function Xn(l){const e=Y.c(16),{value:s,ariaLabel:n,artifactAssets:i,mediaDisplay:a,remoteMedia:o}=l,r=n===void 0?"Formatted action source":n,c=a===void 0?"thumbnail":a,d=o===void 0?!1:o;let u,f,m;if(e[0]!==r||e[1]!==i||e[2]!==c||e[3]!==d||e[4]!==s){const p=ad(s);u="inspector-source-json",f=r;let g;e[8]!==i||e[9]!==c||e[10]!==d?(g=(h,y)=>{const x=h.kind==="string"?rd(h.value):null,j=x?i?.get(x)??(d?fd(x):void 0):void 0;return t.jsxs("span",{className:`json-${h.kind}`,children:[h.value,j&&(c==="preview"?t.jsx(od,{asset:j}):t.jsx(ps,{asset:j}))]},`${y}-${h.value}`)},e[8]=i,e[9]=c,e[10]=d,e[11]=g):g=e[11],m=p.map(g),e[0]=r,e[1]=i,e[2]=c,e[3]=d,e[4]=s,e[5]=u,e[6]=f,e[7]=m}else u=e[5],f=e[6],m=e[7];let b;return e[12]!==u||e[13]!==f||e[14]!==m?(b=t.jsx("pre",{className:u,"aria-label":f,children:m}),e[12]=u,e[13]=f,e[14]=m,e[15]=b):b=e[15],b}function pd(l){const e=Y.c(19),{asset:s}=l;let n;e[0]!==s?(n=t.jsx(ps,{asset:s}),e[0]=s,e[1]=n):n=e[1];let i;e[2]!==s.type?(i=s.type.replaceAll("_"," ").toUpperCase(),e[2]=s.type,e[3]=i):i=e[3];let a;e[4]!==i?(a=t.jsx("strong",{children:i}),e[4]=i,e[5]=a):a=e[5];let o;e[6]!==s.duration||e[7]!==s.height||e[8]!==s.width?(o=t.jsx(ld,{className:"inspector-dolt-artifact-metadata",width:s.width,height:s.height,durationSeconds:s.duration}),e[6]=s.duration,e[7]=s.height,e[8]=s.width,e[9]=o):o=e[9];let r;e[10]!==a||e[11]!==o?(r=t.jsxs("div",{className:"inspector-dolt-artifact-facts",children:[a,o]}),e[10]=a,e[11]=o,e[12]=r):r=e[12];let c;e[13]!==s.mediaUrl?(c=s.mediaUrl&&t.jsx("a",{href:s.mediaUrl,target:"_blank",rel:"noreferrer",children:"Open media"}),e[13]=s.mediaUrl,e[14]=c):c=e[14];let d;return e[15]!==n||e[16]!==r||e[17]!==c?(d=t.jsxs("div",{className:"inspector-dolt-artifact",children:[n,r,c]}),e[15]=n,e[16]=r,e[17]=c,e[18]=d):d=e[18],d}function hd(l){const e=Y.c(11),{notebookId:s,cell:n,artifactAssets:i}=l,a=ri(s,n);let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[0]=o):o=e[0];const[r,c]=C.useState(o);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=x=>{c(j=>{const v=new Set(j);return v.has(x)?v.delete(x):v.add(x),v})},e[1]=d):d=e[1];const u=d,f="inspector-dolt-table",m="Raw Dolt cells row";let b;e[2]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Column"}),t.jsx("th",{children:"Type"}),t.jsx("th",{children:"Raw value"})]})}),e[2]=b):b=e[2];let p;e[3]!==i||e[4]!==r?(p=x=>{const j=cr(x);if(j.kind==="json")return t.jsxs(C.Fragment,{children:[t.jsxs("tr",{className:"inspector-dolt-json-meta",children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsx("code",{className:"dolt-json-kind",children:"JSON"})})]}),t.jsx("tr",{className:"inspector-dolt-json-value",children:t.jsx("td",{colSpan:3,children:t.jsx(Xn,{value:j.value,ariaLabel:`${x.column} JSON`,artifactAssets:i})})})]},x.column);const v=j.kind==="raw"&&typeof j.value=="string"?i.get(j.value):void 0;if(v){const k=r.has(x.column);return t.jsxs(C.Fragment,{children:[t.jsxs("tr",{className:k?"inspector-dolt-artifact-meta":void 0,children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsxs("button",{type:"button",className:"inspector-dolt-artifact-toggle","aria-expanded":k,onClick:()=>u(x.column),children:[t.jsx("code",{children:v.artifactId}),t.jsx(Ns,{size:12,"aria-hidden":"true"})]})})]}),k&&t.jsx("tr",{className:"inspector-dolt-artifact-value",children:t.jsx("td",{colSpan:3,children:t.jsx(pd,{asset:v})})})]},x.column)}return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:x.column}),t.jsx("td",{children:x.type}),t.jsx("td",{children:t.jsx("code",{className:j.kind==="null"?"dolt-null":void 0,children:j.kind==="null"?"NULL":String(j.value)})})]},x.column)},e[3]=i,e[4]=r,e[5]=p):p=e[5];const g=a.map(p);let h;e[6]!==g?(h=t.jsx("tbody",{children:g}),e[6]=g,e[7]=h):h=e[7];let y;return e[8]!==b||e[9]!==h?(y=t.jsxs("table",{className:f,"aria-label":m,children:[b,h]}),e[8]=b,e[9]=h,e[10]=y):y=e[10],y}function Q1(l){const e=Y.c(13),{notebookId:s,cell:n,artifactAssets:i,heading:a}=l,o=a===void 0?!0:a;let r;e[0]!==i||e[1]!==n||e[2]!==s?(r=t.jsx(hd,{notebookId:s,cell:n,artifactAssets:i}),e[0]=i,e[1]=n,e[2]=s,e[3]=r):r=e[3];const c=r;if(!o)return c;let d;e[4]!==n||e[5]!==s?(d=ri(s,n),e[4]=n,e[5]=s,e[6]=d):d=e[6];const u=d.length;let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("span",{children:"Dolt source"}),e[7]=f):f=e[7];let m;e[8]!==u?(m=t.jsxs("header",{className:"inspector-source-meta",children:[f,t.jsxs("code",{children:["cells · ",u," columns"]})]}),e[8]=u,e[9]=m):m=e[9];let b;return e[10]!==m||e[11]!==c?(b=t.jsxs("section",{className:"inspector-source inspector-dolt-source",children:[m,c]}),e[10]=m,e[11]=c,e[12]=b):b=e[12],b}const zl=new WeakMap;function bd(l,e,s){const n=zl.get(l)??new Map;zl.set(l,n);const i=n.get(s);if(i)return i;const a=l(e).then(o=>({ok:!0,inspection:o}),o=>({ok:!1,message:o instanceof Error?o.message:String(o)}));return n.set(s,a),a}function Hi(l){if(!l)return null;const e=Date.parse(l);return Number.isFinite(e)?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):null}function kn(l){return l.length>14?`${l.slice(0,8)}…${l.slice(-4)}`:l}function Ki(l){const e=Y.c(8),{text:s,label:n}=l,[i,a]=C.useState(!1);let o;e[0]!==s?(o=()=>{navigator.clipboard.writeText(s).then(()=>{a(!0),window.setTimeout(()=>a(!1),1500)})},e[0]=s,e[1]=o):o=e[1];let r;e[2]!==i?(r=i?t.jsx(Jt,{size:12,"aria-hidden":"true"}):t.jsx(Gs,{size:12,"aria-hidden":"true"}),e[2]=i,e[3]=r):r=e[3];let c;return e[4]!==n||e[5]!==o||e[6]!==r?(c=t.jsx("button",{type:"button",className:"inspector-generating-copy","aria-label":n,title:n,onClick:o,children:r}),e[4]=n,e[5]=o,e[6]=r,e[7]=c):c=e[7],c}function xd(l){const e=Y.c(12),{step:s,submittedAt:n}=l,i=fr(s.id==="generating"&&s.status==="active"?n:null);if(i!==null){let d;e[0]!==i?(d=Bt(i),e[0]=i,e[1]=d):d=e[1];let u;return e[2]!==d?(u=t.jsxs("span",{children:[d," so far"]}),e[2]=d,e[3]=u):u=e[3],u}let a;e[4]!==s.at||e[5]!==s.id?(a=s.id==="generating"?null:Hi(s.at),e[4]=s.at,e[5]=s.id,e[6]=a):a=e[6];const o=a;if(o){const d=s.at??void 0;let u;return e[7]!==d||e[8]!==o?(u=t.jsx("time",{dateTime:d,children:o}),e[7]=d,e[8]=o,e[9]=u):u=e[9],u}const r=s.status==="pending"?"pending":s.status;let c;return e[10]!==r?(c=t.jsx("span",{children:r}),e[10]=r,e[11]=c):c=e[11],c}function gd(l){const e=Y.c(17),{facts:s,inspection:n}=l;let i,a,o,r;if(e[0]!==s.runKind||e[1]!==s.startedAt||e[2]!==n?.task){const u=ur({runKind:s.runKind,startedAt:s.startedAt,task:n?.task??null});o="inspector-generating-section",e[7]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx("span",{className:"inspector-media-field-label",children:"Timeline"}),e[7]=r):r=e[7],i="inspector-generating-timeline";let f;e[8]!==n?.task?.submittedAt?(f=m=>t.jsxs("li",{"data-status":m.status,children:[t.jsx("span",{className:"inspector-generating-timeline-bar","aria-hidden":"true"}),t.jsx("strong",{children:m.label}),t.jsx(xd,{step:m,submittedAt:n?.task?.submittedAt??null})]},m.id),e[8]=n?.task?.submittedAt,e[9]=f):f=e[9],a=u.map(f),e[0]=s.runKind,e[1]=s.startedAt,e[2]=n?.task,e[3]=i,e[4]=a,e[5]=o,e[6]=r}else i=e[3],a=e[4],o=e[5],r=e[6];let c;e[10]!==i||e[11]!==a?(c=t.jsx("ol",{className:i,children:a}),e[10]=i,e[11]=a,e[12]=c):c=e[12];let d;return e[13]!==o||e[14]!==r||e[15]!==c?(d=t.jsxs("div",{className:o,children:[r,c]}),e[13]=o,e[14]=r,e[15]=c,e[16]=d):d=e[16],d}function yd(l,e){const n=(e?.payload&&typeof e.payload=="object"&&typeof e.payload.model=="string"?e.payload.model:null)??l.model,i=e?.task??null;return[{label:"Provider · model",value:[l.provider,n].filter(Boolean).join(" · ")||"—"},e?.taskType?{label:"Task type",value:e.taskType}:null,i&&!e?.providerTask?{label:"Provider task",value:kn(i.taskId),title:i.taskId,copy:i.taskId}:null,l.runId?{label:"Run",value:kn(l.runId),title:l.runId,copy:l.runId}:null,l.jobNumber!==null?{label:"Job",value:`#${l.jobNumber}`}:null,l.providerArtifactId?{label:"Request artifact",value:kn(l.providerArtifactId),title:l.providerArtifactId,copy:l.providerArtifactId}:null].filter(o=>o!==null)}function jd(l){const e=Y.c(8),{facts:s,inspection:n}=l;let i;if(e[0]!==s||e[1]!==n){const a=mr(n?.payload??null);let o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"inspector-media-field-label",children:"Run"}),e[3]=o):o=e[3];const r=yd(s,n).map(kd);let c;e[4]!==r?(c=t.jsx("dl",{className:"inspector-generating-facts",children:r}),e[4]=r,e[5]=c):c=e[5];let d;e[6]!==n?(d=n?.providerTask&&t.jsx(Jc,{task:n.providerTask}),e[6]=n,e[7]=d):d=e[7],i=t.jsxs("div",{className:"inspector-generating-section",children:[o,c,d,a.length>0&&t.jsx("ul",{className:"inspector-generating-settings","aria-label":"Request settings",children:a.map(vd)})]}),e[0]=s,e[1]=n,e[2]=i}else i=e[2];return i}function vd(l){return t.jsxs("li",{children:[t.jsx("span",{children:l.key.replace(/_/g," ")})," ",l.value]},l.key)}function kd(l){return t.jsxs("div",{children:[t.jsx("dt",{children:l.label}),t.jsxs("dd",{title:l.title,children:[t.jsx("span",{children:l.value}),l.copy&&t.jsx(Ki,{text:l.copy,label:`Copy ${l.label.toLowerCase()}`})]})]},l.label)}function Sd(l){const e=Y.c(11),{written:s,sent:n}=l,[i,a]=C.useState(!1),o=!!(s&&n&&s!==n),r=(i&&o?n:s??n)??"";if(!r)return null;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("span",{className:"inspector-media-field-label",children:"Prompt"}),e[0]=c):c=e[0];let d;e[1]!==o||e[2]!==i?(d=o&&t.jsxs("div",{className:"inspector-generating-toggle",role:"group","aria-label":"Prompt version",children:[t.jsx("button",{type:"button","aria-pressed":!i,onClick:()=>a(!1),children:"As written"}),t.jsx("button",{type:"button","aria-pressed":i,onClick:()=>a(!0),children:"As sent"})]}),e[1]=o,e[2]=i,e[3]=d):d=e[3];let u;e[4]!==d?(u=t.jsxs("div",{className:"inspector-generating-prompt-head",children:[c,d]}),e[4]=d,e[5]=u):u=e[5];let f;e[6]!==r?(f=t.jsx("blockquote",{children:r}),e[6]=r,e[7]=f):f=e[7];let m;return e[8]!==u||e[9]!==f?(m=t.jsxs("div",{className:"inspector-generating-section inspector-media-generating-prompt",children:[u,f]}),e[8]=u,e[9]=f,e[10]=m):m=e[10],m}function wd(l,e){return e&&!e.ok?e.message:e?.ok&&e.inspection.errorMessage?e.inspection.errorMessage:l.runKind==="queued"?"The request is recorded once the run submits it to the provider.":"No provider request was recorded for this run."}function Nd(l){const e=Y.c(28),{facts:s,outcome:n,loading:i,artifactAssets:a,onRefresh:o}=l,r=n?.ok?n.inspection:null,c=r?.payload??null,d=r?.task?.submittedAt??null;let u;e[0]!==d?(u=Hi(d),e[0]=d,e[1]=u):u=e[1];const f=u;let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("span",{className:"inspector-media-field-label",children:"Request payload"}),e[2]=m):m=e[2];let b;e[3]!==r?(b=r?.taskType&&t.jsx("code",{children:r.taskType}),e[3]=r,e[4]=b):b=e[4];let p;e[5]!==f?(p=f&&t.jsxs("span",{className:"inspector-generating-muted",children:["sent ",f]}),e[5]=f,e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("span",{className:"inspector-generating-spacer"}),e[7]=g):g=e[7];let h;e[8]!==i||e[9]!==o?(h=o&&t.jsx("button",{type:"button",className:"inspector-generating-copy","aria-label":"Reload request payload",title:"Reload request payload",disabled:i,onClick:o,children:t.jsx(Bn,{size:12,"aria-hidden":"true"})}),e[8]=i,e[9]=o,e[10]=h):h=e[10];let y;e[11]!==c?(y=c!==null&&t.jsx(Ki,{text:JSON.stringify(c,null,2),label:"Copy request JSON"}),e[11]=c,e[12]=y):y=e[12];let x;e[13]!==b||e[14]!==p||e[15]!==h||e[16]!==y?(x=t.jsxs("header",{className:"inspector-generating-payload-head",children:[m,b,p,g,h,y]}),e[13]=b,e[14]=p,e[15]=h,e[16]=y,e[17]=x):x=e[17];let j;e[18]!==a||e[19]!==s||e[20]!==i||e[21]!==n||e[22]!==c?(j=c!==null?t.jsx("div",{className:"inspector-generating-payload-scroll",tabIndex:0,children:t.jsx(Xn,{value:c,ariaLabel:"Provider request payload",artifactAssets:a,mediaDisplay:"preview",remoteMedia:!0})}):t.jsx("p",{className:"inspector-analysis-json-status",role:"status",children:i?"Loading request payload…":wd(s,n)}),e[18]=a,e[19]=s,e[20]=i,e[21]=n,e[22]=c,e[23]=j):j=e[23];let v;return e[24]!==i||e[25]!==j||e[26]!==x?(v=t.jsxs("aside",{className:"inspector-generating-payload","aria-busy":i,children:[x,j]}),e[24]=i,e[25]=j,e[26]=x,e[27]=v):v=e[27],v}function En(l){const e=Y.c(24),{facts:s,header:n,footer:i,artifactAssets:a,outcome:o,loading:r,onRefresh:c}=l,d=o?.ok?o.inspection:null;let u,f;e[0]!==s||e[1]!==d?(u=t.jsx(gd,{facts:s,inspection:d}),f=t.jsx(jd,{facts:s,inspection:d}),e[0]=s,e[1]=d,e[2]=u,e[3]=f):(u=e[2],f=e[3]);const m=s.writtenPrompt,b=d?.payload??null;let p;e[4]!==b?(p=dr(b),e[4]=b,e[5]=p):p=e[5];let g;e[6]!==s.writtenPrompt||e[7]!==p?(g=t.jsx(Sd,{written:m,sent:p}),e[6]=s.writtenPrompt,e[7]=p,e[8]=g):g=e[8];let h;e[9]!==i||e[10]!==n||e[11]!==u||e[12]!==f||e[13]!==g?(h=t.jsxs("div",{className:"inspector-media-generating-summary",children:[n,u,f,g,i]}),e[9]=i,e[10]=n,e[11]=u,e[12]=f,e[13]=g,e[14]=h):h=e[14];let y;e[15]!==a||e[16]!==s||e[17]!==r||e[18]!==c||e[19]!==o?(y=t.jsx(Nd,{facts:s,outcome:o,loading:r,artifactAssets:a,onRefresh:c}),e[15]=a,e[16]=s,e[17]=r,e[18]=c,e[19]=o,e[20]=y):y=e[20];let x;return e[21]!==h||e[22]!==y?(x=t.jsxs(t.Fragment,{children:[h,y]}),e[21]=h,e[22]=y,e[23]=x):x=e[23],x}function Cd(l){const e=Y.c(6);let s,n;e[0]!==l?({promise:s,...n}=l,e[0]=l,e[1]=s,e[2]=n):(s=e[1],n=e[2]);const i=C.use(s);let a;return e[3]!==i||e[4]!==n?(a=t.jsx(En,{...n,outcome:i,loading:!1}),e[3]=i,e[4]=n,e[5]=a):a=e[5],a}function Z1(l){const e=Y.c(12),{inspect:s,...n}=l,[i,a]=C.useState(0),o=n.facts.providerArtifactId;if(!s||!o)return t.jsx(En,{...n,outcome:null,loading:!1});const r=bd(s,o,`${o}:${n.facts.runKind}:${i}`);let c;e[0]!==a?(c=()=>C.startTransition(()=>a($d)),e[0]=a,e[1]=c):c=e[1];const d=c;let u;e[2]!==d||e[3]!==n?(u=t.jsx(En,{...n,outcome:null,loading:!0,onRefresh:d}),e[2]=d,e[3]=n,e[4]=u):u=e[4];let f;e[5]!==d||e[6]!==r||e[7]!==n?(f=t.jsx(Cd,{...n,promise:r,onRefresh:d}),e[5]=d,e[6]=r,e[7]=n,e[8]=f):f=e[8];let m;return e[9]!==u||e[10]!==f?(m=t.jsx(C.Suspense,{fallback:u,children:f}),e[9]=u,e[10]=f,e[11]=m):m=e[11],m}function $d(l){return l+1}function Xs(l){return`${typeof l}:${String(l)}`}function ef(l){const e=Y.c(67),{control:s,settings:n,busy:i,onFocus:a,onChange:o,toggleClassName:r,booleanLabelFirst:c,labelAsSpan:d}=l,u=c===void 0?!0:c,f=d===void 0?!0:d,m=n[s.name];let b;e[0]!==s||e[1]!==n?(b=pr(s,n),e[0]=s,e[1]=n,e[2]=b):b=e[2];const p=b;if(s.kind==="boolean"){let S;e[3]!==s.label?(S=t.jsx("span",{children:s.label}),e[3]=s.label,e[4]=S):S=e[4];const M=S,N=u&&M,$=p===!0;let R;e[5]!==o?(R=D=>o(D.target.checked),e[5]=o,e[6]=R):R=e[6];let I;e[7]!==i||e[8]!==a||e[9]!==$||e[10]!==R?(I=t.jsx("input",{type:"checkbox",role:"switch",checked:$,disabled:i,onFocus:a,onChange:R}),e[7]=i,e[8]=a,e[9]=$,e[10]=R,e[11]=I):I=e[11];const P=!u&&M;let T;return e[12]!==s.description||e[13]!==N||e[14]!==I||e[15]!==P||e[16]!==r?(T=t.jsxs("label",{className:r,title:s.description,children:[N,I,P]}),e[12]=s.description,e[13]=N,e[14]=I,e[15]=P,e[16]=r,e[17]=T):T=e[17],T}let g;e[18]!==s.label||e[19]!==f?(g=f?t.jsx("span",{children:s.label}):s.label,e[18]=s.label,e[19]=f,e[20]=g):g=e[20];const h=g;if(s.kind==="select"){let S;e[21]!==m?(S=m===void 0?"":Xs(m),e[21]=m,e[22]=S):S=e[22];const M=S;let N;e[23]!==s.options||e[24]!==m?(N=m!==void 0&&!s.options.some(_=>_===m),e[23]=s.options,e[24]=m,e[25]=N):N=e[25];const $=N,R=s.description,I=s.label;let P;e[26]!==s.options||e[27]!==o?(P=_=>{const L=s.options.find(B=>Xs(B)===_.target.value);o(L)},e[26]=s.options,e[27]=o,e[28]=P):P=e[28];const T=s.defaultValue===void 0?s.required?"Select…":"Auto":`Default · ${String(s.defaultValue)}`;let D;e[29]!==T?(D=t.jsx("option",{value:"",children:T}),e[29]=T,e[30]=D):D=e[30];let A;e[31]!==M||e[32]!==m||e[33]!==$?(A=$&&t.jsxs("option",{value:M,children:[String(m)," · incompatible"]}),e[31]=M,e[32]=m,e[33]=$,e[34]=A):A=e[34];let F;e[35]!==s.options?(F=s.options.map(Id),e[35]=s.options,e[36]=F):F=e[36];let E;e[37]!==i||e[38]!==s.label||e[39]!==M||e[40]!==a||e[41]!==D||e[42]!==A||e[43]!==F||e[44]!==P?(E=t.jsxs("select",{"aria-label":I,value:M,disabled:i,onFocus:a,onChange:P,children:[D,A,F]}),e[37]=i,e[38]=s.label,e[39]=M,e[40]=a,e[41]=D,e[42]=A,e[43]=F,e[44]=P,e[45]=E):E=e[45];let z;return e[46]!==s.description||e[47]!==h||e[48]!==E?(z=t.jsxs("label",{title:R,children:[h,E]}),e[46]=s.description,e[47]=h,e[48]=E,e[49]=z):z=e[49],z}const y=s.kind==="number"?"number":"text",x=s.kind==="number"?"any":void 0,j=p===void 0?"":String(p);let v;e[50]!==s.kind||e[51]!==o?(v=S=>{const M=S.target.value;if(!M){o(void 0);return}const N=Number(M);o(s.kind==="number"?Number.isFinite(N)?N:void 0:M)},e[50]=s.kind,e[51]=o,e[52]=v):v=e[52];let k;e[53]!==i||e[54]!==s.label||e[55]!==s.maximum||e[56]!==s.minimum||e[57]!==a||e[58]!==y||e[59]!==x||e[60]!==j||e[61]!==v?(k=t.jsx("input",{type:y,"aria-label":s.label,min:s.minimum,max:s.maximum,step:x,value:j,disabled:i,onFocus:a,onChange:v}),e[53]=i,e[54]=s.label,e[55]=s.maximum,e[56]=s.minimum,e[57]=a,e[58]=y,e[59]=x,e[60]=j,e[61]=v,e[62]=k):k=e[62];let w;return e[63]!==s.description||e[64]!==h||e[65]!==k?(w=t.jsxs("label",{title:s.description,children:[h,k]}),e[63]=s.description,e[64]=h,e[65]=k,e[66]=w):w=e[66],w}function Id(l){return t.jsx("option",{value:Xs(l),children:String(l)},Xs(l))}const Vi=[{name:"start_time",label:"Replace from",hint:"Keep the original before this point."},{name:"resume_time",label:"Resume original at",hint:"Keep the original after this point."},{name:"duration",label:"New scene length",hint:"Generate 5–13 seconds of new footage."}];function gt(l){return`${Number(l.toFixed(3))}s`}function Os(l,e){const s=l[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0}function ms(l){const e=Y.c(12),{length:s,title:n,kind:i}=l;if(s<=0)return null;const a=`insert-video-segment ${i}`;let o;e[0]!==s?(o={flexGrow:s},e[0]=s,e[1]=o):o=e[1];let r;e[2]!==i||e[3]!==s?(r=i==="new"?`New · ${gt(s)}`:gt(s),e[2]=i,e[3]=s,e[4]=r):r=e[4];let c;e[5]!==r?(c=t.jsx("span",{children:r}),e[5]=r,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==o||e[9]!==c||e[10]!==n?(d=t.jsx("span",{className:a,style:o,title:n,children:c}),e[7]=a,e[8]=o,e[9]=c,e[10]=n,e[11]=d):d=e[11],d}function tf(l){const e=Y.c(9),{sources:s,settings:n,controls:i,busy:a,onChange:o}=l;let r;e[0]!==s?(r=oi(s),e[0]=s,e[1]=r):r=e[1];const c=r,d=c?.asset?.mediaUrl??c?.cellId??"empty";let u;return e[2]!==a||e[3]!==i||e[4]!==o||e[5]!==n||e[6]!==s||e[7]!==d?(u=t.jsx(Rd,{sources:s,settings:n,controls:i,busy:a,onChange:o},d),e[2]=a,e[3]=i,e[4]=o,e[5]=n,e[6]=s,e[7]=d,e[8]=u):u=e[8],u}function Rd(l){const e=Y.c(45),{sources:s,settings:n,controls:i,busy:a,onChange:o}=l,r=oi(s),c=C.useRef(null),[d,u]=C.useState(0),[f,m]=C.useState(!1),b=C.useId(),p=r?.asset?.duration??0,g=Os(n,"start_time"),h=Os(n,"resume_time"),y=Os(n,"duration")??Number(i.find(Pd)?.defaultValue??5);let x;if(e[0]!==i||e[1]!==n||e[2]!==s){const X=i.flatMap(Md);x=hr("fal:minimax/h3-max/insert-video",n,s)??br(X,n),e[0]=i,e[1]=n,e[2]=s,e[3]=x}else x=e[3];const j=x,v=!j&&g!==void 0&&h!==void 0,k=v?g+y+p-h:null,w=Math.max(p,k??0);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=X=>{!c.current||!Number.isFinite(c.current.duration)||(c.current.currentTime=Math.max(0,Math.min(X,c.current.duration)))},e[4]=S):S=e[4];const M=S;let N;e[5]!==o?(N=(X,le)=>{o(X,le),le!==void 0&&X!=="duration"&&M(le)},e[5]=o,e[6]=N):N=e[6];const $=N,R="insert-video-editor",I="Insert scene timing";let P;e[7]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx("strong",{children:"Insert a new scene"}),e[7]=P):P=e[7];const T=r?`Original @${r.address} · ${p>0?gt(p):"duration unavailable"}`:"Choose an original video";let D;e[8]!==T?(D=t.jsxs("header",{children:[P,t.jsx("span",{children:T})]}),e[8]=T,e[9]=D):D=e[9];let A;e[10]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx("p",{children:"Replace a section while keeping the original footage before and after it."}),e[10]=A):A=e[10];const F=r?.asset?.mediaUrl&&t.jsxs("div",{className:"insert-video-monitor",children:[t.jsx("video",{ref:c,src:r.asset.mediaUrl,poster:r.asset.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"metadata","aria-label":"Original video for insert",onTimeUpdate:X=>u(X.currentTarget.currentTime),onError:()=>m(!0)}),t.jsxs("div",{className:"insert-video-playhead",children:[t.jsxs("span",{children:["Scrub to a cut point · ",gt(d)]}),t.jsx("button",{type:"button",disabled:a||f||d<1.625||d>60||d>=p,onClick:()=>$("start_time",Number(d.toFixed(3))),children:"Replace from here"}),t.jsx("button",{type:"button",disabled:a||f||d<=(g??1.625)||d>60,onClick:()=>$("resume_time",Number(d.toFixed(3))),children:"Resume from here"})]})]});let E;e[11]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("strong",{children:"Original"}),e[11]=E):E=e[11];const z=p>0?gt(p):"—";let _;e[12]!==z?(_=t.jsxs("div",{className:"insert-video-track-heading",children:[E,t.jsxs("span",{children:["0s → ",z]})]}),e[12]=z,e[13]=_):_=e[13];const L=v?`Original: keep 0 to ${g}s, replace ${g} to ${h}s, keep ${h} to ${p}s`:"Original video: choose a valid replacement range",B=v?t.jsxs("div",{className:"insert-video-track-content",style:{width:`${p/w*100}%`},children:[t.jsx(ms,{kind:"kept",length:g,title:`Keep · ${gt(g)}`}),t.jsx(ms,{kind:"removed",length:h-g,title:`Replace · ${gt(h-g)}`}),t.jsx(ms,{kind:"kept",length:p-h,title:`Keep · ${gt(p-h)}`})]}):t.jsx("span",{className:"insert-video-track-empty",children:"Set the two cut points below"});let H;e[14]!==L||e[15]!==B?(H=t.jsx("div",{className:"insert-video-track",role:"img","aria-label":L,children:B}),e[14]=L,e[15]=B,e[16]=H):H=e[16];let q;e[17]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("strong",{children:"Result"}),e[17]=q):q=e[17];let U;e[18]!==k?(U=k===null?"Choose a valid range":`${gt(k)} total`,e[18]=k,e[19]=U):U=e[19];let K;e[20]!==U?(K=t.jsxs("div",{className:"insert-video-track-heading",children:[q,t.jsx("span",{children:U})]}),e[20]=U,e[21]=K):K=e[21];const ee=k===null?"Result preview unavailable until timing is valid":`Result: ${g}s original opening, ${y}s new scene, ${gt(p-h)} original ending, ${gt(k)} total`,ne=v?t.jsxs("div",{className:"insert-video-track-content",style:{width:`${k/w*100}%`},children:[t.jsx(ms,{kind:"kept",length:g,title:`Opening · ${gt(g)}`}),t.jsx(ms,{kind:"new",length:y,title:`New scene · ${gt(y)}`}),t.jsx(ms,{kind:"kept",length:p-h,title:`Ending · ${gt(p-h)}`})]}):t.jsx("span",{className:"insert-video-track-empty",children:"Original opening → new scene → original ending"});let V;e[22]!==ee||e[23]!==ne?(V=t.jsx("div",{className:"insert-video-track",role:"img","aria-label":ee,children:ne}),e[22]=ee,e[23]=ne,e[24]=V):V=e[24];let re;e[25]===Symbol.for("react.memo_cache_sentinel")?(re=t.jsxs("div",{className:"insert-video-legend",children:[t.jsx("span",{className:"kept",children:"Original footage"}),t.jsx("span",{className:"removed",children:"Replaced section"}),t.jsx("span",{className:"new",children:"Generated scene"})]}),e[25]=re):re=e[25];let W;e[26]!==_||e[27]!==H||e[28]!==K||e[29]!==V?(W=t.jsxs("div",{className:"insert-video-tracks",children:[_,H,K,V,re]}),e[26]=_,e[27]=H,e[28]=K,e[29]=V,e[30]=W):W=e[30];let Z;e[31]!==F||e[32]!==W?(Z=t.jsxs("div",{className:"insert-video-visuals",children:[F,W]}),e[31]=F,e[32]=W,e[33]=Z):Z=e[33];let ie;e[34]!==f?(ie=f&&t.jsx("p",{role:"status",children:"Source playback is unavailable. You can still set the cut points below."}),e[34]=f,e[35]=ie):ie=e[35];const J=Vi.map(X=>{const le=i.find(ue=>ue.name===X.name),de=Os(n,X.name)??(X.name==="duration"?y:void 0),pe=X.name==="duration"?13:Math.min(60,p||60);return t.jsxs("div",{className:"insert-video-field",children:[t.jsx("label",{htmlFor:`${b}-${X.name}`,children:t.jsxs("span",{children:[X.label," ",t.jsx("small",{children:"(seconds)"})]})}),t.jsxs("div",{className:"insert-video-time-input",children:[t.jsx("input",{id:`${b}-${X.name}`,type:"number",step:"any",min:le?.minimum,max:pe,value:de??"",disabled:a,"aria-describedby":j?b:void 0,"aria-invalid":!!j,onChange:ue=>$(X.name,ue.target.value===""?void 0:ue.target.valueAsNumber)}),X.name!=="duration"&&t.jsx("button",{type:"button","aria-label":`View ${X.label.toLowerCase()} cut point`,disabled:a||de===void 0||de>p||f||!r?.asset?.mediaUrl,onClick:()=>M(de),children:"View"})]}),t.jsx("input",{type:"range","aria-label":`${X.label} slider`,min:X.name==="duration"?5:1.625,max:Math.max(X.name==="duration"?5:1.625,pe),step:"0.001",value:Math.min(pe,Math.max(X.name==="duration"?5:1.625,de??1.625)),disabled:a||X.name!=="duration"&&p<=1.625,onChange:ue=>$(X.name,ue.target.valueAsNumber)}),t.jsx("small",{children:X.hint})]},X.name)});let G;e[36]!==J?(G=t.jsx("div",{className:"insert-video-fields",children:J}),e[36]=J,e[37]=G):G=e[37];const ce=j?t.jsx("p",{className:"insert-video-error",id:b,role:"alert",children:j}):v&&t.jsxs("p",{className:"insert-video-summary",role:"status",children:["Replace ",gt(g),"–",gt(h)," of @",r?.address," with ",gt(y)," of new footage. Result: ",gt(k),"."]});let ae;return e[38]!==Z||e[39]!==ie||e[40]!==G||e[41]!==ce||e[42]!==D||e[43]!==A?(ae=t.jsxs("section",{className:R,"aria-label":I,children:[D,A,Z,ie,G,ce]}),e[38]=Z,e[39]=ie,e[40]=G,e[41]=ce,e[42]=D,e[43]=A,e[44]=ae):ae=e[44],ae}function Md(l){const e=Vi.find(s=>s.name===l.name);return e?[{...l,label:e.label}]:[]}function Pd(l){return l.name==="duration"}function Us(l){const e=Y.c(4),{active:s,label:n,onClick:i}=l;let a;return e[0]!==s||e[1]!==n||e[2]!==i?(a=t.jsx("button",{type:"button",className:"prompt-history-segment","aria-pressed":s,onClick:i,children:n}),e[0]=s,e[1]=n,e[2]=i,e[3]=a):a=e[3],a}function Td(l){const e=Y.c(35),{active:s,entry:n,now:i,pinned:a,showBook:o,onPin:r,onUse:c}=l,d=s||void 0;let u;e[0]!==n.prompt?(u=t.jsx("span",{className:"prompt-history-text",children:n.prompt}),e[0]=n.prompt,e[1]=u):u=e[1];let f;e[2]!==n.surface?(f=ci(n.surface),e[2]=n.surface,e[3]=f):f=e[3];let m;e[4]!==f?(m=t.jsx("span",{className:"prompt-history-surface",children:f}),e[4]=f,e[5]=m):m=e[5];let b;e[6]!==n.model?(b=n.model&&t.jsx("span",{children:n.model}),e[6]=n.model,e[7]=b):b=e[7];let p;e[8]!==n.book||e[9]!==o?(p=o&&n.book&&t.jsx("span",{className:"prompt-history-faint",children:n.book}),e[8]=n.book,e[9]=o,e[10]=p):p=e[10];let g;e[11]!==n.createdAt||e[12]!==i?(g=yr(n.createdAt,i),e[11]=n.createdAt,e[12]=i,e[13]=g):g=e[13];let h;e[14]!==g?(h=t.jsx("span",{className:"prompt-history-faint",children:g}),e[14]=g,e[15]=h):h=e[15];let y;e[16]!==m||e[17]!==b||e[18]!==p||e[19]!==h?(y=t.jsxs("span",{className:"prompt-history-meta",children:[m,b,p,h]}),e[16]=m,e[17]=b,e[18]=p,e[19]=h,e[20]=y):y=e[20];let x;e[21]!==c||e[22]!==u||e[23]!==y?(x=t.jsxs("button",{type:"button",className:"prompt-history-use",title:"Use this prompt",onClick:c,children:[u,y]}),e[21]=c,e[22]=u,e[23]=y,e[24]=x):x=e[24];const j=a?"Unpin prompt":"Pin prompt",v=a?"Unpin prompt":"Pin prompt";let k;e[25]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(Uo,{size:11,"aria-hidden":"true"}),e[25]=k):k=e[25];let w;e[26]!==r||e[27]!==a||e[28]!==j||e[29]!==v?(w=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-pressed":a,"aria-label":j,title:v,onClick:r,children:k}),e[26]=r,e[27]=a,e[28]=j,e[29]=v,e[30]=w):w=e[30];let S;return e[31]!==d||e[32]!==x||e[33]!==w?(S=t.jsxs("li",{className:"prompt-history-row","data-active":d,children:[x,w]}),e[31]=d,e[32]=x,e[33]=w,e[34]=S):S=e[34],S}function Ed(l){const e=Y.c(89),{history:s}=l,[n,i]=C.useState(0);let a,o,r,c,d,u,f,m,b;if(e[0]!==n||e[1]!==s){b=xr(gr(s.entries??[],s.query),s.pins);const N=Math.min(n,Math.max(0,b.length-1)),$=s.loadedAt;let R;e[11]!==s.surface?(R=ci(s.surface),e[11]=s.surface,e[12]=R):R=e[12];const I=R,P=ae=>{if(ae.key==="Escape"){ae.preventDefault(),ae.stopPropagation(),s.close();return}if(ae.key==="ArrowDown"||ae.key==="ArrowUp"){ae.preventDefault();const X=ae.key==="ArrowDown"?1:-1;i(Math.min(Math.max(N+X,0),Math.max(0,b.length-1)));return}if(ae.key==="Enter"&&ae.target instanceof HTMLInputElement){const X=b[N];if(!X)return;ae.preventDefault(),ae.stopPropagation(),s.use(X.prompt)}};c="prompt-history-popover",d="dialog",u="Prompt history",f=P;let T,D;e[13]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("span",{className:"confirm-section-label",children:"Prompt history"}),D=t.jsx("span",{className:"prompt-history-faint",children:"newest first"}),e[13]=T,e[14]=D):(T=e[13],D=e[14]);let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(dt,{size:10,"aria-hidden":"true"}),e[15]=A):A=e[15];let F;e[16]!==s.close?(F=t.jsxs("div",{className:"prompt-history-title",children:[T,D,t.jsx("button",{type:"button",className:"prompt-history-icon","aria-label":"Close history",onClick:s.close,children:A})]}),e[16]=s.close,e[17]=F):F=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(is,{size:11,"aria-hidden":"true"}),e[18]=E):E=e[18];let z;e[19]!==s?(z=ae=>{s.setQuery(ae.target.value),i(0)},e[19]=s,e[20]=z):z=e[20];let _;e[21]!==s.query||e[22]!==z?(_=t.jsxs("label",{className:"prompt-history-search",children:[E,t.jsx("input",{type:"search","aria-label":"Search prompts",placeholder:"Search prompts…",autoFocus:!0,value:s.query,onChange:z})]}),e[21]=s.query,e[22]=z,e[23]=_):_=e[23];const L=s.scope==="book";let B;e[24]!==s?(B=()=>s.setScope("book"),e[24]=s,e[25]=B):B=e[25];let H;e[26]!==L||e[27]!==B?(H=t.jsx(Us,{active:L,label:"This book",onClick:B}),e[26]=L,e[27]=B,e[28]=H):H=e[28];const q=s.scope==="library";let U;e[29]!==s?(U=()=>s.setScope("library"),e[29]=s,e[30]=U):U=e[30];let K;e[31]!==q||e[32]!==U?(K=t.jsx(Us,{active:q,label:"All books",onClick:U}),e[31]=q,e[32]=U,e[33]=K):K=e[33];let ee;e[34]!==H||e[35]!==K?(ee=t.jsxs("span",{className:"prompt-history-segments",role:"group","aria-label":"Scope",children:[H,K]}),e[34]=H,e[35]=K,e[36]=ee):ee=e[36];const ne=s.surfaceFilter==="surface";let V;e[37]!==s?(V=()=>s.setSurfaceFilter("surface"),e[37]=s,e[38]=V):V=e[38];let re;e[39]!==I||e[40]!==ne||e[41]!==V?(re=t.jsx(Us,{active:ne,label:I,onClick:V}),e[39]=I,e[40]=ne,e[41]=V,e[42]=re):re=e[42];const W=s.surfaceFilter==="all";let Z;e[43]!==s?(Z=()=>s.setSurfaceFilter("all"),e[43]=s,e[44]=Z):Z=e[44];let ie;e[45]!==W||e[46]!==Z?(ie=t.jsx(Us,{active:W,label:"All surfaces",onClick:Z}),e[45]=W,e[46]=Z,e[47]=ie):ie=e[47];let J;e[48]!==re||e[49]!==ie?(J=t.jsxs("span",{className:"prompt-history-segments",role:"group","aria-label":"Surface",children:[re,ie]}),e[48]=re,e[49]=ie,e[50]=J):J=e[50];let G;e[51]!==_||e[52]!==ee||e[53]!==J?(G=t.jsxs("div",{className:"prompt-history-filters",children:[_,ee,J]}),e[51]=_,e[52]=ee,e[53]=J,e[54]=G):G=e[54],e[55]!==F||e[56]!==G?(m=t.jsxs("div",{className:"prompt-history-head",children:[F,G]}),e[55]=F,e[56]=G,e[57]=m):m=e[57],a="prompt-history-list",o=s.loading;let ce;e[58]!==N||e[59]!==s||e[60]!==$?(ce=(ae,X)=>t.jsx(Td,{active:X===N,entry:ae,now:$,pinned:s.pins.has(ae.prompt),showBook:s.scope==="library",onPin:()=>s.togglePin(ae.prompt),onUse:()=>s.use(ae.prompt)},`${ae.book}:${ae.id}`),e[58]=N,e[59]=s,e[60]=$,e[61]=ce):ce=e[61],r=b.map(ce),e[0]=n,e[1]=s,e[2]=a,e[3]=o,e[4]=r,e[5]=c,e[6]=d,e[7]=u,e[8]=f,e[9]=m,e[10]=b}else a=e[2],o=e[3],r=e[4],c=e[5],d=e[6],u=e[7],f=e[8],m=e[9],b=e[10];let p;e[62]!==s.entries?.length||e[63]!==s.error||e[64]!==s.loading||e[65]!==b.length?(p=b.length===0&&t.jsx("li",{className:"prompt-history-empty",role:s.error?"alert":"status",children:s.error??(s.loading?"Loading prompts…":s.entries?.length?"No prompts match. Clear the search.":"No prompts yet. Widen the scope or generate something.")}),e[62]=s.entries?.length,e[63]=s.error,e[64]=s.loading,e[65]=b.length,e[66]=p):p=e[66];let g;e[67]!==a||e[68]!==o||e[69]!==r||e[70]!==p?(g=t.jsxs("ul",{className:a,"aria-busy":o,children:[r,p]}),e[67]=a,e[68]=o,e[69]=r,e[70]=p,e[71]=g):g=e[71];let h,y;e[72]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("kbd",{children:"↑"}),y=t.jsx("kbd",{children:"↓"}),e[72]=h,e[73]=y):(h=e[72],y=e[73]);let x;e[74]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("kbd",{children:"↵"}),e[74]=x):x=e[74];let j,v;e[75]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("kbd",{children:"⌥↑"}),v=t.jsx("kbd",{children:"⌥↓"}),e[75]=j,e[76]=v):(j=e[75],v=e[76]);let k;e[77]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsxs("span",{children:[h,y," move · ",x," use · ",j,v," step in the prompt · ",t.jsx("kbd",{children:"esc"})," close"]}),e[77]=k):k=e[77];const w=s.entries?.length??0;let S;e[78]!==w||e[79]!==b.length?(S=t.jsxs("div",{className:"prompt-history-foot",children:[k,t.jsxs("span",{children:[b.length," of ",w]})]}),e[78]=w,e[79]=b.length,e[80]=S):S=e[80];let M;return e[81]!==g||e[82]!==S||e[83]!==c||e[84]!==d||e[85]!==u||e[86]!==f||e[87]!==m?(M=t.jsxs("div",{className:c,role:d,"aria-label":u,onKeyDown:f,children:[m,g,S]}),e[81]=g,e[82]=S,e[83]=c,e[84]=d,e[85]=u,e[86]=f,e[87]=m,e[88]=M):M=e[88],M}function sf(l){const e=Y.c(33),{history:s,disabled:n}=l,a=(n===void 0?!1:n)||!s.available;let o;e[0]!==s?(o=w=>{if(!s.open)return;const S=w.relatedTarget;S instanceof Node&&w.currentTarget.contains(S)||s.close()},e[0]=s,e[1]=o):o=e[1];const r=o;let c;e[2]!==s.position||e[3]!==s.stepping?(c=s.stepping&&t.jsxs("span",{className:"prompt-history-status",role:"status",children:["History ",s.position," · esc restores draft"]}),e[2]=s.position,e[3]=s.stepping,e[4]=c):c=e[4];const d=a||!s.canOlder;let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Ys,{size:12,"aria-hidden":"true"}),e[5]=u):u=e[5];let f;e[6]!==s.older||e[7]!==d?(f=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-label":"Older prompt",title:"Older prompt (⌥↑)","aria-keyshortcuts":"Alt+ArrowUp",disabled:d,onClick:s.older,children:u}),e[6]=s.older,e[7]=d,e[8]=f):f=e[8];const m=a||!s.canNewer;let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(On,{size:12,"aria-hidden":"true"}),e[9]=b):b=e[9];let p;e[10]!==s.newer||e[11]!==m?(p=t.jsx("button",{type:"button",className:"prompt-history-icon","aria-label":"Newer prompt",title:"Newer prompt (⌥↓)","aria-keyshortcuts":"Alt+ArrowDown",disabled:m,onClick:s.newer,children:b}),e[10]=s.newer,e[11]=m,e[12]=p):p=e[12];let g;e[13]!==f||e[14]!==p?(g=t.jsxs("span",{className:"prompt-history-steppers",children:[f,p]}),e[13]=f,e[14]=p,e[15]=g):g=e[15];let h,y;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Un,{size:11,"aria-hidden":"true"}),y=t.jsx("span",{children:"History"}),e[16]=h,e[17]=y):(h=e[16],y=e[17]);let x;e[18]!==s.entries?(x=s.entries&&t.jsx("span",{className:"prompt-history-count",children:s.entries.length}),e[18]=s.entries,e[19]=x):x=e[19];let j;e[20]!==s.open||e[21]!==s.toggleOpen||e[22]!==a||e[23]!==x?(j=t.jsxs("button",{type:"button",className:"prompt-history-toggle","aria-expanded":s.open,"aria-haspopup":"dialog",disabled:a,onClick:s.toggleOpen,children:[h,y,x]}),e[20]=s.open,e[21]=s.toggleOpen,e[22]=a,e[23]=x,e[24]=j):j=e[24];let v;e[25]!==s?(v=s.open&&t.jsx(Ed,{history:s}),e[25]=s,e[26]=v):v=e[26];let k;return e[27]!==r||e[28]!==g||e[29]!==j||e[30]!==v||e[31]!==c?(k=t.jsxs("div",{className:"prompt-history-controls",onBlur:r,children:[c,g,j,v]}),e[27]=r,e[28]=g,e[29]=j,e[30]=v,e[31]=c,e[32]=k):k=e[32],k}function Ad(l){return l instanceof HTMLElement?{tagName:l.tagName,type:l instanceof HTMLInputElement?l.type:null}:null}function Dd(l){const e=Y.c(3),{sheetRef:s}=l;let n,i;return e[0]!==s?(n=()=>{s.current?.querySelector('[aria-invalid="true"]:not(:disabled)')?.focus({preventScroll:!0})},i=[s],e[0]=s,e[1]=n,e[2]=i):(n=e[1],i=e[2]),C.useLayoutEffect(n,i),null}function Fd(l){const e=Y.c(11),s=C.useRef(null),{applyDisabled:n,applyFormId:i,applyScopeSelector:a,busy:o,enabled:r,onCancel:c}=l,d=r===void 0?!0:r;let u,f;e[0]!==n||e[1]!==i||e[2]!==a||e[3]!==o||e[4]!==d||e[5]!==c?(u=()=>{if(!d)return;const b=p=>{if(p.defaultPrevented||p.isComposing||o||document.querySelector('dialog[open], :popover-open, [aria-modal="true"], [role="menu"], details.canvas-add-menu[open]'))return;const g=p.target;if(a&&p.key==="Enter"&&(p.metaKey||p.ctrlKey)&&!p.altKey){const h=document.getElementById(i);if(!(h instanceof HTMLFormElement)||!(g instanceof Node)||!h.closest(a)?.contains(g))return;p.preventDefault(),n||h.requestSubmit();return}p.key==="Escape"&&(g!==document.body&&(!(g instanceof Element)||!g.closest(".command-composer"))||g instanceof Element&&g.closest('input, textarea, select, [contenteditable="true"]')||(p.preventDefault(),c()))};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},f=[n,i,a,o,d,c],e[0]=n,e[1]=i,e[2]=a,e[3]=o,e[4]=d,e[5]=c,e[6]=u,e[7]=f):(u=e[6],f=e[7]),C.useLayoutEffect(u,f);let m;return e[8]!==d||e[9]!==l?(m={sheetRef:s,onKeyDown:p=>{if(!d||p.nativeEvent.isComposing||document.querySelector(":popover-open"))return;const g=jr({key:p.key,metaKey:p.metaKey,ctrlKey:p.ctrlKey,altKey:p.altKey,defaultPrevented:p.defaultPrevented,target:Ad(p.target)},{busy:l.busy});if(g==="none")return;if(p.preventDefault(),p.stopPropagation(),g==="cancel"){l.onCancel();return}if(l.applyDisabled)return;const h=document.getElementById(l.applyFormId);h instanceof HTMLFormElement&&h.requestSubmit()}},e[8]=d,e[9]=l,e[10]=m):m=e[10],m}function Gn(l){const e=Y.c(3),{href:s,children:n}=l;let i;return e[0]!==n||e[1]!==s?(i=t.jsx("a",{className:"published-post-link nodrag nopan",href:s,target:"_blank",rel:"noopener noreferrer",onClick:_d,children:n}),e[0]=n,e[1]=s,e[2]=i):i=e[2],i}function _d(l){return l.stopPropagation()}function Ld(l){const e=Y.c(14),{presentation:s}=l;let n;e[0]!==s.badge?(n=t.jsx("span",{className:"published-post-badge",children:s.badge}),e[0]=s.badge,e[1]=n):n=e[1];let i;e[2]!==s.tweetUrl?(i=t.jsx(Gn,{href:s.tweetUrl,children:s.tweetUrl}),e[2]=s.tweetUrl,e[3]=i):i=e[3];let a;e[4]!==s.postedAt||e[5]!==s.postedAtLabel?(a=t.jsx("time",{dateTime:s.postedAt,children:s.postedAtLabel}),e[4]=s.postedAt,e[5]=s.postedAtLabel,e[6]=a):a=e[6];let o;e[7]!==s.replyLabel?(o=t.jsx("span",{children:s.replyLabel}),e[7]=s.replyLabel,e[8]=o):o=e[8];let r;return e[9]!==n||e[10]!==i||e[11]!==a||e[12]!==o?(r=t.jsxs(t.Fragment,{children:[n,i,a,o]}),e[9]=n,e[10]=i,e[11]=a,e[12]=o,e[13]=r):r=e[13],r}function zd(l){const e=Y.c(7),{inputs:s}=l;let n;e[0]!==s?(n=di(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i)return null;let a;e[2]!==i?(a=t.jsx(Ld,{presentation:i}),e[2]=i,e[3]=a):a=e[3];let o;return e[4]!==i.badge||e[5]!==a?(o=t.jsx("div",{className:"cell-published-post",role:"group","aria-label":i.badge,children:a}),e[4]=i.badge,e[5]=a,e[6]=o):o=e[6],o}function nf(l){const e=Y.c(24),{inputs:s}=l;let n,i,a,o,r,c,d,u,f;if(e[0]!==s){f=Symbol.for("react.early_return_sentinel");e:{if(n=di(s),!n){f=null;break e}i="inspector-published-post",a=n.badge,o=t.jsx("span",{className:"inspector-media-field-label",children:n.badge});let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx("span",{children:"Root"}),e[10]=p):p=e[10],r=t.jsxs("p",{children:[p,t.jsx(Gn,{href:n.tweetUrl,children:n.tweetUrl})]});let g;e[11]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("span",{children:"Posted"}),e[11]=g):g=e[11],c=t.jsxs("p",{children:[g,t.jsx("time",{dateTime:n.postedAt,children:n.postedAtLabel})]});let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx("span",{children:"Replies"}),e[12]=h):h=e[12],d=t.jsxs("p",{children:[h,t.jsx("span",{children:n.replyLabel})]}),u=n.replies.map(Bd)}e[0]=s,e[1]=n,e[2]=i,e[3]=a,e[4]=o,e[5]=r,e[6]=c,e[7]=d,e[8]=u,e[9]=f}else n=e[1],i=e[2],a=e[3],o=e[4],r=e[5],c=e[6],d=e[7],u=e[8],f=e[9];if(f!==Symbol.for("react.early_return_sentinel"))return f;let m;e[13]!==n.followupError?(m=n.followupError&&t.jsxs("p",{className:"inspector-published-post-error",children:["Follow-up ",n.followupError.replyNumber," failed: ",n.followupError.message]}),e[13]=n.followupError,e[14]=m):m=e[14];let b;return e[15]!==i||e[16]!==a||e[17]!==o||e[18]!==r||e[19]!==c||e[20]!==d||e[21]!==u||e[22]!==m?(b=t.jsxs("section",{className:i,"aria-label":a,children:[o,r,c,d,u,m]}),e[15]=i,e[16]=a,e[17]=o,e[18]=r,e[19]=c,e[20]=d,e[21]=u,e[22]=m,e[23]=b):b=e[23],b}function Bd(l,e){return t.jsxs("p",{children:[t.jsxs("span",{children:["Reply ",e+1]}),t.jsx(Gn,{href:l.tweetUrl,children:l.tweetUrl})]},l.tweetId)}function Od(l){return l==="copied"?"Copied":l==="failed"?"Retry":"Copy"}function Ud(l){const e=Y.c(3),{text:s,label:n}=l;let i;return e[0]!==n||e[1]!==s?(i=t.jsx("pre",{className:"inspector-transcript-text",tabIndex:0,"aria-label":n,children:s}),e[0]=n,e[1]=s,e[2]=i):i=e[2],i}function Hd(l){const e=Y.c(6),{label:s,running:n,disabled:i,onClick:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(Ni,{size:12,"aria-hidden":"true"}),e[0]=o):o=e[0];let r;return e[1]!==i||e[2]!==s||e[3]!==a||e[4]!==n?(r=t.jsx("button",{type:"button",className:"inspector-insight-rerun","aria-label":s,title:s,"aria-busy":n,disabled:i,onClick:a,children:o}),e[1]=i,e[2]=s,e[3]=a,e[4]=n,e[5]=r):r=e[5],r}function Kd(l){const e=Y.c(8),{icon:s,label:n,runningLabel:i,running:a,disabled:o,onClick:r}=l,c=a?i:n;let d;e[0]!==c?(d=t.jsx("span",{children:c}),e[0]=c,e[1]=d):d=e[1];let u;return e[2]!==o||e[3]!==s||e[4]!==r||e[5]!==a||e[6]!==d?(u=t.jsxs("button",{type:"button",className:"inspector-insight-action","aria-busy":a,disabled:o,onClick:r,children:[s,d]}),e[2]=o,e[3]=s,e[4]=r,e[5]=a,e[6]=d,e[7]=u):u=e[7],u}function Bl(l){const e=Y.c(91),{source:s,title:n,transcript:i,busy:a,transcribing:o,onTranscribe:r,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d}=l,[u,f]=C.useState(null),[m,b]=C.useState("idle"),[p,g]=C.useState(null),[h,y]=C.useState(null),[x,j]=C.useState(null),[v,k]=C.useState(!1);let w,S,M,N,$,R,I,P,T;if(e[0]!==x||e[1]!==h||e[2]!==v||e[3]!==p||e[4]!==r||e[5]!==u||e[6]!==s||e[7]!==i){T=Rr(i,u);let fe;e[17]!==i?(fe=Sr(i),e[17]=i,e[18]=fe):fe=e[18],N=fe,R=s==="elevenlabs",P=s==="elevenlabs"?r:void 0;let xe;e[19]!==R||e[20]!==i?(xe=R&&wr(i),e[19]=R,e[20]=i,e[21]=xe):xe=e[21],S=xe,w=Nr({source:s,transcript:i,view:T,jsonText:p}),$=Cr({transcript:i,view:T,jsonFile:h}),M=$r({source:s,transcript:i,view:T,jsonText:p}),I=Ir({source:s,transcript:i,view:T,jsonLoading:v,jsonError:x,body:w}),e[0]=x,e[1]=h,e[2]=v,e[3]=p,e[4]=r,e[5]=u,e[6]=s,e[7]=i,e[8]=w,e[9]=S,e[10]=M,e[11]=N,e[12]=$,e[13]=R,e[14]=I,e[15]=P,e[16]=T}else w=e[8],S=e[9],M=e[10],N=e[11],$=e[12],R=e[13],I=e[14],P=e[15],T=e[16];const D=I,A=!!i,F=!!M;let E;e[22]!==M?(E=async()=>{if(M)try{await navigator.clipboard.writeText(M),b("copied")}catch{b("failed")}},e[22]=M,e[23]=E):E=e[23];const z=E;let _;e[24]!==A||e[25]!==v||e[26]!==p||e[27]!==c||e[28]!==s?(_=fe=>{fe==="json"&&!A||(f(fe),!(fe!=="json"||p!==null||v||!c)&&(k(!0),j(null),c(s).then(xe=>{g(xe.text),y(xe.file)}).catch(xe=>{j(xe instanceof Error?xe.message:String(xe))}).finally(()=>{k(!1)})))},e[24]=A,e[25]=v,e[26]=p,e[27]=c,e[28]=s,e[29]=_):_=e[29];const L=_;let B;e[30]!==n?(B=t.jsx("span",{className:"inspector-media-field-label",children:n}),e[30]=n,e[31]=B):B=e[31];let H;e[32]!==F||e[33]!==z||e[34]!==m||e[35]!==n?(H=F&&t.jsxs("button",{type:"button",className:`inspector-prompt-copy${m==="copied"?" copied":""}`,"aria-label":m==="copied"?`${n} copied`:`Copy ${n}`,title:m==="copied"?`${n} copied`:`Copy ${n}`,onClick:()=>{z()},children:[m==="copied"?t.jsx(Jt,{size:12,"aria-hidden":"true"}):t.jsx(Gs,{size:12,"aria-hidden":"true"}),t.jsx("span",{"aria-live":"polite",children:Od(m)})]}),e[32]=F,e[33]=z,e[34]=m,e[35]=n,e[36]=H):H=e[36];let q;e[37]!==a||e[38]!==S||e[39]!==d||e[40]!==R?(q=R&&t.jsxs("button",{type:"button",className:"inspector-prompt-copy","aria-label":S?"Download SRT":"Download SRT unavailable",title:S?"Download SRT":"No word-timed ElevenLabs transcript",disabled:!S||a||!d,onClick:()=>d?.(),children:[t.jsx(Js,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:"SRT"})]}),e[37]=a,e[38]=S,e[39]=d,e[40]=R,e[41]=q):q=e[41];let U;e[42]!==a||e[43]!==N||e[44]!==P||e[45]!==o?(U=P&&N&&t.jsx(Hd,{label:"Transcribe again",running:!!o,disabled:a||!!o,onClick:P}),e[42]=a,e[43]=N,e[44]=P,e[45]=o,e[46]=U):U=e[46];let K;e[47]!==H||e[48]!==q||e[49]!==U?(K=t.jsxs("div",{className:"inspector-insight-header-actions",children:[H,q,U]}),e[47]=H,e[48]=q,e[49]=U,e[50]=K):K=e[50];let ee;e[51]!==B||e[52]!==K?(ee=t.jsxs("header",{className:"inspector-insight-header",children:[B,K]}),e[51]=B,e[52]=K,e[53]=ee):ee=e[53];const ne=`${n} view`,V=T==="text",re=T==="text"?"inspector-transcript-tab active":"inspector-transcript-tab";let W;e[54]!==L?(W=()=>L("text"),e[54]=L,e[55]=W):W=e[55];let Z;e[56]!==V||e[57]!==re||e[58]!==W?(Z=t.jsx("button",{type:"button",role:"tab","aria-selected":V,className:re,onClick:W,children:"TEXT"}),e[56]=V,e[57]=re,e[58]=W,e[59]=Z):Z=e[59];const ie=T==="json",J=!A,G=!A,ce=A?"JSON":s==="plain"?"No GPT-4o translation":"No ElevenLabs transcript",ae=T==="json"?"inspector-transcript-tab active":"inspector-transcript-tab";let X;e[60]!==L?(X=()=>L("json"),e[60]=L,e[61]=X):X=e[61];let le;e[62]!==ie||e[63]!==J||e[64]!==G||e[65]!==ce||e[66]!==ae||e[67]!==X?(le=t.jsx("button",{type:"button",role:"tab","aria-selected":ie,"aria-disabled":J,disabled:G,title:ce,className:ae,onClick:X,children:"JSON"}),e[62]=ie,e[63]=J,e[64]=G,e[65]=ce,e[66]=ae,e[67]=X,e[68]=le):le=e[68];let de;e[69]!==ne||e[70]!==Z||e[71]!==le?(de=t.jsxs("div",{className:"inspector-transcript-tabs",role:"tablist","aria-label":ne,children:[Z,le]}),e[69]=ne,e[70]=Z,e[71]=le,e[72]=de):de=e[72];let pe;e[73]!==$?(pe=$&&t.jsx("p",{className:"inspector-insight-meta",children:$}),e[73]=$,e[74]=pe):pe=e[74];let ue;e[75]!==w||e[76]!==a||e[77]!==D||e[78]!==N||e[79]!==n||e[80]!==P||e[81]!==o||e[82]!==i||e[83]!==T?(ue=w&&!D?t.jsx(Ud,{text:w,label:`${n} ${T}`}):t.jsxs("div",{className:"inspector-insight-empty",children:[t.jsx("p",{children:D??"No transcript yet."}),P&&!N&&t.jsx(Kd,{icon:t.jsx(Ho,{size:13,"aria-hidden":"true"}),label:i?"Transcribe again":"Transcribe",runningLabel:"Transcribing…",running:!!o,disabled:a||!!o,onClick:P})]}),e[75]=w,e[76]=a,e[77]=D,e[78]=N,e[79]=n,e[80]=P,e[81]=o,e[82]=i,e[83]=T,e[84]=ue):ue=e[84];let me;return e[85]!==de||e[86]!==pe||e[87]!==ue||e[88]!==ee||e[89]!==n?(me=t.jsxs("section",{className:"inspector-insight-block","aria-label":n,children:[ee,de,pe,ue]}),e[85]=de,e[86]=pe,e[87]=ue,e[88]=ee,e[89]=n,e[90]=me):me=e[90],me}function lf(l){const e=Y.c(19),{artifactId:s,transcript:n,busy:i,transcribing:a,error:o,onTranscribe:r,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d}=l,u=`${s}:plain`,f=n?.plain??null;let m;e[0]!==i||e[1]!==c||e[2]!==u||e[3]!==f?(m=t.jsx(Bl,{source:"plain",title:vr,transcript:f,busy:i,onLoadTranscriptJson:c},u),e[0]=i,e[1]=c,e[2]=u,e[3]=f,e[4]=m):m=e[4];const b=`${s}:elevenlabs`,p=n?.elevenlabs??null;let g;e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==r||e[9]!==b||e[10]!==p||e[11]!==a?(g=t.jsx(Bl,{source:"elevenlabs",title:kr,transcript:p,busy:i,transcribing:a,onTranscribe:r,onLoadTranscriptJson:c,onDownloadTranscriptSrt:d},b),e[5]=i,e[6]=d,e[7]=c,e[8]=r,e[9]=b,e[10]=p,e[11]=a,e[12]=g):g=e[12];let h;e[13]!==o?(h=o&&t.jsxs("p",{className:"inspector-insight-error",role:"alert",children:[t.jsx(wi,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:o})]}),e[13]=o,e[14]=h):h=e[14];let y;return e[15]!==m||e[16]!==g||e[17]!==h?(y=t.jsxs("div",{className:"inspector-media-insights",children:[m,g,h]}),e[15]=m,e[16]=g,e[17]=h,e[18]=y):y=e[18],y}function af(l){const e=Y.c(33),{bookId:s,artifactId:n,kind:i,busy:a,call:o}=l;let r;e[0]!==n||e[1]!==s||e[2]!==o?(r={call:o,bookId:s,artifactId:n},e[0]=n,e[1]=s,e[2]=o,e[3]=r):r=e[3];const{state:c,available:d,run:u}=Mr(r),f=c.phase==="running",m=a||!d||f,b=f&&c.action==="copy";let p;e[4]!==u?(p=()=>{u("copy")},e[4]=u,e[5]=p):p=e[5];let g;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Ci,{size:13,"aria-hidden":"true"}),e[6]=g):g=e[6];const h=f&&c.action==="copy"?"Copying…":`Copy ${i}`;let y;e[7]!==m||e[8]!==b||e[9]!==p||e[10]!==h?(y=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":b,title:"Copy the original media file to the clipboard",onClick:p,children:[g,h]}),e[7]=m,e[8]=b,e[9]=p,e[10]=h,e[11]=y):y=e[11];const x=f&&c.action==="download";let j;e[12]!==u?(j=()=>{u("download")},e[12]=u,e[13]=j):j=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Js,{size:13,"aria-hidden":"true"}),e[14]=v):v=e[14];const k=f&&c.action==="download"?"Downloading…":`Download ${i}`;let w;e[15]!==m||e[16]!==k||e[17]!==x||e[18]!==j?(w=t.jsxs("button",{type:"button",className:"inspector-generation-action",disabled:m,"aria-busy":x,title:"Save the original media file to Downloads",onClick:j,children:[v,k]}),e[15]=m,e[16]=k,e[17]=x,e[18]=j,e[19]=w):w=e[19];let S;e[20]!==w||e[21]!==y?(S=t.jsxs("div",{className:"inspector-media-file-buttons",children:[y,w]}),e[20]=w,e[21]=y,e[22]=S):S=e[22];let M;e[23]!==c.message||e[24]!==c.phase?(M=c.phase==="done"&&t.jsx("p",{role:"status",children:c.message}),e[23]=c.message,e[24]=c.phase,e[25]=M):M=e[25];let N;e[26]!==c.message||e[27]!==c.phase?(N=c.phase==="failed"&&t.jsx("p",{className:"inspector-insight-error",role:"alert",children:c.message}),e[26]=c.message,e[27]=c.phase,e[28]=N):N=e[28];let $;return e[29]!==S||e[30]!==M||e[31]!==N?($=t.jsxs("section",{className:"inspector-media-file-actions","aria-label":"Media file actions",children:[S,M,N]}),e[29]=S,e[30]=M,e[31]=N,e[32]=$):$=e[32],$}const Vd={people:"People",places:"Places",editing:"Editing",custom:"Custom"};function rf(l){const e=Y.c(53),{tags:s,busy:n,error:i,canEdit:a,suggestions:o,onAdd:r,onRemove:c,onRestore:d,onQueryChange:u,status:f,onRetry:m}=l,[b,p]=C.useState(""),g=C.useRef(null),h=C.useId();let y;e[0]!==s?.effective?(y=s?.effective??[],e[0]=s?.effective,e[1]=y):y=e[1];let x;e[2]!==y?(x=ui(y),e[2]=y,e[3]=x):x=e[3];const j=x;let v;e[4]!==s?.dismissed?(v=s?.dismissed??[],e[4]=s?.dismissed,e[5]=v):v=e[5];const k=v;let w;e[6]!==a||e[7]!==b||e[8]!==r||e[9]!==u?(w=function(){const _=b.trim();!_||!a||(r({label:_}),p(""),u(""),g.current?.focus())},e[6]=a,e[7]=b,e[8]=r,e[9]=u,e[10]=w):w=e[10];const S=w;let M;e[11]!==S||e[12]!==b||e[13]!==u?(M=function(_){if(_.key==="Enter"){_.preventDefault(),S();return}_.key==="Escape"&&b&&(_.preventDefault(),p(""),u(""))},e[11]=S,e[12]=b,e[13]=u,e[14]=M):M=e[14];const N=M;let $;if(e[15]!==a||e[16]!==j||e[17]!==c){let z;e[19]!==a||e[20]!==c?(z=_=>t.jsxs("span",{className:`asset-tag-chip asset-tag-chip-${_.origin}`,role:"listitem",children:[t.jsx("span",{className:"asset-tag-chip-label",children:_.label}),a?t.jsx("button",{type:"button",className:"asset-tag-chip-remove",onClick:()=>c({facet:_.facet,label:_.label}),"aria-label":`Remove tag ${_.label} (${gl(_)})`,title:gl(_),children:t.jsx(dt,{size:11})}):null]},`${_.facet}/${_.key}`),e[19]=a,e[20]=c,e[21]=z):z=e[21],$=j.map(z),e[15]=a,e[16]=j,e[17]=c,e[18]=$}else $=e[18];let R;e[22]!==j.length||e[23]!==f?(R=j.length===0?t.jsx("span",{className:"asset-tag-empty",children:f??"No tags yet"}):null,e[22]=j.length,e[23]=f,e[24]=R):R=e[24];let I;e[25]!==$||e[26]!==R?(I=t.jsxs("div",{className:"asset-tag-chips",role:"list",children:[$,R]}),e[25]=$,e[26]=R,e[27]=I):I=e[27];let P;e[28]!==a||e[29]!==S||e[30]!==b||e[31]!==N||e[32]!==h||e[33]!==u||e[34]!==o?(P=a?t.jsxs("div",{className:"asset-tag-input-row",children:[t.jsx("input",{ref:g,className:"asset-tag-input",value:b,list:h,placeholder:"Add a tag","aria-label":"Add a tag",autoComplete:"off",onChange:z=>{p(z.target.value),u(z.target.value)},onKeyDown:N}),t.jsx("datalist",{id:h,children:o.map(qd)}),t.jsx("button",{type:"button",className:"asset-tag-add",onClick:S,disabled:!b.trim(),"aria-label":"Add tag",children:t.jsx(Zt,{size:12})})]}):null,e[28]=a,e[29]=S,e[30]=b,e[31]=N,e[32]=h,e[33]=u,e[34]=o,e[35]=P):P=e[35];let T;e[36]!==I||e[37]!==P?(T=t.jsxs("div",{className:"asset-tag-row",children:[I,P]}),e[36]=I,e[37]=P,e[38]=T):T=e[38];let D;e[39]!==a||e[40]!==k||e[41]!==d?(D=k.length>0?t.jsxs("div",{className:"asset-tag-dismissed",children:[t.jsx("span",{className:"asset-tag-dismissed-label",children:"Removed"}),t.jsx("div",{className:"asset-tag-chips",role:"list",children:k.map(z=>t.jsxs("span",{className:"asset-tag-chip asset-tag-chip-dismissed",role:"listitem",children:[t.jsx("span",{className:"asset-tag-chip-label",children:z.label}),a?t.jsx("button",{type:"button",className:"asset-tag-chip-restore",onClick:()=>d({facet:z.facet,label:z.label}),"aria-label":`Restore tag ${z.label}`,title:"Restore this tag",children:t.jsx(Bn,{size:11})}):null]},`dismissed-${z.facet}/${z.key}`))})]}):null,e[39]=a,e[40]=k,e[41]=d,e[42]=D):D=e[42];let A;e[43]!==i||e[44]!==m?(A=i?t.jsxs("p",{className:"asset-tag-error",role:"status",children:[i,m?t.jsx("button",{type:"button",className:"asset-tag-retry",onClick:m,children:"Retry"}):null]}):null,e[43]=i,e[44]=m,e[45]=A):A=e[45];let F;e[46]!==n?(F=n?t.jsx("span",{className:"sr-only",role:"status",children:"Saving tags"}):null,e[46]=n,e[47]=F):F=e[47];let E;return e[48]!==T||e[49]!==D||e[50]!==A||e[51]!==F?(E=t.jsxs("section",{className:"asset-tag-editor","aria-label":"Asset tags",children:[T,D,A,F]}),e[48]=T,e[49]=D,e[50]=A,e[51]=F,e[52]=E):E=e[52],E}function qd(l){return t.jsx("option",{value:l.label,children:`${Vd[l.facet]} · ${l.assets} asset${l.assets===1?"":"s"}`},`${l.facet}/${l.key}`)}function Ws(...l){return xa(ga(l))}const Wd={cyan:"text-primary border-primary/30 bg-primary/10",amber:"text-amber-400 border-amber-400/30 bg-amber-400/10",violet:"text-violet-400 border-violet-400/30 bg-violet-400/10"};function Xd(l){const e=Y.c(5),{value:s,colorScheme:n}=l,i=Wd[n];let a;e[0]!==i?(a=Ws("inline-flex items-center px-1.5 py-0.5 rounded font-mono text-xs font-bold border",i),e[0]=i,e[1]=a):a=e[1];let o;return e[2]!==a||e[3]!==s?(o=t.jsx("span",{className:a,children:s}),e[2]=a,e[3]=s,e[4]=o):o=e[4],o}const Gd={Zap:Jo,Sparkles:Mi,Scissors:Kn,Mic:ki,Check:Jt,Clapperboard:Yo,Mailbox:Go,ClipboardCopy:Ci,Columns3:Ri,FolderOpen:Xo,History:Un,Eye:Ii,Users:Wo,Archive:qo,NotebookPen:Vo,Rows3:$i,Stethoscope:Ko,Images:Hn};function Yd(l){return Gd[l]}const Gt=8,An=320,Ol=80,Sn=2,Jd=460;function Qd(l,e,s,n){const i=l.top-Gt*2,a=e.height-l.bottom-Gt*2,o=s?i>=Math.min(An,a)||i>a:a<Ol+Sn&&i>a,c=Math.max(Ol,Math.min(An,(o?i:a)-Sn)),d=c+Sn,u=o?Math.max(Gt,l.top-Gt-d):Math.max(Gt,Math.min(l.bottom+Gt,e.height-Gt-d)),f=n??Math.max(l.width,200),m=Math.min(Math.max(Gt,l.left),e.width-f-Gt);return{top:u,left:m,width:f,maxHeight:c,placeAbove:o}}function Zd(l){return l?.closest("dialog[open]")??document.body}function eu(l,e,s){const n=l.getBoundingClientRect();return Qd({top:n.top,bottom:n.bottom,left:n.left,width:n.width},{width:window.innerWidth,height:window.innerHeight},e,s)}const Hs={size:13,"aria-hidden":!0};function tu(l){const e=Y.c(4),{kind:s}=l;if(s==="audio"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ts,{...Hs}),e[0]=i):i=e[0],i}if(s==="image"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Qt,{...Hs}),e[1]=i):i=e[1],i}if(s==="video"||s==="final"){let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Ct,{...Hs}),e[2]=i):i=e[2],i}let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx($s,{...Hs}),e[3]=n):n=e[3],n}function of(l){const e=Y.c(59),{items:s,selectedIndex:n,onSelect:i,onHover:a,anchorRef:o,preferAbove:r,widthPx:c}=l,d=r===void 0?!0:r,u=C.useRef(null),[f,m]=C.useState(null),[b,p]=C.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=[],e[0]=g):g=e[0];const[h,y]=C.useState(g),x=o!=null;let j,v;e[1]!==n?(j=()=>{u.current?.querySelector(`[data-option-index="${n}"]`)?.scrollIntoView({block:"nearest"})},v=[n],e[1]=n,e[2]=j,e[3]=v):(j=e[2],v=e[3]),C.useEffect(j,v);let k;e[4]!==o||e[5]!==d||e[6]!==x||e[7]!==c?(k=()=>{if(!x||!o)return;const U=()=>{const K=o.current;K&&(m(eu(K,d,c)),p(Zd(K)))};return U(),window.addEventListener("resize",U),window.addEventListener("scroll",U,!0),()=>{window.removeEventListener("resize",U),window.removeEventListener("scroll",U,!0)}},e[4]=o,e[5]=d,e[6]=x,e[7]=c,e[8]=k):k=e[8];let w;e[9]!==o||e[10]!==s.length||e[11]!==d||e[12]!==x||e[13]!==c?(w=[x,o,d,c,s.length],e[9]=o,e[10]=s.length,e[11]=d,e[12]=x,e[13]=c,e[14]=w):w=e[14],C.useLayoutEffect(k,w);const S=!x&&"absolute bottom-full left-0 right-0 mb-2 z-50 origin-bottom",M=x&&f?.placeAbove&&"origin-bottom",N=x&&f&&!f.placeAbove&&"origin-top";let $;e[15]!==S||e[16]!==M||e[17]!==N?($=Ws("bg-background border border-primary/30 rounded-sm shadow-[0_18px_48px_rgba(0,0,0,0.62)] overflow-hidden","animate-in fade-in-0 zoom-in-95 duration-150",S,M,N),e[15]=S,e[16]=M,e[17]=N,e[18]=$):$=e[18];const R=$;let I;e[19]!==f||e[20]!==x?(I=x&&f?{position:"fixed",top:f.top,left:f.left,width:f.width,zIndex:Jd}:void 0,e[19]=f,e[20]=x,e[21]=I):I=e[21];const P=I;let T,D,A,F,E,z,_,L;if(e[22]!==h||e[23]!==s||e[24]!==R||e[25]!==P||e[26]!==a||e[27]!==i||e[28]!==f?.maxHeight||e[29]!==n){const U=s.map(iu),K=U.filter(lu),ee=U.filter(nu);z=R,_=P,L=su,T=u,D="overflow-y-auto";const ne=f?.maxHeight??An;e[38]!==ne?(A={maxHeight:ne},e[38]=ne,e[39]=A):A=e[39];let V;e[40]!==h||e[41]!==a||e[42]!==i||e[43]!==n?(V=re=>{const{item:W,index:Z}=re,ie=W.icon?Yd(W.icon):void 0,J=W.thumbnailSrc&&!h.includes(W.thumbnailSrc)?W.thumbnailSrc:null,G=W.type==="mention",ce=J!==null||W.mediaKind!==void 0;return t.jsxs("button",{type:"button","data-option-index":Z,className:Ws("w-full h-10 px-3 text-left text-sm transition-colors flex items-center gap-3",Z===n?"bg-primary/20 text-primary shadow-[inset_2px_0_0_var(--color-primary)]":"text-foreground hover:bg-white/5"),onClick:()=>i(W),onMouseEnter:()=>a(Z),children:[ce&&t.jsx("span",{className:"flex h-[30px] w-[52px] shrink-0 items-center justify-center overflow-hidden rounded-sm border border-primary/20 bg-[#07150e] text-primary/60",children:J?t.jsx("img",{src:J,alt:"",loading:"lazy",decoding:"async",className:"size-full object-cover",onError:()=>y(ae=>ae.includes(J)?ae:[...ae,J])}):t.jsx(tu,{kind:W.mediaKind})}),t.jsx(Xd,{value:W.label,colorScheme:W.colorScheme}),W.example&&W.example!==W.value?t.jsx("span",{className:"text-muted-foreground/50 text-xs font-mono min-w-0 flex-1 truncate",children:W.example.replace(W.value,"").trimStart()}):G?t.jsx("span",{className:"text-xs min-w-0 flex-1 truncate text-[#cde8da]",children:W.caption}):t.jsx("span",{className:"text-muted-foreground text-xs min-w-0 flex-1 truncate",children:W.description}),G&&W.description&&t.jsx("span",{className:"shrink-0 text-[10px] tracking-[0.1em] text-[#8fb9a1]",children:W.description}),ie&&!ce&&t.jsx(ie,{className:"size-3 shrink-0 opacity-50"})]},`${W.value}-${Z}`)},e[40]=h,e[41]=a,e[42]=i,e[43]=n,e[44]=V):V=e[44],F=K.map(V),E=ee.length>0&&t.jsxs("div",{className:"flex h-9 items-center gap-2 overflow-x-auto border-t border-primary/10 px-3",children:[t.jsx("span",{className:"shrink-0 text-[10px] tracking-[0.14em] text-[#6f9a82]",children:"EMPTY"}),ee.map(re=>{const{item:W,index:Z}=re;return t.jsx("button",{type:"button","data-option-index":Z,title:W.description,className:Ws("shrink-0 rounded-sm border border-dashed px-1.5 py-0.5 font-mono text-xs font-bold transition-colors",Z===n?"border-primary/60 bg-primary/20 text-amber-300":"border-primary/25 text-amber-400/80 hover:border-primary/50 hover:text-amber-300"),onClick:()=>i(W),onMouseEnter:()=>a(Z),children:W.label},`${W.value}-${Z}`)})]}),e[22]=h,e[23]=s,e[24]=R,e[25]=P,e[26]=a,e[27]=i,e[28]=f?.maxHeight,e[29]=n,e[30]=T,e[31]=D,e[32]=A,e[33]=F,e[34]=E,e[35]=z,e[36]=_,e[37]=L}else T=e[30],D=e[31],A=e[32],F=e[33],E=e[34],z=e[35],_=e[36],L=e[37];let B;e[45]!==T||e[46]!==D||e[47]!==A||e[48]!==F||e[49]!==E?(B=t.jsxs("div",{ref:T,className:D,style:A,children:[F,E]}),e[45]=T,e[46]=D,e[47]=A,e[48]=F,e[49]=E,e[50]=B):B=e[50];let H;e[51]!==z||e[52]!==_||e[53]!==L||e[54]!==B?(H=t.jsx("div",{className:z,style:_,onMouseDown:L,children:B}),e[51]=z,e[52]=_,e[53]=L,e[54]=B,e[55]=H):H=e[55];const q=H;if(x){if(!f||!b||typeof document>"u")return null;let U;return e[56]!==b||e[57]!==q?(U=hs.createPortal(q,b),e[56]=b,e[57]=q,e[58]=U):U=e[58],U}return q}function su(l){return l.preventDefault()}function nu(l){const{item:e}=l;return e.empty}function lu(l){const{item:e}=l;return!e.empty}function iu(l,e){return{item:l,index:e}}function au(l){const e=Y.c(21),{tags:s,limit:n,onFilter:i,activeTerms:a}=l,o=n===void 0?4:n;let r,c,d,u,f,m;if(e[0]!==o||e[1]!==i||e[2]!==a||e[3]!==s?.effective){m=Symbol.for("react.early_return_sentinel");e:{const g=a===void 0?[]:a,h=ui(s?.effective??[]);if(h.length===0){m=null;break e}const y=h.slice(0,o);r=h.length-y.length;const x=new Set(g.map(ru));c="asset-tag-summary",d="list",u="Tags";let j;e[10]!==x||e[11]!==i?(j=v=>{const k=`${v.facet}/${v.key}`,w=x.has(k);return i?t.jsx("button",{type:"button",role:"listitem",className:"asset-tag-summary-chip asset-tag-summary-chip-action","aria-pressed":w,title:w?`Remove filter ${v.label}`:`Filter by ${v.label}`,onClick:()=>i(Pr(v)),children:v.label},k):t.jsx("span",{className:"asset-tag-summary-chip",role:"listitem",children:v.label},k)},e[10]=x,e[11]=i,e[12]=j):j=e[12],f=y.map(j)}e[0]=o,e[1]=i,e[2]=a,e[3]=s?.effective,e[4]=r,e[5]=c,e[6]=d,e[7]=u,e[8]=f,e[9]=m}else r=e[4],c=e[5],d=e[6],u=e[7],f=e[8],m=e[9];if(m!==Symbol.for("react.early_return_sentinel"))return m;let b;e[13]!==r?(b=r>0?t.jsx("span",{className:"asset-tag-summary-more",role:"listitem",children:`+${r}`}):null,e[13]=r,e[14]=b):b=e[14];let p;return e[15]!==c||e[16]!==d||e[17]!==u||e[18]!==f||e[19]!==b?(p=t.jsxs("div",{className:c,role:d,"aria-label":u,children:[f,b]}),e[15]=c,e[16]=d,e[17]=u,e[18]=f,e[19]=b,e[20]=p):p=e[20],p}function ru(l){return`${l.facet}/${l.key}`}function ou(l){const e=Y.c(54),{mode:s,reference:n,preparing:i,disabled:a,startSeconds:o,durationSeconds:r,children:c,onFile:d,onClear:u,onStartSeconds:f,onDurationSeconds:m}=l;let b;e[0]!==s?(b=Tr(s),e[0]=s,e[1]=b):b=e[1];const p=b,g=p==="image"?"an image":"a video",h=p==="image"?Qt:Ct,y=p==="image"?"image/*,.heic,.heif":"video/*";let x;e[2]!==a||e[3]!==p||e[4]!==d||e[5]!==i?(x=B=>{if(a||i)return;const H=B.find(q=>yl(q,p));H&&d(H)},e[2]=a,e[3]=p,e[4]=d,e[5]=i,e[6]=x):x=e[6];const j=x;let v;e[7]!==j?(v=B=>{B.preventDefault(),B.stopPropagation(),j([...B.dataTransfer.files])},e[7]=j,e[8]=v):v=e[8];const k=v;let w;e[9]!==p||e[10]!==j?(w=B=>{const H=[...B.clipboardData.files],q=H.length>0?H:[...B.clipboardData.items].flatMap(du);q.some(U=>yl(U,p))&&(B.preventDefault(),B.stopPropagation(),j(q))},e[9]=p,e[10]=j,e[11]=w):w=e[11];const S=w;let M;e[12]!==h||e[13]!==p||e[14]!==i||e[15]!==n?(M=i?t.jsx(ct,{size:24}):n?.previewUrl?p==="image"?t.jsx("img",{src:n.previewUrl,alt:""}):t.jsx("video",{src:n.previewUrl,controls:!0,playsInline:!0,preload:"metadata"}):t.jsx(h,{size:26}),e[12]=h,e[13]=p,e[14]=i,e[15]=n,e[16]=M):M=e[16];const N=i?`Preparing ${p}…`:n?n.name:`Drop or paste ${g}`;let $;e[17]!==N?($=t.jsx("strong",{children:N}),e[17]=N,e[18]=$):$=e[18];const R=n?"Temporary search reference":`Choose ${g} file, drag it here, or paste from the clipboard`;let I;e[19]!==R?(I=t.jsx("span",{children:R}),e[19]=R,e[20]=I):I=e[20];let P;e[21]!==$||e[22]!==I?(P=t.jsxs("div",{children:[$,I]}),e[21]=$,e[22]=I,e[23]=P):P=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Qs,{size:14}),e[24]=T):T=e[24];const D=a||i;let A;e[25]!==d?(A=B=>{const H=B.target.files?.[0];H&&d(H),B.target.value=""},e[25]=d,e[26]=A):A=e[26];let F;e[27]!==y||e[28]!==D||e[29]!==A?(F=t.jsxs("label",{className:"reverse-search-upload",children:[T,"Choose file",t.jsx("input",{type:"file",accept:y,disabled:D,onChange:A})]}),e[27]=y,e[28]=D,e[29]=A,e[30]=F):F=e[30];let E;e[31]!==a||e[32]!==u||e[33]!==i||e[34]!==n?(E=n&&t.jsxs("button",{type:"button",className:"reverse-search-clear",disabled:a||i,"aria-label":"Clear search reference",onClick:u,children:[t.jsx(dt,{size:14}),"Clear"]}),e[31]=a,e[32]=u,e[33]=i,e[34]=n,e[35]=E):E=e[35];let z;e[36]!==P||e[37]!==F||e[38]!==E||e[39]!==M?(z=t.jsxs("div",{className:"reverse-search-dropzone",tabIndex:0,autoFocus:!0,children:[M,P,F,E]}),e[36]=P,e[37]=F,e[38]=E,e[39]=M,e[40]=z):z=e[40];let _;e[41]!==r||e[42]!==p||e[43]!==m||e[44]!==f||e[45]!==n||e[46]!==o?(_=p==="video"&&n&&t.jsxs("div",{className:"reverse-search-range",children:[t.jsxs("label",{children:["Start seconds",t.jsx("input",{type:"number",min:"0",step:"0.1",value:o,onChange:B=>f(B.target.value)})]}),t.jsxs("label",{children:["Duration seconds",t.jsx("input",{type:"number",min:"0.1",step:"0.1",value:r,placeholder:"Whole remaining video",onChange:B=>m(B.target.value)})]}),n.durationMs!==void 0&&t.jsxs("span",{children:[(n.durationMs/1e3).toFixed(1),"s available"]})]}),e[41]=r,e[42]=p,e[43]=m,e[44]=f,e[45]=n,e[46]=o,e[47]=_):_=e[47];let L;return e[48]!==c||e[49]!==k||e[50]!==S||e[51]!==z||e[52]!==_?(L=t.jsxs("section",{className:"reverse-search-reference",onDragOver:cu,onDrop:k,onPaste:S,children:[z,c,_]}),e[48]=c,e[49]=k,e[50]=S,e[51]=z,e[52]=_,e[53]=L):L=e[53],L}function cu(l){l.dataTransfer.types.includes("Files")&&l.preventDefault()}function du(l){const e=l.kind==="file"?l.getAsFile():null;return e?[e]:[]}const uu=[{id:"text",label:"Text",icon:is},{id:"image-reverse",label:"Image reverse",icon:Qt},{id:"video-reverse",label:"Vid reverse",icon:Ct}];function Dn(l){return l==="all"?"media":l==="audio"?"audio":`${l}s`}function mu(l,e){if(!l)return null;const s=Date.parse(l);if(!Number.isFinite(s))return null;const n=Math.max(0,Math.round((e-s)/6e4));if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.round(n/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function fu(l){return l.mode!=="text"?"Most similar":l.query.trim()?"Best match":"Recently used"}function pu(l){return l.type==="image"||l.type==="video"||l.type==="final"}function hu(l){const e=Y.c(45),{asset:s,state:n,targetBookId:i,busy:a,now:o,onAttach:r,onSimilar:c,onToggleTagFilter:d}=l,u=n.activeArtifactId===s.artifactId;let f;e[0]!==s.label?(f=s.label.trim()||"Untitled media",e[0]=s.label,e[1]=f):f=e[1];const m=f;let b;e[2]!==s.lastUsedAt||e[3]!==o?(b=mu(s.lastUsedAt,o),e[2]=s.lastUsedAt,e[3]=o,e[4]=b):b=e[4];const p=b;let g;e[5]!==s?(g=t.jsx(sd,{asset:s}),e[5]=s,e[6]=g):g=e[6];let h;e[7]!==m?(h=t.jsx("strong",{children:m}),e[7]=m,e[8]=h):h=e[8];const y=s.owningBookId===i?" · this book":" · copy";let x;e[9]!==s.owningBookName||e[10]!==y?(x=t.jsxs("small",{children:[s.owningBookName,y]}),e[9]=s.owningBookName,e[10]=y,e[11]=x):x=e[11];let j;e[12]!==h||e[13]!==x?(j=t.jsxs("span",{className:"media-library-asset-copy",children:[h,x]}),e[12]=h,e[13]=x,e[14]=j):j=e[14];let v;e[15]!==p?(v=p&&t.jsxs("span",{className:"media-library-asset-used",children:["Used ",p]}),e[15]=p,e[16]=v):v=e[16];let k;e[17]!==s.tags||e[18]!==d||e[19]!==n.tagFilters?(k=t.jsx(au,{tags:s.tags,limit:2,onFilter:d,activeTerms:n.tagFilters}),e[17]=s.tags,e[18]=d,e[19]=n.tagFilters,e[20]=k):k=e[20];let w;e[21]!==u?(w=u&&t.jsxs("span",{className:"media-library-asset-busy",children:[t.jsx(ct,{size:16}),"Attaching…"]}),e[21]=u,e[22]=w):w=e[22];let S;e[23]!==s||e[24]!==a||e[25]!==c?(S=pu(s)&&t.jsxs("button",{type:"button",className:"media-library-asset-similar",disabled:a,title:"Find similar media",onClick:()=>c(s),children:[t.jsx(is,{size:12}),"Similar"]}),e[23]=s,e[24]=a,e[25]=c,e[26]=S):S=e[26];const M=`Use ${m} from ${s.owningBookName}`,N=`Use ${m}`;let $;e[27]!==s||e[28]!==r?($=()=>r(s),e[27]=s,e[28]=r,e[29]=$):$=e[29];let R;e[30]!==a||e[31]!==M||e[32]!==N||e[33]!==$?(R=t.jsx("button",{type:"button",className:"media-library-asset-use",disabled:a,"aria-label":M,title:N,onClick:$}),e[30]=a,e[31]=M,e[32]=N,e[33]=$,e[34]=R):R=e[34];let I;e[35]!==S||e[36]!==R?(I=t.jsxs("span",{className:"media-library-asset-actions",children:[S,R]}),e[35]=S,e[36]=R,e[37]=I):I=e[37];let P;return e[38]!==w||e[39]!==I||e[40]!==g||e[41]!==j||e[42]!==v||e[43]!==k?(P=t.jsxs("article",{className:"media-library-asset",children:[g,j,v,k,w,I]}),e[38]=w,e[39]=I,e[40]=g,e[41]=j,e[42]=v,e[43]=k,e[44]=P):P=e[44],P}function bu(l){const e=Y.c(26),{state:s,onToggleTagFilter:n,onClearTagFilters:i,onTagQuery:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"sr-only",children:"Filter by tag"}),e[0]=o):o=e[0];let r;e[1]!==a?(r=g=>a(g.target.value),e[1]=a,e[2]=r):r=e[2];let c;e[3]!==n||e[4]!==s.tagSuggestions?(c=g=>{if(g.key!=="Enter")return;g.preventDefault();const h=g.currentTarget.value.trim();if(!h)return;const y=s.tagSuggestions.find(x=>x.label.toLowerCase()===h.toLowerCase());y&&(n({facet:y.facet,key:y.key,label:y.label}),g.currentTarget.value="")},e[3]=n,e[4]=s.tagSuggestions,e[5]=c):c=e[5];let d;e[6]!==r||e[7]!==c?(d=t.jsxs("label",{className:"media-library-tag-input-label",children:[o,t.jsx("input",{className:"media-library-tag-input",list:"media-library-tag-suggestions",placeholder:"Filter by tag","aria-label":"Filter by tag",autoComplete:"off",onChange:r,onKeyDown:c})]}),e[6]=r,e[7]=c,e[8]=d):d=e[8];let u;e[9]!==s.tagSuggestions?(u=s.tagSuggestions.map(xu),e[9]=s.tagSuggestions,e[10]=u):u=e[10];let f;e[11]!==u?(f=t.jsx("datalist",{id:"media-library-tag-suggestions",children:u}),e[11]=u,e[12]=f):f=e[12];let m;if(e[13]!==n||e[14]!==s.tagFilters){let g;e[16]!==n?(g=h=>t.jsxs("button",{type:"button",className:"media-library-tag-filter","aria-label":`Remove tag filter ${h.label}`,onClick:()=>n(h),children:[h.label,t.jsx(dt,{size:11})]},`${h.facet}/${h.key}`),e[16]=n,e[17]=g):g=e[17],m=s.tagFilters.map(g),e[13]=n,e[14]=s.tagFilters,e[15]=m}else m=e[15];let b;e[18]!==i||e[19]!==s.tagFilters.length?(b=s.tagFilters.length>0&&t.jsx("button",{type:"button",className:"media-library-tag-clear",onClick:i,children:"Clear tags"}),e[18]=i,e[19]=s.tagFilters.length,e[20]=b):b=e[20];let p;return e[21]!==d||e[22]!==f||e[23]!==m||e[24]!==b?(p=t.jsxs("div",{className:"media-library-tag-filters",children:[d,f,m,b]}),e[21]=d,e[22]=f,e[23]=m,e[24]=b,e[25]=p):p=e[25],p}function xu(l){return t.jsx("option",{value:l.label,children:`${l.facet} · ${l.assets}`},`${l.facet}/${l.key}`)}function gu(l){const e=Y.c(14),{state:s,busy:n,onRepairIndexes:i}=l;let a;e[0]!==s.error?(a=s.error&&t.jsx("p",{className:"media-library-error",role:"alert",children:s.error}),e[0]=s.error,e[1]=a):a=e[1];let o;e[2]!==n||e[3]!==i||e[4]!==s.loading||e[5]!==s.preparingIndex||e[6]!==s.unindexedVisualAssets?(o=s.unindexedVisualAssets>0&&t.jsxs("div",{className:"media-library-warning",role:"status",children:[s.unindexedVisualAssets," media ",s.unindexedVisualAssets===1?"asset is":"assets are"," missing from Similar search."," ",t.jsx("button",{type:"button",disabled:n||s.loading||s.preparingIndex,onClick:i,children:s.preparingIndex?"Indexing…":"Index missing media"})]}),e[2]=n,e[3]=i,e[4]=s.loading,e[5]=s.preparingIndex,e[6]=s.unindexedVisualAssets,e[7]=o):o=e[7];let r;e[8]!==s.booksWithErrors.length?(r=s.booksWithErrors.length>0&&t.jsxs("p",{className:"media-library-warning",role:"status",children:[s.booksWithErrors.length," book",s.booksWithErrors.length===1?"":"s"," could not be searched."]}),e[8]=s.booksWithErrors.length,e[9]=r):r=e[9];let c;return e[10]!==a||e[11]!==o||e[12]!==r?(c=t.jsxs(t.Fragment,{children:[a,o,r]}),e[10]=a,e[11]=o,e[12]=r,e[13]=c):c=e[13],c}function yu(l){const e=Y.c(10),{state:s,kind:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Vn,{size:22}),e[0]=i):i=e[0];let a;e[1]!==n?(a=Dn(n),e[1]=n,e[2]=a):a=e[2];let o;e[3]!==a?(o=t.jsxs("strong",{children:["No ",a," found"]}),e[3]=a,e[4]=o):o=e[4];const r=s.tagFilters.length>0?"No media carries every selected tag. Clear a tag or try another search.":"Try another search, upload a file, or drop one onto the cell.";let c;e[5]!==r?(c=t.jsx("span",{children:r}),e[5]=r,e[6]=c):c=e[6];let d;return e[7]!==o||e[8]!==c?(d=t.jsxs("div",{className:"media-library-empty",children:[i,o,c]}),e[7]=o,e[8]=c,e[9]=d):d=e[9],d}function cf(l){const e=Y.c(93),{state:s,kind:n,accept:i,targetBookId:a,onClose:o,onMode:r,onDraftQuery:c,onSearch:d,onLoadMore:u,onAttach:f,onUpload:m,onSimilar:b,onToggleTagFilter:p}=l,g=C.useRef(null),h=l.disabled||s.activeArtifactId!==null||s.preparingReference||s.uploading,[y]=C.useState(ju);let x;e[0]!==h||e[1]!==o?(x=V=>{V.key!=="Escape"||h||V.nativeEvent.isComposing||(V.preventDefault(),V.stopPropagation(),o())},e[0]=h,e[1]=o,e[2]=x):x=e[2];const j=x,v=n==="all"?"Choose library media":`Choose ${n} media`;let k;e[3]!==h||e[4]!==n||e[5]!==c||e[6]!==d||e[7]!==s.draftQuery||e[8]!==s.mode?(k=s.mode==="text"?t.jsxs("form",{className:"media-library-search",role:"search",onSubmit:V=>{V.preventDefault(),h||d()},children:[t.jsx(is,{size:14,"aria-hidden":"true"}),t.jsx("input",{type:"search",value:s.draftQuery,"aria-label":"Search library",placeholder:`Search ${Dn(n)} in every book`,autoFocus:!0,disabled:h,onChange:V=>c(V.target.value)})]}):t.jsxs("span",{className:"media-library-search media-library-search-reverse",children:[t.jsx(is,{size:14,"aria-hidden":"true"}),"Reverse search across every book"]}),e[3]=h,e[4]=n,e[5]=c,e[6]=d,e[7]=s.draftQuery,e[8]=s.mode,e[9]=k):k=e[9];let w;e[10]!==h||e[11]!==n||e[12]!==r||e[13]!==s.mode?(w=n!=="audio"&&t.jsx("div",{className:"media-library-modes",role:"tablist","aria-label":"Search mode",children:uu.map(V=>{const re=V.icon;return t.jsxs("button",{type:"button",role:"tab","aria-selected":s.mode===V.id,className:s.mode===V.id?"active":"",disabled:h,onClick:()=>r(V.id),children:[t.jsx(re,{size:13}),V.label]},V.id)})}),e[10]=h,e[11]=n,e[12]=r,e[13]=s.mode,e[14]=w):w=e[14];let S;e[15]!==l?(S=t.jsx(bu,{...l}),e[15]=l,e[16]=S):S=e[16];let M;e[17]===Symbol.for("react.memo_cache_sentinel")?(M=()=>g.current?.click(),e[17]=M):M=e[17];let N;e[18]!==s.uploading?(N=s.uploading?t.jsx(ct,{size:13}):t.jsx(Qs,{size:13}),e[18]=s.uploading,e[19]=N):N=e[19];const $=s.uploading?"Uploading…":"Upload";let R;e[20]!==h||e[21]!==N||e[22]!==$?(R=t.jsxs("button",{type:"button",className:"media-library-upload",disabled:h,onClick:M,children:[N,$]}),e[20]=h,e[21]=N,e[22]=$,e[23]=R):R=e[23];let I;e[24]!==m?(I=V=>{const re=V.target.files?.[0];V.target.value="",re&&m(re)},e[24]=m,e[25]=I):I=e[25];let P;e[26]!==i||e[27]!==I?(P=t.jsx("input",{ref:g,className:"media-library-upload-input",type:"file",accept:i,tabIndex:-1,"aria-hidden":"true",onChange:I}),e[26]=i,e[27]=I,e[28]=P):P=e[28];let T;e[29]!==P||e[30]!==k||e[31]!==w||e[32]!==S||e[33]!==R?(T=t.jsxs("div",{className:"media-library-toolbar",children:[k,w,S,R,P]}),e[29]=P,e[30]=k,e[31]=w,e[32]=S,e[33]=R,e[34]=T):T=e[34];let D;e[35]!==h||e[36]!==d||e[37]!==l.onClearReference||e[38]!==l.onReferenceDuration||e[39]!==l.onReferenceFile||e[40]!==l.onReferenceStart||e[41]!==s.activeArtifactId||e[42]!==s.loading||e[43]!==s.mode||e[44]!==s.preparingReference||e[45]!==s.reference||e[46]!==s.referenceDurationSeconds||e[47]!==s.referenceStartSeconds?(D=s.mode!=="text"&&t.jsxs("div",{className:"media-library-search-panel",children:[t.jsx(ou,{mode:s.mode,reference:s.reference,preparing:s.preparingReference,disabled:s.activeArtifactId!==null,startSeconds:s.referenceStartSeconds,durationSeconds:s.referenceDurationSeconds,onFile:l.onReferenceFile,onClear:l.onClearReference,onStartSeconds:l.onReferenceStart,onDurationSeconds:l.onReferenceDuration,children:t.jsx("p",{className:"media-library-similar-hint",children:"Or choose Similar on any result below."})}),s.reference&&t.jsxs("button",{type:"button",className:"media-library-reverse-submit",disabled:h||s.loading,onClick:d,children:[t.jsx(is,{size:14}),"Search similar media"]})]}),e[35]=h,e[36]=d,e[37]=l.onClearReference,e[38]=l.onReferenceDuration,e[39]=l.onReferenceFile,e[40]=l.onReferenceStart,e[41]=s.activeArtifactId,e[42]=s.loading,e[43]=s.mode,e[44]=s.preparingReference,e[45]=s.reference,e[46]=s.referenceDurationSeconds,e[47]=s.referenceStartSeconds,e[48]=D):D=e[48];const A=s.loading||s.loadingMore;let F;e[49]!==h||e[50]!==l.onRepairIndexes||e[51]!==s?(F=t.jsx(gu,{state:s,busy:h,onRepairIndexes:l.onRepairIndexes}),e[49]=h,e[50]=l.onRepairIndexes,e[51]=s,e[52]=F):F=e[52];let E;e[53]!==h||e[54]!==n||e[55]!==y||e[56]!==f||e[57]!==b||e[58]!==p||e[59]!==s||e[60]!==a?(E=s.loading&&s.assets.length===0?t.jsxs("div",{className:"media-library-loading",children:[t.jsx(ct,{size:22}),s.preparingIndex?"Preparing search…":"Loading recent media…"]}):s.assets.length===0?t.jsx(yu,{state:s,kind:n}):t.jsx("div",{className:"media-library-grid",children:s.assets.map(V=>t.jsx(hu,{asset:V,state:s,targetBookId:a,busy:h,now:y,onAttach:f,onSimilar:b,onToggleTagFilter:p},`${V.owningBookId}:${V.artifactId}`))}),e[53]=h,e[54]=n,e[55]=y,e[56]=f,e[57]=b,e[58]=p,e[59]=s,e[60]=a,e[61]=E):E=e[61];let z;e[62]!==A||e[63]!==F||e[64]!==E?(z=t.jsxs("div",{className:"media-library-results","aria-busy":A,children:[F,E]}),e[62]=A,e[63]=F,e[64]=E,e[65]=z):z=e[65];let _;e[66]!==s?(_=fu(s),e[66]=s,e[67]=_):_=e[67];let L;e[68]!==_?(L=t.jsx("strong",{children:_}),e[68]=_,e[69]=L):L=e[69];const B=s.assets.length,H=s.page.total;let q;e[70]!==n?(q=Dn(n),e[70]=n,e[71]=q):q=e[71];let U;e[72]!==s.assets.length||e[73]!==s.page.total||e[74]!==L||e[75]!==q?(U=t.jsxs("span",{children:[L," · ",B," of ",H," ",q]}),e[72]=s.assets.length,e[73]=s.page.total,e[74]=L,e[75]=q,e[76]=U):U=e[76];let K;e[77]!==h||e[78]!==u||e[79]!==s.loadingMore||e[80]!==s.page.hasMore||e[81]!==s.preparingIndex?(K=s.page.hasMore&&t.jsxs("button",{type:"button",disabled:h||s.loadingMore,onClick:u,children:[s.loadingMore?t.jsx(ct,{size:13}):t.jsx(Zt,{size:13}),s.preparingIndex?"Preparing search…":s.loadingMore?"Loading…":"Load more"]}),e[77]=h,e[78]=u,e[79]=s.loadingMore,e[80]=s.page.hasMore,e[81]=s.preparingIndex,e[82]=K):K=e[82];let ee;e[83]!==U||e[84]!==K?(ee=t.jsxs("footer",{className:"media-library-footer",children:[U,K]}),e[83]=U,e[84]=K,e[85]=ee):ee=e[85];let ne;return e[86]!==j||e[87]!==v||e[88]!==T||e[89]!==D||e[90]!==z||e[91]!==ee?(ne=t.jsxs("section",{className:"media-library-panel","aria-label":v,onKeyDown:j,children:[T,D,z,ee]}),e[86]=j,e[87]=v,e[88]=T,e[89]=D,e[90]=z,e[91]=ee,e[92]=ne):ne=e[92],ne}function ju(){return Date.now()}const vs="#f5d76e";function ys(l,e){const s=new Set(l);return s.has(e)?s.delete(e):s.add(e),s}function vu(l){return l instanceof Error?l.message:String(l)}function ku(l,e,s){return l.box?{x:l.box.x*e,y:l.box.y*s,width:l.box.width*e,height:l.box.height*s}:null}function Su(l,e,s){return{x:l.box.x*e,y:l.box.y*s,width:l.box.width*e,height:l.box.height*s}}function wn(l,e,s){const n=l.currentTarget,i=n.getScreenCTM();if(i&&"createSVGPoint"in n){const a=n.createSVGPoint();a.x=l.clientX,a.y=l.clientY;const o=a.matrixTransform(i.inverse());return{x:Math.min(1,Math.max(0,e>0?o.x/e:0)),y:Math.min(1,Math.max(0,s>0?o.y/s:0))}}return Ur(l.clientX,l.clientY,n.getBoundingClientRect())}function wu(l){const e=Y.c(72),{mediaUrl:s,width:n,height:i,subjectMap:a,selectedIds:o,hiddenIds:r,regions:c,selectedRegionIds:d,drawMode:u,draftBox:f,snapRegionId:m,opacity:b,onToggle:p,onToggleRegion:g,onHoverRegion:h,onPointerDown:y,onPointerMove:x,onPointerUp:j,onCancelDraw:v}=l;let k;e[0]!==a?.subjects?(k=a?.subjects??[],e[0]=a?.subjects,e[1]=k):k=e[1];const w=k;if(n<=0||i<=0){let F;return e[2]!==s?(F=t.jsx("img",{src:s,alt:""}),e[2]=s,e[3]=F):F=e[3],F}const S=`notebook-subject-stage-svg${u?" drawing":""}`,M=`0 0 ${n} ${i}`;let N;e[4]!==i||e[5]!==s||e[6]!==n?(N=t.jsx("image",{href:s,width:n,height:i,preserveAspectRatio:"xMidYMid meet"}),e[4]=i,e[5]=s,e[6]=n,e[7]=N):N=e[7];let $;e[8]!==u||e[9]!==i||e[10]!==n?($=u&&t.jsx("rect",{className:"notebook-region-draw-layer",width:n,height:i,fill:"transparent"}),e[8]=u,e[9]=i,e[10]=n,e[11]=$):$=e[11];let R;if(e[12]!==i||e[13]!==w||e[14]!==n){let F;e[16]!==i||e[17]!==n?(F=(E,z)=>E.layerUrl?t.jsx("mask",{id:`notebook-subject-mask-${z}`,className:"notebook-subject-mask",maskUnits:"userSpaceOnUse",x:"0",y:"0",width:n,height:i,children:t.jsx("image",{href:E.layerUrl,width:n,height:i,preserveAspectRatio:"none"})},E.id):null,e[16]=i,e[17]=n,e[18]=F):F=e[18],R=w.map(F),e[12]=i,e[13]=w,e[14]=n,e[15]=R}else R=e[15];let I;e[19]!==R?(I=t.jsx("defs",{children:R}),e[19]=R,e[20]=I):I=e[20];let P;if(e[21]!==u||e[22]!==i||e[23]!==r||e[24]!==p||e[25]!==b||e[26]!==o||e[27]!==w||e[28]!==n){let F;e[30]!==u||e[31]!==i||e[32]!==r||e[33]!==p||e[34]!==b||e[35]!==o||e[36]!==n?(F=(E,z)=>{if(r.has(E.id))return null;const _=ku(E,n,i),L=o.has(E.id);return t.jsxs("g",{className:`notebook-subject-overlay${L?" selected":""}`,onClick:B=>{u||(B.stopPropagation(),p(E.id))},onKeyDown:B=>{u||B.key!=="Enter"&&B.key!==" "||(B.preventDefault(),p(E.id))},role:"button",tabIndex:u?-1:0,"aria-label":`${L?"Deselect":"Select"} ${E.label}`,"aria-pressed":L,children:[t.jsx("title",{children:E.label}),E.layerUrl?t.jsx("rect",{width:n,height:i,fill:E.color,fillOpacity:L?Math.min(.9,b+.18):b,mask:`url(#notebook-subject-mask-${z})`,pointerEvents:"none"}):_?t.jsx("rect",{..._,fill:E.color,fillOpacity:L?Math.min(.72,b+.14):b,pointerEvents:"none"}):null,_&&t.jsx("rect",{..._,className:"notebook-subject-outline",fill:"none",stroke:L?"#ffffff":E.color,strokeWidth:Math.max(2,n/480),strokeDasharray:L?`${n/100} ${n/180}`:void 0,vectorEffect:"non-scaling-stroke"}),_&&t.jsx("rect",{..._,className:"notebook-subject-hit",fill:"transparent",pointerEvents:u?"none":"all"})]},E.id)},e[30]=u,e[31]=i,e[32]=r,e[33]=p,e[34]=b,e[35]=o,e[36]=n,e[37]=F):F=e[37],P=w.map(F),e[21]=u,e[22]=i,e[23]=r,e[24]=p,e[25]=b,e[26]=o,e[27]=w,e[28]=n,e[29]=P}else P=e[29];let T;if(e[38]!==u||e[39]!==i||e[40]!==h||e[41]!==g||e[42]!==c||e[43]!==d||e[44]!==m||e[45]!==n){let F;e[47]!==u||e[48]!==i||e[49]!==h||e[50]!==g||e[51]!==d||e[52]!==m||e[53]!==n?(F=(E,z)=>{const _=Su(E,n,i),L=d.has(E.id);return t.jsxs("g",{className:`notebook-subject-overlay notebook-region-overlay${L?" selected":""}`,onClick:B=>{u||(B.stopPropagation(),g(E.id))},onPointerEnter:()=>h(E.id),onPointerLeave:()=>h(null),role:"button",tabIndex:u?-1:0,"aria-label":`${L?"Deselect":"Select"} region ${z+1}`,"aria-pressed":L,children:[t.jsx("title",{children:E.matchedSubjectId?`Region ${z+1} snapped to subject`:`Drawn region ${z+1}`}),t.jsx("rect",{..._,fill:vs,fillOpacity:L?.28:.16,pointerEvents:"none"}),t.jsx("rect",{..._,className:"notebook-subject-outline",fill:"none",stroke:L?"#ffffff":vs,strokeWidth:Math.max(2,n/480),strokeDasharray:`${n/90} ${n/160}`,vectorEffect:"non-scaling-stroke"}),t.jsx("rect",{..._,className:"notebook-subject-hit",fill:"transparent",pointerEvents:u?"none":"all"}),m===E.id&&t.jsx("title",{children:"Snap to nearby subject available"})]},E.id)},e[47]=u,e[48]=i,e[49]=h,e[50]=g,e[51]=d,e[52]=m,e[53]=n,e[54]=F):F=e[54],T=c.map(F),e[38]=u,e[39]=i,e[40]=h,e[41]=g,e[42]=c,e[43]=d,e[44]=m,e[45]=n,e[46]=T}else T=e[46];let D;e[55]!==f||e[56]!==i||e[57]!==n?(D=f&&t.jsx("rect",{x:f.x*n,y:f.y*i,width:f.width*n,height:f.height*i,className:"notebook-region-draft",fill:vs,fillOpacity:.18,stroke:vs,strokeWidth:Math.max(2,n/480),strokeDasharray:`${n/80} ${n/140}`,pointerEvents:"none"}),e[55]=f,e[56]=i,e[57]=n,e[58]=D):D=e[58];let A;return e[59]!==v||e[60]!==y||e[61]!==x||e[62]!==j||e[63]!==D||e[64]!==S||e[65]!==M||e[66]!==N||e[67]!==$||e[68]!==I||e[69]!==P||e[70]!==T?(A=t.jsxs("svg",{className:S,viewBox:M,preserveAspectRatio:"xMidYMid meet",role:"group","aria-label":"Image with detected subject overlays",onPointerDown:y,onPointerMove:x,onPointerUp:j,onPointerCancel:v,onLostPointerCapture:v,children:[N,$,I,P,T,D]}),e[59]=v,e[60]=y,e[61]=x,e[62]=j,e[63]=D,e[64]=S,e[65]=M,e[66]=N,e[67]=$,e[68]=I,e[69]=P,e[70]=T,e[71]=A):A=e[71],A}function Nu(l){const e=Y.c(20),{mediaUrl:s,subjectMap:n,selectedIds:i}=l,a=n.width??0,o=n.height??0;if(!n.baseUrl||a<=0||o<=0){let m;return e[0]!==s?(m=t.jsx("img",{src:s,alt:""}),e[0]=s,e[1]=m):m=e[1],m}const r=`0 0 ${a} ${o}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("title",{children:"Removal preview"}),e[2]=c):c=e[2];let d;e[3]!==o||e[4]!==n.baseUrl||e[5]!==a?(d=t.jsx("image",{href:n.baseUrl,width:a,height:o,preserveAspectRatio:"xMidYMid meet"}),e[3]=o,e[4]=n.baseUrl,e[5]=a,e[6]=d):d=e[6];let u;if(e[7]!==o||e[8]!==i||e[9]!==n.subjects||e[10]!==a){let m;e[12]!==o||e[13]!==i||e[14]!==a?(m=b=>!i.has(b.id)&&b.layerUrl?t.jsx("image",{href:b.layerUrl,width:a,height:o,preserveAspectRatio:"none"},b.id):null,e[12]=o,e[13]=i,e[14]=a,e[15]=m):m=e[15],u=n.subjects.map(m),e[7]=o,e[8]=i,e[9]=n.subjects,e[10]=a,e[11]=u}else u=e[11];let f;return e[16]!==r||e[17]!==d||e[18]!==u?(f=t.jsxs("svg",{className:"notebook-subject-stage-svg",viewBox:r,preserveAspectRatio:"xMidYMid meet",role:"img","aria-label":"Preview with selected subjects removed",children:[c,d,u]}),e[16]=r,e[17]=d,e[18]=u,e[19]=f):f=e[19],f}function Cu(l){const e=Y.c(41),{analysisUnavailableReason:s,checkingCache:n,analyzing:i,analysisFailed:a,ready:o,hasTargets:r,subjectCount:c,regionCount:d,error:u,onAnalyze:f}=l;if(s){let m,b;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(ks,{size:18}),b=t.jsx("strong",{children:"Subject tools unavailable"}),e[0]=m,e[1]=b):(m=e[0],b=e[1]);let p;return e[2]!==s?(p=t.jsxs("div",{className:"notebook-subject-state unavailable",children:[m,b,t.jsx("p",{children:s})]}),e[2]=s,e[3]=p):p=e[3],p}if(n&&!r){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"notebook-subject-state loading",children:[t.jsx(ct,{size:18}),t.jsx("strong",{children:"Loading cached subjects"}),t.jsx("p",{children:"This does not start a new cloud analysis."})]}),e[4]=m):m=e[4],m}if(i){const m=`notebook-subject-state loading${r?" compact":""}`,b=r?14:18;let p;e[5]!==b?(p=t.jsx(ct,{size:b}),e[5]=b,e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("strong",{children:"Finding people and objects"}),e[7]=g):g=e[7];const h=r?"Analysis continues in the background.":"Analysis continues in the background. You can draw a region meanwhile.";let y;e[8]!==h?(y=t.jsx("p",{children:h}),e[8]=h,e[9]=y):y=e[9];let x;return e[10]!==m||e[11]!==p||e[12]!==y?(x=t.jsxs("div",{className:m,children:[p,g,y]}),e[10]=m,e[11]=p,e[12]=y,e[13]=x):x=e[13],x}if(a){const m=`notebook-subject-state error${r?" compact":""}`,b=r?14:18;let p;e[14]!==b?(p=t.jsx(yn,{size:b}),e[14]=b,e[15]=p):p=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("strong",{children:"Analysis did not finish"}),e[16]=g):g=e[16];const h=u??"The image could not be decomposed.";let y;e[17]!==h?(y=t.jsx("p",{children:h}),e[17]=h,e[18]=y):y=e[18];let x;e[19]!==r?(x=!r&&t.jsx("p",{children:"You can still draw a region to edit, replace, or remove."}),e[19]=r,e[20]=x):x=e[20];let j;e[21]!==f?(j=()=>f(),e[21]=f,e[22]=j):j=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(yn,{size:13}),e[23]=v):v=e[23];let k;e[24]!==j?(k=t.jsxs("button",{type:"button",onClick:j,children:[v,"Retry"]}),e[24]=j,e[25]=k):k=e[25];let w;return e[26]!==m||e[27]!==k||e[28]!==p||e[29]!==y||e[30]!==x?(w=t.jsxs("div",{className:m,children:[p,g,y,x,k]}),e[26]=m,e[27]=k,e[28]=p,e[29]=y,e[30]=x,e[31]=w):w=e[31],w}if(o&&c===0&&d===0){let m,b,p;e[32]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(ks,{size:18}),b=t.jsx("strong",{children:"No editable subjects found"}),p=t.jsx("p",{children:"Draw a region or try analysis again if the image changed."}),e[32]=m,e[33]=b,e[34]=p):(m=e[32],b=e[33],p=e[34]);let g;e[35]!==f?(g=()=>f(!0),e[35]=f,e[36]=g):g=e[36];let h;e[37]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(yn,{size:13}),e[37]=h):h=e[37];let y;return e[38]!==g?(y=t.jsxs("div",{className:"notebook-subject-state empty",children:[m,b,p,t.jsxs("button",{type:"button",onClick:g,children:[h,"Analyze again"]})]}),e[38]=g,e[39]=y):y=e[39],y}if(!o&&!n&&!r){let m;return e[40]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs("div",{className:"notebook-subject-state idle",children:[t.jsx(ks,{size:18}),t.jsx("strong",{children:"Pick what to change"}),t.jsx("p",{children:"Find subjects detects people and objects you can select. Draw region marks any area by hand."})]}),e[40]=m):m=e[40],m}return null}function $u(l){const e=Y.c(8),{targets:s,candidates:n,replacements:i,onPick:a}=l;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{children:"Replacement images"}),e[0]=o):o=e[0];let r;e[1]!==n||e[2]!==a||e[3]!==i||e[4]!==s?(r=n.length===0?t.jsx("p",{className:"notebook-replacement-empty",children:"Place another image on the grid, then pick it here or mention it as @address in the instructions."}):s.map(d=>t.jsxs("div",{className:"notebook-replacement-row",children:[t.jsx("strong",{children:d.label}),i[d.key]&&t.jsxs("button",{type:"button",onClick:()=>a(d.key,""),children:["Clear replacement for ",d.label]}),t.jsx("div",{className:"notebook-replacement-picker",role:"listbox","aria-label":`Replacement for ${d.label}`,children:n.map(u=>{const f=i[d.key]===u.artifactId;return t.jsxs("button",{type:"button",role:"option","aria-selected":f,className:`notebook-replacement-option${f?" selected":""}`,onClick:()=>a(d.key,u.artifactId),children:[u.thumbnailUrl?t.jsx("img",{src:u.thumbnailUrl,alt:""}):null,"@",u.address]},u.artifactId)})})]},d.key)),e[1]=n,e[2]=a,e[3]=i,e[4]=s,e[5]=r):r=e[5];let c;return e[6]!==r?(c=t.jsxs("div",{className:"notebook-replacement-list",children:[o,r]}),e[6]=r,e[7]=c):c=e[7],c}function df({address:l,mediaUrl:e,width:s,height:n,details:i,subjectMap:a,subjectMapLoading:o,analysisUnavailableReason:r,initialRegions:c,instruction:d,onInstructionChange:u,replacementCandidates:f,closeRef:m,imageEditModels:b,imageEditModelsLoading:p,defaultImageEditModelId:g,onEstimateImageEditCost:h,onAnalyzeSubjects:y,onEditingChange:x,onEditSubjects:j,onSubmitInstruction:v,onBack:k,onClose:w}){const S=C.useId(),M=C.useId(),N=C.useId(),$=C.useRef(!1),R=C.useRef(null),[I,P]=C.useState(()=>new Set),[T,D]=C.useState(()=>new Set),[A,F]=C.useState(()=>[...c??[]]),[E,z]=C.useState(()=>new Set(c?.map(se=>se.id))),[_,L]=C.useState(!1),[B,H]=C.useState(null),[q,U]=C.useState(null),[K,ee]=C.useState({}),[ne,V]=C.useState(!1),[re,W]=C.useState(!1),[Z,ie]=C.useState(.42),[J,G]=C.useState(null),[ce,ae]=C.useState(null),[X,le]=C.useState(null),[de,pe]=C.useState(null),ue=a?.status==="ready",me=C.useMemo(()=>a?.subjects??[],[a]),fe=C.useMemo(()=>me.filter(se=>I.has(se.id)),[I,me]),xe=C.useMemo(()=>A.filter(se=>E.has(se.id)),[A,E]),he=C.useMemo(()=>Er(xe,fe,A),[A,xe,fe]),oe=Ar(he,K),Q=Dr(d).length>0||he.some(se=>!!K[se.key]),te=Q?"replace":"edit",be=X??g??b?.[0]?.id??null,ve=se=>se.capabilities[Q?"regionReplace":"semantic"],Ce=se=>{h&&h(se,te).then(ye=>{$.current&&pe(ye)}).catch(()=>{$.current&&pe(null)})},Se=A.find(se=>se.id===q)??null,$e=Se?Fr(Se.box,me):null,Be=o&&a?.status!=="analyzing"&&J!=="analyze",_e=a?.status==="analyzing"||J==="analyze",nt=a?.status==="failed",Ke=!!(r||!y||J&&J!=="analyze"||Be||_e),Xe=A.length>0||ue&&me.length>0,qe=_r(fe,he,Q),Fe=!Q&&he.length===0,Ve=d.trim(),Ze=!!v&&J===null&&(Ve.length>0?qe!==null||Fe:oe),Ge=Q?"Replace with image":"Apply edit";C.useEffect(()=>($.current=!0,()=>{$.current=!1}),[]);const et=async(se,ye)=>{if(!J){G(se),ae(null),se!=="analyze"&&x?.(!0);try{const Me=await ye();$.current&&Me&&ae({tone:"success",text:Me})}catch(Me){$.current&&ae({tone:"error",text:vu(Me)})}finally{$.current&&(G(null),se!=="analyze"&&x?.(!1))}}},tt=(se=!1)=>{if(ue&&!se){W(!1),V(ye=>!ye);return}y&&et("analyze",async()=>(await y(se),null))},Re=()=>{!j||he.length===0||et("remove",async()=>await j({operation:"remove",subjectIds:fe.map(ye=>ye.id),...xe.length>0?{editRegions:xe.map(ye=>ye.box),...be?{model:be}:{}}:{}})?"Removal queued as a new image.":null)},Pe=()=>{if(!v||!Ze)return;const se={...Or(fe.map(ye=>ye.id),xe,Object.fromEntries(he.flatMap(ye=>K[ye.key]?[[ye.key,K[ye.key]]]:[]))),...be?{model:be}:{}};et("apply",async()=>{const ye=await v(Ve,se);if(!ye.ok)throw new Error(ye.message);return ye.message})},Je=se=>{se.key!=="Enter"||!(se.metaKey||se.ctrlKey)||(se.preventDefault(),Pe())},De=()=>{R.current=null,H(null)},ke=()=>{De(),L(se=>!se),W(!1),V(!1)},Oe=se=>{F(ye=>ye.filter(Me=>Me.id!==se)),z(ye=>{const Me=new Set(ye);return Me.delete(se),Me}),ee(ye=>{const Me={...ye};return delete Me[se],Me})},at=()=>{Se&&F(se=>se.map(ye=>ye.id===Se.id?Br(ye,me):ye))},Et=se=>{!_||se.button!==0||(se.preventDefault(),se.currentTarget.setPointerCapture(se.pointerId),R.current=wn(se,s,n),H(null))},At=se=>{!_||!R.current||H(jl(R.current,wn(se,s,n)))},$t=se=>{if(!_||!R.current)return;const ye=jl(R.current,wn(se,s,n));if(De(),!ye)return;const Me={id:zr(A),box:ye};F(Ye=>[...Ye,Me]),z(Ye=>new Set([...Ye,Me.id])),V(!1),W(!1)},lt=Be?"Loading…":_e?"Analyzing…":ue?ne?"Show subjects":"Hide subjects":"Find subjects";return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"image-editor-header",children:[t.jsx("button",{type:"button",className:"image-editor-icon-button","aria-label":"Back to fullscreen view",title:"Back to fullscreen view (Esc)",onClick:k,children:t.jsx(Ys,{size:18})}),i,t.jsx("button",{ref:m,type:"button",className:"image-editor-icon-button notebook-media-fullscreen-close","aria-label":"Close fullscreen preview","data-composer-focus":"return",onClick:w,children:t.jsx(dt,{size:18})})]}),t.jsxs("nav",{className:"image-editor-tools","aria-label":"Selection tools",children:[t.jsxs("button",{type:"button",className:ue&&!ne?"active":"","aria-pressed":ue?!ne:void 0,disabled:Ke,title:lt,onClick:()=>tt(),children:[Be||_e?t.jsx(ct,{size:18}):ue&&!ne?t.jsx(Il,{size:18}):t.jsx(ks,{size:18}),t.jsx("span",{children:lt})]}),t.jsxs("button",{type:"button",className:_?"active":"","aria-pressed":_,disabled:J!==null,title:"Draw region",onClick:ke,children:[t.jsx(Qo,{size:18}),t.jsx("span",{children:"Draw region"})]}),ue&&a?.baseUrl&&t.jsxs("button",{type:"button",className:re?"active":"","aria-pressed":re,disabled:fe.length===0||xe.length>0||J!==null,title:"Preview removal",onClick:()=>{W(se=>!se),V(!1),L(!1)},children:[t.jsx(Rl,{size:18}),t.jsx("span",{children:re?"Show overlays":"Preview removal"})]})]}),t.jsxs("div",{className:"notebook-subject-stage",children:[ue&&a&&re?t.jsx(Nu,{mediaUrl:e,subjectMap:a,selectedIds:I}):t.jsx(wu,{mediaUrl:e,width:s,height:n,subjectMap:ne?null:a,selectedIds:I,hiddenIds:T,regions:ne?[]:A,selectedRegionIds:E,drawMode:_,draftBox:B,snapRegionId:$e?q:null,opacity:Z,onToggle:se=>P(ye=>ys(ye,se)),onToggleRegion:se=>z(ye=>ys(ye,se)),onHoverRegion:U,onPointerDown:Et,onPointerMove:At,onPointerUp:$t,onCancelDraw:De}),_&&t.jsx("p",{className:"image-editor-stage-hint","aria-live":"polite",children:"Drag on the image to draw a region"}),$e&&Se&&!_&&t.jsxs("button",{type:"button",className:"notebook-region-snap",onClick:at,children:["Snap to ",me.find(se=>se.id===$e.subjectId)?.label??"subject"]})]}),t.jsxs("aside",{className:"notebook-subject-panel","aria-label":"Subject editor",children:[t.jsxs("form",{className:"image-editor-instructions","aria-label":`Edit instructions for @${l}`,onSubmit:se=>{se.preventDefault(),Pe()},children:[t.jsxs("div",{className:"image-editor-target",children:[t.jsx("span",{children:"Applies to"}),t.jsx("strong",{className:qe?"":"empty",children:qe??"Whole image"})]}),t.jsx("label",{htmlFor:S,children:"What should change?"}),t.jsx("textarea",{id:S,value:d,rows:5,"aria-describedby":M,placeholder:Lr(fe,he,Q),disabled:!v,autoFocus:!0,onChange:se=>u(se.target.value),onKeyDown:Je}),t.jsxs("p",{id:M,className:"image-editor-hint",children:["The result lands in a new cell next to @",l,"."]}),(b?.length??0)>0&&t.jsxs("div",{className:"image-editor-model",children:[t.jsx("label",{htmlFor:N,children:"Model"}),t.jsx("select",{id:N,value:be??"",disabled:p,onChange:se=>{le(se.target.value),pe(null),Ce(se.target.value)},onFocus:()=>{be&&de===null&&Ce(be)},children:(b??[]).map(se=>t.jsxs("option",{value:se.id,disabled:!ve(se),children:[se.label,ve(se)?"":" — cannot edit this target"]},se.id))}),t.jsx("p",{className:"image-editor-cost",role:"status",children:p?"Loading models…":de===null?"Cost estimate unavailable":`Estimated provider cost ${de}`})]}),ce&&t.jsx("p",{className:`image-editor-status ${ce.tone}`,role:"status",children:ce.text}),t.jsxs("div",{className:"image-editor-submit",children:[t.jsxs("button",{type:"submit",className:"apply",disabled:!Ze,children:[J==="apply"?t.jsx(ct,{size:14}):t.jsx(Si,{size:14}),Ge,t.jsx("kbd",{"aria-hidden":"true",children:"⌘↵"})]}),t.jsxs("button",{type:"button",className:"remove",disabled:he.length===0||J!==null||!j,onClick:Re,children:[J==="remove"?t.jsx(ct,{size:14}):t.jsx(Rl,{size:14}),"Remove"]})]})]}),t.jsxs("div",{className:"notebook-subject-panel-body","aria-live":"polite",children:[t.jsx(Cu,{analysisUnavailableReason:r,checkingCache:Be,analyzing:_e,analysisFailed:nt&&!_e,ready:ue,hasTargets:Xe,subjectCount:me.length,regionCount:A.length,error:a?.error??null,onAnalyze:tt}),Xe&&t.jsxs("div",{className:"notebook-subject-list",children:[t.jsxs("div",{className:"notebook-subject-list-actions",children:[t.jsxs("span",{children:[fe.length+E.size," selected"]}),ue&&me.length>0&&t.jsxs("label",{className:"notebook-subject-opacity",children:[t.jsx("span",{children:"Overlay"}),t.jsx("input",{type:"range",min:"0.15",max:"0.8",step:"0.05",value:Z,onChange:se=>ie(Number(se.target.value))})]}),ue&&me.length>0&&t.jsx("button",{type:"button",onClick:()=>P(new Set(fe.length===me.length?[]:me.map(se=>se.id))),children:fe.length===me.length?"Clear":"Select all"})]}),A.map((se,ye)=>{const Me=E.has(se.id),Ye=me.find(it=>it.id===se.matchedSubjectId);return t.jsxs("div",{className:`notebook-subject-row${Me?" selected":""}`,children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:Me,"aria-label":`Select region ${ye+1}`,onChange:()=>z(it=>ys(it,se.id))}),t.jsx("span",{className:"notebook-subject-swatch",style:{backgroundColor:vs},"aria-hidden":"true"}),t.jsxs("span",{className:"notebook-subject-copy",children:[t.jsx("strong",{children:Ye?`Region · ${Ye.label}`:`Region ${ye+1}`}),t.jsxs("small",{children:[se.box.width.toFixed(2)," × ",se.box.height.toFixed(2)]})]})]}),t.jsx("button",{type:"button",className:"notebook-subject-visibility","aria-label":`Remove region ${ye+1}`,onClick:()=>Oe(se.id),children:t.jsx(dt,{size:14})})]},se.id)}),ue&&me.map(se=>{const ye=I.has(se.id),Me=T.has(se.id);return t.jsxs("div",{className:`notebook-subject-row${ye?" selected":""}`,children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:ye,onChange:()=>P(Ye=>ys(Ye,se.id))}),t.jsx("span",{className:"notebook-subject-swatch",style:{backgroundColor:se.color},"aria-hidden":"true"}),t.jsxs("span",{className:"notebook-subject-copy",children:[t.jsx("strong",{children:se.label}),t.jsx("small",{children:se.description??(se.exactEdit?"Exact mask available":"Editable layer")})]})]}),t.jsx("button",{type:"button",className:"notebook-subject-visibility","aria-label":`${Me?"Show":"Hide"} ${se.label} overlay`,"aria-pressed":!Me,onClick:()=>D(Ye=>ys(Ye,se.id)),children:Me?t.jsx(Il,{size:14}):t.jsx(Ii,{size:14})})]},se.id)}),he.length>0&&t.jsx($u,{targets:he,candidates:f,replacements:K,onPick:(se,ye)=>ee(Me=>({...Me,[se]:ye}))})]})]})]})]})}const Iu={"arrange-column":Ri,"arrange-row":$i,duplicate:Gs,download:Js,"extract-frame":ec,"generate-image":Qt,"generate-video":Cs,generations:Un,"group-images":Hn,inspect:Zo,library:Vn,media:Pi,run:Is,source:$s,split:Kn,upload:Qs,more:qn};function Ul(l){return[...l.querySelectorAll('[role="menuitem"]')].filter(e=>!e.disabled)}function uf(l){const e=Y.c(47),{actions:s,address:n,cellType:i,deleteDisabled:a,menuId:o,menuLabel:r,position:c,returnFocus:d,onAction:u,onClose:f,onDelete:m}=l,b=a===void 0?!1:a,p=C.useRef(null);let g,h;e[0]!==c.x||e[1]!==c.y?(g=()=>{const E=p.current;if(!E)return;const z=()=>{const L=Math.max(8,Math.min(c.x,window.innerWidth-E.offsetWidth-8-1)),B=Math.max(8,Math.min(c.y,window.innerHeight-E.offsetHeight-8-1));E.style.left=`${L}px`,E.style.top=`${B}px`};z();const _=new ResizeObserver(z);return _.observe(E),Ul(E)[0]?.focus({preventScroll:!0}),()=>_.disconnect()},h=[c.x,c.y],e[0]=c.x,e[1]=c.y,e[2]=g,e[3]=h):(g=e[2],h=e[3]),C.useLayoutEffect(g,h);let y,x;e[4]!==f?(y=()=>{const E=_=>{const L=_.target;!(L instanceof Node)||p.current?.contains(L)||f()},z=()=>f();return document.addEventListener("pointerdown",E,!0),window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{document.removeEventListener("pointerdown",E,!0),window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},x=[f],e[4]=f,e[5]=y,e[6]=x):(y=e[5],x=e[6]),C.useEffect(y,x);let j;e[7]!==f||e[8]!==d?(j=()=>{f(),d?.isConnected&&d.focus({preventScroll:!0})},e[7]=f,e[8]=d,e[9]=j):j=e[9];const v=j;let k;e[10]!==u||e[11]!==f?(k=E=>{f(),u(E)},e[10]=u,e[11]=f,e[12]=k):k=e[12];const w=k;let S;e[13]!==b||e[14]!==f||e[15]!==m||e[16]!==v?(S=E=>{const z=p.current;if(!z)return;if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),v();return}if(E.key==="Tab"){f();return}if(m&&!b&&(E.key==="Delete"||E.key==="Backspace")){E.preventDefault(),E.stopPropagation(),f(),m();return}if(E.key!=="ArrowDown"&&E.key!=="ArrowUp"&&E.key!=="Home"&&E.key!=="End")return;E.preventDefault(),E.stopPropagation();const _=Ul(z);if(_.length===0)return;const L=_.findIndex(Mu),B=E.key==="Home"?0:E.key==="End"?_.length-1:E.key==="ArrowDown"?(L+1+_.length)%_.length:(L-1+_.length)%_.length;_[B]?.focus()},e[13]=b,e[14]=f,e[15]=m,e[16]=v,e[17]=S):S=e[17];const M=S,N=r??`Cell actions for ${n}`;let $;e[18]!==c.x||e[19]!==c.y?($={left:c.x,top:c.y},e[18]=c.x,e[19]=c.y,e[20]=$):$=e[20];let R;e[21]!==n?(R=t.jsx("strong",{children:n}),e[21]=n,e[22]=R):R=e[22];let I;e[23]!==i?(I=t.jsx("span",{children:i}),e[23]=i,e[24]=I):I=e[24];let P;e[25]!==R||e[26]!==I?(P=t.jsxs("div",{className:"cell-context-menu-heading","aria-hidden":"true",children:[R,I]}),e[25]=R,e[26]=I,e[27]=P):P=e[27];let T;if(e[28]!==s||e[29]!==w){let E;e[31]!==w?(E=z=>{const _=Iu[z.icon];return t.jsxs("button",{type:"button",role:"menuitem","data-cell-action":z.id,"data-workspace-action-surface":z.id==="more"?"cell-menu":void 0,disabled:z.disabled,onClick:()=>w(z.id),children:[t.jsx(_,{size:15,"aria-hidden":"true"}),t.jsx("span",{children:z.label})]},z.id)},e[31]=w,e[32]=E):E=e[32],T=s.map(E),e[28]=s,e[29]=w,e[30]=T}else T=e[30];let D;e[33]!==T?(D=t.jsx("div",{className:"cell-context-menu-actions",role:"presentation",children:T}),e[33]=T,e[34]=D):D=e[34];let A;e[35]!==b||e[36]!==f||e[37]!==m?(A=m&&t.jsx("div",{className:"cell-context-menu-danger",role:"presentation",children:t.jsxs("button",{type:"button",role:"menuitem","data-cell-action":"delete","aria-keyshortcuts":"Delete Backspace",disabled:b,onClick:()=>{f(),m()},children:[t.jsx(as,{size:15,"aria-hidden":"true"}),t.jsx("span",{children:"Delete cell"}),t.jsx("kbd",{children:"⌫"})]})}),e[35]=b,e[36]=f,e[37]=m,e[38]=A):A=e[38];let F;if(e[39]!==M||e[40]!==o||e[41]!==$||e[42]!==P||e[43]!==D||e[44]!==A||e[45]!==N){const E=t.jsxs("div",{ref:p,id:o,className:"cell-context-menu","data-composer-focus":"return",role:"menu","aria-label":N,style:$,onContextMenu:Ru,onKeyDown:M,children:[P,D,A]});F=typeof document>"u"?E:hs.createPortal(E,document.body),e[39]=M,e[40]=o,e[41]=$,e[42]=P,e[43]=D,e[44]=A,e[45]=N,e[46]=F}else F=e[46];return F}function Ru(l){return l.preventDefault()}function Mu(l){return l===document.activeElement}function mf(l){const e=Y.c(91),{activeBook:s,books:n,disabled:i,error:a,loading:o,open:r,onCreate:c,onDelete:d,onOpenChange:u,onRefresh:f,onRename:m,onSelect:b}=l,p=C.useRef(null),g=C.useRef(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={kind:"idle"},e[0]=h):h=e[0];const[y,x]=C.useState(h),[j,v]=C.useState(""),[k,w]=C.useState(""),[S,M]=C.useState(null),[N,$]=C.useState(null),R=y.kind==="rename"?y.bookId:null,I=y.kind==="create",P=y.kind==="delete"?y.bookId:null;let T;e[1]===Symbol.for("react.memo_cache_sentinel")?(T=Q=>{Q!==void 0&&Q&&g.current?.focus(),x({kind:"idle"}),v(""),w(""),$(null)},e[1]=T):T=e[1];const D=T;let A;e[2]!==y||e[3]!==u||e[4]!==S?(A=Q=>{const te=Q===void 0?!1:Q;ds(y,{kind:"close"},S!==null).closeMenu&&(D(te),u(!1))},e[2]=y,e[3]=u,e[4]=S,e[5]=A):A=e[5];const F=A;let E,z;e[6]!==F||e[7]!==y||e[8]!==u||e[9]!==r||e[10]!==S?(E=()=>{if(!r)return;const Q=be=>{p.current?.contains(be.target)||F()},te=be=>{if(be.key!=="Escape")return;const ve=ds(y,{kind:"escape"},S!==null);if(ve.closeMenu){be.preventDefault(),D(!0),u(!1);return}ve.mode!==y&&(be.preventDefault(),D(!0))};return document.addEventListener("pointerdown",Q),document.addEventListener("focusin",Q),document.addEventListener("keydown",te),()=>{document.removeEventListener("pointerdown",Q),document.removeEventListener("focusin",Q),document.removeEventListener("keydown",te)}},z=[F,y,u,r,S,D],e[6]=F,e[7]=y,e[8]=u,e[9]=r,e[10]=S,e[11]=E,e[12]=z):(E=e[11],z=e[12]),C.useEffect(E,z);let _;e[13]!==y||e[14]!==S?(_=()=>{const Q=ds(y,{kind:"begin-create"},S!==null);Q.mode!==y&&(x(Q.mode),v(""),$(null))},e[13]=y,e[14]=S,e[15]=_):_=e[15];const L=_;let B;e[16]!==y||e[17]!==S?(B=Q=>{const te=ds(y,{kind:"begin-rename",bookId:Q.bookId},S!==null);te.mode!==y&&(x(te.mode),w(""),$(null),v(Q.name))},e[16]=y,e[17]=S,e[18]=B):B=e[18];const H=B;let q;e[19]!==n||e[20]!==y||e[21]!==S?(q=Q=>{if(n.length<2)return;const te=ds(y,{kind:"begin-delete",bookId:Q},S!==null);te.mode!==y&&(x(te.mode),v(""),w(""),$(null))},e[19]=n,e[20]=y,e[21]=S,e[22]=q):q=e[22];const U=q;let K;e[23]!==y||e[24]!==S?(K=()=>{ds(y,{kind:"cancel"},S!==null).mode!==y&&D(!0)},e[23]=y,e[24]=S,e[25]=K):K=e[25];const ee=K;let ne;e[26]!==s?.bookId||e[27]!==F||e[28]!==i||e[29]!==b||e[30]!==S?(ne=async Q=>{if(i||S||Q===s?.bookId){Q===s?.bookId&&F(!0);return}$(null),M({kind:"select",bookId:Q});const te=await b(Q);if(M(null),!te.ok){$(te.error);return}F(!0)},e[26]=s?.bookId,e[27]=F,e[28]=i,e[29]=b,e[30]=S,e[31]=ne):ne=e[31];const V=ne;let re;e[32]!==n||e[33]!==ee||e[34]!==j||e[35]!==R||e[36]!==m||e[37]!==S?(re=async Q=>{if(Q?.preventDefault(),!R||S)return;const te=cs(j),be=n.find(Ce=>Ce.bookId===R);if(!te){$(cl);return}if(te===be?.name){ee();return}$(null),M({kind:"rename",bookId:R});const ve=await m(R,te);if(M(null),!ve.ok){$(ve.error);return}ee()},e[32]=n,e[33]=ee,e[34]=j,e[35]=R,e[36]=m,e[37]=S,e[38]=re):re=e[38];const W=re;let Z;e[39]!==k||e[40]!==c||e[41]!==u||e[42]!==S?(Z=async Q=>{if(Q?.preventDefault(),S)return;const te=cs(k);if(!te){$(cl);return}$(null),M({kind:"create"});const be=await c(te);if(M(null),!be.ok){$(be.error);return}D(!0),u(!1)},e[39]=k,e[40]=c,e[41]=u,e[42]=S,e[43]=Z):Z=e[43];const ie=Z;let J;e[44]!==n||e[45]!==d||e[46]!==S?(J=async Q=>{if(S||n.length<2)return;$(null),M({kind:"delete",bookId:Q.bookId});const te=await d(Q.bookId,Q.name);if(M(null),!te.ok){$(te.error);return}D(!0)},e[44]=n,e[45]=d,e[46]=S,e[47]=J):J=e[47];const G=J;let ce;e[48]!==F||e[49]!==u||e[50]!==r?(ce=()=>{if(r){F();return}u(!0)},e[48]=F,e[49]=u,e[50]=r,e[51]=ce):ce=e[51];const ae=ce;let X;e[52]!==s?(X=s?xn(s.artifactCount):"No active project",e[52]=s,e[53]=X):X=e[53];const le=X,de=i||S!==null,pe=s?.name??"select-project";let ue;e[54]!==pe?(ue=t.jsx("strong",{children:pe}),e[54]=pe,e[55]=ue):ue=e[55];let me;e[56]!==le||e[57]!==s?(me=s&&t.jsx("span",{className:"book-project-active-count",title:le,children:s.artifactCount}),e[56]=le,e[57]=s,e[58]=me):me=e[58];let fe;e[59]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsx(Ns,{size:14}),e[59]=fe):fe=e[59];let xe;e[60]!==r||e[61]!==ue||e[62]!==me||e[63]!==ae?(xe=t.jsxs("button",{ref:g,type:"button",className:"brand-project-menu-toggle","aria-controls":"book-project-menu","aria-expanded":r,"aria-haspopup":"menu",onClick:ae,children:[ue,me,fe]}),e[60]=r,e[61]=ue,e[62]=me,e[63]=ae,e[64]=xe):xe=e[64];let he;e[65]!==s?.bookId||e[66]!==L||e[67]!==U||e[68]!==H||e[69]!==n||e[70]!==ee||e[71]!==G||e[72]!==k||e[73]!==I||e[74]!==P||e[75]!==j||e[76]!==R||e[77]!==a||e[78]!==o||e[79]!==de||e[80]!==f||e[81]!==r||e[82]!==N||e[83]!==S||e[84]!==V||e[85]!==ie||e[86]!==W?(he=r&&t.jsxs("div",{id:"book-project-menu",className:"book-project-menu",role:"menu","aria-label":"Videobook projects",children:[t.jsxs("header",{className:"book-project-menu-header",children:[t.jsxs("div",{children:[t.jsx("span",{children:"Projects"}),o&&t.jsx(ct,{size:13})]}),t.jsxs("small",{children:[n.length," total"]})]}),a&&t.jsxs("div",{className:"book-project-menu-message error",role:"alert",children:[t.jsx("span",{children:a}),t.jsx("button",{type:"button",disabled:o,onClick:f,children:"Retry"})]}),N&&!R&&!I&&!P&&t.jsx("div",{className:"book-project-menu-message error",role:"alert",children:t.jsx("span",{children:N})}),t.jsxs("div",{className:"book-project-menu-list",children:[o&&n.length===0&&t.jsxs("div",{className:"book-project-menu-empty",children:[t.jsx(ct,{size:15}),t.jsx("span",{children:"Loading projects"})]}),!o&&n.length===0&&t.jsx("div",{className:"book-project-menu-empty",children:"No projects available"}),n.map(Q=>{const te=Q.bookId===s?.bookId,be=Q.bookId===R,ve=Q.bookId===P,Ce=S&&"bookId"in S?S.bookId===Q.bookId:!1,Se=n.length>1;return be?t.jsxs("form",{className:"book-project-form",onSubmit:W,children:[t.jsx("input",{autoFocus:!0,"aria-label":`New name for ${Q.name}`,autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,disabled:S!==null,value:j,onChange:$e=>v($e.target.value)}),t.jsxs("div",{className:"book-project-form-actions",children:[t.jsx("button",{type:"submit",disabled:S!==null,title:"Save project name","aria-label":"Save project name",children:S?.kind==="rename"?t.jsx(ct,{size:14}):t.jsx(Jt,{size:14})}),t.jsx("button",{type:"button",disabled:S!==null,title:"Cancel rename","aria-label":"Cancel rename",onClick:ee,children:t.jsx(dt,{size:14})})]}),j&&cs(j)!==j&&t.jsxs("small",{className:"book-project-form-hint",children:["Slug: ",cs(j)||"Enter letters or numbers"]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]},Q.bookId):ve?t.jsxs("div",{className:"book-project-delete",role:"group","aria-label":`Delete ${Q.name}`,children:[t.jsx(as,{size:15}),t.jsxs("div",{children:[t.jsxs("strong",{children:["Delete ",Q.name,"?"]}),t.jsxs("small",{children:[xn(Q.artifactCount)," and"," ",vl(Q.notebookCount)," will be removed"]})]}),t.jsxs("div",{className:"book-project-form-actions",children:[t.jsx("button",{type:"button",disabled:S!==null,title:`Confirm deletion of ${Q.name}`,"aria-label":`Confirm deletion of ${Q.name}`,onClick:()=>{G(Q)},children:S?.kind==="delete"?t.jsx(ct,{size:14}):t.jsx(Jt,{size:14})}),t.jsx("button",{type:"button",disabled:S!==null,title:"Cancel deletion","aria-label":"Cancel deletion",onClick:ee,children:t.jsx(dt,{size:14})})]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]},Q.bookId):t.jsxs("div",{className:`book-project-row ${te?"active":""}`,"aria-busy":Ce,children:[t.jsxs("button",{type:"button",className:"book-project-select",role:"menuitem","aria-current":te?"true":void 0,disabled:de,onClick:()=>{V(Q.bookId)},children:[t.jsx("span",{className:"book-project-marker"}),t.jsxs("span",{className:"book-project-copy",children:[t.jsx("strong",{children:Q.name}),t.jsx("small",{children:vl(Q.notebookCount)})]}),t.jsx("span",{className:`book-project-artifact-count ${Q.artifactCount===0?"empty":""}`,title:xn(Q.artifactCount),children:Ce?t.jsx(ct,{size:12}):Q.artifactCount})]}),t.jsxs("div",{className:"book-project-actions",children:[t.jsx("button",{type:"button",disabled:de,title:`Rename ${Q.name}`,"aria-label":`Rename ${Q.name}`,onClick:()=>H(Q),children:t.jsx(tc,{size:13})}),t.jsx("button",{type:"button",disabled:de||!Se,title:Se?`Delete ${Q.name}`:"Create another project before deleting this one","aria-label":`Delete ${Q.name}`,onClick:()=>U(Q.bookId),children:t.jsx(as,{size:13})})]})]},Q.bookId)})]}),t.jsx("footer",{className:"book-project-menu-footer",children:I?t.jsxs("form",{className:"book-project-form",onSubmit:ie,children:[t.jsx("input",{autoFocus:!0,"aria-label":"New project slug",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,disabled:S!==null,placeholder:"my-project",value:k,onChange:Q=>w(Q.target.value)}),t.jsxs("div",{className:"book-project-form-actions",children:[t.jsx("button",{type:"submit",disabled:S!==null,title:"Create project","aria-label":"Create project",children:S?.kind==="create"?t.jsx(ct,{size:14}):t.jsx(Jt,{size:14})}),t.jsx("button",{type:"button",disabled:S!==null,title:"Cancel new project","aria-label":"Cancel new project",onClick:ee,children:t.jsx(dt,{size:14})})]}),k&&cs(k)!==k&&t.jsxs("small",{className:"book-project-form-hint",children:["Slug: ",cs(k)||"Enter letters or numbers"]}),N&&t.jsx("span",{className:"book-project-form-error",role:"alert",children:N})]}):t.jsxs("button",{type:"button",className:"book-project-create",disabled:de,onClick:L,children:[t.jsx(Zt,{size:14}),t.jsx("span",{children:"New project"})]})})]}),e[65]=s?.bookId,e[66]=L,e[67]=U,e[68]=H,e[69]=n,e[70]=ee,e[71]=G,e[72]=k,e[73]=I,e[74]=P,e[75]=j,e[76]=R,e[77]=a,e[78]=o,e[79]=de,e[80]=f,e[81]=r,e[82]=N,e[83]=S,e[84]=V,e[85]=ie,e[86]=W,e[87]=he):he=e[87];let oe;return e[88]!==xe||e[89]!==he?(oe=t.jsxs("div",{className:"book-project-selector","data-composer-focus":"return",ref:p,children:[xe,he]}),e[88]=xe,e[89]=he,e[90]=oe):oe=e[90],oe}function Pu(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:{}}function Fn(l){const e=Object.values(l.properties??{}).find(s=>"const"in s);return l.title??(e?ws(String(e.const)):ws(String(l.type??"value")))}function Hl({id:l,value:e,disabled:s,onChange:n}){const[i,a]=C.useState(()=>JSON.stringify(e??{},null,2));return t.jsx("textarea",{id:l,value:i,disabled:s,rows:5,spellCheck:!1,onChange:o=>{const r=o.target.value;a(r);try{n(r.trim()?JSON.parse(r):void 0),o.target.setCustomValidity("")}catch{o.target.setCustomValidity("Enter valid JSON for these additional options.")}}})}function _n(l){const e=Y.c(13),{name:s,schema:n,value:i,required:a,disabled:o,choices:r,choiceName:c,onChange:d}=l,u=a===void 0?!1:a,f=o===void 0?!1:o,m=C.useId(),b=Hr(n),[p,g]=C.useState(null),h=p===null?Kr(n,i):{...n,...b[p]},y=n.title??ws(s),x=r[c??s],j=h.type==="object"||h.type==="array",v=b.findIndex(I=>Fn(I)===Fn(h)),k=h.enum??(h.type==="boolean"?[!0,!1]:void 0),w=Pu(i),S=Array.isArray(i)?i:[];if("const"in h){const I=String(h.const);let P;return e[0]!==I?(P=t.jsx("strong",{children:I}),e[0]=I,e[1]=P):P=e[1],t.jsxs("div",{className:"workspace-action-fixed",children:[t.jsx("span",{children:y}),P]})}const M=()=>{if(k)return t.jsxs("select",{id:m,required:u,disabled:f,value:i===void 0?"":String(k.indexOf(i)),onChange:D=>d(D.target.value===""?void 0:k[Number(D.target.value)]),children:[t.jsx("option",{value:"",children:u?`Choose ${y.toLowerCase()}`:"Use default"}),k.map(Au)]});if(x)return t.jsxs("select",{id:m,required:u,disabled:f,value:typeof i=="string"?i:"",onChange:D=>d(D.target.value||void 0),children:[t.jsx("option",{value:"",children:x.length?`Choose ${y.toLowerCase()}`:`No ${y.toLowerCase()} available`}),x.map(Eu)]});if(!h.type)return t.jsx(Hl,{id:m,value:i,disabled:f,onChange:d});if(h.type==="null")return t.jsx("output",{id:m,children:"No value"});const I=h.type==="number"||h.type==="integer",P=h.format==="password"||/secret|password|api_key|access_token/u.test(s);return!I&&/prompt|text|description|markdown|content|script/u.test(s)?t.jsx("textarea",{id:m,value:typeof i=="string"?i:"",disabled:f,required:u,minLength:h.minLength,maxLength:h.maxLength,rows:4,onChange:D=>d(D.target.value)}):t.jsx("input",{id:m,type:I?"number":P?"password":"text",value:typeof i=="string"||typeof i=="number"?i:"",required:u,disabled:f,autoComplete:"off",step:h.type==="integer"?1:"any",min:h.minimum??(h.type==="integer"&&h.exclusiveMinimum!==void 0?h.exclusiveMinimum+1:void 0),max:h.maximum??(h.type==="integer"&&h.exclusiveMaximum!==void 0?h.exclusiveMaximum-1:void 0),minLength:h.minLength,maxLength:h.maxLength,onChange:D=>d(I?D.target.value===""?void 0:Number(D.target.value):D.target.value)})};let N;e[2]!==u?(N=u&&t.jsx("span",{"aria-hidden":"true",children:" *"}),e[2]=u,e[3]=N):N=e[3];let $;e[4]!==n.description?($=n.description&&t.jsx("p",{className:"workspace-action-hint",children:n.description}),e[4]=n.description,e[5]=$):$=e[5];let R;return e[6]!==f||e[7]!==y||e[8]!==d||e[9]!==u||e[10]!==j||e[11]!==i?(R=j&&!u&&i!==void 0&&t.jsxs("button",{type:"button",disabled:f,onClick:()=>d(void 0),children:["Use default ",y.toLowerCase()]}),e[6]=f,e[7]=y,e[8]=d,e[9]=u,e[10]=j,e[11]=i,e[12]=R):R=e[12],t.jsxs("div",{className:`workspace-action-field${j?" workspace-action-structure":""}`,children:[t.jsxs("label",{htmlFor:m,children:[y,N]}),$,b.length>1&&t.jsx("select",{"aria-label":`${y} format`,disabled:f,value:Math.max(0,v),onChange:I=>{const P=Number(I.target.value);g(P),d(gn(b[P],!0))},children:b.map(Tu)}),j&&!u&&i===void 0?t.jsxs("button",{type:"button",disabled:f,onClick:()=>d(gn(h,!0)),children:["Add ",y.toLowerCase()]}):h.type==="object"?Object.keys(h.properties??{}).length?t.jsx("fieldset",{id:m,disabled:f,"aria-label":y,children:Object.entries(h.properties??{}).map(I=>{const[P,T]=I;return t.jsx(_n,{name:P,schema:T,value:w[P],choices:r,required:h.required?.includes(P),disabled:f,onChange:D=>d({...w,[P]:D})},P)})}):t.jsx(Hl,{id:m,value:i,disabled:f,onChange:d}):h.type==="array"?t.jsxs("fieldset",{id:m,disabled:f,"aria-label":y,children:[S.map((I,P)=>t.jsxs("div",{className:"workspace-action-array-row",children:[t.jsx(_n,{name:`${s} ${P+1}`,schema:h.items??{},value:I,required:!0,choices:r,choiceName:c??s,disabled:f,onChange:T=>d(S.map((D,A)=>A===P?T:D))}),t.jsx("button",{type:"button",disabled:f||S.length<=(h.minItems??0),"aria-label":`Remove ${y.toLowerCase()} ${P+1}`,onClick:()=>d(S.filter((T,D)=>D!==P)),children:"Remove"})]},P)),t.jsx("button",{type:"button",disabled:f||h.maxItems!==void 0&&S.length>=h.maxItems,onClick:()=>d([...S,gn(h.items??{},!0)]),children:"Add item"})]}):M(),R]})}function Tu(l,e){return t.jsx("option",{value:e,children:Fn(l)},e)}function Eu(l){return t.jsxs("option",{value:l.value,children:[l.label,l.detail?` · ${l.detail}`:""]},l.value)}function Au(l,e){return t.jsx("option",{value:e,children:typeof l=="boolean"?l?"Yes":"No":String(l)},e)}function Kl(l){return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:null}function Ks(l,e){const s=Array.isArray(l)?l:Kl(l)?.[e];return Array.isArray(s)?s.flatMap(n=>{const i=Kl(n);return i?[i]:[]}):[]}function Du(l){const e=Y.c(32),{action:s,value:n,values:i,onOpen:a}=l;if(s.handler.kind!=="tool")return null;const o=s.handler.tool;if(o==="list_entities"){let r;if(e[0]!==a||e[1]!==n){let d;e[3]!==a?(d=u=>t.jsxs("li",{children:[t.jsx("strong",{children:String(u.name)}),t.jsx("span",{children:String(u.prompt??u.description??"")}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>a("tool.update_entity",{entity_id:u.id}),children:"Edit"}),t.jsx("button",{type:"button",onClick:()=>a("tool.delete_entity",{entity_id:u.id}),children:"Delete saved item"})]})]},String(u.id)),e[3]=a,e[4]=d):d=e[4],r=Ks(n,"entities").map(d),e[0]=a,e[1]=n,e[2]=r}else r=e[2];let c;return e[5]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[5]=r,e[6]=c):c=e[6],c}if(o==="list_notebooks"){let r;if(e[7]!==a||e[8]!==n){let d;e[10]!==a?(d=u=>t.jsxs("li",{children:[t.jsx("strong",{children:String(u.name)}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>a("tool.get_notebook",{notebook_id:u.id}),children:"Open notebook"}),t.jsx("button",{type:"button",onClick:()=>a("tool.rename_notebook",{notebook_id:u.id,name:u.name}),children:"Rename"}),t.jsx("button",{type:"button",onClick:()=>a("tool.delete_notebook",{notebook_id:u.id}),children:"Delete notebook"})]})]},String(u.id)),e[10]=a,e[11]=d):d=e[11],r=Ks(n,"notebooks").map(d),e[7]=a,e[8]=n,e[9]=r}else r=e[9];let c;return e[12]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[12]=r,e[13]=c):c=e[13],c}if(o==="asset_history"||o==="list_book_actions"){let r;if(e[14]!==a||e[15]!==o||e[16]!==n||e[17]!==i){let d;e[19]!==a||e[20]!==o||e[21]!==i?(d=(u,f)=>{const m=u.hash??u.revision;return t.jsxs("li",{children:[t.jsx("strong",{children:String(u.message??u.operation??"Revision")}),t.jsx("span",{children:String(u.date??u.createdAt??"")}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>a(o==="asset_history"?"tool.read_file_at_commit":"tool.get_history_action",{...i,commit_hash:m,action_id:u.actionId??u.id??m}),children:"Preview revision"}),t.jsx("button",{type:"button",onClick:()=>a(o==="asset_history"?"tool.restore_asset_version":"tool.restore_edit_action",{...i,commit_hash:m,target_revision:m}),children:"Restore revision"})]})]},String(m??f))},e[19]=a,e[20]=o,e[21]=i,e[22]=d):d=e[22],r=Ks(n,o==="asset_history"?"commits":"actions").map(d),e[14]=a,e[15]=o,e[16]=n,e[17]=i,e[18]=r}else r=e[18];let c;return e[23]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[23]=r,e[24]=c):c=e[24],c}if(o==="search_archive"){let r;if(e[25]!==a||e[26]!==n){let d;e[28]!==a?(d=u=>t.jsxs("li",{children:[t.jsx("strong",{children:String(u.title??u.archive_id)}),t.jsx("span",{children:String(u.transcript_excerpt??"")}),t.jsxs("div",{children:[typeof u.media_url=="string"&&t.jsx("a",{href:u.media_url,target:"_blank",rel:"noreferrer",children:"Preview media"}),t.jsx("button",{type:"button",onClick:()=>a("tool.restore_archive_clips",{archive_ids:[u.archive_id]}),children:"Restore to project"})]})]},String(u.archive_id)),e[28]=a,e[29]=d):d=e[29],r=Ks(n,"results").map(d),e[25]=a,e[26]=n,e[27]=r}else r=e[27];let c;return e[30]!==r?(c=t.jsx("ul",{className:"workspace-action-linked-results",children:r}),e[30]=r,e[31]=c):c=e[31],c}return null}function Fu(l){const e=Y.c(61),{media:s,values:n,disabled:i,onChange:a}=l,o=C.useRef(null),r=s.width&&s.height?s.width/s.height:1.7777777777777777,c=typeof n.x=="number"?n.x:0,d=typeof n.y=="number"?n.y:0,u=typeof n.w=="number"?n.w:1,f=typeof n.h=="number"?n.h:1;let m;e[0]!==r?(m={aspectRatio:r},e[0]=r,e[1]=m):m=e[1];const b=m,p=`${c*100}%`,g=`${d*100}%`,h=`${u*100}%`,y=`${f*100}%`;let x;e[2]!==p||e[3]!==g||e[4]!==h||e[5]!==y?(x={left:p,top:g,width:h,height:y},e[2]=p,e[3]=g,e[4]=h,e[5]=y,e[6]=x):x=e[6];const j=x;let v;e[7]!==i||e[8]!==s.height||e[9]!==s.width||e[10]!==a?(v=U=>{i||a(mi(U,s.width,s.height))},e[7]=i,e[8]=s.height,e[9]=s.width,e[10]=a,e[11]=v):v=e[11];const k=v;if(!s.url){let U;return e[12]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{children:"Preview unavailable for this media."}),e[12]=U):U=e[12],U}const w=n.ratio==="16:9";let S;e[13]!==k?(S=()=>k("16:9"),e[13]=k,e[14]=S):S=e[14];let M;e[15]!==i||e[16]!==w||e[17]!==S?(M=t.jsx("button",{type:"button",disabled:i,"aria-pressed":w,onClick:S,children:"Landscape 16:9"}),e[15]=i,e[16]=w,e[17]=S,e[18]=M):M=e[18];const N=n.ratio==="9:16";let $;e[19]!==k?($=()=>k("9:16"),e[19]=k,e[20]=$):$=e[20];let R;e[21]!==i||e[22]!==N||e[23]!==$?(R=t.jsx("button",{type:"button",disabled:i,"aria-pressed":N,onClick:$,children:"Portrait 9:16"}),e[21]=i,e[22]=N,e[23]=$,e[24]=R):R=e[24];const I=n.ratio==="1:1";let P;e[25]!==k?(P=()=>k("1:1"),e[25]=k,e[26]=P):P=e[26];let T;e[27]!==i||e[28]!==I||e[29]!==P?(T=t.jsx("button",{type:"button",disabled:i,"aria-pressed":I,onClick:P,children:"Square 1:1"}),e[27]=i,e[28]=I,e[29]=P,e[30]=T):T=e[30];let D;e[31]!==M||e[32]!==R||e[33]!==T?(D=t.jsxs("div",{className:"workspace-crop-ratios",role:"group","aria-label":"Crop aspect ratio",children:[M,R,T]}),e[31]=M,e[32]=R,e[33]=T,e[34]=D):D=e[34];let A;e[35]!==i||e[36]!==c||e[37]!==d?(A=U=>{i||U.button!==0||(U.preventDefault(),U.currentTarget.setPointerCapture(U.pointerId),o.current={pointerId:U.pointerId,x:U.clientX,y:U.clientY,originX:c,originY:d})},e[35]=i,e[36]=c,e[37]=d,e[38]=A):A=e[38];let F;e[39]!==i||e[40]!==f||e[41]!==a||e[42]!==u?(F=U=>{const K=o.current;if(i||!K||U.pointerId!==K.pointerId)return;const ee=U.currentTarget.getBoundingClientRect();a({x:Math.max(0,Math.min(1-u,K.originX+(U.clientX-K.x)/ee.width)),y:Math.max(0,Math.min(1-f,K.originY+(U.clientY-K.y)/ee.height))})},e[39]=i,e[40]=f,e[41]=a,e[42]=u,e[43]=F):F=e[43];let E,z;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{o.current=null},z=()=>{o.current=null},e[44]=E,e[45]=z):(E=e[44],z=e[45]);let _;e[46]!==s.type||e[47]!==s.url?(_=s.type==="image"?t.jsx("img",{src:s.url,alt:"Source crop preview",draggable:!1}):t.jsx("video",{src:s.url,muted:!0,playsInline:!0,preload:"metadata"}),e[46]=s.type,e[47]=s.url,e[48]=_):_=e[48];let L;e[49]!==j?(L=t.jsx("div",{className:"workspace-crop-region",style:j}),e[49]=j,e[50]=L):L=e[50];let B;e[51]!==b||e[52]!==A||e[53]!==F||e[54]!==_||e[55]!==L?(B=t.jsxs("div",{className:"workspace-crop-frame",style:b,onPointerDown:A,onPointerMove:F,onPointerUp:E,onPointerCancel:z,children:[_,L]}),e[51]=b,e[52]=A,e[53]=F,e[54]=_,e[55]=L,e[56]=B):B=e[56];let H;e[57]===Symbol.for("react.memo_cache_sentinel")?(H=t.jsx("p",{children:"Choose an aspect ratio, then drag the crop to position it. The numeric fields below also control its position and size."}),e[57]=H):H=e[57];let q;return e[58]!==D||e[59]!==B?(q=t.jsxs("section",{className:"workspace-crop-preview","aria-label":"Crop preview",children:[D,B,H]}),e[58]=D,e[59]=B,e[60]=q):q=e[60],q}function Yn(l){const e=Y.c(12),{value:s,name:n}=l,i=n===void 0?"Result":n;if(s==null)return null;if(Array.isArray(s)){let r;if(e[0]!==i||e[1]!==s){let d;e[3]!==i?(d=(u,f)=>t.jsx("li",{children:t.jsx(Yn,{value:u,name:`${i} ${f+1}`})},f),e[3]=i,e[4]=d):d=e[4],r=s.map(d),e[0]=i,e[1]=s,e[2]=r}else r=e[2];let c;return e[5]!==i||e[6]!==r?(c=t.jsx("ol",{className:"workspace-action-result-list","aria-label":i,children:r}),e[5]=i,e[6]=r,e[7]=c):c=e[7],c}if(typeof s=="object"){let r;return e[8]!==s?(r=t.jsx("dl",{className:"workspace-action-result-fields",children:Object.entries(s).map(_u)}),e[8]=s,e[9]=r):r=e[9],r}const a=typeof s=="boolean"?s?"Yes":"No":String(s);let o;return e[10]!==a?(o=t.jsx("span",{children:a}),e[10]=a,e[11]=o):o=e[11],o}function _u(l){const[e,s]=l;return t.jsxs("div",{children:[t.jsx("dt",{children:ws(e)}),t.jsx("dd",{children:t.jsx(Yn,{value:s,name:ws(e)})})]},e)}function Lu({action:l,context:e,initialValues:s,initialResult:n,variants:i,onExecute:a,onReview:o,onBack:r,onOpenAction:c}){const[d,u]=C.useState(()=>({...Vr(l,{...e,assetId:typeof s?.asset_id=="string"?s.asset_id:e.assetId,cellId:typeof s?.cell_id=="string"?s.cell_id:e.cellId,assetIds:Array.isArray(s?.artifact_ids)?s.artifact_ids.filter(F=>typeof F=="string"):e.assetIds,cellIds:Array.isArray(s?.cell_ids)?s.cell_ids.filter(F=>typeof F=="string"):e.cellIds}),...Object.fromEntries(Object.entries(s??{}).filter(([F])=>F in(l.inputSchema.properties??{})&&(F!=="_provider"||!l.generation)))})),f=l.generation&&typeof d.model=="string"?pi(d.model,d):void 0,m=qr(String(d.model??""),d.mode),b=m?{...d,options:{...d.options&&typeof d.options=="object"?d.options:{},aspect_ratio:"adaptive",duration:-1}}:f?{...d,options:{...d.options&&typeof d.options=="object"?d.options:{},aspect_ratio:f}}:d,[p,g]=C.useState(!1),[h,y]=C.useState(null),[x,j]=C.useState(null),[v,k]=C.useState(n??null),w=new Set(l.inputSchema.required??[]),S=new Set(["book_id","actor","source_surface"]);l.generation&&S.add("_provider");const M=Object.entries(l.inputSchema.properties??{}).filter(([A])=>!S.has(A)),N=l.handler.kind==="tool"&&l.handler.tool==="update_entity",$=b.entity&&typeof b.entity=="object"&&"id"in b.entity?String(b.entity.id):"",R=ii(l,e),I=["commit_hash","filename","subject_id","subject_ids"].some(A=>A in(l.inputSchema.properties??{})),P=l.handler.kind==="tool"&&l.handler.tool==="crop_asset"&&typeof b.asset_id=="string"?e.media?.[b.asset_id]:void 0,T=l.target.argument&&l.target.mediaKinds?{...e.choices,[l.target.argument]:(e.choices[l.target.argument]??e.choices.asset_id??[]).filter(A=>l.target.mediaKinds?.some(F=>F===A.detail))}:e.choices,D=async()=>{if(!(p||R)){g(!0),y(null);try{l.confirmation!=="none"&&!x?j(await o(l,b)):(k(await a(l,b)),j(null))}catch(A){y(A instanceof Error?A.message:String(A))}finally{g(!1)}}};return t.jsxs("form",{className:"workspace-action-form","data-action-id":l.id,onSubmit:A=>{A.preventDefault(),D()},children:[t.jsxs("button",{type:"button",className:"workspace-actions-back",disabled:p,onClick:r,children:[t.jsx(sc,{size:15}),"All actions"]}),t.jsxs("div",{className:"workspace-action-heading",children:[t.jsx("h3",{children:l.title}),t.jsx("code",{children:l.command})]}),t.jsx("p",{children:l.description}),i.length>1&&t.jsxs("details",{className:"workspace-action-variants",children:[t.jsx("summary",{children:"Advanced provider and model"}),t.jsxs("label",{children:["Provider and model",t.jsx("select",{"aria-label":"Provider and model",value:l.id,disabled:p,onChange:A=>c(A.target.value,b),children:i.map(A=>t.jsxs("option",{value:A.id,children:[A.generation?.provider," · ",A.title]},A.id))})]})]}),t.jsxs("div",{className:"workspace-action-fields",children:[P&&t.jsx(Fu,{media:P,values:b,disabled:p,onChange:A=>{u(F=>({...F,...A})),j(null),k(null)}}),N&&t.jsxs("label",{className:"workspace-action-field",children:["Saved item",t.jsxs("select",{"aria-label":"Saved item",required:!0,value:$,disabled:p,onChange:A=>{u(F=>({...F,entity:structuredClone(e.entities?.[A.target.value])})),k(null),j(null)},children:[t.jsx("option",{value:"",children:"Choose a saved item"}),(e.choices.entity_id??[]).map(A=>t.jsx("option",{value:A.value,children:A.label},A.value))]})]}),M.map(([A,F])=>t.jsx(_n,{name:A,schema:N&&A==="entity"?{type:"object",required:["name"],properties:{name:{type:"string",minLength:1},description:{type:"string"},prompt:{type:"string"},data:{type:"object",description:"Optional advanced saved-item data",additionalProperties:!0}}}:F,value:b[A],choices:T,required:w.has(A),disabled:p||A==="aspect_ratio"&&!!f,onChange:E=>{u(z=>({...z,[A]:E,...P&&A==="ratio"&&typeof E=="string"?mi(E,P.width,P.height):{},...A===l.target.argument&&typeof E=="string"&&l.inputSchema.properties?.object_hash?{object_hash:e.media?.[E]?.objectHash??""}:{}})),j(null),k(null)}},N&&A==="entity"?`${A}:${$}`:A))]}),m&&t.jsx("p",{role:"status",children:Wr}),f&&t.jsx("p",{role:"status",children:Xr}),I&&t.jsx("button",{type:"button",disabled:p,onClick:()=>c(l.id,b),children:"Refresh available choices"}),R&&t.jsx("p",{role:"status",children:R}),h&&t.jsx("p",{role:"alert",className:"workspace-action-error",children:h}),x&&t.jsxs("div",{className:"workspace-action-review",role:"status",children:[t.jsx("strong",{children:x.cost??"Review action"}),t.jsx("p",{children:x.message})]}),v&&t.jsxs("section",{className:"workspace-action-result","aria-label":"Action result",children:[t.jsx("p",{role:"status",children:v.message}),Gr(l)?t.jsx(Du,{action:l,value:v.value,values:b,onOpen:c}):t.jsx(Yn,{value:v.value})]}),t.jsxs("footer",{children:[t.jsxs("button",{type:"submit",className:"workspace-action-submit",disabled:p||!!R,children:[p?t.jsx(ct,{size:15}):t.jsx(Is,{size:15}),p?"Working…":x?"Confirm and run":l.confirmation!=="none"?"Review action":"Run action"]}),x&&t.jsx("button",{type:"button",onClick:()=>j(null),disabled:p,children:"Cancel review"})]})]})}function ff({actions:l,context:e,initialActionId:s,initialValues:n,initialResult:i,returnFocus:a,loading:o=!1,error:r,onClose:c,onBack:d,onOpenAction:u,onExecute:f,onReview:m}){const b=C.useRef(null),p=l.find(x=>x.id===s),g=p?.id,h=C.useMemo(()=>p?.generation?l.filter(x=>x.generation?.operation===p.generation?.operation&&x.generation?.mediaType===p.generation?.mediaType):[],[l,p]);C.useLayoutEffect(()=>{const x=b.current;if(x)return x.showModal(),()=>x.close()},[]),C.useLayoutEffect(()=>{o||b.current?.querySelector(".workspace-action-fields input, .workspace-action-fields textarea, .workspace-action-fields select")?.focus()},[g,o]);const y=()=>{const x=fi(a);c(),x()};return hs.createPortal(t.jsxs("dialog",{ref:b,className:"workspace-actions-dialog","aria-label":"Workspace actions",onKeyDown:x=>{x.key!=="Escape"||x.nativeEvent.isComposing||(x.preventDefault(),x.stopPropagation(),y())},onCancel:x=>{x.preventDefault(),y()},children:[t.jsxs("header",{children:[t.jsx("h2",{children:"Actions"}),t.jsx("button",{type:"button","aria-label":"Close actions",onClick:y,children:t.jsx(dt,{size:18})})]}),o&&t.jsx("p",{role:"status",children:"Loading action…"}),r&&t.jsx("p",{role:"alert",className:"workspace-action-error",children:r}),p&&!o&&t.jsx(Lu,{action:p,context:e,initialValues:n,initialResult:i,variants:h,onExecute:f,onReview:m,onBack:d,onOpenAction:u},p.id),!p&&!o&&t.jsxs("p",{role:"alert",children:["This action is no longer available. ",t.jsx("button",{type:"button",onClick:d,children:"All actions"})]})]}),document.body)}function qi(l){return l.frameRate.numerator/l.frameRate.denominator}function Jn(l,e){const s=e.source.range.startTick*e.source.range.timeBase.numerator/e.source.range.timeBase.denominator;return Math.max(0,Math.round(s*qi(l)))}function Wi(l,e){const s=(e.source.range.startTick+e.source.range.durationTicks)*e.source.range.timeBase.numerator/e.source.range.timeBase.denominator;return Math.max(Jn(l,e)+1,Math.ceil(s*qi(l)))}function Xi(l,e){return{incoming:e.find(s=>s.kind==="dissolve"&&s.incomingClipId===l.clipId),outgoing:e.find(s=>s.kind==="dissolve"&&s.outgoingClipId===l.clipId)}}function zu(l){const e=Y.c(40),{sequence:s,clip:n,src:i,defaultFit:a}=l,o=mc(),r=n.transform;let c,d;e[0]!==n||e[1]!==o||e[2]!==s.transitions?(d=Xi(n,s.transitions),c=d.incoming?Ml(o,[0,d.incoming.durationFrames],[0,1],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}):1,e[0]=n,e[1]=o,e[2]=s.transitions,e[3]=c,e[4]=d):(c=e[3],d=e[4]);const u=c;let f;e[5]!==n.durationFrames||e[6]!==o||e[7]!==d.outgoing?(f=d.outgoing?Ml(o,[Math.max(0,n.durationFrames-d.outgoing.durationFrames),n.durationFrames],[1,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp"}):1,e[5]=n.durationFrames,e[6]=o,e[7]=d.outgoing,e[8]=f):f=e[8];const m=f,b=(r?.fit??a)==="fit"?"contain":"cover",p=(r?.opacity??1)*u*m,g=`translate(${r?.positionX??0}px, ${r?.positionY??0}px)`,h=`scale(${r?.scaleX??1}, ${r?.scaleY??1})`,y=`rotate(${r?.rotationDegrees??0}deg)`;let x;e[9]!==g||e[10]!==h||e[11]!==y?(x=[g,h,y],e[9]=g,e[10]=h,e[11]=y,e[12]=x):x=e[12];const j=x.join(" "),v=`${(r?.anchorX??.5)*100}% ${(r?.anchorY??.5)*100}%`,k=r?`inset(${r.cropTop*100}% ${r.cropRight*100}% ${r.cropBottom*100}% ${r.cropLeft*100}%)`:void 0;let w;e[13]!==v||e[14]!==k||e[15]!==b||e[16]!==p||e[17]!==j?(w={width:"100%",height:"100%",objectFit:b,objectPosition:"center",opacity:p,transform:j,transformOrigin:v,clipPath:k},e[13]=v,e[14]=k,e[15]=b,e[16]=p,e[17]=j,e[18]=w):w=e[18];const S=w;if(n.source.kind==="still"){let T;return e[19]!==i||e[20]!==S?(T=t.jsx(fc,{src:i,style:S}),e[19]=i,e[20]=S,e[21]=T):T=e[21],T}const M=n;if(M.reverse){let T;e[22]!==S?(T={...S,display:"grid",placeItems:"center",background:"#07120c"},e[22]=S,e[23]=T):T=e[23];let D;e[24]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("span",{style:{color:"#8fbaa0",fontFamily:"monospace",fontSize:24},children:"Reverse preview is available after render"}),e[24]=D):D=e[24];let A;return e[25]!==T?(A=t.jsx(Wn,{style:T,children:D}),e[25]=T,e[26]=A):A=e[26],A}let N;e[27]!==s||e[28]!==M?(N=Jn(s,M),e[27]=s,e[28]=M,e[29]=N):N=e[29];let $;e[30]!==s||e[31]!==M?($=Wi(s,M),e[30]=s,e[31]=M,e[32]=$):$=e[32];const R=M.speed.numerator/M.speed.denominator,I=M.audioPolicy==="mute";let P;return e[33]!==i||e[34]!==S||e[35]!==N||e[36]!==$||e[37]!==R||e[38]!==I?(P=t.jsx(pc,{src:i,startFrom:N,endAt:$,playbackRate:R,muted:I,style:S}),e[33]=i,e[34]=S,e[35]=N,e[36]=$,e[37]=R,e[38]=I,e[39]=P):P=e[39],P}function Bu(l){const e=Y.c(24),{sequence:s,clip:n,src:i}=l,a=n.audio;let o;e[0]!==n||e[1]!==s.transitions?(o=Xi(n,s.transitions),e[0]=n,e[1]=s.transitions,e[2]=o):o=e[2];const r=o;let c;e[3]!==a?.fadeInFrames||e[4]!==a?.fadeOutFrames||e[5]!==a?.gainDb||e[6]!==a?.muted||e[7]!==n.durationFrames||e[8]!==r.incoming?.durationFrames||e[9]!==r.outgoing?.durationFrames?(c=g=>{if(a?.muted)return 0;const h=10**((a?.gainDb??0)/20),y=Math.max(1,a?.fadeInFrames??0,r.incoming?.durationFrames??0),x=Math.max(1,a?.fadeOutFrames??0,r.outgoing?.durationFrames??0);return y>0&&g<y?h*g/y:x>0&&g>n.durationFrames-x?h*Math.max(0,n.durationFrames-g)/x:h},e[3]=a?.fadeInFrames,e[4]=a?.fadeOutFrames,e[5]=a?.gainDb,e[6]=a?.muted,e[7]=n.durationFrames,e[8]=r.incoming?.durationFrames,e[9]=r.outgoing?.durationFrames,e[10]=c):c=e[10];const d=c;if(n.reverse)return null;let u;e[11]!==n||e[12]!==s?(u=Jn(s,n),e[11]=n,e[12]=s,e[13]=u):u=e[13];let f;e[14]!==n||e[15]!==s?(f=Wi(s,n),e[14]=n,e[15]=s,e[16]=f):f=e[16];const m=n.speed.numerator/n.speed.denominator,b=n.audioPolicy==="mute"||a?.muted;let p;return e[17]!==i||e[18]!==u||e[19]!==f||e[20]!==m||e[21]!==b||e[22]!==d?(p=t.jsx(hc,{src:i,startFrom:u,endAt:f,playbackRate:m,volume:d,muted:b}),e[17]=i,e[18]=u,e[19]=f,e[20]=m,e[21]=b,e[22]=d,e[23]=p):p=e[23],p}function Ou(l){const e=Y.c(8),{text:s,styleId:n}=l;let i;e[0]!==n?(i=n==="bold"?{background:"#ffe500",color:"#090909",fontWeight:900}:n==="high-contrast"?{background:"#000",color:"#fff",fontWeight:800}:{background:"rgba(0, 0, 0, 0.78)",color:"#fff",fontWeight:700},e[0]=n,e[1]=i):i=e[1];const a=i;let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={justifyContent:"flex-end",alignItems:"center",padding:"0 6% 7%"},e[2]=o):o=e[2];let r;e[3]!==a?(r={...a,maxWidth:"88%",padding:"0.3em 0.55em",fontFamily:"Inter, system-ui, sans-serif",fontSize:52,lineHeight:1.15,textAlign:"center"},e[3]=a,e[4]=r):r=e[4];let c;return e[5]!==r||e[6]!==s?(c=t.jsx(Wn,{style:o,children:t.jsx("span",{style:r,children:s})}),e[5]=r,e[6]=s,e[7]=c):c=e[7],c}function Uu(l){const e=Y.c(21),{sequence:s,assets:n,defaultFit:i}=l,a=i===void 0?"fit":i;let o,r,c,d;if(e[0]!==n||e[1]!==a||e[2]!==s){const m=new Map(n.map(qu)),b=new Map(s.tracks.map(Vu));let p;e[7]!==s.tracks?(p=s.tracks.some(Ku),e[7]=s.tracks,e[8]=p):p=e[8];const g=p,h=s.clips.filter(v=>{const k=b.get(v.trackId);return v.enabled&&k?.enabled&&k.kind==="video"}).sort((v,k)=>{const w=b.get(v.trackId),S=b.get(k.trackId);return(w?.ordinal??0)-(S?.ordinal??0)}),y=s.clips.flatMap(v=>{const k=b.get(v.trackId);return!v.enabled||v.source.kind!=="timed"||!k?.enabled||k.kind!=="audio"||k.muted||g&&!k.solo?[]:[v]});o=Wn;let x;e[9]!==s.backgroundRgba?(x=s.backgroundRgba.join(","),e[9]=s.backgroundRgba,e[10]=x):x=e[10];const j=`rgba(${x})`;e[11]!==j?(r={backgroundColor:j},e[11]=j,e[12]=r):r=e[12],c=h.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(Tn,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(zu,{sequence:s,clip:v,src:k.mediaUrl,defaultFit:a})},v.clipId)}),d=y.map(v=>{const k=m.get(v.source.artifactId);return k&&t.jsx(Tn,{from:v.timelineStartFrame,durationInFrames:v.durationFrames,children:t.jsx(Bu,{sequence:s,clip:v,src:k.mediaUrl})},`audio:${v.clipId}`)}),e[0]=n,e[1]=a,e[2]=s,e[3]=o,e[4]=r,e[5]=c,e[6]=d}else o=e[3],r=e[4],c=e[5],d=e[6];let u;e[13]!==s.captions?(u=s.captions.map(Hu),e[13]=s.captions,e[14]=u):u=e[14];let f;return e[15]!==o||e[16]!==r||e[17]!==c||e[18]!==d||e[19]!==u?(f=t.jsxs(o,{style:r,children:[c,d,u]}),e[15]=o,e[16]=r,e[17]=c,e[18]=d,e[19]=u,e[20]=f):f=e[20],f}function Hu(l){return t.jsx(Tn,{from:l.timelineStartFrame,durationInFrames:l.durationFrames,children:t.jsx(Ou,{text:l.text,styleId:l.styleId})},l.cueId)}function Ku(l){return l.kind==="audio"&&l.solo}function Vu(l){return[l.trackId,l]}function qu(l){return[l.artifactId,l]}const Wu={width:"100%",maxHeight:520},Xu={width:"100%",height:"100%"},Gu=({playing:l,isBuffering:e})=>e?t.jsx(vi,{size:16,className:"timeline-preview-buffering"}):l?t.jsx(Ti,{size:16}):t.jsx(Is,{size:16});function Yu(l){return Math.max(1,...l.clips.map(e=>e.timelineStartFrame+e.durationFrames),...l.captions.map(e=>e.timelineStartFrame+e.durationFrames))}function Ju(l){const e=l.key.toLowerCase();return e==="i"?"mark-in":e==="o"?"mark-out":e==="s"?"split":l.key==="Delete"||l.key==="Backspace"?"delete":(l.metaKey||l.ctrlKey)&&e==="z"?l.shiftKey?"redo":"undo":e==="f"?"search":e==="+"||e==="="?"zoom-in":e==="-"?"zoom-out":null}const Qu=C.forwardRef(function(e,s){const n=Y.c(51),{sequence:i,assets:a,onFrameUpdate:o,onKeyboardAction:r,editingEnabled:c,presentation:d,allowFullscreen:u,initialFrame:f}=e,m=c===void 0?!0:c,b=d===void 0?"default":d,p=u===void 0?!0:u,g=f===void 0?0:f,h=C.useRef(null),y=C.useRef(null),x=i.frameRate.numerator/i.frameRate.denominator,j=Yu(i);let v;n[0]!==g?(v=Math.round(g),n[0]=g,n[1]=v):v=n[1];const k=Math.max(0,Math.min(j-1,v)),w=C.useRef(k),[S,M]=C.useState(k),N=b==="preview";let $;n[2]!==a||n[3]!==i?($={sequence:i,assets:a,defaultFit:"fit"},n[2]=a,n[3]=i,n[4]=$):$=n[4];const R=$;let I;n[5]!==j||n[6]!==m||n[7]!==x||n[8]!==r?(I=J=>{if(J.nativeEvent.isComposing||J.nativeEvent.keyCode===229)return;const G=J.target;if(["INPUT","TEXTAREA","SELECT"].includes(G.tagName))return;const ce=h.current;if(!ce)return;const ae=w.current,X=J.key.toLowerCase();if(X===" "||X==="k"){J.preventDefault(),ce.isPlaying()?ce.pause():ce.play();return}if(X==="j"||J.key==="ArrowLeft"){J.preventDefault(),ce.seekTo(Math.max(0,ae-(X==="j"?Math.round(x):1)));return}if(X==="l"||J.key==="ArrowRight"){J.preventDefault(),ce.seekTo(Math.min(j-1,ae+(X==="l"?Math.round(x):1)));return}if(!m)return;const le=Ju(J);le&&(J.preventDefault(),r(le,ae))},n[5]=j,n[6]=m,n[7]=x,n[8]=r,n[9]=I):I=n[9];const P=I;let T,D;n[10]!==j||n[11]!==P||n[12]!==o?(T=()=>({pause:()=>h.current?.pause(),togglePlay:()=>{const J=h.current;J&&(J.isPlaying()?J.pause():J.play())},seekTo:J=>{const G=Math.max(0,Math.min(j-1,Math.round(J)));w.current=G,M(G),o(G),h.current?.seekTo(G)},focus:()=>y.current?.focus(),handleKeyDown:P}),D=[j,P,o],n[10]=j,n[11]=P,n[12]=o,n[13]=T,n[14]=D):(T=n[13],D=n[14]),C.useImperativeHandle(s,T,D);let A,F;n[15]!==o?(A=()=>{const J=h.current;if(!J)return;const G=ce=>{w.current=ce.detail.frame,M(ce.detail.frame),o(ce.detail.frame)};return J.addEventListener("frameupdate",G),()=>J.removeEventListener("frameupdate",G)},F=[o],n[15]=o,n[16]=A,n[17]=F):(A=n[16],F=n[17]),C.useEffect(A,F);const E=N?!1:void 0,z=N?"timeline-preview-screen":void 0,_=N?Xu:Wu,L=N?Gu:void 0;let B;n[18]!==p||n[19]!==j||n[20]!==k||n[21]!==x||n[22]!==R||n[23]!==N||n[24]!==i.height||n[25]!==i.width||n[26]!==E||n[27]!==z||n[28]!==_||n[29]!==L?(B=t.jsx(bc,{ref:h,component:Uu,inputProps:R,durationInFrames:j,fps:x,compositionWidth:i.width,compositionHeight:i.height,initialFrame:k,controls:!0,spaceKeyToPlayOrPause:E,allowFullscreen:p,alwaysShowControls:N,className:z,style:_,renderPlayPauseButton:L}),n[18]=p,n[19]=j,n[20]=k,n[21]=x,n[22]=R,n[23]=N,n[24]=i.height,n[25]=i.width,n[26]=E,n[27]=z,n[28]=_,n[29]=L,n[30]=B):B=n[30];const H=B,q=N?"canonical-player canonical-player-preview":"canonical-player";let U;n[31]!==N||n[32]!==H?(U=N?t.jsx("div",{className:"timeline-preview-stage",children:H}):H,n[31]=N,n[32]=H,n[33]=U):U=n[33];let K;n[34]!==S?(K=t.jsxs("span",{className:"canonical-player-frame",title:"Current frame",children:["F",S]}),n[34]=S,n[35]=K):K=n[35];const ee=S/x;let ne;n[36]!==ee?(ne=ee.toFixed(2),n[36]=ee,n[37]=ne):ne=n[37];let V;n[38]!==ne?(V=t.jsxs("span",{children:[ne,"s"]}),n[38]=ne,n[39]=V):V=n[39];const re=m?"Space/K play · J/L shuttle · ←/→ frame · I/O marks · S split · Delete · ⌘Z/⇧⌘Z restore":"Space/K play · J/L shuttle · ←/→ frame";let W;n[40]!==re?(W=t.jsx("span",{className:"canonical-player-shortcuts",children:re}),n[40]=re,n[41]=W):W=n[41];let Z;n[42]!==K||n[43]!==V||n[44]!==W?(Z=t.jsxs("footer",{children:[K,V,W]}),n[42]=K,n[43]=V,n[44]=W,n[45]=Z):Z=n[45];let ie;return n[46]!==P||n[47]!==q||n[48]!==U||n[49]!==Z?(ie=t.jsxs("section",{className:q,ref:y,tabIndex:0,onKeyDown:P,"aria-label":"Canonical sequence player",children:[U,Z]}),n[46]=P,n[47]=q,n[48]=U,n[49]=Z,n[50]=ie):ie=n[50],ie});function pf(l){const e=Y.c(64),{media:s,sequence:n,assets:i,opener:a,initialFrame:o,onActions:r,onClose:c,composerPortalRef:d,actionsOpen:u}=l,f=o===void 0?0:o,m=u===void 0?!1:u,b=C.useRef(null),p=C.useRef(null),[g,h]=C.useState(s?.initialFile??"");let y,x;if(e[0]!==g||e[1]!==s?.files||e[2]!==s?.type||e[3]!==s?.url){const K=s?.files.find(ee=>ee.name===g);x=K?.url??s?.url,y=K?/\.(?:mp4|webm|mov)$/iu.test(K.name)?"video":/\.(?:wav|mp3|m4a|weba|ogg)$/iu.test(K.name)?"audio":/\.(?:png|jpg|jpeg|webp|gif)$/iu.test(K.name)?"image":"file":s?.type,e[0]=g,e[1]=s?.files,e[2]=s?.type,e[3]=s?.url,e[4]=y,e[5]=x}else y=e[4],x=e[5];const j=y;let v;e[6]!==c||e[7]!==a?(v=()=>{const K=fi(a);c(),K()},e[6]=c,e[7]=a,e[8]=v):v=e[8];const k=v;let w,S;e[9]!==f?(w=()=>{const K=b.current;return K?.showModal(),p.current?.seekTo(f),()=>K?.close()},S=[f],e[9]=f,e[10]=w,e[11]=S):(w=e[10],S=e[11]),C.useLayoutEffect(w,S);const M=s?.label??"Sequence preview";let N;e[12]!==k?(N=K=>{K.preventDefault(),k()},e[12]=k,e[13]=N):N=e[13];const $=s?.label??"Sequence preview";let R;e[14]!==$?(R=t.jsx("h2",{children:$}),e[14]=$,e[15]=R):R=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(dt,{size:18}),e[16]=I):I=e[16];let P;e[17]!==k?(P=t.jsx("button",{type:"button","aria-label":"Close preview",onClick:k,children:I}),e[17]=k,e[18]=P):P=e[18];let T;e[19]!==R||e[20]!==P?(T=t.jsxs("header",{children:[R,P]}),e[19]=R,e[20]=P,e[21]=T):T=e[21];let D;e[22]!==g||e[23]!==s?(D=s&&t.jsxs("label",{children:["Version or file",t.jsxs("select",{value:g,onChange:K=>h(K.target.value),children:[t.jsx("option",{value:"",children:"Current media"}),s.files.map(tm)]})]}),e[22]=g,e[23]=s,e[24]=D):D=e[24];let A;e[25]!==i||e[26]!==n?(A=n&&t.jsx(Qu,{ref:p,sequence:n,assets:i,editingEnabled:!1,onFrameUpdate:em,onKeyboardAction:Zu}),e[25]=i,e[26]=n,e[27]=A):A=e[27];let F;e[28]!==s||e[29]!==x?(F=s&&!x&&t.jsx("p",{role:"status",children:"This media has no playable file yet. Check its processing status in Jobs."}),e[28]=s,e[29]=x,e[30]=F):F=e[30];let E;e[31]!==s?.label||e[32]!==j||e[33]!==x?(E=x&&j==="image"&&t.jsx("img",{src:x,alt:s?.label??"Media preview"}),e[31]=s?.label,e[32]=j,e[33]=x,e[34]=E):E=e[34];let z;e[35]!==s?.thumbnailUrl||e[36]!==j||e[37]!==x?(z=x&&(j==="video"||j==="final")&&t.jsx("video",{src:x,poster:s?.thumbnailUrl??void 0,controls:!0,playsInline:!0,preload:"metadata"}),e[35]=s?.thumbnailUrl,e[36]=j,e[37]=x,e[38]=z):z=e[38];let _;e[39]!==j||e[40]!==x?(_=x&&j==="audio"&&t.jsx("audio",{src:x,controls:!0,preload:"metadata"}),e[39]=j,e[40]=x,e[41]=_):_=e[41];let L;e[42]!==x?(L=x&&t.jsx("a",{href:x,target:"_blank",rel:"noreferrer",children:"Open current file"}),e[42]=x,e[43]=L):L=e[43];let B;e[44]!==r?(B=t.jsx("button",{type:"button",onClick:r,children:"More actions"}),e[44]=r,e[45]=B):B=e[45];let H;e[46]!==D||e[47]!==A||e[48]!==F||e[49]!==E||e[50]!==z||e[51]!==_||e[52]!==L||e[53]!==B?(H=t.jsxs("div",{className:"workspace-preview-content",children:[D,A,F,E,z,_,L,B]}),e[46]=D,e[47]=A,e[48]=F,e[49]=E,e[50]=z,e[51]=_,e[52]=L,e[53]=B,e[54]=H):H=e[54];let q;e[55]!==m||e[56]!==d?(q=m&&t.jsx("div",{className:"workspace-preview-composer-host",ref:d}),e[55]=m,e[56]=d,e[57]=q):q=e[57];let U;return e[58]!==T||e[59]!==H||e[60]!==q||e[61]!==M||e[62]!==N?(U=hs.createPortal(t.jsxs("dialog",{ref:b,className:"workspace-actions-dialog workspace-preview-dialog","aria-label":M,onCancel:N,children:[T,H,q]}),document.body),e[58]=T,e[59]=H,e[60]=q,e[61]=M,e[62]=N,e[63]=U):U=e[63],U}function Zu(){}function em(){}function tm(l){return t.jsx("option",{value:l.name,children:l.name},l.name)}const Yt={image:{row:0,column:0},video:{row:0,column:1},download:{row:0,column:2},library:{row:0,column:3}},sm={image:{title:"Add a picture",hint:"png · jpg · webp · heic",label:"Image",icon:Qt},video:{title:"Add a video",hint:"mp4 · mov · webm",label:"Video",icon:Cs}};function Vs(l){const e=Ln(l);return{width:He.squareSize,height:He.squareSize,transform:`translate(${e.x}px, ${e.y}px)`}}const nm={image:Vs(Yt.image),video:Vs(Yt.video),download:Vs(Yt.download),library:Vs(Yt.library)},Vl=Ln(Yt.library),lm={width:Vl.x+He.squareSize,height:Vl.y+He.squareSize};function Qn(l){const e=Y.c(19),{kind:s,title:n,icon:i,children:a}=l,o=Yt[s];let r;e[0]!==o?(r=Vt(o),e[0]=o,e[1]=r):r=e[1];const c=r,d=`notebook-start-tile notebook-start-tile-${s}`,u=nm[s],f=`${c} ${n}`;let m;e[2]!==c?(m=t.jsx("span",{children:c}),e[2]=c,e[3]=m):m=e[3];let b;e[4]!==i?(b=t.jsx(i,{"aria-hidden":"true"}),e[4]=i,e[5]=b):b=e[5];let p;e[6]!==m||e[7]!==b?(p=t.jsxs("div",{className:"notebook-start-tile-head",children:[m,b]}),e[6]=m,e[7]=b,e[8]=p):p=e[8];let g;e[9]!==n?(g=t.jsx("strong",{children:n}),e[9]=n,e[10]=g):g=e[10];let h;return e[11]!==c||e[12]!==a||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==p||e[17]!==g?(h=t.jsxs("section",{className:d,style:u,"aria-label":f,"data-start-address":c,children:[p,g,a]}),e[11]=c,e[12]=a,e[13]=d,e[14]=u,e[15]=f,e[16]=p,e[17]=g,e[18]=h):h=e[18],h}function ql(l){const e=Y.c(35),{kind:s,busy:n,onUpload:i,onPick:a}=l,o=C.useRef(null),r=sm[s],c=Yt[s];let d;e[0]!==i||e[1]!==c?(d=M=>{const N=M.target.files?.[0];M.target.value="",N&&i(c,N)},e[0]=i,e[1]=c,e[2]=d):d=e[2];const u=d;let f;e[3]!==r.hint?(f=t.jsx("span",{className:"notebook-start-tile-hint notebook-start-tile-hint-optional",children:r.hint}),e[3]=r.hint,e[4]=f):f=e[4];const m=`Upload ${s}`;let b,p;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=()=>o.current?.click(),p=t.jsx(Zt,{"aria-hidden":"true"}),e[5]=b,e[6]=p):(b=e[5],p=e[6]);let g;e[7]!==r.label?(g=t.jsx("span",{children:r.label}),e[7]=r.label,e[8]=g):g=e[8];let h;e[9]!==n||e[10]!==m||e[11]!==g?(h=t.jsxs("button",{type:"button",className:"notebook-start-tile-primary","aria-label":m,disabled:n,onClick:b,children:[p,g]}),e[9]=n,e[10]=m,e[11]=g,e[12]=h):h=e[12];const y=`${r.label} from library`;let x;e[13]!==s||e[14]!==a||e[15]!==c?(x=()=>a(s,c),e[13]=s,e[14]=a,e[15]=c,e[16]=x):x=e[16];let j;e[17]!==n||e[18]!==y||e[19]!==x?(j=t.jsx("button",{type:"button",className:"notebook-start-tile-secondary","aria-label":y,disabled:n,onClick:x,children:"From library"}),e[17]=n,e[18]=y,e[19]=x,e[20]=j):j=e[20];let v;e[21]!==j||e[22]!==h?(v=t.jsxs("div",{className:"notebook-start-tile-actions",children:[h,j]}),e[21]=j,e[22]=h,e[23]=v):v=e[23];const k=hi[s];let w;e[24]!==u||e[25]!==n||e[26]!==k?(w=t.jsx("input",{ref:o,type:"file",accept:k,hidden:!0,disabled:n,onChange:u}),e[24]=u,e[25]=n,e[26]=k,e[27]=w):w=e[27];let S;return e[28]!==r.icon||e[29]!==r.title||e[30]!==s||e[31]!==v||e[32]!==w||e[33]!==f?(S=t.jsxs(Qn,{kind:s,title:r.title,icon:r.icon,children:[f,v,w]}),e[28]=r.icon,e[29]=r.title,e[30]=s,e[31]=v,e[32]=w,e[33]=f,e[34]=S):S=e[34],S}function im({busy:l,onDownload:e}){const[s,n]=C.useState(""),[i,a]=C.useState(!1),o=s.trim(),r=l||i,c=async d=>{if(d.preventDefault(),!(r||!o)){a(!0);try{await e(o,Yt.download),n("")}finally{a(!1)}}};return t.jsx(Qn,{kind:"download",title:"Download a clip",icon:Ei,children:t.jsxs("form",{className:"notebook-start-tile-form",noValidate:!0,onSubmit:d=>{c(d)},children:[t.jsx("input",{type:"url",inputMode:"url","aria-label":"Clip link",placeholder:"Paste a link",value:s,disabled:r,onChange:d=>n(d.target.value)}),t.jsxs("button",{type:"submit",className:"notebook-start-tile-primary",disabled:r||!o,children:[t.jsx(Js,{"aria-hidden":"true"}),t.jsx("span",{children:i?"Queuing…":"Download"})]})]})})}function am(l){const e=Y.c(6),{busy:s,onBrowseLibrary:n}=l;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("span",{className:"notebook-start-tile-hint",children:"From every book"}),e[0]=i):i=e[0];let a;e[1]!==n?(a=()=>n(Yt.library),e[1]=n,e[2]=a):a=e[2];let o;return e[3]!==s||e[4]!==a?(o=t.jsxs(Qn,{kind:"library",title:"Your library",icon:Vn,children:[i,t.jsx("div",{className:"notebook-start-tile-actions",children:t.jsx("button",{type:"button",className:"notebook-start-tile-secondary","aria-label":"Browse library",disabled:s,onClick:a,children:"Browse"})})]}),e[3]=s,e[4]=a,e[5]=o):o=e[5],o}function hf(l){const e=Y.c(18),{busy:s,compact:n,dimmed:i,onUpload:a,onPick:o,onDownload:r,onBrowseLibrary:c}=l;let d,u;e[0]!==s||e[1]!==o||e[2]!==a?(d=t.jsx(ql,{kind:"image",busy:s,onUpload:a,onPick:o}),u=t.jsx(ql,{kind:"video",busy:s,onUpload:a,onPick:o}),e[0]=s,e[1]=o,e[2]=a,e[3]=d,e[4]=u):(d=e[3],u=e[4]);let f;e[5]!==s||e[6]!==r?(f=t.jsx(im,{busy:s,onDownload:r}),e[5]=s,e[6]=r,e[7]=f):f=e[7];let m;e[8]!==s||e[9]!==c?(m=t.jsx(am,{busy:s,onBrowseLibrary:c}),e[8]=s,e[9]=c,e[10]=m):m=e[10];let b;return e[11]!==n||e[12]!==i||e[13]!==d||e[14]!==u||e[15]!==f||e[16]!==m?(b=t.jsx(_i,{children:t.jsxs("div",{className:"notebook-start-tiles nodrag nopan",style:lm,role:"group","aria-label":"Start this notebook","data-compact":n,"data-dimmed":i,children:[d,u,f,m]})}),e[11]=n,e[12]=i,e[13]=d,e[14]=u,e[15]=f,e[16]=m,e[17]=b):b=e[17],b}const rm={post:Ct,audio:ts,image:Qt,video:Cs,character:Di,prompt:Ai,analyze:zn,generate_video:Cs,generate_image:Qt,generate_audio:ts,extract_audio:ts,split_video:Ct,concat:Ct,splice:Ct,timeline:Ct};function om(l){const e=Y.c(27),{disabled:s,onAdd:n,onDragEnd:i}=l,[a,o]=C.useState(""),r=C.useRef(null),c=C.useRef(null),d=C.useRef(null),u=Yr(a);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=_=>{r.current&&(r.current.open=!1),o(""),_&&d.current?.focus()},e[0]=f):f=e[0];const m=f;let b,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const _=L=>{const B=r.current;!B?.open||!(L.target instanceof Node)||B.contains(L.target)||m(!1)};return document.addEventListener("pointerdown",_,!0),document.addEventListener("focusin",_),()=>{document.removeEventListener("pointerdown",_,!0),document.removeEventListener("focusin",_)}},p=[m],e[1]=b,e[2]=p):(b=e[1],p=e[2]),C.useEffect(b,p);let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=_=>{if(!_.currentTarget.open){o("");return}const L=document.activeElement;L!==d.current&&_.currentTarget.contains(L)||c.current?.focus()},e[3]=g):g=e[3];const h=g;let y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=_=>{_.key!=="Escape"||!r.current?.open||(_.preventDefault(),_.stopPropagation(),m(!0))},e[4]=y):y=e[4];const x=y;let j;e[5]!==n?(j=_=>{m(!0),n(_)},e[5]=n,e[6]=j):j=e[6];const v=j;let k;e[7]!==i?(k=()=>{i(),m(!1)},e[7]=i,e[8]=k):k=e[8];const w=k,S="canvas-add-menu";let M;e[9]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsxs("summary",{ref:d,"aria-label":"Add cell",title:"Add cell",children:[t.jsx(Zt,{size:15}),t.jsx("span",{children:"Add cell"}),t.jsx(Ns,{size:13})]}),e[9]=M):M=e[9];const N="canvas-add-popover";let $;e[10]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx(is,{size:14,"aria-hidden":"true"}),e[10]=$):$=e[10];let R;e[11]===Symbol.for("react.memo_cache_sentinel")?(R=_=>o(_.target.value),e[11]=R):R=e[11];let I;e[12]!==a?(I=t.jsxs("label",{className:"canvas-add-search",children:[$,t.jsx("input",{ref:c,type:"search",value:a,"aria-label":"Search cell types",placeholder:"Search cell types",onChange:R})]}),e[12]=a,e[13]=I):I=e[13];const P="canvas-add-results",T="polite",D=Jr.map(_=>{const L=u.filter(B=>B.group===_);return L.length===0?null:t.jsxs("section",{className:"canvas-add-group",children:[t.jsx("span",{children:_}),L.map(B=>{const H=rm[B.type];return t.jsxs("button",{type:"button",draggable:!0,disabled:s,onDragStart:q=>q.dataTransfer.setData("application/x-videobook-cell",B.type),onDragEnd:w,onClick:()=>v(B.type),children:[t.jsx(H,{size:15}),t.jsx("span",{children:B.label})]},B.type)})]},_)});let A;e[14]!==u.length?(A=u.length===0&&t.jsx("p",{className:"canvas-add-empty",children:"No cell types found"}),e[14]=u.length,e[15]=A):A=e[15];let F;e[16]!==D||e[17]!==A?(F=t.jsxs("div",{className:P,"aria-live":T,children:[D,A]}),e[16]=D,e[17]=A,e[18]=F):F=e[18];let E;e[19]!==I||e[20]!==F?(E=t.jsxs("div",{className:N,children:[I,F]}),e[19]=I,e[20]=F,e[21]=E):E=e[21];let z;return e[22]!==x||e[23]!==h||e[24]!==E||e[25]!==M?(z=t.jsxs("details",{ref:r,className:S,onToggle:h,onKeyDown:x,children:[M,E]}),e[22]=x,e[23]=h,e[24]=E,e[25]=M,e[26]=z):z=e[26],z}function bf(l){const e=Y.c(41),{busy:s,arrangeDisabled:n,selectedCount:i,activeAddress:a,onAdd:o,onAddDragEnd:r,onArrange:c,onDeleteSelection:d,onClearSelection:u,onSelectionActions:f}=l,m=`Delete ${i} selected ${i===1?"cell":"cells"}`;let b;e[0]!==s||e[1]!==o||e[2]!==r?(b=t.jsx(om,{disabled:s,onAdd:o,onDragEnd:r}),e[0]=s,e[1]=o,e[2]=r,e[3]=b):b=e[3];let p;e[4]!==o?(p=()=>{o("image")},e[4]=o,e[5]=p):p=e[5];let g,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Zt,{size:15}),h=t.jsx("span",{children:"Image"}),e[6]=g,e[7]=h):(g=e[6],h=e[7]);let y;e[8]!==s||e[9]!==p?(y=t.jsxs("button",{type:"button",className:"canvas-auto-arrange canvas-quick-add",title:"Add an image cell and pick from recent media","aria-label":"Add image",disabled:s,onClick:p,children:[g,h]}),e[8]=s,e[9]=p,e[10]=y):y=e[10];let x;e[11]!==o?(x=()=>{o("video")},e[11]=o,e[12]=x):x=e[12];let j,v;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(Zt,{size:15}),v=t.jsx("span",{children:"Video"}),e[13]=j,e[14]=v):(j=e[13],v=e[14]);let k;e[15]!==s||e[16]!==x?(k=t.jsxs("button",{type:"button",className:"canvas-auto-arrange canvas-quick-add",title:"Add a video cell and pick from recent media","aria-label":"Add video",disabled:s,onClick:x,children:[j,v]}),e[15]=s,e[16]=x,e[17]=k):k=e[17];let w;e[18]!==c?(w=()=>{c()},e[18]=c,e[19]=w):w=e[19];let S,M;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(nc,{size:15}),M=t.jsx("span",{children:"Arrange"}),e[20]=S,e[21]=M):(S=e[20],M=e[21]);let N;e[22]!==n||e[23]!==w?(N=t.jsxs("button",{type:"button",className:"canvas-auto-arrange",title:"Arrange cells by workflow and media type","aria-label":"Auto-arrange notebook",disabled:n,onClick:w,children:[S,M]}),e[22]=n,e[23]=w,e[24]=N):N=e[24];let $;e[25]!==b||e[26]!==N||e[27]!==y||e[28]!==k?($=t.jsxs("div",{className:"canvas-primary-actions",role:"group","aria-label":"Notebook editing tools",children:[b,y,k,N]}),e[25]=b,e[26]=N,e[27]=y,e[28]=k,e[29]=$):$=e[29];let R;e[30]!==a||e[31]!==s||e[32]!==m||e[33]!==u||e[34]!==d||e[35]!==f||e[36]!==i?(R=i>0&&t.jsxs("div",{className:"canvas-selection-actions",role:"group","aria-label":"Notebook selection actions",children:[t.jsxs("span",{className:"canvas-selection-count",title:"Shift-click cells or drag across the canvas to select more",children:[t.jsx("strong",{children:i}),t.jsx("span",{children:" selected"})]}),i>1&&a&&t.jsxs("code",{children:[a," active"]}),f&&t.jsx("button",{type:"button",className:"canvas-clear-selection",title:"Selection actions","aria-label":"Selection actions","data-workspace-action-surface":"selection-menu",onClick:f,children:t.jsx(qn,{size:14})}),t.jsxs("button",{type:"button",className:"canvas-delete-selection",title:m,"aria-label":m,"aria-keyshortcuts":"Delete Backspace",disabled:s,onClick:()=>{d()},children:[t.jsx(as,{size:14}),t.jsx("span",{children:"Delete"})]}),t.jsx("button",{type:"button",className:"canvas-clear-selection",title:"Clear selection","aria-label":"Clear selection",onClick:u,children:t.jsx(dt,{size:14})})]}),e[30]=a,e[31]=s,e[32]=m,e[33]=u,e[34]=d,e[35]=f,e[36]=i,e[37]=R):R=e[37];let I;return e[38]!==$||e[39]!==R?(I=t.jsxs("div",{className:"canvas-toolbar","data-composer-focus":"return",role:"group","aria-label":"Notebook canvas controls",children:[$,R]}),e[38]=$,e[39]=R,e[40]=I):I=e[40],I}function cm(l){return l.costUsd===null||l.status!=="completed"&&l.basis!=="reported"&&l.inputTokens===null&&l.outputTokens===null?"Unpriced":`${l.basis==="estimated"?"~":""}${js(l.costUsd)}`}function dm(){const l=Y.c(5),e=C.useId(),s=C.useRef(null),n=C.useRef(null);let i;l[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{if(!s.current||!n.current)return;const d=s.current.getBoundingClientRect(),u=Math.min(d.bottom+8,window.innerHeight-100);n.current.style.top=`${u}px`,n.current.style.maxHeight=`${Math.max(80,window.innerHeight-u-12)}px`},l[0]=i):i=l[0];const a=i;let o,r;l[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>(window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)),r=[],l[1]=o,l[2]=r):(o=l[1],r=l[2]),C.useEffect(o,r);let c;return l[3]!==e?(c={id:e,buttonRef:s,panelRef:n,position:a},l[3]=e,l[4]=c):c=l[4],c}function xf(l){const e=Y.c(51),{bookName:s,enabled:n,snapshot:i,stale:a,onRetry:o}=l,{id:r,buttonRef:c,panelRef:d,position:u}=dm(),f=i?.totals;let m;e[0]!==f?(m=f?ls(f.inputTokens+f.outputTokens):"—",e[0]=f,e[1]=m):m=e[1];const b=m;let p;e[2]!==f?(p=f?Mn(f):"— cost",e[2]=f,e[3]=p):p=e[3];const g=p,h=!!f&&(f.unpriced>0||f.missingTokens>0||i?.incomplete);let y;e[4]!==i?.groups?(y=new Set(i?.groups.map(bm)??[]),e[4]=i?.groups,e[5]=y):y=e[5];let x;e[6]!==y?(x=[...y],e[6]=y,e[7]=x):x=e[7];const j=x,v=!n,k=`Book usage: ${b} tokens, ${g}${a?", stale":h?", incomplete":""}`;let w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx("small",{children:" tokens"}),e[8]=w):w=e[8];let S;e[9]!==b?(S=t.jsxs("span",{children:[b,w]}),e[9]=b,e[10]=S):S=e[10];let M;e[11]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx("span",{className:"book-usage-divider","aria-hidden":"true",children:"·"}),e[11]=M):M=e[11];let N;e[12]!==g?(N=t.jsx("span",{children:g}),e[12]=g,e[13]=N):N=e[13];let $;e[14]!==h||e[15]!==a?($=(a||h)&&t.jsx("span",{className:"book-usage-indicator","aria-hidden":"true"}),e[14]=h,e[15]=a,e[16]=$):$=e[16];let R;e[17]!==c||e[18]!==r||e[19]!==N||e[20]!==$||e[21]!==v||e[22]!==k||e[23]!==S?(R=t.jsxs("button",{ref:c,type:"button",className:"book-usage-trigger",popoverTarget:r,disabled:v,"aria-label":k,title:"Tokens and cost for this book",children:[S,M,N,$]}),e[17]=c,e[18]=r,e[19]=N,e[20]=$,e[21]=v,e[22]=k,e[23]=S,e[24]=R):R=e[24];let I;e[25]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("h2",{children:"Book usage"}),e[25]=I):I=e[25];let P;e[26]!==s?(P=t.jsxs("div",{children:[I,t.jsx("p",{children:s})]}),e[26]=s,e[27]=P):P=e[27];let T;e[28]!==r?(T=t.jsx("button",{type:"button",popoverTarget:r,popoverTargetAction:"hide","aria-label":"Close book usage",children:"×"}),e[28]=r,e[29]=T):T=e[29];let D;e[30]!==P||e[31]!==T?(D=t.jsxs("header",{children:[P,T]}),e[30]=P,e[31]=T,e[32]=D):D=e[32];let A;e[33]!==o||e[34]!==a?(A=a&&t.jsxs("p",{className:"book-usage-notice",children:["Usage may be out of date. ",t.jsx("button",{type:"button",onClick:o,children:"Retry"})]}),e[33]=o,e[34]=a,e[35]=A):A=e[35];let F;e[36]!==j||e[37]!==h||e[38]!==i||e[39]!==a?(F=i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"book-usage-totals",children:[t.jsxs("div",{children:[t.jsx("small",{children:"Reported tokens"}),t.jsx("strong",{children:ls(i.totals.inputTokens+i.totals.outputTokens,!0)})]}),t.jsxs("div",{children:[t.jsx("small",{children:"Known cost · USD"}),t.jsx("strong",{children:Mn(i.totals)})]})]}),t.jsxs("dl",{className:"book-usage-facts",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Input / output"}),t.jsxs("dd",{children:[ls(i.totals.inputTokens,!0)," / ",ls(i.totals.outputTokens,!0)]})]}),t.jsxs("div",{children:[t.jsxs("dt",{children:["Cached input ",t.jsx("small",{children:"(included)"})]}),t.jsx("dd",{children:ls(i.totals.cachedTokens,!0)})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Reported charges"}),t.jsx("dd",{children:js(i.totals.reportedUsd)})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Estimated charges"}),t.jsx("dd",{children:js(i.totals.estimatedUsd)})]})]}),h&&t.jsxs("p",{className:"book-usage-notice",children:[i.totals.unpriced>0&&`${i.totals.unpriced} ${i.totals.unpriced===1?"request has an unavailable price":"requests have unavailable prices"}. `,i.totals.missingTokens>0&&`${i.totals.missingTokens} ${i.totals.missingTokens===1?"request has":"requests have"} missing token counts. `,i.incomplete&&"Some usage could not be recorded."]}),i.totals.pendingCount>0&&t.jsxs("p",{className:"book-usage-pending",children:[i.totals.pendingCount," in progress · ",js(i.totals.pendingUsd)," estimated, excluded from total"]}),t.jsx("section",{"aria-label":"Usage by activity",className:"book-usage-breakdown",children:j.map(_=>{const L=i.groups.filter(U=>U.activity===_),B=L.reduce(hm,0),H=L.reduce(pm,0),q=L.some(fm);return t.jsxs("details",{children:[t.jsxs("summary",{children:[t.jsx("span",{children:bi[_]}),t.jsx("span",{children:B===0&&H?"Unpriced":`${q?"~":""}${js(B)}`})]}),L.map(mm)]},_)})}),i.recent.length>0?t.jsxs("section",{className:"book-usage-recent","aria-label":"Recent usage",children:[t.jsx("h3",{children:"Recent usage"}),i.recent.map(um)]}):t.jsx("p",{className:"book-usage-empty",children:"New AI activity will appear here."}),t.jsxs("footer",{children:["Tracked since ",new Date(i.trackedSince).toLocaleString([],{dateStyle:"medium",timeStyle:"short"}),".",t.jsx("br",{}),"Estimates use recorded provider rates. Earlier usage is not included."]})]}):t.jsx("p",{className:"book-usage-empty",children:a?"Usage is unavailable.":"Loading usage…"}),e[36]=j,e[37]=h,e[38]=i,e[39]=a,e[40]=F):F=e[40];let E;e[41]!==r||e[42]!==d||e[43]!==u||e[44]!==D||e[45]!==A||e[46]!==F?(E=t.jsxs("div",{ref:d,id:r,popover:"auto",role:"dialog","aria-label":"Book usage",className:"book-usage-popover",onToggle:u,children:[D,A,F]}),e[41]=r,e[42]=d,e[43]=u,e[44]=D,e[45]=A,e[46]=F,e[47]=E):E=e[47];let z;return e[48]!==R||e[49]!==E?(z=t.jsxs("div",{className:"book-usage","data-composer-focus":"preserve",children:[R,E]}),e[48]=R,e[49]=E,e[50]=z):z=e[50],z}function um(l){return t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.model}),t.jsxs("small",{children:[bi[l.activity]," · ",l.status," · ",new Date(l.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),l.units!==null&&l.unit&&` · ${ls(l.units)} ${l.unit}`]})]}),t.jsx("span",{children:l.status==="pending"?"Pending":cm(l)})]},l.id)}function mm(l){return t.jsxs("div",{className:"book-usage-model",children:[t.jsxs("div",{children:[t.jsx("strong",{children:l.model}),t.jsxs("small",{children:[l.provider," · ",l.count," requests · ",ls(l.inputTokens+l.outputTokens)," tokens"]})]}),t.jsx("span",{children:Mn(l)})]},`${l.provider}:${l.model}`)}function fm(l){return l.estimatedUsd>0}function pm(l,e){return l+e.unpriced}function hm(l,e){return l+e.reportedUsd+e.estimatedUsd}function bm(l){return l.activity}function xm({call:l}){const[e,s]=C.useState(null),[n,i]=C.useState(!1),[a,o]=C.useState(null),r=async c=>{if(!l)return;const d=c?window.open("about:blank","_blank"):null;i(!0),o(null);try{if(c){const u=await l("connect_service",{service:"dropbox"});d?d.location.href=u.authorize_url:window.open(u.authorize_url,"_blank","noopener,noreferrer")}s(await l("service_status",{service:"dropbox"}))}catch(u){d?.close(),o(u instanceof Error?u.message:String(u))}finally{i(!1)}};return t.jsxs("article",{className:"settings-dropbox-connection",children:[t.jsxs("div",{className:"settings-credential-copy",children:[t.jsx("strong",{children:"Dropbox delivery"}),t.jsx("p",{children:e?.connected?"Connected · offline access enabled":e?.pending?"Approve access in Dropbox, then check connection.":"Deliver private clip files and captions for manual posting."}),t.jsx("small",{children:"App key: DROPBOX_CLIENT_ID · Redirect: http://127.0.0.1:8766/callback"})]}),t.jsx("button",{type:"button",disabled:n||!l,onClick:()=>{r(!0)},children:e?.connected?"Reconnect Dropbox":"Connect Dropbox"}),t.jsx("button",{type:"button",disabled:n||!l,onClick:()=>{r(!1)},children:"Check connection"}),(a||e?.error)&&t.jsx("p",{role:"alert",className:"settings-error",children:a??e?.error})]})}function gm(l){const e=Y.c(27),{busy:s,connection:n,onConnect:i}=l;let a;e[0]!==n.connecting||e[1]!==n.status?(a=Qr(n.status,{connecting:n.connecting}),e[0]=n.connecting,e[1]=n.status,e[2]=a):a=e[2];const o=a,r=s||n.connecting||o.actionLabel===null,c=`provider-card x-connection-card x-connection-${o.tone}`;let d,u;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"provider-dot","aria-hidden":"true"}),u=t.jsx("strong",{children:"X account"}),e[3]=d,e[4]=u):(d=e[3],u=e[4]);let f;e[5]!==o.detail||e[6]!==o.label?(f=t.jsxs("p",{children:[o.label," · ",o.detail]}),e[5]=o.detail,e[6]=o.label,e[7]=f):f=e[7];let m;e[8]!==n.authorizeUrl||e[9]!==n.connecting?(m=n.connecting&&n.authorizeUrl&&t.jsxs("p",{children:[t.jsx("a",{href:n.authorizeUrl,target:"_blank",rel:"noopener noreferrer",children:"Open the X authorization page"})," ","if no browser tab appeared."]}),e[8]=n.authorizeUrl,e[9]=n.connecting,e[10]=m):m=e[10];let b;e[11]!==n.connecting||e[12]!==n.error?(b=n.error&&!n.connecting&&t.jsx("p",{className:"x-connection-error",role:"alert",children:n.error}),e[11]=n.connecting,e[12]=n.error,e[13]=b):b=e[13];let p;e[14]!==f||e[15]!==m||e[16]!==b?(p=t.jsxs("div",{children:[u,f,m,b]}),e[14]=f,e[15]=m,e[16]=b,e[17]=p):p=e[17];let g;e[18]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(lc,{size:13,"aria-hidden":"true"}),e[18]=g):g=e[18];const h=n.connecting?"Waiting…":o.actionLabel??"Connect X";let y;e[19]!==r||e[20]!==i||e[21]!==h?(y=t.jsxs("button",{type:"button",disabled:r,onClick:i,children:[g,h]}),e[19]=r,e[20]=i,e[21]=h,e[22]=y):y=e[22];let x;return e[23]!==y||e[24]!==c||e[25]!==p?(x=t.jsxs("article",{className:c,"aria-label":"X account",children:[d,p,y]}),e[23]=y,e[24]=c,e[25]=p,e[26]=x):x=e[26],x}function qs(l){const e=Y.c(9),{providers:s,editor:n,busy:i}=l;let a;if(e[0]!==i||e[1]!==n||e[2]!==s){let r;e[4]!==i||e[5]!==n?(r=c=>{const d=eo(c),u=n.draft?.key===c.envKey&&c.editable,f=n.message?.key===c.envKey?n.message:null;return t.jsxs("article",{className:"settings-credential","aria-label":`${d} setting`,children:[t.jsxs("div",{className:"settings-credential-summary",children:[t.jsx("span",{className:`settings-key-status settings-key-${c.keyStatus}`,"aria-hidden":"true"}),t.jsxs("div",{className:"settings-credential-copy",children:[t.jsx("strong",{children:d}),t.jsx("span",{className:"settings-key-caption",children:c.keyStatus==="configured"?"Configured":c.keyStatus==="placeholder"?"Placeholder key":"Not configured"}),c.maskedKey&&t.jsx("span",{className:"settings-key-value",children:c.maskedKey}),!c.editable&&t.jsx("span",{className:"settings-key-source",children:c.source==="1password"?"Managed in 1Password":"Read only"})]}),c.editable&&t.jsx("button",{type:"button","aria-label":`Edit ${d}`,"aria-expanded":u,disabled:i||n.saving,onClick:m=>n.edit(c,m.currentTarget),children:c.keyStatus==="configured"?"Edit":c.secret?"Set key":"Set value"})]}),u&&t.jsxs("form",{className:"settings-key-editor","aria-label":`Edit ${d}`,onSubmit:m=>{m.preventDefault(),n.save(c)},onKeyDown:m=>{m.key!=="Escape"||m.nativeEvent.isComposing||n.saving||(m.preventDefault(),m.stopPropagation(),n.close())},children:[t.jsx("label",{htmlFor:`setting-${c.envKey}`,children:d}),t.jsx("input",{id:`setting-${c.envKey}`,autoFocus:!0,type:c.secret?"password":"text",value:n.draft?.value??"",autoComplete:"off",spellCheck:!1,disabled:i||n.saving,onChange:m=>n.change(m.target.value)}),t.jsxs("small",{children:[c.envKey," · Saved locally"]}),t.jsxs("div",{className:"settings-key-actions",children:[t.jsx("button",{type:"submit",disabled:i||n.saving||!n.draft?.value.trim(),children:n.saving?"Saving…":"Save"}),t.jsx("button",{type:"button",disabled:n.saving,onClick:n.close,children:"Cancel"})]})]}),f&&t.jsx("p",{className:f.error?"settings-error":"settings-feedback",role:f.error?"alert":"status",children:f.text})]},c.envKey)},e[4]=i,e[5]=n,e[6]=r):r=e[6],a=s.map(r),e[0]=i,e[1]=n,e[2]=s,e[3]=a}else a=e[3];let o;return e[7]!==a?(o=t.jsx("div",{className:"settings-credentials",children:a}),e[7]=a,e[8]=o):o=e[8],o}function Nn(l){return`${l.filter(s=>s.keyStatus==="configured").length} of ${l.length} configured`}function gf(l){const e=Y.c(129),{call:s,providers:n,loading:i,error:a,refreshed:o,storage:r,bookId:c,bookName:d,connection:u,busy:f,onRefresh:m,onSave:b,onConnect:p}=l,g=Zr(b);let h,y,x,j,v,k,w,S,M,N,$,R,I,P,T,D,A,F;if(e[0]!==c||e[1]!==d||e[2]!==f||e[3]!==s||e[4]!==u||e[5]!==g||e[6]!==a||e[7]!==i||e[8]!==p||e[9]!==m||e[10]!==n||e[11]!==o||e[12]!==r){const ee=n.filter(km);let ne;e[31]!==n?(ne=n.filter(vm),e[31]=n,e[32]=ne):ne=e[32];const V=ne,re=n.filter(jm);h=n.filter(ym);const W=r?.bookId===c?r:null,Z=W?.status==="ready"?W.value:null;w="workspace-screen settings-screen",S="Settings";let ie;e[33]===Symbol.for("react.memo_cache_sentinel")?(ie=t.jsxs("div",{children:[t.jsx("h1",{children:"Settings"}),t.jsx("p",{children:"Providers, connected accounts and project storage."})]}),e[33]=ie):ie=e[33];const J=i?"Refreshing…":o?"Up to date":"";let G;e[34]!==J?(G=t.jsx("span",{role:"status",children:J}),e[34]=J,e[35]=G):G=e[35];const ce=f||i;let ae;e[36]!==m?(ae=()=>{m()},e[36]=m,e[37]=ae):ae=e[37];let X;e[38]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(Ni,{size:15,"aria-hidden":"true"}),e[38]=X):X=e[38];let le;e[39]!==ce||e[40]!==ae?(le=t.jsxs("button",{type:"button",disabled:ce,onClick:ae,children:[X,"Refresh"]}),e[39]=ce,e[40]=ae,e[41]=le):le=e[41],e[42]!==G||e[43]!==le?(M=t.jsxs("header",{children:[ie,t.jsxs("div",{className:"settings-refresh",children:[G,le]})]}),e[42]=G,e[43]=le,e[44]=M):M=e[44],e[45]!==a?(N=a&&t.jsx("p",{role:"alert",className:"settings-error",children:a}),e[45]=a,e[46]=N):N=e[46],v="settings-layout";let de;e[47]===Symbol.for("react.memo_cache_sentinel")?(de=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-providers-heading",children:"Providers"}),t.jsx("span",{children:"Application"})]}),e[47]=de):de=e[47];const pe=ee.length?Nn(ee):i?"Loading providers…":"Refresh to load provider settings.";let ue;e[48]!==pe?(ue=t.jsx("p",{className:"settings-section-summary",children:pe}),e[48]=pe,e[49]=ue):ue=e[49];let me;e[50]!==f||e[51]!==g||e[52]!==ee?(me=t.jsx(qs,{providers:ee,editor:g,busy:f}),e[50]=f,e[51]=g,e[52]=ee,e[53]=me):me=e[53],e[54]!==ue||e[55]!==me?(k=t.jsxs("section",{className:"settings-panel settings-providers","aria-labelledby":"settings-providers-heading",children:[de,ue,me]}),e[54]=ue,e[55]=me,e[56]=k):k=e[56],F="settings-secondary";let fe;e[57]===Symbol.for("react.memo_cache_sentinel")?(fe=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-x-heading",children:"X account"}),t.jsx("span",{children:"Application"})]}),e[57]=fe):fe=e[57];let xe;e[58]!==f||e[59]!==u||e[60]!==p?(xe=t.jsx(gm,{busy:f,connection:u,onConnect:p}),e[58]=f,e[59]=u,e[60]=p,e[61]=xe):xe=e[61];const he=Nn(re);let oe;e[62]!==he?(oe=t.jsxs("summary",{children:["X credentials ",t.jsx("span",{children:he})]}),e[62]=he,e[63]=oe):oe=e[63];let Q;e[64]!==f||e[65]!==g||e[66]!==re?(Q=t.jsx(qs,{providers:re,editor:g,busy:f}),e[64]=f,e[65]=g,e[66]=re,e[67]=Q):Q=e[67];let te;e[68]!==oe||e[69]!==Q?(te=t.jsxs("details",{className:"settings-details",children:[oe,Q]}),e[68]=oe,e[69]=Q,e[70]=te):te=e[70],e[71]!==xe||e[72]!==te?(x=t.jsxs("section",{className:"settings-panel","aria-labelledby":"settings-x-heading",children:[fe,xe,te]}),e[71]=xe,e[72]=te,e[73]=x):x=e[73];let be;e[74]===Symbol.for("react.memo_cache_sentinel")?(be=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-dropbox-heading",children:"Dropbox"}),t.jsx("span",{children:"Application"})]}),e[74]=be):be=e[74];let ve;e[75]!==s?(ve=t.jsx(xm,{call:s}),e[75]=s,e[76]=ve):ve=e[76];let Ce;e[77]===Symbol.for("react.memo_cache_sentinel")?(Ce=t.jsx("summary",{children:"Dropbox credentials"}),e[77]=Ce):Ce=e[77];let Se;e[78]!==f||e[79]!==V||e[80]!==g?(Se=t.jsxs("details",{className:"settings-details",children:[Ce,t.jsx(qs,{providers:V,editor:g,busy:f})]}),e[78]=f,e[79]=V,e[80]=g,e[81]=Se):Se=e[81],e[82]!==ve||e[83]!==Se?(j=t.jsxs("section",{className:"settings-panel","aria-labelledby":"settings-dropbox-heading",children:[be,ve,Se]}),e[82]=ve,e[83]=Se,e[84]=j):j=e[84],I="settings-panel",P="settings-storage-heading",e[85]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsxs("div",{className:"settings-panel-heading",children:[t.jsx("h2",{id:"settings-storage-heading",children:"Storage"}),t.jsx("span",{children:"Selected project"})]}),e[85]=T):T=e[85];const $e=d??"No project selected";e[86]!==$e?(D=t.jsx("p",{className:"settings-section-summary",children:$e}),e[86]=$e,e[87]=D):D=e[87],e[88]!==c||e[89]!==W||e[90]!==i||e[91]!==Z?(A=c?W?.status==="error"?t.jsx("p",{role:"alert",className:"settings-error",children:W.error}):Z?t.jsxs(t.Fragment,{children:[t.jsxs("dl",{className:"settings-storage-summary",children:[t.jsxs("div",{children:[t.jsx("dt",{children:"Backup"}),t.jsx("dd",{children:Z.state.replaceAll("_"," ")})]}),t.jsxs("div",{children:[t.jsx("dt",{children:"Pending objects"}),t.jsx("dd",{children:Z.pendingObjects})]})]}),Z.lastError&&t.jsx("p",{role:"alert",className:"settings-error",children:Z.lastError}),t.jsxs("details",{className:"settings-details",children:[t.jsx("summary",{children:"Technical details"}),t.jsxs("p",{children:["videobook-engine ",ya.version," · schema ",ja]}),t.jsx("pre",{children:JSON.stringify(Z,null,2)})]})]}):t.jsx("p",{role:"status",children:i?"Loading storage…":"Refresh to inspect storage."}):t.jsx("p",{children:"Select a project to inspect its storage."}),e[88]=c,e[89]=W,e[90]=i,e[91]=Z,e[92]=A):A=e[92],R="settings-details",$="Backblaze configuration ",y=Nn(h),e[0]=c,e[1]=d,e[2]=f,e[3]=s,e[4]=u,e[5]=g,e[6]=a,e[7]=i,e[8]=p,e[9]=m,e[10]=n,e[11]=o,e[12]=r,e[13]=h,e[14]=y,e[15]=x,e[16]=j,e[17]=v,e[18]=k,e[19]=w,e[20]=S,e[21]=M,e[22]=N,e[23]=$,e[24]=R,e[25]=I,e[26]=P,e[27]=T,e[28]=D,e[29]=A,e[30]=F}else h=e[13],y=e[14],x=e[15],j=e[16],v=e[17],k=e[18],w=e[19],S=e[20],M=e[21],N=e[22],$=e[23],R=e[24],I=e[25],P=e[26],T=e[27],D=e[28],A=e[29],F=e[30];let E;e[93]!==y?(E=t.jsx("span",{children:y}),e[93]=y,e[94]=E):E=e[94];let z;e[95]!==E||e[96]!==$?(z=t.jsxs("summary",{children:[$,E]}),e[95]=E,e[96]=$,e[97]=z):z=e[97];let _;e[98]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx("p",{children:"Application · shared by all projects."}),e[98]=_):_=e[98];let L;e[99]!==f||e[100]!==g||e[101]!==h?(L=t.jsx(qs,{providers:h,editor:g,busy:f}),e[99]=f,e[100]=g,e[101]=h,e[102]=L):L=e[102];let B;e[103]!==z||e[104]!==L||e[105]!==R?(B=t.jsxs("details",{className:R,children:[z,_,L]}),e[103]=z,e[104]=L,e[105]=R,e[106]=B):B=e[106];let H;e[107]!==B||e[108]!==I||e[109]!==P||e[110]!==T||e[111]!==D||e[112]!==A?(H=t.jsxs("section",{className:I,"aria-labelledby":P,children:[T,D,A,B]}),e[107]=B,e[108]=I,e[109]=P,e[110]=T,e[111]=D,e[112]=A,e[113]=H):H=e[113];let q;e[114]!==x||e[115]!==j||e[116]!==H||e[117]!==F?(q=t.jsxs("div",{className:F,children:[x,j,H]}),e[114]=x,e[115]=j,e[116]=H,e[117]=F,e[118]=q):q=e[118];let U;e[119]!==v||e[120]!==k||e[121]!==q?(U=t.jsxs("div",{className:v,children:[k,q]}),e[119]=v,e[120]=k,e[121]=q,e[122]=U):U=e[122];let K;return e[123]!==w||e[124]!==S||e[125]!==M||e[126]!==N||e[127]!==U?(K=t.jsxs("section",{className:w,"aria-label":S,children:[M,N,U]}),e[123]=w,e[124]=S,e[125]=M,e[126]=N,e[127]=U,e[128]=K):K=e[128],K}function ym(l){return l.provider==="b2"}function jm(l){return l.provider==="x"}function vm(l){return l.provider==="dropbox"}function km(l){return!["x","b2","dropbox"].includes(l.provider)}function Sm(l){const e=Y.c(16),{applyDisabled:s,applyFormId:n,applyLabel:i,busy:a,busyLabel:o,failed:r,onCancel:c}=l,d=a||s;let u;e[0]!==i||e[1]!==a||e[2]!==o||e[3]!==r?(u=a?o:t.jsxs(t.Fragment,{children:[r?"Retry":i," ",t.jsx("kbd",{children:"↵"})]}),e[0]=i,e[1]=a,e[2]=o,e[3]=r,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==d||e[7]!==u?(f=t.jsx("button",{type:"submit",form:n,className:"confirm-sheet-apply",disabled:d,children:u}),e[5]=n,e[6]=d,e[7]=u,e[8]=f):f=e[8];let m;e[9]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx("kbd",{children:"Esc"}),e[9]=m):m=e[9];let b;e[10]!==a||e[11]!==c?(b=t.jsxs("button",{type:"button",disabled:a,onClick:c,children:["Cancel ",m]}),e[10]=a,e[11]=c,e[12]=b):b=e[12];let p;return e[13]!==f||e[14]!==b?(p=t.jsxs("div",{className:"confirm-sheet-actions",children:[f,b]}),e[13]=f,e[14]=b,e[15]=p):p=e[15],p}function Gi(){const l=Y.c(4);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx("kbd",{children:"↵"}),l[0]=e):e=l[0];let s;l[1]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("kbd",{children:"Esc"}),l[1]=s):s=l[1];let n;l[2]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx("kbd",{children:"⌘↵"}),l[2]=n):n=l[2];let i;return l[3]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("span",{children:[e," apply · ",s," cancel · ",n," apply from any field · ",t.jsx("kbd",{children:"Tab"})," moves through settings"]}),l[3]=i):i=l[3],i}function wm(l){const e=Y.c(6),{effect:s}=l,n=`confirm-sheet-effect confirm-sheet-effect-${s.tone}`;let i;e[0]!==s.tone?(i=s.tone==="warning"&&t.jsx(Fi,{size:11,"aria-hidden":"true"}),e[0]=s.tone,e[1]=i):i=e[1];let a;return e[2]!==s.label||e[3]!==n||e[4]!==i?(a=t.jsxs("span",{className:n,children:[i,s.label]}),e[2]=s.label,e[3]=n,e[4]=i,e[5]=a):a=e[5],a}function Nm(l){const e=Y.c(4),{state:s}=l;if(s==="blocking"){let n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(ic,{size:14,"aria-hidden":"true"}),e[0]=n):n=e[0],n}if(s==="failed"){let n;return e[1]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(wi,{size:14,"aria-hidden":"true"}),e[1]=n):n=e[1],n}if(s==="notice"){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(Fi,{size:14,"aria-hidden":"true"}),e[2]=n):n=e[2],n}if(s==="busy"){let n;return e[3]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsxs("span",{className:"confirm-sheet-signal","aria-hidden":"true",children:[t.jsx("i",{}),t.jsx("i",{}),t.jsx("i",{})]}),e[3]=n):n=e[3],n}return null}function Cm(l){const e=Y.c(23),{hints:s,onDismissStatus:n,secondaryActions:i,status:a,statusId:o}=l,r=a.state==="blocking"||a.state==="failed",c=`confirm-sheet-foot confirm-sheet-foot-${a.state}`,d=`confirm-sheet-status confirm-sheet-status-${a.state}`,u=r?"alert":"status",f=r?"assertive":"polite";let m;e[0]!==a.state?(m=t.jsx(Nm,{state:a.state}),e[0]=a.state,e[1]=m):m=e[1];let b;e[2]!==s||e[3]!==a.message||e[4]!==a.state?(b=a.state==="ready"?s??t.jsx(Gi,{}):t.jsxs("span",{children:[a.state==="blocking"&&t.jsx("strong",{children:"Can’t apply — "}),a.state==="failed"&&t.jsx("strong",{children:"Apply failed — "}),a.message]}),e[2]=s,e[3]=a.message,e[4]=a.state,e[5]=b):b=e[5];let p;e[6]!==n||e[7]!==a.dismissible?(p=a.dismissible&&t.jsx("button",{type:"button",className:"confirm-sheet-status-dismiss","aria-label":"Dismiss message",onClick:n,children:t.jsx(dt,{size:14,"aria-hidden":"true"})}),e[6]=n,e[7]=a.dismissible,e[8]=p):p=e[8];let g;e[9]!==o||e[10]!==d||e[11]!==u||e[12]!==f||e[13]!==m||e[14]!==b||e[15]!==p?(g=t.jsxs("div",{id:o,className:d,role:u,"aria-live":f,children:[m,b,p]}),e[9]=o,e[10]=d,e[11]=u,e[12]=f,e[13]=m,e[14]=b,e[15]=p,e[16]=g):g=e[16];let h;e[17]!==i?(h=i&&t.jsx("div",{className:"confirm-sheet-aside",children:i}),e[17]=i,e[18]=h):h=e[18];let y;return e[19]!==c||e[20]!==g||e[21]!==h?(y=t.jsxs("footer",{className:c,children:[g,h]}),e[19]=c,e[20]=g,e[21]=h,e[22]=y):y=e[22],y}function $m(l){const e=Y.c(22),{actions:s,address:n,effect:i,hints:a,hintsId:o,tag:r,title:c,titleId:d}=l;let u;e[0]!==r?(u=t.jsx("span",{className:"section-label",children:r}),e[0]=r,e[1]=u):u=e[1];let f;e[2]!==c||e[3]!==d?(f=t.jsx("h2",{id:d,children:c}),e[2]=c,e[3]=d,e[4]=f):f=e[4];let m;e[5]!==n?(m=n&&t.jsx("span",{className:"confirm-sheet-address",children:n}),e[5]=n,e[6]=m):m=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("span",{className:"confirm-sheet-spacer","aria-hidden":"true"}),e[7]=b):b=e[7];let p;e[8]!==a||e[9]!==o?(p=a&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"confirm-sheet-head-divider","aria-hidden":"true"}),t.jsx("span",{id:o,className:"confirm-sheet-head-hints",children:a})]}),e[8]=a,e[9]=o,e[10]=p):p=e[10];let g;e[11]!==i?(g=i&&t.jsx(wm,{effect:i}),e[11]=i,e[12]=g):g=e[12];let h;e[13]!==s||e[14]!==g?(h=t.jsxs("div",{className:"confirm-sheet-decisions",children:[g,s]}),e[13]=s,e[14]=g,e[15]=h):h=e[15];let y;return e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==p||e[20]!==h?(y=t.jsxs("header",{className:"confirm-sheet-head",children:[u,f,m,b,p,h]}),e[16]=u,e[17]=f,e[18]=m,e[19]=p,e[20]=h,e[21]=y):y=e[21],y}function Yi(){return typeof window>"u"||typeof window.matchMedia!="function"?null:window.matchMedia(to)}function Im(l){const e=Yi();return e?(e.addEventListener("change",l),()=>e.removeEventListener("change",l)):()=>{}}function Rm(){return Yi()?.matches??!0}function Mm(){return C.useSyncExternalStore(Im,Rm,Pm)}function Pm(){return!0}function yf(l){const e=Y.c(58),{address:s,applyFormId:n,applyLabel:i,ariaLabel:a,busy:o,busyLabel:r,children:c,effect:d,hints:u,kind:f,onCancel:m,secondaryActions:b,tag:p,title:g,validation:h}=l,y=s===void 0?null:s,x=i===void 0?"Apply":i,j=r===void 0?"Applying…":r,v=d===void 0?null:d,k=u===void 0?null:u,w=b===void 0?null:b,S=C.useId(),M=`${S}-title`,N=`${S}-status`,$=C.useContext(Oi),[R,I]=C.useState(null);let P;e[0]!==$?.outcome?(P=()=>$?.outcome??null,e[0]=$?.outcome,e[1]=P):P=e[1];const[T]=C.useState(P);let D;e[2]!==$?.notice?(D=()=>$?.notice??null,e[2]=$?.notice,e[3]=D):D=e[3];const[A]=C.useState(D),F=$&&$.outcome!==T?$.outcome:null,E=$&&$.notice!==A?$.notice:null,z=so({busy:o,busyLabel:j,validation:h,outcome:F,notice:E}),_=Mm(),L=no({state:z.state,hasSecondaryActions:!!w,wideEnough:_}),B=h.blocking!==null;let H;e[4]!==B||e[5]!==n||e[6]!==o||e[7]!==m?(H={applyFormId:n,applyDisabled:B,busy:o,onCancel:m},e[4]=B,e[5]=n,e[6]=o,e[7]=m,e[8]=H):H=e[8];const{sheetRef:q,onKeyDown:U}=Fd(H);let K;e[9]!==$||e[10]!==E||e[11]!==F?(K=()=>{F?$?.dismissOutcome():E&&$?.dismissNotice()},e[9]=$,e[10]=E,e[11]=F,e[12]=K):K=e[12];const ee=K,ne=`confirm-sheet confirm-sheet-${f}`;let V;e[13]!==R?(V=R===null?void 0:{"--confirm-review-height":`${R}px`},e[13]=R,e[14]=V):V=e[14];const re=z.message??j,W=z.state==="failed";let Z;e[15]!==B||e[16]!==n||e[17]!==x||e[18]!==o||e[19]!==m||e[20]!==re||e[21]!==W?(Z=t.jsx(Sm,{applyDisabled:B,applyFormId:n,applyLabel:x,busy:o,busyLabel:re,failed:W,onCancel:m}),e[15]=B,e[16]=n,e[17]=x,e[18]=o,e[19]=m,e[20]=re,e[21]=W,e[22]=Z):Z=e[22];let ie;e[23]!==k||e[24]!==L?(ie=L?k??t.jsx(Gi,{}):null,e[23]=k,e[24]=L,e[25]=ie):ie=e[25];const J=L?N:void 0;let G;e[26]!==y||e[27]!==v||e[28]!==Z||e[29]!==ie||e[30]!==J||e[31]!==p||e[32]!==g||e[33]!==M?(G=t.jsx($m,{actions:Z,address:y,effect:v,hints:ie,hintsId:J,tag:p,title:g,titleId:M}),e[26]=y,e[27]=v,e[28]=Z,e[29]=ie,e[30]=J,e[31]=p,e[32]=g,e[33]=M,e[34]=G):G=e[34];let ce;e[35]!==q?(ce=t.jsx(Dd,{sheetRef:q}),e[35]=q,e[36]=ce):ce=e[36];let ae;e[37]!==c||e[38]!==ce?(ae=t.jsx("div",{className:"confirm-sheet-body",children:t.jsxs(C.Suspense,{fallback:null,children:[c,ce]})}),e[37]=c,e[38]=ce,e[39]=ae):ae=e[39];let X;e[40]!==ee||e[41]!==k||e[42]!==L||e[43]!==w||e[44]!==z||e[45]!==N?(X=!L&&t.jsx(Cm,{hints:k,onDismissStatus:ee,secondaryActions:w,status:z,statusId:N}),e[40]=ee,e[41]=k,e[42]=L,e[43]=w,e[44]=z,e[45]=N,e[46]=X):X=e[46];let le;e[47]===Symbol.for("react.memo_cache_sentinel")?(le=t.jsx(zi,{label:"Resize review and log",targetSelector:".confirm-sheet",edge:"bottom",minimum:180,reserve:36,onResize:I}),e[47]=le):le=e[47];let de;return e[48]!==a||e[49]!==U||e[50]!==q||e[51]!==N||e[52]!==ne||e[53]!==V||e[54]!==G||e[55]!==ae||e[56]!==X?(de=t.jsxs("aside",{ref:q,className:ne,style:V,role:"dialog","aria-label":a,"aria-describedby":N,"aria-keyshortcuts":"Escape Meta+Enter Control+Enter",onKeyDown:U,children:[G,ae,X,le]}),e[48]=a,e[49]=U,e[50]=q,e[51]=N,e[52]=ne,e[53]=V,e[54]=G,e[55]=ae,e[56]=X,e[57]=de):de=e[57],de}function Tm(l){const e=Y.c(13),{post:s,source:n}=l;let i;e[0]!==s||e[1]!==n?(i=t.jsx(Em,{post:s,source:n}),e[0]=s,e[1]=n,e[2]=i):i=e[2];const a=s?.definition.caption??"";let o;e[3]!==a?(o=t.jsx(Dm,{caption:a}),e[3]=a,e[4]=o):o=e[4];let r;e[5]!==s?(r=s?t.jsx(Fm,{post:s}):t.jsx("span",{className:"post-tile-hint",children:"Choose a clip to post"}),e[5]=s,e[6]=r):r=e[6];let c;e[7]!==o||e[8]!==r?(c=t.jsxs("div",{className:"post-tile-body",children:[o,r]}),e[7]=o,e[8]=r,e[9]=c):c=e[9];let d;return e[10]!==i||e[11]!==c?(d=t.jsxs("div",{className:"post-tile",children:[i,c]}),e[10]=i,e[11]=c,e[12]=d):d=e[12],d}function Em(l){const e=Y.c(22),{post:s,source:n}=l,i=n?.asset,a=i?.type==="video",o=i?.thumbnailUrl??(a?null:i?.mediaUrl??null),r=o||!a?null:i?.mediaUrl??null,c=i?.duration??null;let d,u,f,m;if(e[0]!==s||e[1]!==o||e[2]!==r){const h=s?xi(s):[];d="post-tile-media",e[7]!==o?(u=o&&t.jsx("img",{src:o,alt:"",draggable:!1}),e[7]=o,e[8]=u):u=e[8],e[9]!==r?(f=r&&t.jsx("video",{src:`${r}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),e[9]=r,e[10]=f):f=e[10],m=h.length>0&&t.jsx("span",{className:"post-tile-overlay post-tile-overlay-top",children:h.map(Am)}),e[0]=s,e[1]=o,e[2]=r,e[3]=d,e[4]=u,e[5]=f,e[6]=m}else d=e[3],u=e[4],f=e[5],m=e[6];let b;e[11]!==n?(b=n?.address&&t.jsxs("span",{className:"post-tile-overlay post-tile-overlay-start",children:["from ",n.address]}),e[11]=n,e[12]=b):b=e[12];let p;e[13]!==c?(p=c!=null&&c>0&&t.jsx("span",{className:"post-tile-overlay post-tile-overlay-end",children:Bt(c)}),e[13]=c,e[14]=p):p=e[14];let g;return e[15]!==d||e[16]!==u||e[17]!==f||e[18]!==m||e[19]!==b||e[20]!==p?(g=t.jsxs("div",{className:d,children:[u,f,m,b,p]}),e[15]=d,e[16]=u,e[17]=f,e[18]=m,e[19]=b,e[20]=p,e[21]=g):g=e[21],g}function Am(l){return t.jsxs("span",{className:"post-badge",children:[t.jsx(Jt,{size:10,strokeWidth:2.6,"aria-hidden":"true"}),l]},l)}function Dm(l){const e=Y.c(5),{caption:s}=l;let n;e[0]!==s?(n=s.trim(),e[0]=s,e[1]=n):n=e[1];const i=n;if(!i){let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"post-tile-caption post-tile-caption-empty",children:"No caption yet"}),e[2]=o):o=e[2],o}let a;return e[3]!==i?(a=t.jsx("span",{className:"post-tile-caption",title:i,children:i}),e[3]=i,e[4]=a):a=e[4],a}function Fm(l){const e=Y.c(14),{post:s}=l;let n;e[0]!==s?(n=lo(s),e[0]=s,e[1]=n):n=e[1];const i=n;if(i){let u;return e[2]!==i||e[3]!==s?(u=t.jsx(Lm,{post:s,text:i}),e[2]=i,e[3]=s,e[4]=u):u=e[4],u}let a;if(e[5]!==s){a=Symbol.for("react.early_return_sentinel");e:{const u=io(s);if(u.length>0){a=t.jsx("span",{className:"post-tile-stats",children:u.map(_m)});break e}}e[5]=s,e[6]=a}else a=e[6];if(a!==Symbol.for("react.early_return_sentinel"))return a;let o;e[7]!==s?(o=ao(s)??"Posted",e[7]=s,e[8]=o):o=e[8];let r;e[9]!==o?(r=t.jsx("span",{children:o}),e[9]=o,e[10]=r):r=e[10];let c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx("span",{className:"post-tile-hint post-tile-hint-action",children:"Add results"}),e[11]=c):c=e[11];let d;return e[12]!==r?(d=t.jsxs("span",{className:"post-tile-stats",children:[r,c]}),e[12]=r,e[13]=d):d=e[13],d}function _m(l){return t.jsxs("span",{children:[t.jsx("strong",{children:l.value})," ",l.label]},l.label)}function Lm(l){const e=Y.c(8),{post:s,text:n}=l;let i;e[0]!==s?(i=xi(s),e[0]=s,e[1]=i):i=e[1];const a=i.length>0,o=`post-tile-hint${a?" post-tile-hint-action":""}`;let r;e[2]!==a?(r=a&&t.jsx(Ei,{size:11,"aria-hidden":"true"}),e[2]=a,e[3]=r):r=e[3];let c;return e[4]!==o||e[5]!==r||e[6]!==n?(c=t.jsxs("span",{className:o,children:[r,n]}),e[4]=o,e[5]=r,e[6]=n,e[7]=c):c=e[7],c}const zm=C.createContext({ready:!1,states:{},onFile:()=>{},onFileError:()=>{},onOpenLibrary:()=>{}}),Bm=C.createContext(async()=>{}),Om=C.createContext({ready:!1,deleteCell:async()=>{},repairCell:async()=>{},retryCell:async()=>{}}),Um=C.createContext(null),Hm=C.createContext(new Map),Km=C.createContext({openCellId:null,open:()=>{}});function Vm(l){return`cell-context-menu-${l}`}const qm=C.createContext(null),jf=C.createContext(new Map),vf=C.createContext(new Map),Wm=C.createContext(new Map);function Xm(l){const e=Y.c(26),{analysisInfo:s,fallbackShotCount:n,fallbackSourceDurationSeconds:i}=l,a=n===void 0?null:n,o=i===void 0?null:i,r=s?.shots.length??a??0,c=s?.sourceDurationSeconds??o;let d,u,f,m,b;if(e[0]!==s?.outputJson||e[1]!==s?.shots||e[2]!==c||e[3]!==r){const y=s?.shots.slice(0,3)??[];u=Math.max(0,r-y.length),d=s?.outputJson,f="cell-copy cell-copy-analysis";const x=r>0?`${r} shots`:"Analysis pending";let j;e[9]!==x?(j=t.jsx("strong",{children:x}),e[9]=x,e[10]=j):j=e[10];let v;e[11]!==c?(v=c!==null&&t.jsx("span",{children:Bt(c)}),e[11]=c,e[12]=v):v=e[12],e[13]!==j||e[14]!==v?(m=t.jsxs("div",{className:"analysis-cell-summary",children:[j,v]}),e[13]=j,e[14]=v,e[15]=m):m=e[15],b=y.length>0&&t.jsx("ol",{className:"analysis-cell-shots",children:y.map(Gm)}),e[0]=s?.outputJson,e[1]=s?.shots,e[2]=c,e[3]=r,e[4]=d,e[5]=u,e[6]=f,e[7]=m,e[8]=b}else d=e[4],u=e[5],f=e[6],m=e[7],b=e[8];let p;e[16]!==u?(p=u>0&&t.jsxs("span",{className:"analysis-cell-overflow",children:["+",u," more"]}),e[16]=u,e[17]=p):p=e[17];let g;e[18]!==d?(g=d!=null&&t.jsxs("details",{className:"analysis-cell-output-json nodrag nowheel",children:[t.jsxs("summary",{children:[t.jsx($s,{size:11,"aria-hidden":"true"}),"Output JSON"]}),t.jsx("div",{className:"analysis-cell-output-json-scroll",tabIndex:0,children:t.jsx(Xn,{value:d,ariaLabel:"Analysis output JSON"})})]}),e[18]=d,e[19]=g):g=e[19];let h;return e[20]!==f||e[21]!==m||e[22]!==b||e[23]!==p||e[24]!==g?(h=t.jsxs("div",{className:f,children:[m,b,p,g]}),e[20]=f,e[21]=m,e[22]=b,e[23]=p,e[24]=g,e[25]=h):h=e[25],h}function Gm(l){return t.jsxs("li",{children:[t.jsx("span",{children:l.label}),t.jsxs("time",{children:[Bt(l.startSeconds),"–",Bt(l.endSeconds)]})]},l.ordinal)}function Ym(l){return Number.isFinite(l.duration)&&l.duration>0?Math.min(1,Math.max(0,l.currentTime/l.duration)):0}function Wl(l){const e=Y.c(58),{address:s,posterUrl:n,waveform:i,mediaUrl:a,playbackKind:o,alt:r,title:c,badges:d,meter:u,metadataLabel:f,pendingLabel:m,pendingIcon:b,children:p}=l,[g,h]=C.useState(!1),[y,x]=C.useState(!1),[j,v]=C.useState(0),[k,w]=C.useState(0),S=C.useRef(null),M=C.useRef(!1),N=o!==null&&a!==null,$=i!==null,R=$?i.length===0:n===null;let I;e[0]===Symbol.for("react.memo_cache_sentinel")?(I=J=>{S.current=J,!(!J||!M.current)&&(M.current=!1,J.play().catch(()=>x(!1)))},e[0]=I):I=e[0];const P=I;let T;e[1]!==y?(T=J=>{J.preventDefault();const G=S.current;if(y){G?.pause();return}if(!G){M.current=!0,h(!0);return}G.play().catch(()=>x(!1))},e[1]=y,e[2]=T):T=e[2];const D=T;let A;e[3]===Symbol.for("react.memo_cache_sentinel")?(A=J=>{const G=J.currentTarget;v(Ym(G)),w(G.currentTime)},e[3]=A):A=e[3];const F=A;let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{x(!1),v(0),w(0)},e[4]=E):E=e[4];const z=E;let _;e[5]!==k||e[6]!==u||e[7]!==y?(_=u&&y?`${Bt(Math.floor(k))} / ${u.label}`:u?.label??null,e[5]=k,e[6]=u,e[7]=y,e[8]=_):_=e[8];const L=_,B=`cell-media${y?" cell-media-playing":""}`;let H;e[9]===Symbol.for("react.memo_cache_sentinel")?(H=()=>h(!0),e[9]=H):H=e[9];let q;e[10]!==y?(q=()=>{y||h(!1)},e[10]=y,e[11]=q):q=e[11];let U;e[12]===Symbol.for("react.memo_cache_sentinel")?(U=()=>h(!0),e[12]=U):U=e[12];let K;e[13]!==r||e[14]!==g||e[15]!==$||e[16]!==a||e[17]!==o||e[18]!==y||e[19]!==n||e[20]!==j||e[21]!==i?(K=$?i.length>0?t.jsx(td,{peaks:i,progress:j}):t.jsx(Ui,{}):g&&a&&o==="video"?t.jsx("video",{ref:P,src:a,poster:n??void 0,muted:!y,playsInline:!0,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:F,onEnded:z}):n?t.jsx("img",{src:n,alt:r,loading:"lazy",decoding:"async"}):null,e[13]=r,e[14]=g,e[15]=$,e[16]=a,e[17]=o,e[18]=y,e[19]=n,e[20]=j,e[21]=i,e[22]=K):K=e[22];let ee;e[23]!==g||e[24]!==$||e[25]!==a?(ee=$&&g&&a&&t.jsx("audio",{ref:P,src:a,preload:"metadata",onPlay:()=>x(!0),onPause:()=>x(!1),onTimeUpdate:F,onEnded:z}),e[23]=g,e[24]=$,e[25]=a,e[26]=ee):ee=e[26];let ne;e[27]!==R||e[28]!==b||e[29]!==m||e[30]!==y?(ne=R&&!y&&t.jsxs("span",{className:"cell-media-pending-face","aria-hidden":"true",children:[b,t.jsx("span",{children:m})]}),e[27]=R,e[28]=b,e[29]=m,e[30]=y,e[31]=ne):ne=e[31];let V;e[32]!==d||e[33]!==f?(V=d.length>0&&t.jsx("div",{className:"cell-media-rail",role:"group","aria-label":f,children:d.map(Qm)}),e[32]=d,e[33]=f,e[34]=V):V=e[34];let re;e[35]!==u||e[36]!==L?(re=L&&u&&t.jsx("time",{className:"cell-media-meter",dateTime:`PT${u.seconds}S`,title:"Duration",children:L}),e[35]=u,e[36]=L,e[37]=re):re=e[37];let W;e[38]!==s||e[39]!==N||e[40]!==y||e[41]!==D?(W=N&&t.jsx("button",{type:"button",className:"cell-media-play nodrag","aria-label":`${y?"Pause":"Play"} ${s}`,onClick:D,onPointerDown:Jm,children:y?t.jsx(Ti,{size:13,strokeWidth:2,"aria-hidden":"true"}):t.jsx(Is,{size:13,fill:"currentColor",strokeWidth:0,"aria-hidden":"true"})}),e[38]=s,e[39]=N,e[40]=y,e[41]=D,e[42]=W):W=e[42];let Z;e[43]!==N||e[44]!==j?(Z=N&&t.jsx("span",{className:"cell-media-progress","aria-hidden":"true",children:t.jsx("span",{style:{width:`${j*100}%`}})}),e[43]=N,e[44]=j,e[45]=Z):Z=e[45];let ie;return e[46]!==p||e[47]!==K||e[48]!==ee||e[49]!==ne||e[50]!==V||e[51]!==re||e[52]!==W||e[53]!==Z||e[54]!==B||e[55]!==q||e[56]!==c?(ie=t.jsxs("div",{className:B,title:c,onPointerEnter:H,onPointerLeave:q,onFocus:U,children:[K,ee,ne,V,re,W,Z,p]}),e[46]=p,e[47]=K,e[48]=ee,e[49]=ne,e[50]=V,e[51]=re,e[52]=W,e[53]=Z,e[54]=B,e[55]=q,e[56]=c,e[57]=ie):ie=e[57],ie}function Jm(l){return l.stopPropagation()}function Qm(l){return t.jsx("span",{className:`cell-media-badge${l.emphasis==="generator"?" cell-media-badge-wide":""}`,title:l.title,children:l.label},l.key)}const Zm=[{left:"12%",delay:0,duration:1.6},{left:"32%",delay:.7,duration:2.2},{left:"50%",delay:.3,duration:1.8},{left:"70%",delay:1.1,duration:1.5},{left:"88%",delay:.5,duration:2}];function e1(l){const e=Y.c(2),{variant:s}=l;if((s===void 0?"rise":s)==="stream"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("div",{className:"cell-state-streaks","aria-hidden":"true",children:Zm.map(t1)}),e[0]=a):a=e[0],a}let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("div",{className:"cell-state-shimmer","aria-hidden":"true"}),e[1]=i):i=e[1],i}function t1(l){return t.jsx("span",{className:"cell-state-streak",style:{left:l.left,animationDelay:`${l.delay}s`,animationDuration:`${l.duration}s`}},l.left)}const s1=1e3,n1=Array.from({length:gi},(l,e)=>e+1);function l1(l){const e=Math.max(0,Math.floor(l/1e3)),s=Math.floor(e/3600),n=Math.floor(e%3600/60),i=e%60,a=o=>o.toString().padStart(2,"0");return s>0?`${s}:${a(n)}:${a(i)}`:`${n}:${a(i)}`}function i1(l,e){return l<e?"done":l===e?"active":"pending"}function a1(l){const e=Y.c(14),{phase:s}=l;let n;e[0]!==s.step?(n=n1.map(d=>t.jsx("span",{className:"cell-state-phase-step","data-status":i1(d,s.step)},d)),e[0]=s.step,e[1]=n):n=e[1];let i;e[2]!==n?(i=t.jsx("div",{className:"cell-state-phase-rail","aria-hidden":"true",children:n}),e[2]=n,e[3]=i):i=e[3];let a;e[4]!==s.label?(a=t.jsx("span",{children:s.label}),e[4]=s.label,e[5]=a):a=e[5];let o;e[6]!==s.step?(o=t.jsxs("span",{children:[s.step,"/",gi]}),e[6]=s.step,e[7]=o):o=e[7];let r;e[8]!==a||e[9]!==o?(r=t.jsxs("div",{className:"cell-state-phase-label",children:[a,o]}),e[8]=a,e[9]=o,e[10]=r):r=e[10];let c;return e[11]!==i||e[12]!==r?(c=t.jsxs("div",{className:"cell-state-phase",children:[i,r]}),e[11]=i,e[12]=r,e[13]=c):c=e[13],c}function r1(l){const e=Y.c(32),{icon:s,label:n,address:i,startedAt:a,variant:o,meta:r,phase:c}=l,d=r===void 0?null:r,u=c===void 0?null:c,[f]=C.useState(c1),m=a??f,[b,p]=C.useState(o1);let g,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{const A=setInterval(()=>p(Date.now()),s1);return()=>clearInterval(A)},h=[],e[0]=g,e[1]=h):(g=e[0],h=e[1]),C.useEffect(g,h);const y=Math.max(0,b-m);let x;e[2]!==y?(x=l1(y),e[2]=y,e[3]=x):x=e[3];const j=x;let v;e[4]!==n?(v=n.toLowerCase(),e[4]=n,e[5]=v):v=e[5];const k=`@${i} ${v}`;let w;e[6]!==o?(w=t.jsx(e1,{variant:o}),e[6]=o,e[7]=w):w=e[7];let S;e[8]!==s?(S=t.jsx("span",{className:"cell-state-overlay-icon","aria-hidden":"true",children:s}),e[8]=s,e[9]=S):S=e[9];let M;e[10]!==n?(M=t.jsx("strong",{children:n}),e[10]=n,e[11]=M):M=e[11];let N;e[12]!==j?(N=t.jsx("span",{className:"cell-state-timer","aria-hidden":"true",children:j}),e[12]=j,e[13]=N):N=e[13];let $;e[14]!==M||e[15]!==N?($=t.jsxs("div",{className:"cell-state-overlay-copy",children:[M,N]}),e[14]=M,e[15]=N,e[16]=$):$=e[16];let R;e[17]!==S||e[18]!==$?(R=t.jsxs("div",{className:"cell-state-clock-row",children:[S,$]}),e[17]=S,e[18]=$,e[19]=R):R=e[19];let I;e[20]!==d?(I=d&&t.jsx("span",{className:"cell-state-meta",title:d,children:d}),e[20]=d,e[21]=I):I=e[21];let P;e[22]!==u?(P=u&&t.jsx(a1,{phase:u}),e[22]=u,e[23]=P):P=e[23];let T;e[24]!==R||e[25]!==I||e[26]!==P?(T=t.jsxs("div",{className:"cell-state-overlay-body cell-state-clock-body",children:[R,I,P]}),e[24]=R,e[25]=I,e[26]=P,e[27]=T):T=e[27];let D;return e[28]!==T||e[29]!==k||e[30]!==w?(D=t.jsxs("div",{className:"cell-state-overlay cell-state-overlay-clock",role:"status","aria-label":k,"aria-live":"polite",children:[w,T]}),e[28]=T,e[29]=k,e[30]=w,e[31]=D):D=e[31],D}function o1(){return Date.now()}function c1(){return Date.now()}function Cn(l){l.stopPropagation()}function d1(l){const e=Y.c(25),{error:s,label:n,address:i,meta:a,onRepair:o,onRetry:r,onDelete:c,disabled:d}=l,u=a===void 0?null:a,f=d===void 0?!1:d,m=u1;let b;e[0]!==n?(b=n.toLowerCase(),e[0]=n,e[1]=b):b=e[1];const p=`@${i} ${b}`;let g,h;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx("div",{className:"cell-state-scanlines","aria-hidden":"true"}),h=t.jsx("div",{className:"cell-state-failed-wash","aria-hidden":"true"}),e[2]=g,e[3]=h):(g=e[2],h=e[3]);let y;e[4]!==n?(y=t.jsx("strong",{children:n}),e[4]=n,e[5]=y):y=e[5];let x;e[6]!==s?(x=t.jsx("p",{className:"cell-state-failed-message",children:s}),e[6]=s,e[7]=x):x=e[7];let j;e[8]!==u?(j=u&&t.jsx("span",{className:"cell-state-meta",title:u,children:u}),e[8]=u,e[9]=j):j=e[9];let v;e[10]!==i||e[11]!==f||e[12]!==c||e[13]!==o||e[14]!==r?(v=(o||r||c)&&t.jsxs("div",{className:"cell-state-actions",children:[r&&t.jsxs("button",{type:"button",className:"cell-state-action cell-state-retry nodrag","aria-label":`Retry @${i}`,title:"Delete this failed output and generate again with the saved settings",disabled:f,onPointerDown:Cn,onClick:m(r),children:[t.jsx(Bn,{size:10,"aria-hidden":"true"}),"RETRY"]}),o&&t.jsxs("button",{type:"button",className:"cell-state-action cell-state-repair nodrag","aria-label":`Repair @${i} in chat`,title:"Send this failure to chat for a corrected re-run",onPointerDown:Cn,onClick:m(o),children:[t.jsx(ac,{size:10,"aria-hidden":"true"}),"REPAIR"]}),c&&t.jsxs("button",{type:"button",className:"cell-state-action cell-state-delete nodrag","aria-label":`Delete @${i}`,title:"Delete this cell now",onPointerDown:Cn,onClick:m(c),children:[t.jsx(as,{size:10,"aria-hidden":"true"}),"DELETE"]})]}),e[10]=i,e[11]=f,e[12]=c,e[13]=o,e[14]=r,e[15]=v):v=e[15];let k;e[16]!==v||e[17]!==y||e[18]!==x||e[19]!==j?(k=t.jsxs("div",{className:"cell-state-overlay-body cell-state-failed-body",children:[y,x,j,v]}),e[16]=v,e[17]=y,e[18]=x,e[19]=j,e[20]=k):k=e[20];let w;return e[21]!==s||e[22]!==k||e[23]!==p?(w=t.jsxs("div",{className:"cell-state-overlay cell-state-overlay-failed",role:"alert","aria-label":p,title:s,children:[g,h,k]}),e[21]=s,e[22]=k,e[23]=p,e[24]=w):w=e[24],w}function u1(l){return e=>{e.stopPropagation(),l()}}function m1(l){const e=Y.c(25),{kind:s,address:n,status:i,statusStartedAt:a,statusError:o,icon:r,generator:c,generation:d,onRepair:u,onRetry:f,onDelete:m,disabled:b}=l,p=c===void 0?null:c,g=d===void 0?!1:d;let h;if(e[0]!==n||e[1]!==b||e[2]!==g||e[3]!==p||e[4]!==r||e[5]!==s||e[6]!==m||e[7]!==u||e[8]!==f||e[9]!==i||e[10]!==o||e[11]!==a){h=Symbol.for("react.early_return_sentinel");e:{const y=ro(s,i,{error:o??null,startedAt:a??null});if(y.overlay==="clock"&&y.label){let x;e[13]!==g||e[14]!==i?(x=g?oo(i):null,e[13]=g,e[14]=i,e[15]=x):x=e[15],h=t.jsx(r1,{icon:r,label:y.label,address:n,startedAt:y.startedAt,variant:i==="downloading"?"stream":"rise",meta:p,phase:x});break e}if(y.overlay==="failed"&&y.error){const x=co(y.error),j=uo(s)?"MEDIA FAILED":"GENERATION FAILED",v=x?void 0:u,k=x?f:void 0;let w;e[16]!==n||e[17]!==b||e[18]!==p||e[19]!==m||e[20]!==y||e[21]!==j||e[22]!==v||e[23]!==k?(w=t.jsx(d1,{error:y.error,label:j,address:n,meta:p,onRepair:v,onRetry:k,onDelete:m,disabled:b}),e[16]=n,e[17]=b,e[18]=p,e[19]=m,e[20]=y,e[21]=j,e[22]=v,e[23]=k,e[24]=w):w=e[24],h=w;break e}}e[0]=n,e[1]=b,e[2]=g,e[3]=p,e[4]=r,e[5]=s,e[6]=m,e[7]=u,e[8]=f,e[9]=i,e[10]=o,e[11]=a,e[12]=h}else h=e[12];return h!==Symbol.for("react.early_return_sentinel")?h:null}const Ji=He.columnCount*He.columnPitch-He.gap,Xl=200,f1=36,Gl=120,p1={width:Ji,height:He.squareSize};function h1(l,e,s){return l.edge==="start"?{start:Math.max(s.min,Math.min(l.end-1,e)),end:l.end}:{start:l.start,end:Math.min(s.max,Math.max(l.start+1,e))}}function $n(l){return`${Math.floor(l/60)}:${Math.floor(l%60).toString().padStart(2,"0")}`}function b1(l){const e=Y.c(64),{assembly:s}=l,n=C.useRef(null),[i,a]=C.useState("");let o,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{const I=document.activeElement,P=n.current;return P?.showModal(),P?.querySelector("input")?.focus(),()=>{P?.close(),po(I instanceof HTMLElement?I:null)}},r=[],e[0]=o,e[1]=r):(o=e[0],r=e[1]),C.useEffect(o,r);const c=s.picker;if(!c)return null;let d,u,f,m,b,p,g,h,y,x,j,v,k;if(e[2]!==s||e[3]!==c.items||e[4]!==c.trackId||e[5]!==i){let I;e[19]!==i?(I=F=>F.label.toLowerCase().includes(i.toLowerCase()),e[19]=i,e[20]=I):I=e[20],d=c.items.filter(I),p=hs.createPortal,y=n,x="timeline-source-picker",j="Add a timeline clip",v="preserve",e[21]!==s?(k=F=>{F.preventDefault(),s.closePicker()},e[21]=s,e[22]=k):k=e[22],e[23]!==s.closePicker?(u=F=>{F.stopPropagation(),ho(F,{busy:!1,container:F.currentTarget,onClose:s.closePicker})},e[23]=s.closePicker,e[24]=u):u=e[24],e[25]!==s?(f=F=>{F.target===F.currentTarget&&s.closePicker()},e[25]=s,e[26]=f):f=e[26];let P;e[27]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx("strong",{children:"Add a clip"}),e[27]=P):P=e[27];let T;e[28]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(dt,{size:16}),e[28]=T):T=e[28],e[29]!==s.closePicker?(m=t.jsxs("header",{children:[P,t.jsx("button",{type:"button",onClick:s.closePicker,"aria-label":"Close clip picker",children:T})]}),e[29]=s.closePicker,e[30]=m):m=e[30];let D;e[31]===Symbol.for("react.memo_cache_sentinel")?(D=F=>a(F.target.value),e[31]=D):D=e[31],e[32]!==i?(b=t.jsx("input",{autoFocus:!0,"aria-label":"Filter timeline sources",placeholder:"Filter media by name",value:i,onChange:D}),e[32]=i,e[33]=b):b=e[33],g="timeline-source-list";let A;e[34]!==s||e[35]!==c.trackId?(A=F=>t.jsxs("button",{type:"button",disabled:s.busy,onClick:()=>{s.append(c.trackId,F.artifactId)},children:[F.thumbnailUrl?t.jsx("img",{src:F.thumbnailUrl,alt:"",loading:"lazy"}):t.jsx(Ct,{size:24}),t.jsx("span",{children:F.label}),t.jsx(Zt,{size:16})]},F.artifactId),e[34]=s,e[35]=c.trackId,e[36]=A):A=e[36],h=d.map(A),e[2]=s,e[3]=c.items,e[4]=c.trackId,e[5]=i,e[6]=d,e[7]=u,e[8]=f,e[9]=m,e[10]=b,e[11]=p,e[12]=g,e[13]=h,e[14]=y,e[15]=x,e[16]=j,e[17]=v,e[18]=k}else d=e[6],u=e[7],f=e[8],m=e[9],b=e[10],p=e[11],g=e[12],h=e[13],y=e[14],x=e[15],j=e[16],v=e[17],k=e[18];let w;e[37]!==d.length?(w=d.length===0&&t.jsx("p",{children:"No matching media on this page."}),e[37]=d.length,e[38]=w):w=e[38];let S;e[39]!==w||e[40]!==g||e[41]!==h?(S=t.jsxs("div",{className:g,children:[h,w]}),e[39]=w,e[40]=g,e[41]=h,e[42]=S):S=e[42];let M;e[43]!==s.error?(M=s.error&&t.jsx("p",{role:"alert",children:s.error}),e[43]=s.error,e[44]=M):M=e[44];let N;e[45]!==s||e[46]!==c.offset?(N=c.offset!==null&&t.jsx("button",{type:"button",disabled:s.busy,onClick:()=>{s.loadMore()},children:"Load more media"}),e[45]=s,e[46]=c.offset,e[47]=N):N=e[47];let $;e[48]!==u||e[49]!==f||e[50]!==m||e[51]!==b||e[52]!==S||e[53]!==M||e[54]!==N||e[55]!==y||e[56]!==x||e[57]!==j||e[58]!==v||e[59]!==k?($=t.jsxs("dialog",{ref:y,className:x,"aria-label":j,"data-composer-focus":v,onCancel:k,onKeyDown:u,onClick:f,children:[m,b,S,M,N]}),e[48]=u,e[49]=f,e[50]=m,e[51]=b,e[52]=S,e[53]=M,e[54]=N,e[55]=y,e[56]=x,e[57]=j,e[58]=v,e[59]=k,e[60]=$):$=e[60];let R;return e[61]!==p||e[62]!==$?(R=p($,document.body),e[61]=p,e[62]=$,e[63]=R):R=e[63],R}function x1(l){const e=Y.c(185),{sequence:s,assets:n,assembly:i,disabled:a,frame:o,address:r,onSeek:c,onPreview:d,onExport:u,onRemove:f,presentation:m,toolbar:b,onSelectClip:p,onMoveClip:g,onRemoveClip:h,onTrimClip:y,trimBounds:x,rhythm:j}=l,v=m===void 0?"canvas":m,[k,w]=C.useState(v==="preview"?"fit":48),[S,M]=C.useState(0),[N,$]=C.useState(0),R=i.selectedClipId,[I,P]=C.useState(null),T=C.useRef(!1),[D,A]=C.useState(null),F=C.useRef(null),E=C.useRef(null),[z,_]=C.useState(120),[L,B]=C.useState(Ji-Xl),H=s?s.frameRate.numerator/s.frameRate.denominator:30;let q;if(e[0]!==s?.captions||e[1]!==s?.clips){const Re=s?.clips.reduce(S1,0)??0;q=s?.captions.reduce(k1,Re)??Re,e[0]=s?.captions,e[1]=s?.clips,e[2]=q}else q=e[2];const U=q,K=U/H,ee=v==="preview"?Math.min(Gl,L/10):Gl,ne=Math.max(1,L-ee)/Math.max(1,K),V=Math.min(k==="fit"?ne:k,8e6/Math.max(1,K)),re=k==="fit"?L:Math.max(L,K*V+ee),W=Math.min(S,re-L);let Z;e[3]!==s?.tracks?(Z=s?.tracks.reduce(v1,void 0),e[3]=s?.tracks,e[4]=Z):Z=e[4];const ie=Z;ie?.trackId;let J;e[5]!==ie?.trackId||e[6]!==s?(J=s?.tracks.filter(Re=>Re.kind==="audio"||Re.kind==="video"&&Re.trackId!==ie?.trackId&&s.clips.some(Pe=>Pe.trackId===Re.trackId))??[],e[5]=ie?.trackId,e[6]=s,e[7]=J):J=e[7];const G=J;let ce;if(e[8]!==s?.clips){ce=new Map;for(const Re of s?.clips??[]){const Pe=ce.get(Re.trackId)??[];Pe.push(Re),ce.set(Re.trackId,Pe)}e[8]=s?.clips,e[9]=ce}else ce=e[9];const ae=ce;let X;e[10]!==n?(X=new Map(n.map(j1)),e[10]=n,e[11]=X):X=e[11];const le=X;let de,pe;e[12]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{const Re=F.current,Pe=E.current;if(!Re||!Pe)return;const Je=new ResizeObserver(()=>{_(Re.clientHeight);const De=Number.parseFloat(getComputedStyle(Pe).marginLeft)||Xl;B(Math.max(1,Math.min(Pe.clientWidth,Re.clientWidth-De)))});return Je.observe(Re),Je.observe(Pe),()=>Je.disconnect()},pe=[],e[12]=de,e[13]=pe):(de=e[12],pe=e[13]),C.useEffect(de,pe);const ue=v==="preview"?64:f1,me=Math.max(0,Math.min(Math.floor(N/ue),G.length-1)-1);let fe,xe,he,oe,Q,te,be,ve,Ce,Se,$e,Be,_e,nt,Ke,Xe;if(e[14]!==r||e[15]!==i||e[16]!==le||e[17]!==z||e[18]!==W||e[19]!==ae||e[20]!==a||e[21]!==I||e[22]!==K||e[23]!==U||e[24]!==me||e[25]!==ne||e[26]!==H||e[27]!==o||e[28]!==L||e[29]!==ie||e[30]!==u||e[31]!==g||e[32]!==d||e[33]!==f||e[34]!==h||e[35]!==c||e[36]!==p||e[37]!==y||e[38]!==V||e[39]!==v||e[40]!==j||e[41]!==R||e[42]!==s||e[43]!==b||e[44]!==ue||e[45]!==G||e[46]!==D||e[47]!==x||e[48]!==k){const Re=G.slice(me,me+Math.ceil(z/ue)+3),Pe=a||i.busy;let Je;e[65]!==R||e[66]!==s?.clips?(Je=s?.clips.find(Te=>Te.clipId===R),e[65]=R,e[66]=s?.clips,e[67]=Je):Je=e[67];const De=Je;let ke;e[68]!==De?.trackId||e[69]!==s?.tracks?(ke=s?.tracks.find(Te=>Te.trackId===De?.trackId),e[68]=De?.trackId,e[69]=s?.tracks,e[70]=ke):ke=e[70];const Oe=ke,at=De&&!Oe?.locked&&(Oe?.kind==="audio"||Oe?.trackId===ie?.trackId),Et=Math.max(1,2**Math.ceil(Math.log2(100/V))),At=Math.floor(W/V/Et),$t=Array.from({length:Math.ceil(L/V/Et)+2},(Te,Ne)=>(At+Ne)*Et);j?.markers;let lt;if(e[71]!==W||e[72]!==H||e[73]!==L||e[74]!==V||e[75]!==j?.markers){lt=[];for(const Te of j?.markers??[]){const Ne=Te.frame/H*V-W,Nt=lt[lt.length-1],Lt=Nt?Nt.frame/H*V-W:-1/0;if(!(Ne<0||Ne>L)){if(Ne-Lt<(Te.bar?8:14)){Te.bar&&Nt&&!Nt.bar&&(lt[lt.length-1]=Te);continue}lt.push(Te)}}e[71]=W,e[72]=H,e[73]=L,e[74]=V,e[75]=j?.markers,e[76]=lt}else lt=e[76];const se=lt;let ye;e[77]!==W||e[78]!==U||e[79]!==H||e[80]!==c||e[81]!==V?(ye=function(Ne,Nt){const Lt=Nt.getBoundingClientRect(),ot=(Ne-Lt.left)*Nt.clientWidth/Lt.width;c(Math.max(0,Math.min(U-1,Math.round((ot+W)/V*H))))},e[77]=W,e[78]=U,e[79]=H,e[80]=c,e[81]=V,e[82]=ye):ye=e[82];const Me=ye,Ye=function(Ne,Nt){const Lt=ae.get(Ne.trackId)??[],ot=Ne.kind==="video"&&Ne.trackId!==ie?.trackId,Rs=Lt.filter(ge=>{const Pt=ge.timelineStartFrame/H*V;return Pt+ge.durationFrames/H*V>=W-100&&Pt<=W+L+100});return t.jsxs("div",{className:`timeline-track timeline-track-${Ne.kind}`,"data-track-id":Ne.trackId,style:Nt,children:[t.jsxs("div",{className:"timeline-track-label",children:[t.jsx("span",{title:Ne.name,children:ot?`${Ne.name} · read only`:Ne.name}),!ot&&t.jsx("button",{type:"button",disabled:Pe||Ne.locked,onClick:()=>{i.openPicker(Ne.trackId)},"aria-label":`Add clip to ${Ne.name}`,children:t.jsx(Zt,{size:14})}),Ne.kind==="audio"&&Lt.length===0&&G.filter(y1).length>1&&t.jsx("button",{type:"button",disabled:Pe||Ne.locked,onClick:()=>{i.removeTrack(Ne.trackId)},"aria-label":`Remove ${Ne.name}`,children:t.jsx(dt,{size:12})})]}),t.jsxs("div",{className:"timeline-track-lane",onClick:ge=>Me(ge.clientX,ge.currentTarget),children:[Rs.map(ge=>{const Pt=le.get(ge.source.artifactId),qt=D?.clipId===ge.clipId?D:null,Ms=(qt?qt.start:I?.clipId===ge.clipId?I.frame:ge.timelineStartFrame)/H*V-W,Wt=(qt?qt.end-qt.start:ge.durationFrames)/H*V,en=!!(y&&x&&R===ge.clipId&&Ne.kind==="video"&&!ot&&!Ne.locked&&!Pe),Ht=j?.analysis?.artifactId===ge.source.artifactId?j.analysis:null,tn=Ne.kind==="audio"?mo(ge,Ht?.waveform??Pt?.waveform??[],Ht?.durationSeconds??Pt?.duration??0,H,Math.min(2048,Math.max(32,Math.ceil(Wt/2)))):[],Ps=fo(tn);return t.jsxs("button",{className:`timeline-clip${R===ge.clipId?" selected":""}${j?.masterClipId===ge.clipId?" timeline-master":""}`,type:"button","data-clip-id":ge.clipId,"aria-pressed":R===ge.clipId,title:`${Pt?.label??"Clip"} · ${(ge.durationFrames/H).toFixed(2)}s`,style:{left:Ms,width:Math.max(2,Wt)},onPointerDown:st=>{!g||ot||Ne.kind!=="video"||Ne.locked||Pe||st.button!==0||(T.current=!1,st.currentTarget.setPointerCapture(st.pointerId),P({clipId:ge.clipId,clientX:st.clientX,start:ge.timelineStartFrame,frame:ge.timelineStartFrame}))},onPointerMove:st=>{if(!I||I.clipId!==ge.clipId)return;Math.abs(st.clientX-I.clientX)>4&&(T.current=!0);const Ue=Math.max(0,I.start+(st.clientX-I.clientX)/V*H),We=st.altKey?Math.round(Ue):kl(Ue,j?.markers??[],j?.snap??"off",12/V*H);P({...I,frame:We})},onPointerUp:()=>{I?.clipId===ge.clipId&&T.current&&I.frame!==ge.timelineStartFrame&&g?.(ge,I.frame),P(null)},onPointerCancel:()=>{T.current=!1,P(null)},onKeyDown:st=>{st.key==="Escape"&&I&&(st.stopPropagation(),T.current=!1,P(null))},onClick:st=>{if(st.stopPropagation(),T.current){T.current=!1;return}i.selectClip(ge.clipId),p?.(ge),c(ge.timelineStartFrame)},children:[Ps&&t.jsx("svg",{className:"timeline-waveform",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:t.jsx("path",{d:Ps})}),Pt?.thumbnailUrl&&Ne.kind==="video"&&Wt>55&&t.jsx("img",{src:Pt.thumbnailUrl,alt:"",loading:"lazy"}),t.jsx("span",{children:Pt?.label??"Clip"}),en&&["start","end"].map(st=>t.jsx("i",{className:`timeline-trim-handle ${st}`,title:`Drag to trim the ${st==="start"?"in":"out"} point`,"aria-hidden":"true",onClick:g1,onPointerDown:Ue=>{if(Ue.button!==0)return;Ue.stopPropagation(),Ue.currentTarget.setPointerCapture(Ue.pointerId);const We=ge.timelineStartFrame+ge.durationFrames;A({clipId:ge.clipId,edge:st,clientX:Ue.clientX,start:ge.timelineStartFrame,end:We,origin:st==="start"?ge.timelineStartFrame:We})},onPointerMove:Ue=>{if(!D||D.clipId!==ge.clipId||D.edge!==st||!x)return;const We=D.origin+(Ue.clientX-D.clientX)/V*H,sn=Ue.altKey?Math.round(We):kl(We,j?.markers??[],j?.snap??"off",12/V*H);A({...D,...h1(D,sn,x)})},onPointerUp:Ue=>{Ue.stopPropagation();const We=D;A(null),!(!We||We.clipId!==ge.clipId)&&(We.start===ge.timelineStartFrame&&We.end===ge.timelineStartFrame+ge.durationFrames||y?.(ge,st,We.start,We.end))},onPointerCancel:()=>A(null)},st))]},ge.clipId)}),Lt.length===0&&t.jsxs("span",{className:"timeline-empty-lane",children:["Add ",Ne.kind," to begin"]}),se.map(ge=>t.jsx("i",{className:`timeline-beat${ge.bar?" bar":""}${ge.manual?" manual":""}`,style:{left:ge.frame/H*V-W},"aria-hidden":"true"},ge.frame)),t.jsx("i",{className:"timeline-playhead",style:{left:o/H*V-W}})]})]},Ne.trackId)};Ce=`notebook-timeline${v==="preview"?" notebook-timeline-preview":""}`,Se=v==="canvas"?p1:void 0,$e=`Timeline ${r}`,Be="preserve";let it,Ot;e[83]===Symbol.for("react.memo_cache_sentinel")?(it=t.jsx(Ct,{size:15}),Ot=t.jsx("strong",{children:"Timeline"}),e[83]=it,e[84]=Ot):(it=e[83],Ot=e[84]);let ut;e[85]!==r?(ut=t.jsx("code",{children:r}),e[85]=r,e[86]=ut):ut=e[86];let kt;e[87]!==K?(kt=$n(K),e[87]=K,e[88]=kt):kt=e[88];let St;e[89]!==kt?(St=t.jsx("span",{children:kt}),e[89]=kt,e[90]=St):St=e[90];const mt=Pe||!s;let ft;e[91]!==i?(ft=()=>{i.addTrack()},e[91]=i,e[92]=ft):ft=e[92];let rt;e[93]!==mt||e[94]!==ft?(rt=t.jsx("button",{type:"button",disabled:mt,onClick:ft,children:"+ Audio track"}),e[93]=mt,e[94]=ft,e[95]=rt):rt=e[95];let wt;e[96]!==U||e[97]!==d||e[98]!==s?(wt=d&&t.jsx("button",{type:"button",disabled:!s||U===0,onClick:d,children:"Preview"}),e[96]=U,e[97]=d,e[98]=s,e[99]=wt):wt=e[99];const It=Pe||U===0;let Rt;e[100]!==u||e[101]!==It?(Rt=t.jsx("button",{type:"button",disabled:It,onClick:u,children:"Export"}),e[100]=u,e[101]=It,e[102]=Rt):Rt=e[102];const Le=Pe||!at;let Dt;e[103]!==i||e[104]!==h||e[105]!==De?(Dt=()=>{De&&(h?h(De):i.removeClip(De.clipId))},e[103]=i,e[104]=h,e[105]=De,e[106]=Dt):Dt=e[106];let yt;e[107]!==Le||e[108]!==Dt?(yt=t.jsx("button",{type:"button",disabled:Le,onClick:Dt,children:"Remove clip"}),e[107]=Le,e[108]=Dt,e[109]=yt):yt=e[109];let jt;e[110]!==ne||e[111]!==V?(jt=t.jsx("button",{type:"button","aria-label":"Zoom timeline out",onClick:()=>w(Math.max(Math.min(.25,ne),V/2)),children:"−"}),e[110]=ne,e[111]=V,e[112]=jt):jt=e[112];let Ft;e[113]!==ne||e[114]!==V?(Ft=t.jsx("button",{type:"button","aria-label":"Zoom timeline in",onClick:()=>w(Math.min(Math.max(768,ne),V*2)),children:"+"}),e[113]=ne,e[114]=V,e[115]=Ft):Ft=e[115];const Ut=k==="fit";let vt;e[116]===Symbol.for("react.memo_cache_sentinel")?(vt=()=>{w("fit"),M(0),E.current?.scrollTo({left:0})},e[116]=vt):vt=e[116];let pt;e[117]!==Ut?(pt=t.jsx("button",{type:"button","aria-pressed":Ut,onClick:vt,children:"Fit"}),e[117]=Ut,e[118]=pt):pt=e[118];let _t;e[119]!==Pe||e[120]!==f?(_t=f&&t.jsx("button",{type:"button",disabled:Pe,"aria-label":"Remove Timeline element",onClick:f,children:t.jsx(as,{size:14})}),e[119]=Pe,e[120]=f,e[121]=_t):_t=e[121];let ht;e[122]!==rt||e[123]!==wt||e[124]!==Rt||e[125]!==yt||e[126]!==jt||e[127]!==Ft||e[128]!==pt||e[129]!==_t?(ht=t.jsxs("div",{className:"timeline-toolbar nodrag nopan nowheel",children:[rt,wt,Rt,yt,jt,Ft,pt,_t]}),e[122]=rt,e[123]=wt,e[124]=Rt,e[125]=yt,e[126]=jt,e[127]=Ft,e[128]=pt,e[129]=_t,e[130]=ht):ht=e[130],e[131]!==ut||e[132]!==St||e[133]!==ht?(_e=t.jsxs("header",{className:"notebook-timeline-header",children:[it,Ot,ut,St,ht]}),e[131]=ut,e[132]=St,e[133]=ht,e[134]=_e):_e=e[134],e[135]!==b?(nt=b&&t.jsx("div",{className:"timeline-music-toolbar",children:b}),e[135]=b,e[136]=nt):nt=e[136],Q="timeline-assembly nodrag nopan nowheel",e[137]!==i.error||e[138]!==i.picker?(te=i.error&&!i.picker&&t.jsx("div",{role:"alert",className:"timeline-error",children:i.error}),e[137]=i.error,e[138]=i.picker,e[139]=te):te=e[139];const Mt=o/H;let bt;e[140]!==Mt?(bt=$n(Mt),e[140]=Mt,e[141]=bt):bt=e[141];let xt;e[142]!==bt?(xt=t.jsx("span",{children:bt}),e[142]=bt,e[143]=xt):xt=e[143];let Ee;e[144]!==Me?(Ee=Te=>Me(Te.clientX,Te.currentTarget),e[144]=Me,e[145]=Ee):Ee=e[145];const Ie=$t.map(Te=>t.jsx("span",{style:{left:Te*V-W},children:$n(Te)},Te));let Ae;e[146]!==Ee||e[147]!==Ie?(Ae=t.jsx("div",{className:"timeline-ruler","aria-label":"Timeline ruler",onClick:Ee,children:Ie}),e[146]=Ee,e[147]=Ie,e[148]=Ae):Ae=e[148],e[149]!==xt||e[150]!==Ae?(be=t.jsxs("div",{className:"timeline-ruler-row",children:[xt,Ae]}),e[149]=xt,e[150]=Ae,e[151]=be):be=e[151],ve=ie&&Ye(ie),xe="timeline-audio-viewport",he=F,e[152]===Symbol.for("react.memo_cache_sentinel")?(oe=Te=>$(Te.currentTarget.scrollTop),e[152]=oe):oe=e[152],Ke="timeline-audio-content";const Qe=G.length*ue;e[153]!==Qe?(Xe={height:Qe},e[153]=Qe,e[154]=Xe):Xe=e[154],fe=Re.map((Te,Ne)=>Ye(Te,{position:"absolute",top:(me+Ne)*ue,height:ue,width:"100%"})),e[14]=r,e[15]=i,e[16]=le,e[17]=z,e[18]=W,e[19]=ae,e[20]=a,e[21]=I,e[22]=K,e[23]=U,e[24]=me,e[25]=ne,e[26]=H,e[27]=o,e[28]=L,e[29]=ie,e[30]=u,e[31]=g,e[32]=d,e[33]=f,e[34]=h,e[35]=c,e[36]=p,e[37]=y,e[38]=V,e[39]=v,e[40]=j,e[41]=R,e[42]=s,e[43]=b,e[44]=ue,e[45]=G,e[46]=D,e[47]=x,e[48]=k,e[49]=fe,e[50]=xe,e[51]=he,e[52]=oe,e[53]=Q,e[54]=te,e[55]=be,e[56]=ve,e[57]=Ce,e[58]=Se,e[59]=$e,e[60]=Be,e[61]=_e,e[62]=nt,e[63]=Ke,e[64]=Xe}else fe=e[49],xe=e[50],he=e[51],oe=e[52],Q=e[53],te=e[54],be=e[55],ve=e[56],Ce=e[57],Se=e[58],$e=e[59],Be=e[60],_e=e[61],nt=e[62],Ke=e[63],Xe=e[64];let qe;e[155]!==fe||e[156]!==Ke||e[157]!==Xe?(qe=t.jsx("div",{className:Ke,style:Xe,children:fe}),e[155]=fe,e[156]=Ke,e[157]=Xe,e[158]=qe):qe=e[158];let Fe;e[159]!==xe||e[160]!==he||e[161]!==oe||e[162]!==qe?(Fe=t.jsx("div",{className:xe,ref:he,onScroll:oe,children:qe}),e[159]=xe,e[160]=he,e[161]=oe,e[162]=qe,e[163]=Fe):Fe=e[163];let Ve;e[164]===Symbol.for("react.memo_cache_sentinel")?(Ve=Re=>M(Re.currentTarget.scrollLeft),e[164]=Ve):Ve=e[164];let Ze;e[165]!==re?(Ze=t.jsx("div",{className:"timeline-horizontal",ref:E,onScroll:Ve,children:t.jsx("div",{style:{width:re,height:1}})}),e[165]=re,e[166]=Ze):Ze=e[166];let Ge;e[167]!==Q||e[168]!==te||e[169]!==be||e[170]!==ve||e[171]!==Fe||e[172]!==Ze?(Ge=t.jsxs("div",{className:Q,children:[te,be,ve,Fe,Ze]}),e[167]=Q,e[168]=te,e[169]=be,e[170]=ve,e[171]=Fe,e[172]=Ze,e[173]=Ge):Ge=e[173];let et;e[174]!==i?(et=i.picker&&t.jsx(b1,{assembly:i}),e[174]=i,e[175]=et):et=e[175];let tt;return e[176]!==Ce||e[177]!==Se||e[178]!==$e||e[179]!==Be||e[180]!==_e||e[181]!==nt||e[182]!==Ge||e[183]!==et?(tt=t.jsxs("section",{className:Ce,style:Se,"aria-label":$e,"data-composer-focus":Be,children:[_e,nt,Ge,et]}),e[176]=Ce,e[177]=Se,e[178]=$e,e[179]=Be,e[180]=_e,e[181]=nt,e[182]=Ge,e[183]=et,e[184]=tt):tt=e[184],tt}function g1(l){return l.stopPropagation()}function y1(l){return l.kind==="audio"}function j1(l){return[l.artifactId,l]}function v1(l,e){return e.kind==="video"&&(!l||e.ordinal<l.ordinal)?e:l}function k1(l,e){return Math.max(l,e.timelineStartFrame+e.durationFrames)}function S1(l,e){return Math.max(l,e.timelineStartFrame+e.durationFrames)}function Yl(l){const e=Y.c(10),{kind:s}=l;if(s==="video"||s==="generate_video"||s==="split_video"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Cs,{size:14}),e[0]=i):i=e[0],i}if(s==="image"||s==="generate_image"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Qt,{size:14}),e[1]=i):i=e[1],i}if(s==="audio"||s==="extract_audio"||s==="generate_audio"){let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ts,{size:14}),e[2]=i):i=e[2],i}if(s==="prompt"){let i;return e[3]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Ai,{size:14}),e[3]=i):i=e[3],i}if(s==="analyze"){let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(zn,{size:14}),e[4]=i):i=e[4],i}if(s==="analysis"){let i;return e[5]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx($s,{size:14}),e[5]=i):i=e[5],i}if(s==="character"){let i;return e[6]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Di,{size:14}),e[6]=i):i=e[6],i}if(s==="post"){let i;return e[7]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Pn,{size:14}),e[7]=i):i=e[7],i}if(s==="goal"){let i;return e[8]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Pn,{size:14}),e[8]=i):i=e[8],i}let n;return e[9]===Symbol.for("react.memo_cache_sentinel")?(n=t.jsx(Ct,{size:14}),e[9]=n):n=e[9],n}function w1(l){return l==="generate_video"?"GEN VID":l==="generate_image"?"GEN IMG":l==="generate_audio"?"GEN AUD":ji(l)}function Jl(l){return yi(l.kind)?l.tool??l.model??l.operation??"Choose a generation action":l.kind==="video"||l.kind==="image"||l.kind==="audio"?`Select ${l.kind} media`:l.kind==="character"?"Select a character":l.kind==="extract_audio"?"Connect a video to extract audio":l.kind==="analysis"?"Run the connected Analyze cell":l.kind==="split_video"?"Configure a video range":l.kind==="concat"?"Connect clip:0 and clip:1":l.kind==="splice"?"Connect first and second":l.prompt||Vt(l.slot)}function N1(l){return l?.thumbnailUrl??l?.mediaUrl??null}function Ql(l){const e=Y.c(18),{asset:s,artifactId:n,label:i,time:a}=l;let o;e[0]!==s?(o=N1(s),e[0]=s,e[1]=o):o=e[1];const r=o,c=n??i;let d;e[2]!==i||e[3]!==r?(d=r?t.jsx("img",{src:r,alt:`${i} frame`}):t.jsx(Ct,{size:24,"aria-hidden":!0}),e[2]=i,e[3]=r,e[4]=d):d=e[4];let u;e[5]!==i?(u=t.jsx("strong",{children:i}),e[5]=i,e[6]=u):u=e[6];let f;e[7]!==a?(f=a===null?"Frame pending":Bt(a),e[7]=a,e[8]=f):f=e[8];let m;e[9]!==f?(m=t.jsx("span",{children:f}),e[9]=f,e[10]=m):m=e[10];let b;e[11]!==u||e[12]!==m?(b=t.jsxs("figcaption",{children:[u,m]}),e[11]=u,e[12]=m,e[13]=b):b=e[13];let p;return e[14]!==c||e[15]!==d||e[16]!==b?(p=t.jsxs("figure",{title:c,children:[d,b]}),e[14]=c,e[15]=d,e[16]=b,e[17]=p):p=e[17],p}function C1(l){const e=Y.c(13),{data:s}=l;let n;e[0]!==s.inputs?(n=Ao(s.inputs),e[0]=s.inputs,e[1]=n):n=e[1];const i=n,a=s.splitFrames?.first.asset,o=s.splitFrames?.first.artifactId??null,r=i?.startSeconds??null;let c;e[2]!==a||e[3]!==o||e[4]!==r?(c=t.jsx(Ql,{asset:a,artifactId:o,label:"First",time:r}),e[2]=a,e[3]=o,e[4]=r,e[5]=c):c=e[5];const d=s.splitFrames?.last.asset,u=s.splitFrames?.last.artifactId??null,f=i?.endSeconds??null;let m;e[6]!==d||e[7]!==u||e[8]!==f?(m=t.jsx(Ql,{asset:d,artifactId:u,label:"Last",time:f}),e[6]=d,e[7]=u,e[8]=f,e[9]=m):m=e[9];let b;return e[10]!==c||e[11]!==m?(b=t.jsxs("div",{className:"cell-split-frames",children:[c,m]}),e[10]=c,e[11]=m,e[12]=b):b=e[12],b}function $1(l){const e=Y.c(48),{cellId:s,kind:n,ready:i,state:a,onFile:o,onFileError:r,onOpenLibrary:c}=l,d=C.useRef(null),[u,f]=C.useState(!1),m=a?.operation!==null&&a?.operation!==void 0;let b;e[0]!==m||e[1]!==s||e[2]!==o||e[3]!==r||e[4]!==i?(b=B=>{if(m||!i)return;const H=B?[...B]:[];if(H.length!==1){r(s,"Choose one file for this media slot.");return}o(s,H[0])},e[0]=m,e[1]=s,e[2]=o,e[3]=r,e[4]=i,e[5]=b):b=e[5];const p=b,g=`cell-media-slot nodrag nowheel${u?" cell-media-slot-dragging":""}`,h=`Empty ${n} media slot`;let y,x;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=B=>{Ls(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),f(!0))},x=B=>{Ls(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),f(!1))},e[6]=y,e[7]=x):(y=e[6],x=e[7]);let j;e[8]!==m||e[9]!==i?(j=B=>{Ls(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),B.dataTransfer.dropEffect=i&&!m?"copy":"none")},e[8]=m,e[9]=i,e[10]=j):j=e[10];let v;e[11]!==p||e[12]!==m?(v=B=>{Ls(B.dataTransfer)&&(B.preventDefault(),B.stopPropagation(),f(!1),m||p(B.dataTransfer.files))},e[11]=p,e[12]=m,e[13]=v):v=e[13];const k=m||!i;let w;e[14]!==s||e[15]!==c?(w=B=>{B.stopPropagation(),c(s)},e[14]=s,e[15]=c,e[16]=w):w=e[16];let S;e[17]!==m?(S=m?t.jsx(ct,{size:22}):t.jsx(Hn,{size:22}),e[17]=m,e[18]=S):S=e[18];const M=m?"Attaching media…":`Add ${n}`;let N;e[19]!==M?(N=t.jsx("strong",{children:M}),e[19]=M,e[20]=N):N=e[20];let $;e[21]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx("span",{children:"Recent media or drop a file"}),e[21]=$):$=e[21];let R;e[22]!==S||e[23]!==N||e[24]!==k||e[25]!==w?(R=t.jsxs("button",{type:"button",className:"cell-media-slot-library",disabled:k,onClick:w,children:[S,N,$]}),e[22]=S,e[23]=N,e[24]=k,e[25]=w,e[26]=R):R=e[26];const I=m||!i;let P,T;e[27]===Symbol.for("react.memo_cache_sentinel")?(P=B=>{B.stopPropagation(),d.current?.click()},T=t.jsx(Qs,{size:13}),e[27]=P,e[28]=T):(P=e[27],T=e[28]);let D;e[29]!==I?(D=t.jsxs("button",{type:"button",className:"cell-media-slot-upload",disabled:I,onClick:P,children:[T,"Upload file"]}),e[29]=I,e[30]=D):D=e[30];const A=hi[n],F=m||!i;let E;e[31]!==p?(E=B=>{p(B.target.files),B.target.value=""},e[31]=p,e[32]=E):E=e[32];let z;e[33]!==A||e[34]!==F||e[35]!==E?(z=t.jsx("input",{ref:d,className:"cell-media-slot-input",type:"file",accept:A,disabled:F,onChange:E}),e[33]=A,e[34]=F,e[35]=E,e[36]=z):z=e[36];let _;e[37]!==a?(_=a?.error&&t.jsx("span",{className:"cell-media-slot-error",role:"alert",children:a.error}),e[37]=a,e[38]=_):_=e[38];let L;return e[39]!==R||e[40]!==D||e[41]!==g||e[42]!==z||e[43]!==_||e[44]!==h||e[45]!==j||e[46]!==v?(L=t.jsxs("section",{className:g,"aria-label":h,onDragEnter:y,onDragLeave:x,onDragOver:j,onDrop:v,children:[R,D,z,_]}),e[39]=R,e[40]=D,e[41]=g,e[42]=z,e[43]=_,e[44]=h,e[45]=j,e[46]=v,e[47]=L):L=e[47],L}const I1=["left","right","bottom"],R1=I1.flatMap(l=>Rn.map((e,s)=>({id:bo(l,s),position:l==="left"?Ss.Left:l==="right"?Ss.Right:Ss.Bottom,style:l==="bottom"?{left:`${e*100}%`}:{top:`${e*100}%`}})));function M1(l){const e=Y.c(10),{status:s}=l;if(!s)return null;let n;e[0]!==s?(n=s.replaceAll("-"," ").replaceAll("_"," "),e[0]=s,e[1]=n):n=e[1];const i=n,a=`cell-status cell-status-${s}`,o=`Status: ${i}`;let r;e[2]!==i||e[3]!==s?(r=s==="completed"?t.jsx(Jt,{size:11,strokeWidth:2.4,"aria-hidden":"true"}):t.jsx("span",{children:i}),e[2]=i,e[3]=s,e[4]=r):r=e[4];let c;return e[5]!==i||e[6]!==a||e[7]!==o||e[8]!==r?(c=t.jsx("span",{className:a,"aria-label":o,title:i,children:r}),e[5]=i,e[6]=a,e[7]=o,e[8]=r,e[9]=c):c=e[9],c}function kf({id:l,data:e,selected:s}){const n=C.useContext(zm),i=C.useContext(Bm),a=C.useContext(Om),o=C.useContext(Um),r=C.useContext(Hm),c=C.useContext(Km),d=C.useContext(Wm).get(l)??null,u=uc(),f=s&&o===l,m=e.asset?.mediaUrl,b=e.asset?.thumbnailUrl,p=e.targetInputs?.length?e.targetInputs:["input"],g=e.targetConnectionCount??0,h=e.targetInputConnectionCounts??{},y=xo(e.kind),x=y!==null&&go(e.kind,e.outputArtifactId,g),j=e.asset?.type==="video"||e.asset?.type==="final",v=e.asset?.type==="audio",k=e.kind==="audio"||e.kind==="extract_audio",w=e.kind==="video"||e.kind==="image",S=!j&&e.kind==="image",M=e.kind==="prompt"||e.kind==="analyze",N=e.slot.row===0,$=[N?"top":"lower",...p,"|",...e.sourcePorts??[]].join("\0");C.useEffect(()=>{u(l)},[$,l,u]);const R=yo({type:e.kind,model:e.model,operation:e.operation,outputArtifactId:e.outputArtifactId,tool:e.tool},e.status),I=e.post?jo(e.post):vo(e.kind,e.status),P=yi(e.kind),T=P||Sl({type:e.kind,inputs:e.inputs}),D=T&&[e.provider??e.producerProvider,e.model??e.producerModel].filter(oe=>typeof oe=="string"&&oe.length>0).join(" · ")||null,A=P&&e.model?r.get(e.model)??null:null,F=P?A??e.model??e.tool??null:null,E=P?us(e.inputs?.generationMode):null,z=E&&/^[a-z]2[a-z]$/i.test(E)?E.toUpperCase():null,_=F?(()=>{const oe=ko(F);return z&&!oe.toUpperCase().includes(z)?`${oe} · ${z}`:oe})():null,L=P?So(e.inputs?.generationSettings):null,B=pi(e.model??"",e.inputs??{})??(L?us(L.aspect_ratio):null),H=L?us(L.duration)??us(L.duration_seconds)??(typeof L.duration=="number"?String(L.duration):null):null,q=ji(e.kind),U=P&&H!==null&&B!==null,K=U?w1(e.kind):q,ee=us(e.prompt)||us(e.inputs?.resolvedPrompt),ne=S?ee??e.asset?.prompt??null:null,V=S&&e.model?r.get(e.model)??null:null,re=M||P&&!!e.prompt,W=Vt(e.slot),Z=e.frameProvenance&&[e.frameProvenance.sourceAddress,e.frameProvenance.atSeconds===null?null:Bt(e.frameProvenance.atSeconds)].filter(Boolean).join(" · ")||null,ie={audioInfo:e.asset?.audioInfo??null,durationSeconds:e.asset?.duration??null,hasOutput:!!e.outputArtifactId,inputs:e.inputs},J=k&&v,G=w&&!!(m||b),ce=J?wo(ie):[],ae=J?No(ie):null,X=G?S?Co({width:e.asset?.width??null,height:e.asset?.height??null,tool:V,model:e.model??e.tool??null,provenance:Z}):$o({aspectRatio:e.videoAspectRatio??null,width:e.asset?.width??null,height:e.asset?.height??null,tool:e.model?r.get(e.model)??null:null,model:e.model??e.tool??null,provenance:Z}):[],le=G&&j?Io(e.videoDurationSeconds??e.asset?.duration??null):null,de=Ro(e.status),pe=e.status==="error",ue=Mo(e.inputs,e.outputArtifactId),me=(e.kind==="audio"||e.kind==="analysis"||e.kind==="extract_audio"||(e.kind==="image"||e.kind==="video")&&!Sl({type:e.kind,inputs:e.inputs}))&&ue.length>1,fe=Math.max(1,ue.indexOf(e.outputArtifactId??"")+1),xe=Vm(l),he=(oe,Q,te)=>{c.open(l,{x:oe,y:Q},te)};return t.jsxs("article",{className:["cell-node",`cell-kind-${e.kind}`,`cell-family-${Eo(e.kind)}`,s?"cell-node-selected":"",f?"cell-node-primary":"",de?"cell-node-running":"",e.status==="queued"?"cell-node-queued":"",pe?"cell-node-error":"",me?"cell-node-version-stack":"",e.deleting?"cell-node-deleting":"",e.revealing?"cell-node-created":"",e.highlighted?"cell-node-highlight":""].filter(Boolean).join(" "),"aria-busy":de,"data-lane-family":To(e.kind),"data-selection":f?"primary":s?"selected":void 0,"data-highlight":e.highlighted?"generated":void 0,"data-version-count":ue.length,"data-cell-status":e.status,"data-context-menu-open":c.openCellId===l?"true":void 0,onContextMenu:oe=>{oe.preventDefault(),oe.stopPropagation(),he(oe.clientX,oe.clientY,document.activeElement instanceof HTMLElement?document.activeElement:null)},onKeyDown:oe=>{if(oe.key!=="ContextMenu"&&!(oe.shiftKey&&oe.key==="F10"))return;oe.preventDefault(),oe.stopPropagation();const Q=oe.currentTarget.getBoundingClientRect();he(Q.left+Math.min(Q.width-12,40),Q.top+40,document.activeElement instanceof HTMLElement?document.activeElement:null)},children:[p.map((oe,Q)=>t.jsx(jn,{type:"target",position:Ss.Top,id:oe,className:`cell-target-handle${N?" cell-target-handle-top-row":""}`,style:{left:`${(Q+1)/(p.length+1)*100}%`}},oe)),p.map((oe,Q)=>{const te=h[oe]??0;return te<2?null:t.jsx("span",{className:"cell-target-connection-count","aria-label":`${te} connections into ${oe}`,"data-connection-count":te,style:{left:`${(Q+1)/(p.length+1)*100}%`},children:te},`${oe}-count`)}),R1.map(oe=>t.jsx(jn,{type:"source",position:oe.position,id:oe.id,isConnectable:!1,className:`cell-route-handle${e.sourcePorts?.includes(oe.id)?" cell-route-handle-active":""}`,style:oe.style},oe.id)),t.jsxs("section",{className:"cell-node-shell",children:[t.jsxs("header",{className:"cell-node-header",children:[t.jsxs("span",{className:"cell-node-type","aria-label":q,title:U?q:void 0,children:[t.jsx(Yl,{kind:e.kind}),t.jsx("span",{className:"cell-node-type-label","aria-hidden":"true",children:K})]}),e.post&&t.jsx("span",{className:"cell-generation-chips",children:t.jsx("span",{className:"cell-aspect-ratio",title:"Platform",children:Po(e.post)})}),(P||d)&&t.jsxs("span",{className:"cell-generation-chips",children:[H&&t.jsxs("span",{className:"cell-aspect-ratio",title:"Duration",children:[H,/^\d+(\.\d+)?$/.test(H)?"s":""]}),B&&t.jsx("span",{className:"cell-aspect-ratio",title:"Aspect ratio",children:B}),d&&t.jsxs("span",{className:"cell-aspect-ratio cell-goal-mark",title:`Goal ${d}`,children:[t.jsx(Pn,{size:9,"aria-hidden":"true"}),d.split(" · ")[0]]})]}),R&&!P&&t.jsx("button",{type:"button",className:"cell-run-button nodrag",disabled:R.disabled,onClick:oe=>{oe.stopPropagation(),i(l)},children:R.label}),!R&&me&&t.jsxs("span",{className:"cell-version-count","aria-label":`Current output version ${fe} of ${ue.length}`,title:`Current output · version ${fe} of ${ue.length}`,children:[t.jsx(ks,{size:12,"aria-hidden":"true"}),"v",fe,"/",ue.length]})]}),t.jsxs("div",{className:"cell-node-body",children:[e.kind==="post"?t.jsx(Tm,{post:e.post,source:e.postSource}):x&&y?t.jsx($1,{cellId:l,kind:y,ready:n.ready,state:n.states[l],onFile:n.onFile,onFileError:n.onFileError,onOpenLibrary:n.onOpenLibrary}):e.kind==="split_video"?t.jsx(C1,{data:e}):e.kind==="analysis"?t.jsx(Xm,{analysisInfo:e.asset?.analysisInfo??null,fallbackShotCount:wl(e.inputs?.shotCount),fallbackSourceDurationSeconds:wl(e.inputs?.sourceDurationSeconds)}):J?t.jsx(Wl,{address:W,posterUrl:null,waveform:e.asset?.waveform??[],mediaUrl:m??null,playbackKind:m?"audio":null,alt:e.label??W,badges:ce,meter:ae,metadataLabel:Nl(q,ce,ae,null),pendingLabel:"Waveform pending",pendingIcon:t.jsx(ts,{size:26,"aria-hidden":"true"})}):G?t.jsx(Wl,{address:W,posterUrl:b??(j?null:m??null),waveform:null,mediaUrl:m??null,playbackKind:j&&m?"video":null,alt:e.label??W,title:ne??void 0,badges:X,meter:le,metadataLabel:Nl(q,X,le,ne),pendingLabel:"Poster pending",pendingIcon:t.jsx(Ct,{size:26,"aria-hidden":"true"}),children:t.jsx(zd,{inputs:e.inputs})}):t.jsxs("div",{className:`cell-copy ${re?"cell-copy-text":""}`,children:[_&&t.jsx("span",{className:"cell-model-line",title:_,children:_}),re?t.jsx("p",{title:e.prompt||void 0,children:e.prompt||Jl(e)}):t.jsx(Mi,{size:28}),!re&&t.jsx("span",{children:_?"Add a prompt":Jl(e)})]}),t.jsx(m1,{kind:e.kind,address:ti(e.slot),status:e.status,statusStartedAt:e.statusStartedAt,statusError:e.statusError,icon:t.jsx(Yl,{kind:e.kind}),generator:D,generation:T,onRepair:T?()=>{a.repairCell(l)}:void 0,onRetry:e.inputs?.producerCellId?()=>{a.retryCell(l)}:void 0,disabled:!a.ready,onDelete:()=>{a.deleteCell(l)}})]}),t.jsxs("footer",{className:"cell-node-footer",children:[t.jsx("strong",{children:Vt(e.slot)}),t.jsxs("span",{className:"cell-node-footer-actions",children:[t.jsx(M1,{status:I}),t.jsx("button",{type:"button",className:"cell-context-menu-trigger nodrag","aria-label":`Open ${Vt(e.slot)} cell menu`,"aria-haspopup":"menu","aria-expanded":c.openCellId===l,"aria-controls":xe,title:"Cell actions",onClick:oe=>{oe.preventDefault(),oe.stopPropagation();const Q=oe.currentTarget.getBoundingClientRect();he(Q.right-4,Q.bottom+4,oe.currentTarget)},children:t.jsx(qn,{size:16,"aria-hidden":"true"})})]})]})]}),t.jsx(jn,{type:"source",position:Ss.Bottom,id:"output",className:"cell-connect-handle"})]})}function Sf(l){const e=Y.c(13),{id:s,data:n}=l,i=C.useContext(qm);if(!i)return null;let a;e[0]!==n.slot?(a=Vt(n.slot),e[0]=n.slot,e[1]=a):a=e[1];let o,r,c;e[2]!==i||e[3]!==s?(o=u=>i.onSeek(s,u),r=()=>i.onPreview(s),c=()=>i.onRemove(s),e[2]=i,e[3]=s,e[4]=o,e[5]=r,e[6]=c):(o=e[4],r=e[5],c=e[6]);let d;return e[7]!==i||e[8]!==a||e[9]!==o||e[10]!==r||e[11]!==c?(d=t.jsx(x1,{...i,address:a,onSeek:o,onPreview:r,onRemove:c}),e[7]=i,e[8]=a,e[9]=o,e[10]=r,e[11]=c,e[12]=d):d=e[12],d}function wf(l){const e=Y.c(262),{rhythm:s,sequence:n,assets:i,frame:a,correctionsOpen:o,onCorrectionsOpenChange:r}=l;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const d=C.useRef(c),[u,f]=C.useState(""),[m,b]=C.useState(""),[p,g]=C.useState(""),h=s.master,y=s.status==="queued"||s.status==="analyzing",x=n.frameRate.numerator/n.frameRate.denominator;let j;e[1]!==n.tracks?(j=new Set(n.tracks.filter(A1).map(E1)),e[1]=n.tracks,e[2]=j):j=e[2];const v=j;let k,w,S,M,N,$,R,I,P,T,D,A,F,E,z,_,L,B,H,q,U;if(e[3]!==i||e[4]!==v||e[5]!==x||e[6]!==a||e[7]!==h||e[8]!==m||e[9]!==s||e[10]!==n.clips||e[11]!==n.tracks||e[12]!==u){let Le;e[34]!==v?(Le=Ee=>v.has(Ee.trackId),e[34]=v,e[35]=Le):Le=e[35];const Dt=n.clips.filter(Le);let yt;if(e[36]!==a||e[37]!==s.mapped){let Ee;e[39]!==a?(Ee=(Ie,Ae)=>!Ie||Math.abs(Ae.frame-a)<Math.abs(Ie.frame-a)?Ae:Ie,e[39]=a,e[40]=Ee):Ee=e[40],yt=s.mapped.reduce(Ee,null),e[36]=a,e[37]=s.mapped,e[38]=yt}else yt=e[38];I=yt,M=s.rhythm.settings.correction?.bpm??s.analysis?.bpm,S=s.rhythm.settings.correction?.beatsPerBar??s.analysis?.beatsPerBar??null;let jt;e[41]!==s.mapped?(jt=s.mapped.filter(T1),e[41]=s.mapped,e[42]=jt):jt=e[42],w=jt.length,$=s.analysis?.barSource==="estimated"&&!s.rhythm.settings.correction;let Ft;e[43]!==h||e[44]!==n.tracks?(Ft=h&&!n.tracks.find(Ee=>Ee.trackId===h.trackId)?.locked,e[43]=h,e[44]=n.tracks,e[45]=Ft):Ft=e[45],N=Ft;let Ut;e[46]!==S||e[47]!==M||e[48]!==h||e[49]!==s?(Ut=function(Ie,Ae,Qe){const Te=Ae===void 0?M??null:Ae,Ne=Qe===void 0?S:Qe;h&&(g(""),s.save({masterClipId:h.clipId,correction:{objectHash:h.source.range.objectHash,analysisId:s.analysis?.analysisId??null,markers:Ie,bpm:Te,beatsPerBar:Ne}}))},e[46]=S,e[47]=M,e[48]=h,e[49]=s,e[50]=Ut):Ut=e[50],T=Ut;let vt;e[51]===Symbol.for("react.memo_cache_sentinel")?(vt=function(){const Ie=performance.now(),Ae=d.current[d.current.length-1];if(d.current=Ae===void 0||Ie-Ae>3e3?[Ie]:[...d.current.slice(-7),Ie],d.current.length>1){const Qe=d.current.slice(1).map((Te,Ne)=>Te-d.current[Ne]).sort(P1);f(Math.min(400,Math.max(20,6e4/Qe[Math.floor(Qe.length/2)])).toFixed(1))}g(`${d.current.length} taps. Use Set grid from playhead when ready.`)},e[51]=vt):vt=e[51],U=vt;let pt;e[52]!==M||e[53]!==x||e[54]!==a||e[55]!==h||e[56]!==m||e[57]!==T||e[58]!==u?(pt=function(){if(!h)return;const Ie=Number(u||M),Ae=m?Number(m):null;if(!(Ie>=20&&Ie<=400)||Ae!==null&&(!Number.isInteger(Ae)||Ae<1||Ae>16)){g("Enter 20–400 BPM and, optionally, 1–16 beats per bar.");return}const Qe=h.source.range,Te=Qe.timeBase.numerator/Qe.timeBase.denominator,Ne=(Qe.startTick+Qe.durationTicks)*Te;if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead inside the soundtrack.");return}const Nt=Math.min(Ne-Te,Cl(h,a,x)),Lt=h.reverse?Math.floor((Nt-Qe.startTick*Te)/(60/Ie))+1:Math.ceil((Ne-Nt)/(60/Ie)),ot=Array.from({length:Math.max(0,Lt)},(Rs,ge)=>({id:`grid-${ge}`,timeSeconds:Nt+(h.reverse?-1:1)*ge*60/Ie,bar:Ae!==null&&ge%Ae===0,manual:!0}));T(ot,Ie,Ae)},e[52]=M,e[53]=x,e[54]=a,e[55]=h,e[56]=m,e[57]=T,e[58]=u,e[59]=pt):pt=e[59],R=pt;let _t;e[60]!==x||e[61]!==a||e[62]!==h||e[63]!==s.markers||e[64]!==T?(_t=function(){if(!h)return;const Ie=h.source.range,Ae=(Ie.startTick+Ie.durationTicks-1)*Ie.timeBase.numerator/Ie.timeBase.denominator,Qe=Math.min(Ae,Cl(h,a,x));if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead inside the soundtrack.");return}s.markers.some(Te=>Math.abs(Te.timeSeconds-Qe)<.5/x)||T([...s.markers,{id:crypto.randomUUID(),timeSeconds:Qe,bar:!1,manual:!0}])},e[60]=x,e[61]=a,e[62]=h,e[63]=s.markers,e[64]=T,e[65]=_t):_t=e[65],k=_t;let ht;e[66]!==S||e[67]!==M||e[68]!==a||e[69]!==h||e[70]!==m||e[71]!==I||e[72]!==s.markers||e[73]!==T?(ht=function(){if(!h||!I)return;const Ie=m?Number(m):S;if(Ie===null||!Number.isInteger(Ie)||Ie<1||Ie>16){g("Enter 1–16 beats per bar.");return}if(a<h.timelineStartFrame||a>=h.timelineStartFrame+h.durationFrames){g("Place the playhead at the first beat of a bar inside the soundtrack.");return}T(Do(s.markers,I.id,Ie,M??null),M??null,Ie)},e[66]=S,e[67]=M,e[68]=a,e[69]=h,e[70]=m,e[71]=I,e[72]=s.markers,e[73]=T,e[74]=ht):ht=e[74],D=ht;let Mt;e[75]!==x||e[76]!==h||e[77]!==I||e[78]!==s.markers||e[79]!==T?(Mt=function(Ie){if(!h||!I)return;const Ae=I.timeSeconds+Ie/x*h.speed.numerator/h.speed.denominator*(h.reverse?-1:1);Ae<0||T(s.markers.map(Qe=>Qe.id===I.id?{...Qe,timeSeconds:Ae,manual:!0}:Qe))},e[75]=x,e[76]=h,e[77]=I,e[78]=s.markers,e[79]=T,e[80]=Mt):Mt=e[80],P=Mt,F="music-rhythm-controls",A="music-rhythm-row",q="Soundtrack",E="Master soundtrack",z=h?.clipId??"",_=s.busy,e[81]!==s?(L=Ee=>{s.save({masterClipId:Ee.target.value||null,correction:null})},e[81]=s,e[82]=L):L=e[82];const bt=Dt.length?"Choose audio clip":"Add audio to the timeline";e[83]!==bt?(B=t.jsx("option",{value:"",children:bt}),e[83]=bt,e[84]=B):B=e[84];let xt;e[85]!==i||e[86]!==x?(xt=Ee=>t.jsxs("option",{value:Ee.clipId,children:[i.find(Ie=>Ie.artifactId===Ee.source.artifactId)?.label??"Audio"," · ",(Ee.timelineStartFrame/x).toFixed(1),"s"]},Ee.clipId),e[85]=i,e[86]=x,e[87]=xt):xt=e[87],H=Dt.map(xt),e[3]=i,e[4]=v,e[5]=x,e[6]=a,e[7]=h,e[8]=m,e[9]=s,e[10]=n.clips,e[11]=n.tracks,e[12]=u,e[13]=k,e[14]=w,e[15]=S,e[16]=M,e[17]=N,e[18]=$,e[19]=R,e[20]=I,e[21]=P,e[22]=T,e[23]=D,e[24]=A,e[25]=F,e[26]=E,e[27]=z,e[28]=_,e[29]=L,e[30]=B,e[31]=H,e[32]=q,e[33]=U}else k=e[13],w=e[14],S=e[15],M=e[16],N=e[17],$=e[18],R=e[19],I=e[20],P=e[21],T=e[22],D=e[23],A=e[24],F=e[25],E=e[26],z=e[27],_=e[28],L=e[29],B=e[30],H=e[31],q=e[32],U=e[33];let K;e[88]!==E||e[89]!==z||e[90]!==_||e[91]!==L||e[92]!==B||e[93]!==H?(K=t.jsxs("select",{"aria-label":E,value:z,disabled:_,onChange:L,children:[B,H]}),e[88]=E,e[89]=z,e[90]=_,e[91]=L,e[92]=B,e[93]=H,e[94]=K):K=e[94];let ee;e[95]!==K||e[96]!==q?(ee=t.jsxs("label",{children:[q,K]}),e[95]=K,e[96]=q,e[97]=ee):ee=e[97];const ne=!h||s.busy||y;let V;e[98]!==s?(V=()=>{s.analyze(!!s.analysis)},e[98]=s,e[99]=V):V=e[99];const re=s.analysis?"Analyze again":"Analyze beats";let W;e[100]!==ne||e[101]!==V||e[102]!==re?(W=t.jsx("button",{type:"button",disabled:ne,onClick:V,children:re}),e[100]=ne,e[101]=V,e[102]=re,e[103]=W):W=e[103];let Z;e[104]!==y||e[105]!==s?(Z=y&&t.jsx("button",{type:"button",disabled:s.busy,onClick:()=>{s.cancel()},children:"Cancel analysis"}),e[104]=y,e[105]=s,e[106]=Z):Z=e[106];let ie;e[107]!==M||e[108]!==y||e[109]!==s.mapped.length||e[110]!==s.status?(ie=y?"Analyzing soundtrack…":s.status==="no-beats"?"Analysis complete. No reliable beats found. Set a grid below.":M?`${M.toFixed(1)} BPM · ${s.mapped.length} beats`:"Analyze the song or set a beat grid.",e[107]=M,e[108]=y,e[109]=s.mapped.length,e[110]=s.status,e[111]=ie):ie=e[111];let J;e[112]!==ie?(J=t.jsx("span",{role:"status",children:ie}),e[112]=ie,e[113]=J):J=e[113];let G;e[114]!==s?(G=()=>{s.load()},e[114]=s,e[115]=G):G=e[115];let ce;e[116]!==s.busy||e[117]!==G?(ce=t.jsx("button",{type:"button",disabled:s.busy,onClick:G,children:"Reload beats"}),e[116]=s.busy,e[117]=G,e[118]=ce):ce=e[118];let ae;e[119]!==A||e[120]!==ee||e[121]!==W||e[122]!==Z||e[123]!==J||e[124]!==ce?(ae=t.jsxs("div",{className:A,children:[ee,W,Z,J,ce]}),e[119]=A,e[120]=ee,e[121]=W,e[122]=Z,e[123]=J,e[124]=ce,e[125]=ae):ae=e[125];let X;e[126]!==h||e[127]!==n.tracks?(X=h&&(!h.enabled||h.audio?.muted||h.audioPolicy==="mute"||n.tracks.some(Le=>Le.trackId===h.trackId&&(!Le.enabled||Le.kind==="audio"&&Le.muted)))&&t.jsx("p",{children:"Soundtrack is muted or disabled. Its beat map is a timing guide."}),e[126]=h,e[127]=n.tracks,e[128]=X):X=e[128];let le;e[129]!==h?.reverse?(le=h?.reverse&&t.jsx("p",{children:"Reversed audio is heard in the export. Render the reversed soundtrack to audition it in this preview."}),e[129]=h?.reverse,e[130]=le):le=e[130];let de;e[131]!==s.analysis?.lowConfidence||e[132]!==s.mapped.length||e[133]!==s.rhythm.settings.correction?(de=s.analysis?.lowConfidence&&s.mapped.length>0&&!s.rhythm.settings.correction&&t.jsx("p",{children:"Beat timing is uncertain. Listen and adjust the markers."}),e[131]=s.analysis?.lowConfidence,e[132]=s.mapped.length,e[133]=s.rhythm.settings.correction,e[134]=de):de=e[134];let pe;e[135]!==s.rhythm.settings.correction?(pe=s.rhythm.settings.correction&&t.jsx("p",{children:"Using your corrected beat map. Reanalysis preserves this map."}),e[135]=s.rhythm.settings.correction,e[136]=pe):pe=e[136];const ue=w?`${w} ${$?"estimated bar starts":"bar starts"} · ${S??"Unknown"} beats per bar`:"Set bar starts";let me;e[137]!==ue?(me=t.jsx("strong",{children:ue}),e[137]=ue,e[138]=me):me=e[138];let fe;e[139]!==$?(fe=$&&t.jsx("p",{children:"Bars start at the first detected beat. Adjust them below if needed."}),e[139]=$,e[140]=fe):fe=e[140];let xe;e[141]===Symbol.for("react.memo_cache_sentinel")?(xe=t.jsx("p",{children:"Place the playhead on the first beat of a bar, then enter the number of beats per bar."}),e[141]=xe):xe=e[141];let he;e[142]!==S?(he=S?.toString()??"e.g. 4",e[142]=S,e[143]=he):he=e[143];let oe;e[144]===Symbol.for("react.memo_cache_sentinel")?(oe=Le=>b(Le.target.value),e[144]=oe):oe=e[144];let Q;e[145]!==m||e[146]!==he?(Q=t.jsxs("label",{children:["Beats per bar",t.jsx("input",{name:"beats-per-bar",type:"number",min:"1",max:"16",value:m,placeholder:he,onChange:oe})]}),e[145]=m,e[146]=he,e[147]=Q):Q=e[147];const te=!N||!I||s.busy;let be;e[148]!==D||e[149]!==te?(be=t.jsx("button",{type:"button",disabled:te,onClick:D,children:"Set bars from playhead"}),e[148]=D,e[149]=te,e[150]=be):be=e[150];let ve;e[151]!==Q||e[152]!==be?(ve=t.jsxs("div",{className:"music-rhythm-row",children:[Q,be]}),e[151]=Q,e[152]=be,e[153]=ve):ve=e[153];let Ce;e[154]!==x||e[155]!==I?(Ce=I&&t.jsxs("small",{children:["Use the beat at ",(I.frame/x).toFixed(3),"s as a bar start."]}),e[154]=x,e[155]=I,e[156]=Ce):Ce=e[156];let Se;e[157]!==me||e[158]!==fe||e[159]!==ve||e[160]!==Ce?(Se=t.jsxs("section",{className:"music-bar-setup","aria-label":"Bar setup",children:[me,fe,xe,ve,Ce]}),e[157]=me,e[158]=fe,e[159]=ve,e[160]=Ce,e[161]=Se):Se=e[161];let $e;e[162]!==r?($e=Le=>r(Le.currentTarget.open),e[162]=r,e[163]=$e):$e=e[163];let Be;e[164]===Symbol.for("react.memo_cache_sentinel")?(Be=t.jsx("summary",{children:"Correct the beat grid"}),e[164]=Be):Be=e[164];let _e;e[165]!==M?(_e=M?.toFixed(1)??"120",e[165]=M,e[166]=_e):_e=e[166];let nt;e[167]===Symbol.for("react.memo_cache_sentinel")?(nt=Le=>f(Le.target.value),e[167]=nt):nt=e[167];let Ke;e[168]!==_e||e[169]!==u?(Ke=t.jsxs("label",{children:["BPM",t.jsx("input",{type:"number",min:"20",max:"400",value:u,placeholder:_e,onChange:nt})]}),e[168]=_e,e[169]=u,e[170]=Ke):Ke=e[170];const Xe=!N||s.busy;let qe;e[171]!==Xe||e[172]!==U?(qe=t.jsx("button",{type:"button",disabled:Xe,onClick:U,children:"Tap tempo"}),e[171]=Xe,e[172]=U,e[173]=qe):qe=e[173];const Fe=!N||s.busy;let Ve;e[174]!==R||e[175]!==Fe?(Ve=t.jsx("button",{type:"button",disabled:Fe,onClick:R,children:"Set grid from playhead"}),e[174]=R,e[175]=Fe,e[176]=Ve):Ve=e[176];const Ze=!N||s.busy;let Ge;e[177]!==k||e[178]!==Ze?(Ge=t.jsx("button",{type:"button",disabled:Ze,onClick:k,children:"Add beat at playhead"}),e[177]=k,e[178]=Ze,e[179]=Ge):Ge=e[179];const et=!N||!I||s.busy;let tt;e[180]!==I?.id||e[181]!==s.markers||e[182]!==T?(tt=()=>T(s.markers.filter(Le=>Le.id!==I?.id)),e[180]=I?.id,e[181]=s.markers,e[182]=T,e[183]=tt):tt=e[183];let Re;e[184]!==et||e[185]!==tt?(Re=t.jsx("button",{type:"button",disabled:et,onClick:tt,children:"Remove nearest beat"}),e[184]=et,e[185]=tt,e[186]=Re):Re=e[186];const Pe=!N||!I||s.busy;let Je;e[187]!==P?(Je=()=>P(-1),e[187]=P,e[188]=Je):Je=e[188];let De;e[189]!==Pe||e[190]!==Je?(De=t.jsx("button",{type:"button",disabled:Pe,onClick:Je,children:"Beat −1 frame"}),e[189]=Pe,e[190]=Je,e[191]=De):De=e[191];const ke=!N||!I||s.busy;let Oe;e[192]!==P?(Oe=()=>P(1),e[192]=P,e[193]=Oe):Oe=e[193];let at;e[194]!==ke||e[195]!==Oe?(at=t.jsx("button",{type:"button",disabled:ke,onClick:Oe,children:"Beat +1 frame"}),e[194]=ke,e[195]=Oe,e[196]=at):at=e[196];const Et=!N||!I||s.busy;let At;e[197]!==I?.id||e[198]!==s.markers||e[199]!==T?(At=()=>T(s.markers.map(Le=>Le.id===I?.id?{...Le,bar:!Le.bar,manual:!0}:Le)),e[197]=I?.id,e[198]=s.markers,e[199]=T,e[200]=At):At=e[200];let $t;e[201]!==Et||e[202]!==At?($t=t.jsx("button",{type:"button",disabled:Et,onClick:At,children:"Toggle bar start"}),e[201]=Et,e[202]=At,e[203]=$t):$t=e[203];let lt;e[204]!==Ke||e[205]!==qe||e[206]!==Ve||e[207]!==Ge||e[208]!==Re||e[209]!==De||e[210]!==at||e[211]!==$t?(lt=t.jsxs("div",{className:"music-rhythm-row",children:[Ke,qe,Ve,Ge,Re,De,at,$t]}),e[204]=Ke,e[205]=qe,e[206]=Ve,e[207]=Ge,e[208]=Re,e[209]=De,e[210]=at,e[211]=$t,e[212]=lt):lt=e[212];let se;e[213]!==x||e[214]!==I?(se=I&&t.jsxs("span",{children:["Nearest beat · ",(I.frame/x).toFixed(3),"s",I.manual?" · adjusted":""]}),e[213]=x,e[214]=I,e[215]=se):se=e[215];let ye;e[216]!==N||e[217]!==s.analysis?.beats.length||e[218]!==s.busy||e[219]!==s.markers||e[220]!==s.rhythm.settings.correction||e[221]!==T?(ye=s.analysis?.beats.length&&!s.rhythm.settings.correction?t.jsx("button",{type:"button",disabled:!N||s.busy,onClick:()=>T(s.markers),children:"Confirm detected beats"}):null,e[216]=N,e[217]=s.analysis?.beats.length,e[218]=s.busy,e[219]=s.markers,e[220]=s.rhythm.settings.correction,e[221]=T,e[222]=ye):ye=e[222];const Me=!s.rhythm.canUndo||s.busy;let Ye;e[223]!==s?(Ye=()=>{s.save("undo")},e[223]=s,e[224]=Ye):Ye=e[224];let it;e[225]!==Me||e[226]!==Ye?(it=t.jsx("button",{type:"button",disabled:Me,onClick:Ye,children:"Undo beat change"}),e[225]=Me,e[226]=Ye,e[227]=it):it=e[227];const Ot=!s.rhythm.canRedo||s.busy;let ut;e[228]!==s?(ut=()=>{s.save("redo")},e[228]=s,e[229]=ut):ut=e[229];let kt;e[230]!==Ot||e[231]!==ut?(kt=t.jsx("button",{type:"button",disabled:Ot,onClick:ut,children:"Redo beat change"}),e[230]=Ot,e[231]=ut,e[232]=kt):kt=e[232];const St=!s.rhythm.settings.correction||s.busy;let mt;e[233]!==s?(mt=()=>{s.save({...s.rhythm.settings,correction:null})},e[233]=s,e[234]=mt):mt=e[234];let ft;e[235]!==St||e[236]!==mt?(ft=t.jsx("button",{type:"button",disabled:St,onClick:mt,children:"Use detected beats"}),e[235]=St,e[236]=mt,e[237]=ft):ft=e[237];let rt;e[238]!==se||e[239]!==ye||e[240]!==it||e[241]!==kt||e[242]!==ft?(rt=t.jsxs("div",{className:"music-rhythm-row",children:[se,ye,it,kt,ft]}),e[238]=se,e[239]=ye,e[240]=it,e[241]=kt,e[242]=ft,e[243]=rt):rt=e[243];let wt;e[244]!==o||e[245]!==$e||e[246]!==lt||e[247]!==rt?(wt=t.jsxs("details",{className:"music-rhythm-fixes",open:o,onToggle:$e,children:[Be,lt,rt]}),e[244]=o,e[245]=$e,e[246]=lt,e[247]=rt,e[248]=wt):wt=e[248];let It;e[249]!==p||e[250]!==s.error?(It=(p||s.error)&&t.jsx("p",{role:"alert",children:p||s.error}),e[249]=p,e[250]=s.error,e[251]=It):It=e[251];let Rt;return e[252]!==F||e[253]!==ae||e[254]!==X||e[255]!==le||e[256]!==de||e[257]!==pe||e[258]!==Se||e[259]!==wt||e[260]!==It?(Rt=t.jsxs("div",{className:F,children:[ae,X,le,de,pe,Se,wt,It]}),e[252]=F,e[253]=ae,e[254]=X,e[255]=le,e[256]=de,e[257]=pe,e[258]=Se,e[259]=wt,e[260]=It,e[261]=Rt):Rt=e[261],Rt}function P1(l,e){return l-e}function T1(l){return l.bar}function E1(l){return l.trackId}function A1(l){return l.kind==="audio"}function Nf(l){const e=Y.c(90),{sources:s,trackId:n,startFrame:i,endFrame:a,fps:o,hasBars:r,busy:c,draft:d,onPlan:u,onOrder:f}=l,[m,b]=C.useState(""),[p,g]=C.useState(""),[h,y]=C.useState(4),[x,j]=C.useState("beats"),[v,k]=C.useState("0.25"),[w,S]=C.useState(!0),[M,N]=C.useState(!1),[$,R]=C.useState(!1);let I;e[0]!==f||e[1]!==s?(I=function(be,ve){const Ce=s.map(L1),Se=be+ve;if(Se<0||Se>=Ce.length)return;const[$e,Be]=[Ce[Se],Ce[be]];Ce[be]=$e,Ce[Se]=Be,f(Ce)},e[0]=f,e[1]=s,e[2]=I):I=e[2];const P=I;let T;e[3]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("p",{children:"Cut the selected footage to the music. You review the draft before anything changes."}),e[3]=T):T=e[3];let D;e[4]!==p||e[5]!==a||e[6]!==o||e[7]!==h||e[8]!==v||e[9]!==u||e[10]!==w||e[11]!==$||e[12]!==M||e[13]!==s||e[14]!==m||e[15]!==i||e[16]!==n||e[17]!==x?(D=te=>{te.preventDefault(),n&&u({track_id:n,start_frame:Math.round(Number(m||i/o)*o),end_frame:Math.round(Number(p||a/o)*o),sources:s.map(_1),interval:h,unit:x,minimum_shot_frames:Math.max(1,Math.round(Number(v)*o)),preserve_existing:w,preserve_clip_ids:[],reuse_sources:M,allow_retiming:$,strategy:"beat_interval"})},e[4]=p,e[5]=a,e[6]=o,e[7]=h,e[8]=v,e[9]=u,e[10]=w,e[11]=$,e[12]=M,e[13]=s,e[14]=m,e[15]=i,e[16]=n,e[17]=x,e[18]=D):D=e[18];const A=i/o;let F;e[19]!==A?(F=A.toFixed(2),e[19]=A,e[20]=F):F=e[20];let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=te=>b(te.target.value),e[21]=E):E=e[21];let z;e[22]!==m||e[23]!==F?(z=t.jsxs("label",{children:["From (s)",t.jsx("input",{"aria-label":"Draft start seconds",type:"number",min:"0",step:"any",placeholder:F,value:m,onChange:E})]}),e[22]=m,e[23]=F,e[24]=z):z=e[24];const _=a/o;let L;e[25]!==_?(L=_.toFixed(2),e[25]=_,e[26]=L):L=e[26];let B;e[27]===Symbol.for("react.memo_cache_sentinel")?(B=te=>g(te.target.value),e[27]=B):B=e[27];let H;e[28]!==p||e[29]!==L?(H=t.jsxs("label",{children:["To (s)",t.jsx("input",{"aria-label":"Draft end seconds",type:"number",min:"0",step:"any",placeholder:L,value:p,onChange:B})]}),e[28]=p,e[29]=L,e[30]=H):H=e[30];let q,U;e[31]===Symbol.for("react.memo_cache_sentinel")?(q=te=>y(Number(te.target.value)),U=[1,2,4,8].map(F1),e[31]=q,e[32]=U):(q=e[31],U=e[32]);let K;e[33]!==h?(K=t.jsxs("label",{children:["Cut every",t.jsx("select",{"aria-label":"Draft cut interval",value:h,onChange:q,children:U})]}),e[33]=h,e[34]=K):K=e[34];let ee,ne;e[35]===Symbol.for("react.memo_cache_sentinel")?(ee=te=>j(te.target.value),ne=t.jsx("option",{value:"beats",children:"beats"}),e[35]=ee,e[36]=ne):(ee=e[35],ne=e[36]);const V=!r;let re;e[37]!==V?(re=t.jsx("option",{value:"bars",disabled:V,children:"bars"}),e[37]=V,e[38]=re):re=e[38];let W;e[39]!==re||e[40]!==x?(W=t.jsxs("select",{"aria-label":"Draft interval unit",value:x,onChange:ee,children:[ne,re]}),e[39]=re,e[40]=x,e[41]=W):W=e[41];let Z;e[42]===Symbol.for("react.memo_cache_sentinel")?(Z=te=>k(te.target.value),e[42]=Z):Z=e[42];let ie;e[43]!==v?(ie=t.jsxs("label",{children:["Minimum shot (s)",t.jsx("input",{"aria-label":"Minimum shot seconds",type:"number",min:"0.04",step:"0.01",value:v,onChange:Z})]}),e[43]=v,e[44]=ie):ie=e[44];let J;e[45]===Symbol.for("react.memo_cache_sentinel")?(J=te=>S(te.target.checked),e[45]=J):J=e[45];let G;e[46]!==w?(G=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:w,onChange:J}),"Keep existing clips"]}),e[46]=w,e[47]=G):G=e[47];let ce;e[48]===Symbol.for("react.memo_cache_sentinel")?(ce=te=>N(te.target.checked),e[48]=ce):ce=e[48];let ae;e[49]!==M?(ae=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:M,onChange:ce}),"Allow repeated footage"]}),e[49]=M,e[50]=ae):ae=e[50];let X;e[51]===Symbol.for("react.memo_cache_sentinel")?(X=te=>R(te.target.checked),e[51]=X):X=e[51];let le;e[52]!==$?(le=t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:$,onChange:X}),"Allow speed changes"]}),e[52]=$,e[53]=le):le=e[53];const de=c||!n||s.length===0;let pe;e[54]!==de?(pe=t.jsx("button",{type:"submit",disabled:de,children:"Preview draft"}),e[54]=de,e[55]=pe):pe=e[55];let ue;e[56]!==H||e[57]!==K||e[58]!==W||e[59]!==ie||e[60]!==G||e[61]!==ae||e[62]!==le||e[63]!==pe||e[64]!==z?(ue=t.jsxs("div",{className:"music-rhythm-row",children:[z,H,K,W,ie,G,ae,le,pe]}),e[56]=H,e[57]=K,e[58]=W,e[59]=ie,e[60]=G,e[61]=ae,e[62]=le,e[63]=pe,e[64]=z,e[65]=ue):ue=e[65];let me;if(e[66]!==c||e[67]!==P||e[68]!==s){let te;e[70]!==c||e[71]!==P||e[72]!==s.length?(te=(be,ve)=>t.jsxs("li",{children:[t.jsx("b",{children:ve+1}),t.jsx("span",{children:be.label}),t.jsx("button",{type:"button","aria-label":`Move ${be.label} earlier`,disabled:c||ve===0,onClick:()=>P(ve,-1),children:"↑"}),t.jsx("button",{type:"button","aria-label":`Move ${be.label} later`,disabled:c||ve===s.length-1,onClick:()=>P(ve,1),children:"↓"})]},be.artifactId),e[70]=c,e[71]=P,e[72]=s.length,e[73]=te):te=e[73],me=s.map(te),e[66]=c,e[67]=P,e[68]=s,e[69]=me}else me=e[69];let fe;e[74]!==me?(fe=t.jsx("ol",{className:"music-draft-order","aria-label":"Draft source order",children:me}),e[74]=me,e[75]=fe):fe=e[75];let xe;e[76]!==s.length?(xe=!s.length&&t.jsx("p",{children:"Select footage in Media, in the order you want it to appear."}),e[76]=s.length,e[77]=xe):xe=e[77];let he;e[78]!==D||e[79]!==ue||e[80]!==fe||e[81]!==xe?(he=t.jsxs("form",{onSubmit:D,children:[ue,fe,xe]}),e[78]=D,e[79]=ue,e[80]=fe,e[81]=xe,e[82]=he):he=e[82];let oe;e[83]!==d||e[84]!==o||e[85]!==s?(oe=d&&t.jsxs("div",{className:"music-draft-review","aria-label":"Draft review",children:[t.jsxs("strong",{children:[d.plan.summary," · ",d.preview.diff.removedClipIds.length," clips replaced"]}),d.warnings.map(D1),d.uncovered.map(te=>t.jsxs("p",{children:["Uncovered: ",(te.startFrame/o).toFixed(2),"–",(te.endFrame/o).toFixed(2),"s"]},te.startFrame)),t.jsxs("table",{children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Shot"}),t.jsx("th",{children:"Timeline"}),t.jsx("th",{children:"Source range"}),t.jsx("th",{children:"Speed"})]})}),t.jsx("tbody",{children:d.shots.map((te,be)=>t.jsxs("tr",{children:[t.jsxs("td",{children:[be+1," · ",s.find(ve=>ve.artifactId===te.artifactId)?.label??"Source"]}),t.jsxs("td",{children:[(te.startFrame/o).toFixed(2),"–",(te.endFrame/o).toFixed(2),"s"]}),t.jsxs("td",{children:[te.sourceStartSeconds.toFixed(2),"–",te.sourceEndSeconds.toFixed(2),"s"]}),t.jsxs("td",{children:[te.speed.toFixed(2),"×"]})]},te.clipId))})]})]}),e[83]=d,e[84]=o,e[85]=s,e[86]=oe):oe=e[86];let Q;return e[87]!==he||e[88]!==oe?(Q=t.jsxs("section",{className:"music-draft-controls","aria-label":"Auto-cut to music",children:[T,he,oe]}),e[87]=he,e[88]=oe,e[89]=Q):Q=e[89],Q}function D1(l){return t.jsx("p",{children:l},l)}function F1(l){return t.jsx("option",{value:l,children:l},l)}function _1(l){return{artifact_id:l.artifactId}}function L1(l){return l.artifactId}function Zl(l){const e=Y.c(13),{label:s,options:n,value:i,disabled:a,stretch:o,onChange:r}=l,c=a===void 0?!1:a,u=(o===void 0?!1:o)?"mv-segmented stretch":"mv-segmented";let f;if(e[0]!==c||e[1]!==r||e[2]!==n||e[3]!==i){let b;e[5]!==c||e[6]!==r||e[7]!==i?(b=p=>t.jsx("button",{type:"button","aria-pressed":p.value===i,title:p.title,disabled:c||p.disabled,onClick:()=>{p.value!==i&&r(p.value)},children:p.label},p.value),e[5]=c,e[6]=r,e[7]=i,e[8]=b):b=e[8],f=n.map(b),e[0]=c,e[1]=r,e[2]=n,e[3]=i,e[4]=f}else f=e[4];let m;return e[9]!==s||e[10]!==u||e[11]!==f?(m=t.jsx("div",{className:u,role:"group","aria-label":s,children:f}),e[9]=s,e[10]=u,e[11]=f,e[12]=m):m=e[12],m}function ei(l){const e=Y.c(26),{label:s,frame:n,fps:i,min:a,max:o,disabled:r,onCommit:c}=l;let d;e[0]!==i||e[1]!==n?(d=()=>fs(n,i),e[0]=i,e[1]=n,e[2]=d):d=e[2];const[u,f]=C.useState(d),[m,b]=C.useState(!1);let p;e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==a||e[7]!==c||e[8]!==u?(p=()=>{const w=Fo(u,i);if(w===null){b(!0);return}const S=Math.max(a,Math.min(o,w));b(!1),f(fs(S,i)),S!==n&&c(S)},e[3]=i,e[4]=n,e[5]=o,e[6]=a,e[7]=c,e[8]=u,e[9]=p):p=e[9];const g=p;let h;e[10]!==g||e[11]!==i||e[12]!==n?(h=w=>{w.key==="Enter"&&g(),w.key==="Escape"&&(w.stopPropagation(),f(fs(n,i)),b(!1))},e[10]=g,e[11]=i,e[12]=n,e[13]=h):h=e[13];const y=h;let x;e[14]!==s?(x=t.jsx("span",{children:s}),e[14]=s,e[15]=x):x=e[15];let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=w=>f(w.target.value),e[16]=j):j=e[16];let v;e[17]!==g||e[18]!==r||e[19]!==m||e[20]!==y||e[21]!==u?(v=t.jsx("input",{value:u,disabled:r,"aria-invalid":m,spellCheck:!1,onChange:j,onBlur:g,onKeyDown:y}),e[17]=g,e[18]=r,e[19]=m,e[20]=y,e[21]=u,e[22]=v):v=e[22];let k;return e[23]!==x||e[24]!==v?(k=t.jsxs("label",{className:"mv-field",children:[x,v]}),e[23]=x,e[24]=v,e[25]=k):k=e[25],k}function Cf(l){const e=Y.c(49),{frame:s,durationFrames:n,fps:i,previousBeat:a,nextBeat:o,onTogglePlay:r,onSeek:c}=l;let d;e[0]!==i||e[1]!==s?(d=fs(s,i),e[0]=i,e[1]=s,e[2]=d):d=e[2];let u;e[3]!==d?(u=t.jsx("strong",{children:d}),e[3]=d,e[4]=u):u=e[4];let f;e[5]!==n||e[6]!==i?(f=fs(n,i),e[5]=n,e[6]=i,e[7]=f):f=e[7];let m;e[8]!==u||e[9]!==f?(m=t.jsxs("span",{className:"mv-timecode",children:[u," / ",f]}),e[8]=u,e[9]=f,e[10]=m):m=e[10];let b;e[11]!==c?(b=()=>c(0),e[11]=c,e[12]=b):b=e[12];let p;e[13]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(rc,{size:17}),e[13]=p):p=e[13];let g;e[14]!==b?(g=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Go to start",onClick:b,children:p}),e[14]=b,e[15]=g):g=e[15];const h=a===null;let y;e[16]!==c||e[17]!==a?(y=()=>{a!==null&&c(a)},e[16]=c,e[17]=a,e[18]=y):y=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(Ys,{size:18}),e[19]=x):x=e[19];let j;e[20]!==h||e[21]!==y?(j=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Previous beat",title:"Previous beat",disabled:h,onClick:y,children:x}),e[20]=h,e[21]=y,e[22]=j):j=e[22];let v;e[23]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Is,{size:17}),e[23]=v):v=e[23];let k;e[24]!==r?(k=t.jsx("button",{type:"button",className:"mv-play","aria-label":"Play or pause",title:"Play or pause (Space)",onClick:r,children:v}),e[24]=r,e[25]=k):k=e[25];const w=o===null;let S;e[26]!==o||e[27]!==c?(S=()=>{o!==null&&c(o)},e[26]=o,e[27]=c,e[28]=S):S=e[28];let M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(On,{size:18}),e[29]=M):M=e[29];let N;e[30]!==w||e[31]!==S?(N=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Next beat",title:"Next beat",disabled:w,onClick:S,children:M}),e[30]=w,e[31]=S,e[32]=N):N=e[32];let $;e[33]!==n||e[34]!==c?($=()=>c(n-1),e[33]=n,e[34]=c,e[35]=$):$=e[35];let R;e[36]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(oc,{size:17}),e[36]=R):R=e[36];let I;e[37]!==$?(I=t.jsx("button",{type:"button",className:"mv-icon","aria-label":"Go to end",onClick:$,children:R}),e[37]=$,e[38]=I):I=e[38];let P;e[39]!==j||e[40]!==k||e[41]!==N||e[42]!==I||e[43]!==g?(P=t.jsxs("div",{className:"mv-transport-buttons",children:[g,j,k,N,I]}),e[39]=j,e[40]=k,e[41]=N,e[42]=I,e[43]=g,e[44]=P):P=e[44];let T;e[45]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("span",{className:"mv-transport-spacer"}),e[45]=T):T=e[45];let D;return e[46]!==P||e[47]!==m?(D=t.jsxs("div",{className:"mv-transport",role:"toolbar","aria-label":"Transport",children:[m,P,T]}),e[46]=P,e[47]=m,e[48]=D):D=e[48],D}const z1=[{value:"fit",label:"Fit",title:"Show the full frame"},{value:"fill",label:"Fill",title:"Fill the frame, cropping edges"},{value:"crop",label:"Crop",title:"Use the clip crop"}];function $f(l){const e=Y.c(92),{clip:s,fps:n,trimStart:i,trimEnd:a,busy:o,editsDisabled:r}=l;let c;e[0]!==l.thumbnailUrl?(c=l.thumbnailUrl?t.jsx("img",{src:l.thumbnailUrl,alt:""}):t.jsx("span",{className:"mv-clip-swatch"}),e[0]=l.thumbnailUrl,e[1]=c):c=e[1];let d;e[2]!==l.label?(d=t.jsx("strong",{title:l.label,children:l.label}),e[2]=l.label,e[3]=d):d=e[3];const u=l.index,f=l.count,m=a-i;let b;e[4]!==n||e[5]!==m?(b=fs(m,n),e[4]=n,e[5]=m,e[6]=b):b=e[6];let p;e[7]!==l.count||e[8]!==l.index||e[9]!==b?(p=t.jsxs("small",{children:["Clip ",u," of ",f," · ",b]}),e[7]=l.count,e[8]=l.index,e[9]=b,e[10]=p):p=e[10];let g;e[11]!==d||e[12]!==p?(g=t.jsxs("div",{children:[d,p]}),e[11]=d,e[12]=p,e[13]=g):g=e[13];let h;e[14]!==c||e[15]!==g?(h=t.jsxs("header",{children:[c,g]}),e[14]=c,e[15]=g,e[16]=h):h=e[16];const y=`in-${s.clipId}-${i}`,x=a-1;let j;e[17]!==l||e[18]!==a?(j=G=>l.onTrim("start",G,a),e[17]=l,e[18]=a,e[19]=j):j=e[19];let v;e[20]!==o||e[21]!==n||e[22]!==l.trimMin||e[23]!==x||e[24]!==j||e[25]!==y||e[26]!==i?(v=t.jsx(ei,{label:"In point",frame:i,fps:n,min:l.trimMin,max:x,disabled:o,onCommit:j},y),e[20]=o,e[21]=n,e[22]=l.trimMin,e[23]=x,e[24]=j,e[25]=y,e[26]=i,e[27]=v):v=e[27];const k=`out-${s.clipId}-${a}`,w=i+1;let S;e[28]!==l||e[29]!==i?(S=G=>l.onTrim("end",i,G),e[28]=l,e[29]=i,e[30]=S):S=e[30];let M;e[31]!==o||e[32]!==n||e[33]!==l.trimMax||e[34]!==k||e[35]!==w||e[36]!==S||e[37]!==a?(M=t.jsx(ei,{label:"Out point",frame:a,fps:n,min:w,max:l.trimMax,disabled:o,onCommit:S},k),e[31]=o,e[32]=n,e[33]=l.trimMax,e[34]=k,e[35]=w,e[36]=S,e[37]=a,e[38]=M):M=e[38];let N;e[39]!==v||e[40]!==M?(N=t.jsxs("div",{className:"mv-field-pair",children:[v,M]}),e[39]=v,e[40]=M,e[41]=N):N=e[41];let $;e[42]===Symbol.for("react.memo_cache_sentinel")?($=t.jsx("p",{className:"mv-hint",children:"Or drag the clip edges on the timeline. I and O set them at the playhead."}),e[42]=$):$=e[42];let R;e[43]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("span",{children:"Speed"}),e[43]=R):R=e[43];const I=o||!l.retimable;let P;e[44]!==l.onSpeed||e[45]!==l.speed||e[46]!==l.speedOptions||e[47]!==I?(P=t.jsxs("div",{className:"mv-control",children:[R,t.jsx(Zl,{label:"Clip speed",options:l.speedOptions,value:l.speed,disabled:I,stretch:!0,onChange:l.onSpeed})]}),e[44]=l.onSpeed,e[45]=l.speed,e[46]=l.speedOptions,e[47]=I,e[48]=P):P=e[48];let T;e[49]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("span",{children:"Frame"}),e[49]=T):T=e[49];const D=s.transform?.fit??"fit";let A;e[50]!==r||e[51]!==l.onFit||e[52]!==D?(A=t.jsxs("div",{className:"mv-control",children:[T,t.jsx(Zl,{label:"Clip frame fit",options:z1,value:D,disabled:r,stretch:!0,onChange:l.onFit})]}),e[50]=r,e[51]=l.onFit,e[52]=D,e[53]=A):A=e[53];let F;e[54]!==N||e[55]!==P||e[56]!==A?(F=t.jsxs("div",{className:"mv-clip-body",children:[N,$,P,A]}),e[54]=N,e[55]=P,e[56]=A,e[57]=F):F=e[57];let E;e[58]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Kn,{size:15}),e[58]=E):E=e[58];let z;e[59]!==o||e[60]!==l.onSplit?(z=t.jsxs("button",{type:"button",disabled:o,onClick:l.onSplit,children:[E," Split at playhead"]}),e[59]=o,e[60]=l.onSplit,e[61]=z):z=e[61];const _=r||!l.canStretch;let L;e[62]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsx(Pi,{size:15}),e[62]=L):L=e[62];let B;e[63]!==l.onStretch||e[64]!==_?(B=t.jsxs("button",{type:"button",disabled:_,title:"Extend to the next clip or the end",onClick:l.onStretch,children:[L," Fill to next"]}),e[63]=l.onStretch,e[64]=_,e[65]=B):B=e[65];const H=r||!l.canMoveEarlier;let q;e[66]!==l?(q=()=>l.onMove(-1),e[66]=l,e[67]=q):q=e[67];let U;e[68]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx(Ys,{size:15}),e[68]=U):U=e[68];let K;e[69]!==H||e[70]!==q?(K=t.jsxs("button",{type:"button","aria-label":"Move earlier",disabled:H,onClick:q,children:[U," Earlier"]}),e[69]=H,e[70]=q,e[71]=K):K=e[71];const ee=r||!l.canMoveLater;let ne;e[72]!==l?(ne=()=>l.onMove(1),e[72]=l,e[73]=ne):ne=e[73];let V;e[74]===Symbol.for("react.memo_cache_sentinel")?(V=t.jsx(On,{size:15}),e[74]=V):V=e[74];let re;e[75]!==ee||e[76]!==ne?(re=t.jsxs("button",{type:"button","aria-label":"Move later",disabled:ee,onClick:ne,children:["Later ",V]}),e[75]=ee,e[76]=ne,e[77]=re):re=e[77];let W;e[78]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx(as,{size:15}),e[78]=W):W=e[78];let Z;e[79]!==r||e[80]!==l.onDelete?(Z=t.jsxs("button",{type:"button",className:"danger-button wide",disabled:r,onClick:l.onDelete,children:[W," Delete clip"]}),e[79]=r,e[80]=l.onDelete,e[81]=Z):Z=e[81];let ie;e[82]!==z||e[83]!==B||e[84]!==K||e[85]!==re||e[86]!==Z?(ie=t.jsxs("footer",{className:"mv-clip-actions",children:[z,B,K,re,Z]}),e[82]=z,e[83]=B,e[84]=K,e[85]=re,e[86]=Z,e[87]=ie):ie=e[87];let J;return e[88]!==F||e[89]!==ie||e[90]!==h?(J=t.jsxs("div",{className:"mv-clip-inspector",children:[h,F,ie]}),e[88]=F,e[89]=ie,e[90]=h,e[91]=J):J=e[91],J}export{J1 as $,ps as A,ct as B,Li as C,Q1 as D,cf as E,Yl as F,ef as G,X1 as H,tf as I,mf as J,bf as K,xf as L,sd as M,ld as N,zm as O,yc as P,Bm as Q,Xn as R,Zl as S,qm as T,Om as U,Bc as V,Hm as W,Wm as X,Y1 as Y,Sf as Z,kf as _,sf as a,hf as a0,gf as a1,uf as a2,pf as a3,ff as a4,G1 as a5,Jc as b,lf as c,af as d,nf as e,of as f,td as g,Ui as h,rf as i,Z1 as j,df as k,jf as l,vf as m,Um as n,Km as o,Vm as p,Cc as q,wf as r,Nf as s,Qu as t,Fd as u,Cf as v,$f as w,x1 as x,yf as y,Ll as z};
|