PageSourceSearch

https://trybrain.io/assets/_authenticated.organic-selfie-B71HH0b1.js

js trybrain.io collected 2026-09-24 15:05:04 UTC 14,779 bytes, 2 lines download raw bytes

1import{z as I,D as M,E as q,e as D,P as se,f as H,aF as ae,au as ne,r as h,K as ie,j as e,B as m,L as K,ay as oe,h as V,k as w,ar as Z,b_ as re,at as le,t as U,am as Q,an as Y,ao as X,ap as G,as as J,I as de,aq as ce,aa as ue,s as me}from"./index-DHwBXtP2.js";import{F as pe}from"./file-text-CzX-qSj6.js";import{D as he}from"./download-Dm0Bb9aW.js";import{U as fe}from"./upload-D6q4E55j.js";const xe=I({method:"POST"}).middleware([M]).handler(q("src_lib_organic-selfie-export_functions_ts--listSelfieScripts_createServerFn_handler")),ge=I({method:"POST"}).middleware([M]).handler(q("src_lib_organic-selfie-export_functions_ts--logSelfieDelivery_createServerFn_handler"));I({method:"POST"}).middleware([M]).handler(q("src_lib_organic-selfie-export_functions_ts--listSelfieDeliveries_createServerFn_handler"));const je=I({method:"POST"}).middleware([M]).handler(q("src_lib_organic-selfie-export_functions_ts--listSelfieUploadStatus_createServerFn_handler")),ye=I({method:"POST"}).middleware([M]).handler(q("src_lib_organic-selfie-export_functions_ts--submitSelfieUpload_createServerFn_handler"));function W(n){const s=[];return(n.angle||n.format)&&s.push(`[${[n.angle,n.format].filter(Boolean).join(" · ")}]`),s.push(""),s.push("=== HOOK (first 1.5s, look straight at lens) ==="),s.push(n.hook_line),n.hook_visual&&(s.push(""),s.push(`On-screen text: ${n.hook_visual}`)),s.push(""),s.push("=== BEATS — one continuous take, no cuts (speak clearly, keep energy up) ==="),(Array.isArray(n.beats)?n.beats:[]).forEach((a,j)=>{const f=typeof a=="string"?a:a?.say??a?.line??a?.text??a?.script??JSON.stringify(a),r=typeof a=="object"&&a?.timestamp?` (${a.timestamp})`:"";s.push(`${j+1}.${r} ${f}`);const c=typeof a=="object"?a?.text_overlay??a?.show??"":"";c&&s.push(`    On-screen text: ${c}`)}),n.cta_soft&&(s.push(""),s.push("=== CTA (soft, spoken naturally) ==="),s.push(n.cta_soft)),s.push(""),s.push("=== POST DETAILS ==="),n.caption&&(s.push("Caption:"),s.push(n.caption),s.push("")),n.hashtags?.length&&s.push(`Hashtags: ${n.hashtags.map(a=>a.startsWith("#")?a:`#${a}`).join(" ")}`),n.music_direction&&s.push(`Music: ${n.music_direction}`),n.platform_notes&&(s.push(""),s.push("Platform notes:"),s.push(n.platform_notes)),s.join(`
2`)}function Fe(){const n=D(se),{data:s}=H({queryKey:["workspaces"],queryFn:()=>n({})}),a=s?.[0]?.id,j=D(xe),f=D(ge),r=D(je),c=D(ye),o=D(ae),x=ne(),[p,y]=h.useState(!0),{data:v,isLoading:z}=H({queryKey:["organic-selfie",a,p],queryFn:()=>j({data:{workspaceId:a,onlyApproved:p}}),enabled:!!a}),O=v?.scripts??[],g=O.map(t=>t.id),{data:_}=H({queryKey:["organic-selfie-status",a,g.join(",")],queryFn:()=>r({data:{workspaceId:a,scriptIds:g}}),enabled:!!a&&g.length>0,refetchInterval:t=>(t.state.data?.statuses??[]).some(P=>P.composition&&["queued","submitting","rendering"].includes(P.composition.status))?5e3:!1}),u=new Map;for(const t of _?.statuses??[])u.set(t.script_id,t);const[S,$]=h.useState(null),[F,b]=h.useState(null),[T,B]=h.useState(""),[C,l]=h.useState(null),d=ie({mutationFn:async t=>{await f({data:{workspaceId:a,scriptId:t.scriptId,deliveryChannel:t.channel,deliveredTo:t.to??null}})}});async function k(t){const N=W(t);await navigator.clipboard.writeText(N),U.success("Copied teleprompter script"),d.mutate({scriptId:t.id,channel:"copy"})}function E(t){const N=W(t),A=new Blob([N],{type:"text/plain;charset=utf-8"}),P=URL.createObjectURL(A),L=document.createElement("a");L.href=P,L.download=`selfie-script-${t.id.slice(0,8)}.txt`,document.body.appendChild(L),L.click(),L.remove(),URL.revokeObjectURL(P),d.mutate({scriptId:t.id,channel:"download_txt"})}function R(t){B(""),b(t)}function te(){if(!F)return;const t=F,N=encodeURIComponent(`Reel script: ${t.hook_line.slice(0,60)}`),A=encodeURIComponent(W(t)),P=encodeURIComponent(T);window.location.href=`mailto:${P}?subject=${N}&body=${A}`,d.mutate({scriptId:t.id,channel:"email",to:T}),b(null)}return e.jsxs("div",{className:"mx-auto max-w-6xl p-4 md:p-6 space-y-6",children:[e.jsxs("header",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Founder-selfie scripts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Teleprompter-ready scripts from the Organic Matrix cells set to "founder selfie". Copy, download, or email them to whoever is filming.'})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(K,{to:"/organic",children:"← Matrix"})}),e.jsx(m,{asChild:!0,variant:"outline",size:"sm",children:e.jsx(K,{to:"/organic-gallery",children:"Gallery"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border p-3",children:[e.jsx(oe,{id:"only-approved",checked:p,onCheckedChange:y}),e.jsx(V,{htmlFor:"only-approved",children:"Only show approved scripts"})]}),z?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):O.length===0?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No founder-selfie scripts yet. In the"," ",e.jsx(K,{to:"/organic",className:"underline",children:"Matrix"}),`, set a cell's render platform to "founder selfie" and generate a script.`]}):e.jsx("ul",{className:"space-y-3",children:O.map(t=>e.jsxs("li",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[(t.angle||t.format)&&e.jsx(w,{variant:"outline",children:[t.angle,t.format].filter(
2Boolean).join(" · ")}),t.is_approved?e.jsx(w,{className:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"Approved"}):e.jsx(w,{variant:"secondary",children:"Draft"}),e.jsx(ve,{status:u.get(t.id)})]}),e.jsx("h3",{className:"font-semibold leading-snug",children:t.hook_line}),t.hook_visual&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Visual: ",t.hook_visual]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>$(t),children:[e.jsx(pe,{className:"h-3.5 w-3.5 mr-1"})," Teleprompter"]}),e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>k(t),children:[e.jsx(Z,{className:"h-3.5 w-3.5 mr-1"})," Copy"]}),e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>E(t),children:[e.jsx(he,{className:"h-3.5 w-3.5 mr-1"})," .txt"]}),e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>R(t),children:[e.jsx(re,{className:"h-3.5 w-3.5 mr-1"})," Email"]}),e.jsx(be,{status:u.get(t.id),onClick:()=>l(t)}),u.get(t.id)?.composition?.status==="failed"&&u.get(t.id)?.composition?.id&&e.jsxs(m,{size:"sm",variant:"outline",onClick:async()=>{try{await o({data:{workspaceId:a,jobId:u.get(t.id).composition.id}}),U.success("Composition re-queued"),x.invalidateQueries({queryKey:["organic-selfie-status"]})}catch(N){U.error(N.message)}},children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1"})," Retry composition"]})]})]}),e.jsx(we,{status:u.get(t.id)})]},t.id))}),e.jsx(Q,{open:!!S,onOpenChange:t=>!t&&$(null),children:e.jsxs(Y,{className:"max-w-2xl",children:[e.jsx(X,{children:e.jsx(G,{children:"Teleprompter view"})}),S&&e.jsx("pre",{className:"whitespace-pre-wrap text-base leading-relaxed font-medium max-h-[60vh] overflow-y-auto rounded bg-muted p-4",children:W(S)}),e.jsxs(J,{children:[S&&e.jsxs(m,{onClick:()=>k(S),children:[e.jsx(Z,{className:"h-4 w-4 mr-2"})," Copy"]}),e.jsx(m,{variant:"outline",onClick:()=>$(null),children:"Close"})]})]})}),e.jsx(Q,{open:!!F,onOpenChange:t=>!t&&b(null),children:e.jsxs(Y,{children:[e.jsx(X,{children:e.jsx(G,{children:"Email script to founder"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{children:"Recipient email"}),e.jsx(de,{type:"email",value:T,onChange:t=>B(t.target.value),placeholder:"[email protected]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opens your mail client with the teleprompter script pre-filled."})]}),e.jsxs(J,{children:[e.jsx(m,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(m,{onClick:te,disabled:!T,children:"Send"})]})]})}),e.jsx(Se,{workspaceId:a,script:C,status:C?u.get(C.id):null,onClose:()=>l(null),onDone:()=>{l(null),x.invalidateQueries({queryKey:["organic-selfie-status"]})},uploadFn:c})]})}function ve({status:n}){if(!n?.has_filmed_upload)return null;const s=n.composition,i=n.publish;return i?.published_at?e.jsx(w,{className:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"Published"}):i?.status==="scheduled"&&i?.media_url?e.jsx(w,{className:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"Scheduled"}):i?.status==="awaiting_composition"||s&&["queued","submitting","rendering"].includes(s.status)?e.jsx(w,{className:"bg-amber-500/15 text-amber-600 dark:text-amber-400",children:"Waiting for composition"}):s?.status==="failed"||i?.status==="composition_failed"?e.jsx(w,{className:"bg-red-500/15 text-red-600 dark:text-red-400",children:"Composition failed"}):s?.status==="succeeded"?e.jsx(w,{className:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",children:"Composed"}):e.jsx(w,{variant:"secondary",children:"Uploaded"})}function be({status:n,onClick:s}){if(n?.publish?.published_at??null)return null;const a=!!n?.has_filmed_upload;return e.jsxs(m,{size:"sm",onClick:s,children:[e.jsx(fe,{className:"h-3.5 w-3.5 mr-1"}),a?"Re-upload":"Upload filmed video"]})}function we({status:n}){if(!n?.has_filmed_upload)return null;const s=n.composition,i=n.publish,a=[];return i?.scheduled_for&&!i?.published_at&&a.push(`Scheduled ${new Date(i.scheduled_for).toLocaleString()}`),i?.published_at&&a.push(`Published ${new Date(i.published_at).toLocaleStr
2ing()}`),s?.status==="failed"&&s?.error_message&&a.push(`Composition error: ${s.error_message}`),i?.status==="composition_failed"&&i?.last_error&&!s?.error_message&&a.push(`Publish held: ${i.last_error}`),a.length===0?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:a.join(" · ")})}const _e=500*1024*1024;function Se({workspaceId:n,script:s,status:i,onClose:a,onDone:j,uploadFn:f}){const[r,c]=h.useState(null),[o,x]=h.useState(null),[p,y]=h.useState(null),[v,z]=h.useState(null),[O,g]=h.useState(0),[_,u]=h.useState("idle"),[S,$]=h.useState(null),F=h.useRef(null);function b(){c(null),x(null),y(null),v&&URL.revokeObjectURL(v),z(null),g(0),u("idle"),$(null),F.current&&(F.current.value="")}async function T(l){if(b(),!l.type.startsWith("video/")){U.error("Please pick a video file");return}if(l.size>_e){U.error(`File too large — max 500 MB (this is ${Math.round(l.size/1024/1024)} MB)`);return}c(l),u("extracting");try{const{duration:d,thumbnail:k}=await Ce(l);x(d),y(k),z(URL.createObjectURL(k)),d<10?$(`Clip is only ${d.toFixed(1)}s — Reels usually work best over 10s. You can still upload.`):d>180&&$(`Clip is ${Math.round(d)}s — over 3 min may be trimmed by Instagram. You can still upload.`)}catch(d){U.error(`Could not read video metadata: ${d.message}`)}finally{u("idle")}}async function B(){if(!r||!n||!s)return;u("uploading"),g(0);const l=crypto.randomUUID(),d=(r.name.split(".").pop()||"mp4").toLowerCase(),k=`${n}/${s.id}/${l}.${d}`,E=p?`${n}/${s.id}/${l}.jpg`:null;try{await ee("selfie-videos",k,r,R=>g(Math.round(R*.9))),p&&E&&await ee("selfie-videos",E,p,R=>g(90+Math.round(R*.05))),g(95),u("finalizing"),await f({data:{workspaceId:n,scriptId:s.id,videoStoragePath:k,thumbnailStoragePath:E,durationSeconds:o??null,supersedePrior:!!i?.has_filmed_upload}}),g(100),U.success("Uploaded — composition will run in the background"),j(),b()}catch(R){U.error(`Upload failed: ${R.message}`),u("idle"),g(0)}}const C=_==="uploading"||_==="finalizing"||_==="extracting";return e.jsx(Q,{open:!!s,onOpenChange:l=>{!l&&!C&&(b(),a())},children:e.jsxs(Y,{className:"max-w-md",children:[e.jsxs(X,{children:[e.jsx(G,{children:i?.has_filmed_upload?"Re-upload filmed video":"Upload filmed video"}),e.jsx(ce,{className:"text-xs",children:i?.has_filmed_upload?"Re-uploading cancels the prior composition and starts a fresh job.":"Record or pick the filmed selfie. We'll extract a thumbnail, upload, and hand off to composition."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{ref:F,type:"file",accept:"video/*",capture:"user",className:"block w-full text-sm file:mr-3 file:rounded-md file:border-0 file:bg-primary file:px-3 file:py-2 file:text-primary-foreground",disabled:C,onChange:l=>{const d=l.target.files?.[0];d&&T(d)}}),r&&e.jsxs("div",{className:"rounded-md border p-3 text-xs space-y-1",children:[e.jsx("div",{className:"font-medium truncate",children:r.name}),e.jsxs("div",{className:"text-muted-foreground",children:[(r.size/1024/1024).toFixed(1)," MB",o!==null&&` · ${o.toFixed(1)}s`]}),v&&e.jsx("img",{src:v,alt:"First-frame thumbnail preview",className:"mt-2 h-32 rounded object-cover"})]}),S&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:S}),(_==="uploading"||_==="finalizing")&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(ue,{value:O}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_==="finalizing"?"Finalizing…":`Uploading ${O}%`})]})]}),e.jsxs(J,{children:[e.jsx(m,{variant:"outline",disabled:C,onClick:()=>{b(),a()},children:"Cancel"}),e.jsx(m,{disabled:!r||C,onClick:B,children:i?.has_filmed_upload?"Replace & compose":"Upload"})]})]})})}async function Ce(n){const s=URL.createObjectURL(n),i=document.createElement("video");i.preload="metadata",i.muted=!0,i.playsInline=!0,i.src=s;try{await new Promise((p,y)=>{i.onloadedmetadata=()=>p(),i.onerror=()=>y(new Error("Failed to load video"))});const a=i.duration,j=Math.min(1,Math.max(0,a-.1));await new Promise((p,y)=>{i.onseeked=()=>p(),i.onerror=()=>y(new Error("Failed to seek video")),i.currentTime=j});
2const f=i.videoWidth||720,r=i.videoHeight||1280,c=document.createElement("canvas");c.width=f,c.height=r;const o=c.getContext("2d");if(!o)throw new Error("Canvas 2D not available");o.drawImage(i,0,0,f,r);const x=await new Promise((p,y)=>c.toBlob(v=>v?p(v):y(new Error("Thumbnail encode failed")),"image/jpeg",.85));return{duration:a,thumbnail:x}}finally{URL.revokeObjectURL(s)}}async function ee(n,s,i,a){const{data:j,error:f}=await me.storage.from(n).createSignedUploadUrl(s);if(f||!j?.signedUrl)throw new Error(f?.message??"Could not sign upload URL");await new Promise((r,c)=>{const o=new XMLHttpRequest;o.open("PUT",j.signedUrl),o.setRequestHeader("x-upsert","true"),i.type&&o.setRequestHeader("Content-Type",i.type),o.upload.onprogress=x=>{x.lengthComputable&&a(x.loaded/x.total*100)},o.onload=()=>{o.status>=200&&o.status<300?r():c(new Error(`Upload failed (${o.status}): ${o.responseText}`))},o.onerror=()=>c(new Error("Network error during upload")),o.send(i)})}export{Fe as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.