1import{q as T,U as b,r as E,j as a}from"./vendor-react-C7ASs9Oj.js";import{aY as j,gI as C,o as k,et as v,ce as F,t as L}from"./index-u3J_xIHd.js";import{N as w}from"./NoteEditor-Bd09x62x.js";import{S as N,F as B}from"./ScratchPadEmptyState-BzzULDAW.js";import{S as D}from"./ScratchPadLayout-Bh9jqMxx.js";import{u as U}from"./usePageTitle-T4dL9DRD.js";import{g as Y}from"./scratchPadEditor-C9aUAUpY.js";import{e as m,s as $}from"./snapshotMindElixir-DOX7_Cq6.js";import{u as R}from"./useScratchpadWorkspace-BZGA2uzK.js";import"./vendor-charts-BBg_9aJv.js";import"./vendor-motion-D0i_FyGX.js";import"./vendor-editor-D1tNzar-.js";import"./scratchPadMentionHoverDetails-DV35N0pp.js";import"./libraryQueries-DY0mJRrj.js";import"./SendCopyDialog-BwORxQ8O.js";import"./checkbox-B-HilsCT.js";import"./unlink-Dux1Tlxl.js";import"./pagination-BhQI5AlH.js";import"./ellipsis-CGXeEO7U.js";import"./sticky-note-Ccw8BqBF.js";import"./time-9-KLj7BP.js";const g=new Set(["bulletList","orderedList","taskList"]),_=new Set(["listItem","taskItem"]);function S(e){if(!e?.content)return"";let o="";for(const t of e.content)if(t.type==="text"&&typeof t.text=="string")o+=t.text;else if(t.type==="scratchPadMention"){const n=typeof t.attrs?.label=="string"?t.attrs.label:"";o+=n||"Mention"}else t.type==="hardBreak"&&(o+=" ");return o.trim()}function q(e,o){const t=e.content??[],n=t.find(r=>r.type==="paragraph"||r.type==="heading"),s=S(n),c=t.filter(r=>g.has(r.type??"")).flatMap(r=>y(r,o));if(!s&&c.length===0)return null;const l={id:o(),topic:m(s)};return c.length>0&&(l.children=c),l}function y(e,o){return(e.content??[]).filter(t=>_.has(t.type??"")).map(t=>q(t,o)).filter(t=>t!==null)}function z(e,o){const t=[];for(const n of e)if(g.has(n.type??""))t.push(...y(n,o));else if(n.type==="paragraph"||n.type==="heading"){const s=S(n);s&&t.push({id:o(),topic:m(s)})}return t}function A(e,o,t){const n=t(),s=z(e.content??[],t),i={id:n,topic:m(o)};return s.length>0&&(i.children=s),i}const x=e=>e.content;function dt(){U("Scratch Pad");const e=T(),t=b({strict:!1}).noteId??null,n=E.useCallback(p=>{e({to:"/scratch-pad/note/$noteId",params:{noteId:p}})},[e]),{selectedNote:s,isNoteNotFound:i,titleInputRef:c,createNote:l}=R({selectedNoteId:t,onSelectNote:n}),r=j(),u=C(),M=p=>{const f=Y(p.title,x(p));r.mutate({title:f},{onSuccess:d=>{const I=A(x(p),f,(()=>{let h=!0;return()=>h?(h=!1,d.rootNodeId):crypto.randomUUID()})()),P=$(I);u.mutate({mapId:d.id,input:{nodes:P}},{onSuccess:()=>e({to:"/scratch-pad/map/$mapId",params:{mapId:d.id}}),onError:()=>e({to:"/scratch-pad/map/$mapId",params:{mapId:d.id}})})},onError:()=>L.error("Failed to create mind map")})};return a.jsx(D,{onCreate:l,children:i?a.jsx(N,{icon:B,title:"Note not found",description:"This note doesn't exist or has been deleted."}):s?a.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:a.jsx(w,{note:s,titleInputRef:c,toolbarActions:a.jsxs(k,{variant:"ghost",size:"sm",className:"gap-1.5 rounded-xl",onClick:()=>M(s),disabled:r.isPending||u.isPending,children:[a.jsx(v,{className:"h-4 w-4"})," Create mind map"]})},s.id)}):a.jsx(N,{icon:F,title:"No note selected",description:"Create a note to start writing."})})}export{dt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.