PageSourceSearch

https://beatbandit.ai/assets/NovelSourceStage-CFaK2U9f.js

js beatbandit.ai collected 2026-10-05 11:52:02 UTC 8,025 bytes, 2 lines download raw bytes

1import{k as J,j as s,r as i,B as u,T as c,f as v}from"./index-CzOd9Km7.js";import{u as X}from"./useQuery-BcbK_yvX.js";import{u as Z}from"./useNovelAdaptation-BlE6m0el.js";import"./axiosConfig-BS0LIV0L.js";import"./projectSchemas-h1QnwtOV.js";import"./screenplaySchemas-D4JI8Qiv.js";import"./supabaseAuthClient-D4COccm1.js";import{n as N}from"./novelChapterApi-eEzelnV3.js";import{C as D}from"./CircularProgress-CFKeHsf1.js";import{A as w}from"./Alert-BXc9IPcV.js";import{S as f}from"./Stack-E99Gdh2J.js";import{C as d}from"./dividerClasses-CE6pxdyz.js";import{T as z}from"./TextField-BLDfXARA.js";import{I as ee,S as se}from"./Search-BcRNGXqA.js";import{M as m}from"./MenuItem-CKC7Jjka.js";import{D as re}from"./Divider-UFPhkgyE.js";import{I as te}from"./IconButton-DX7NfjoN.js";import{E as oe}from"./Restore-ruzW0M8I.js";import{E as le}from"./ExpandMore-5fy3CFZO.js";import{C as O}from"./Collapse-Bnk0IQSm.js";import"./useMutation-CJKToZ6s.js";import"./novelAdaptationApi-CZpQ3oSP.js";import"./Paper-2iw6XA5a.js";import"./styled-D002SLmF.js";import"./useThemeProps-Dhrs3fnV.js";import"./getThemeProps-whaKXyLK.js";import"./useControlled-C1WEhlQX.js";import"./Menu-BAMQbaXI.js";import"./ownerWindow-D5LHhVun.js";import"./usePreviousProps-D6D_fzw_.js";const ie=J(s.jsx("path",{d:"M14 17H4v2h10zm6-8H4v2h16zM4 15h16v-2H4zM4 5v2h16V5z"}),"Subject"),U=t=>Array.isArray(t)?t.filter(l=>typeof l=="string"):[],ne=(t,l)=>{const n=t.fields[l];return typeof n=="string"?n:""},ae=t=>t.startsWith("source:")?t.slice(7):t;function Oe({project:t,onNavigateToCard:l,navigationData:n,clearNavigationData:j}){const x=Number(t.id),b=Z(Number.isFinite(x)?x:null),C=i.useMemo(()=>Object.values(t.cards??{}).some(e=>e.type==="CHAPTER"||e.card_type==="CHAPTER"||e.entity_type==="chapter"||e.code.startsWith("chapter_")),[t.cards]),I=X({queryKey:["novel-chapters",x],queryFn:()=>N.list(x),enabled:Number.isFinite(x)&&C}),[F,k]=i.useState(""),[g,E]=i.useState("all"),[y,M]=i.useState("all"),[P,A]=i.useState(new Set),[G,Q]=i.useState(new Set),[W,T]=i.useState(null),V=i.useMemo(()=>Object.values(t.cards??{}).filter(e=>e.code.startsWith("adaptation_unit_")),[t.cards]),_=i.useMemo(()=>{var r;const e=(r=t.cards)==null?void 0:r["10.10.05"];return new Set(e?U(e.fields.load_bearing_source_ids):[])},[t.cards]);if(i.useEffect(()=>{if((n==null?void 0:n.type)!=="novel-source-focus"||!n.sourceId)return;const e=ae(n.sourceId);T(e),E("all"),M("all"),k(""),A(r=>new Set(r).add(e)),window.setTimeout(()=>{var r;(r=document.getElementById(`novel-source-${e}`))==null||r.scrollIntoView({behavior:"smooth",block:"center"}),j==null||j()},100)},[j,n]),!x||b.isLoading)return s.jsx(u,{sx:{display:"flex",justifyContent:"center",p:4},children:s.jsx(D,{size:28})});if(b.error||!b.data)return s.jsx(w,{severity:"error",children:"Could not load the adaptation source."});const o=b.data.source_payload_json,K=o.provenance.source_project_name?`BeatBandit project: ${o.provenance.source_project_name}`:o.provenance.inputs.map(e=>e.filename||e.kind.replace("_"," ")).join(" + "),$=e=>V.filter(r=>U(r.fields.source_unit_ids).includes(e)),B=e=>{var r;return(((r=I.data)==null?void 0:r.chapters)??[]).filter(h=>h.fields.source_unit_ids.includes(e))},q=F.trim().toLocaleLowerCase(),S=o.units.filter(e=>{if(g!=="all"&&e.kind!==g)return!1;const r=$(e.source_id).length>0||B(e.source_id).length>0;return y==="mapped"&&!r||y==="unmapped"&&r||y==="required"&&!_.has(e.source_id)?!1:q?[e.heading,e.summary,e.source_text,...e.character_ids,...e.beat_ids].join(" ").toLocaleLowerCase().includes(q):!0}),L=(e,r)=>e(h=>{const p=new Set(h);return p.has(r)?p.delete(r):p.add(r),p});return s.jsxs(u,{sx:{p:{xs:1,sm:2},height:"100%",overflowY:"auto"},children:[s.jsxs(f,{direction:{xs:"column",sm:"row"},spacing:1,alignItems:{sm:"center"},sx:{mb:2},children:[s.jsx(c,{variant:"h5",sx:{fontWeight:700},children:"Source"}),s.jsx(d,{size:"small",label:o.source_kind.replaceAll("_"," ")}),s.jsx(c,{variant:"body2",color:"text.secondary",children:K})]}),[...o.warnings,...o.source_gaps].map(e=>s.jsx(w,{severity:"warning",sx:{mb:1.5},children:e},e)),C&&I.error&&s.jsx(w,{severity:"warning",sx:{mb:1.5},children:"Chapter mappings could not be loaded."}),s.jsxs(f,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",sx:{mb:2},children:[s.jsx(d,{label:`${o.units.filter(e=>e.kind==="scene").length} scenes`}),s.jsx(d,{label:`${o.beats.length} beats`}),s.jsx(d,{label:`${o.characters.length} characters`}),_.size>0&&s.jsx(d,{color:"primary",variant:"outlined",label:`${_.size} required`})]}),s.jsxs(u,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"minmax(240px, 1fr) 180px 180px"},gap:1,mb:1.5},children:[s.jsx(z,{size:"small",label:"Search source",value:F,onChange:e=>k(e.target.value),InputProps:{startAdornment:s.jsx(ee,{position:"start",children:s.jsx(se,{fontSize:"small"})})}}),s.jsxs(z,{select:!0,size:"small",label:"Material",value:g,onChange:e=>E(e.target.value),children:[s.jsx(m,{value:"all",children:"All material"}),s.jsx(m,{value:"scene",children:"Scenes"}),s.jsx(m,{value:"beat",children:"Story beats"}),s.jsx(m,{value:"outline_section",children:"Outline material"})]}),s.jsxs(z,{select:!0,size:"small",label:"Mapping",value:y,onChange:e=>M(e.target.value),children:[s.jsx(m,{value:"all",children:"All mapping states"}),s.jsx(m,{value:"mapped",children:"Mapped"}),s.jsx(m,{value:"unmapped",children:"Unmapped"}),s.jsx(m,{value:"required",children:"Required"})]})]}),s.jsxs(c,{variant:"caption",color:"text.secondary",children:[S.length," of ",o.units.length," source items"]}),s.jsx(re,{sx:{mt:1}}),S.length===0?s.jsx(u,{sx:{py:6,textAlign:"center"},children:s.jsx(c,{variant:"body2",color:"text.secondary",children:"No source material matches these filters."})}):S.map(e=>{const r=P.has(e.source_id),h=G.has(e.source_id),p=$(e.source_id),R=B(e.source_id),H=p.length>0||R.length>0,Y=_.has(e.source_id);return s.jsxs(u,{id:`novel-source-${e.source_id}`,sx:{py:1.5,px:{xs:0,sm:1},borderBottom:"1px solid",borderColor:W===e.source_id?"primary.main":"divider",bgcolor:W===e.source_id?"action.selected":"transparent",transition:"background-color 160ms ease, border-color 160ms ease"},children:[s.jsxs(f,{direction:"row",spacing:1,alignItems:"flex-start",children:[s.jsx(c,{variant:"overline",color:"text.secondary",sx:{minWidth:34},children:e.order}),s.jsxs(u,{sx:{minWidth:0,flex:1},children:[s.jsxs(f,{direction:"row",spacing:.75,useFlexGap:!0,flexWrap:"wrap",alignItems:"center",children:[s.jsx(c,{sx:{fontWeight:650},children:e.heading||e.summary||`${e.kind.replace("_"," ")} ${e.order}`}),s.jsx(d,{size:"small",variant:"outlined",label:e.kind.replace("_"," ")}),Y&&s.jsx(d,{size:"small",color:"primary",label:"Required"}),s.jsx(d,{size:"small",color:H?"success":"default",label:H?"Mapped":"Unmapped"})]}),!r&&e.summary&&s.jsx(c,{variant:"body2",color:"text.secondary",noWrap:!0,sx:{mt:.5},children:e.summary})]}),s.jsx(te,{size:"small","aria-label":`${r?"Collapse":"Expand"} ${e.heading||e.source_id}`,onClick:()=>L(A,e.source_id),children:r?s.jsx(oe,{}):s.jsx(le,{})})]}),s.jsx(O,{in:r,timeout:"auto",unmountOnExit:!0,children:s.jsxs(u,{sx:{pl:{xs:0,sm:5.25},pr:1,pt:1},children:[e.summary&&s.jsx(c,{variant:"body2",children:e.summary}),s.jsxs(f,{direction:"row",spacing:1,useFlexGap:!0,flexWrap:"wrap",sx:{mt:1},children:[p.map(a=>s.jsx(v,{size:"small",variant:"outlined",onClick:()=>l==null?void 0:l(a.code),children:ne(a,"summary")||a.name},a.code)),R.map(a=>s.jsxs(v,{size:"small",variant:"outlined",onClick:()=>l==null?void 0:l(a.code),children:["Chapter ",a.fields.number,": ",a.name]},a.code)),e.source_text&&e.source_text!==e.summary&&s.jsx(v,{size:"small",startIcon:s.jsx(ie,{}),onClick:()=>L(Q,e.source_id),children:h?"Hide full text":"Show full text"})]}),s.jsx(O,{in:h,timeout:"auto",unmountOnExit:!0,children:s.jsx(c,{variant:"body2",sx:{mt:1.5,pt:1.5,borderTop:"1px solid",borderColor:"divider",whiteSpace:"pre-wrap"},children:e.source_text})})]})})]},e.source_id)})]})}export{Oe as NovelSourceStage};
2//# sourceMappingURL=NovelSourceStage-CFaK2U9f.js.map

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