react-reason-editor 1.0.61 → 1.0.63

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.
@@ -231,24 +231,26 @@ return me("div",{className:"h-full flex flex-col",children:[
231
231
  /* @__PURE__ */me("div",{className:"p-3 border-b border-sidebar-border",children:[/* @__PURE__ */pe("div",{className:"text-xs font-semibold text-sidebar-foreground mb-3",children:"AI SUGGESTION"}),a&&s.length>0&&/* @__PURE__ */me("div",{className:"mb-3",children:[/* @__PURE__ */pe("div",{className:"text-xs text-muted-foreground mb-2",children:"Rewrite Mode:"}),/* @__PURE__ */pe("div",{className:"flex flex-wrap gap-1",children:s.map(e=>/* @__PURE__ */pe(hf,{variant:"outline",className:Dl("cursor-pointer text-xs px-2 py-0.5 transition-colors",c(e.color),i===e.id&&"ring-2 ring-offset-1"),onClick:()=>a(e),children:e.name},e.id))})]})]}),
232
232
  /* @__PURE__ */me("div",{className:"flex-1 overflow-auto p-3 space-y-4",children:[/* @__PURE__ */me("div",{children:[/* @__PURE__ */pe("div",{className:"text-xs font-semibold text-muted-foreground mb-2",children:"Original:"}),/* @__PURE__ */pe("div",{className:"text-sm text-foreground/70 line-through bg-muted/50 p-3 rounded-md",children:e})]}),/* @__PURE__ */me("div",{children:[/* @__PURE__ */pe("div",{className:"text-xs font-semibold text-muted-foreground mb-2",children:"Suggested:"}),/* @__PURE__ */pe("div",{className:"text-sm text-foreground font-medium bg-primary/10 p-3 rounded-md border border-primary/20",children:t})]})]}),
233
233
  /* @__PURE__ */pe("div",{className:"border-t border-sidebar-border p-3",children:/* @__PURE__ */me("div",{className:"flex flex-col gap-2",children:[/* @__PURE__ */me(np,{variant:"default",size:"sm",onClick:n,className:"w-full h-9 bg-green-500 hover:bg-green-600 text-white",title:"Approve",children:[/* @__PURE__ */pe(ve,{className:"h-4 w-4 mr-1"}),"Approve"]}),/* @__PURE__ */me(np,{variant:"outline",size:"sm",onClick:r,className:"w-full h-9",title:"Reject",children:[/* @__PURE__ */pe(Tt,{className:"h-4 w-4 mr-1"}),"Reject"]})]})})]})};function yf({className:e,type:t,...n}){/* @__PURE__ */
234
- return pe("input",{type:t,"data-slot":"input",className:Dl("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground flex h-11 w-full min-w-0 rounded-2xl border bg-card px-3 py-1 text-sm font-medium transition-[color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","focus:outline-none focus:ring-2 focus:ring-primary/50","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function bf(...e){return e.filter(Boolean).join(" ")}var xf=X(function(e,t){const{className:n,style:r,children:a,defaultSize:o,size:i,minSize:s,maxSize:l,...c}=e,d={position:"relative",outline:"none",overflow:"auto",flex:"none",...r},u=bf("split-pane-pane",n);return pe("div",{ref:t,className:u,style:d,"data-pane":"true",...c,children:a})});function wf(e,t="polite"){if("undefined"==typeof document)return;const n=document.createElement("div");n.setAttribute("role","status"),n.setAttribute("aria-live",t),n.setAttribute("aria-atomic","true"),n.style.position="absolute",n.style.left="-10000px",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n.textContent=e,document.body.appendChild(n),setTimeout(()=>{document.body.removeChild(n)},1e3)}function Sf(e){return 1e3>e?Math.round(e)+" pixels":Math.round(e/10)/100+" thousand pixels"}function kf(e){const{direction:t,index:n,isDragging:r,disabled:a,onPointerDown:o,onKeyDown:i,className:s,style:l,currentSize:c,minSize:d,maxSize:u,children:h}=e,p="horizontal"===t?"vertical":"horizontal",m={flex:"none",position:"relative",userSelect:"none",touchAction:"none",..."horizontal"===t?{width:"1px",cursor:a?"default":"col-resize"}:{height:"1px",cursor:a?"default":"row-resize"},...r&&{cursor:"horizontal"===t?"col-resize":"row-resize"},...l},f=bf("split-pane-divider",t,r&&"dragging",s),g=function(e,t){return`${"horizontal"===t?"vertical":"horizontal"} divider ${e+1}`}(n,t);return pe("div",{role:"separator","aria-orientation":p,"aria-label":g,"aria-valuenow":c,"aria-valuemin":d,"aria-valuemax":void 0===u||u===1/0?void 0:u,"aria-description":function(e){return`Use ${"horizontal"===e?"left and right arrow keys":"up and down arrow keys"} to resize. Hold Shift for larger steps. Press Home or End to minimize or maximize.`}(t),tabIndex:a?-1:0,className:f,style:m,onPointerDown:a?void 0:o,onKeyDown:a?void 0:i,"data-divider-index":n,children:h})}function Cf(e,t){if("number"==typeof e)return e;if(e.endsWith("%"))return parseFloat(e)/100*t;if(e.endsWith("px"))return parseFloat(e);const n=parseFloat(e);return isNaN(n)?0:n}function Nf(e,t,n){return Math.min(Math.max(e,t),n)}function Tf(e,t,n,r,a){const o=[...e],i=e[t]??0,s=e[t+1]??0,l=r[t+1]??0,c=a[t+1]??1/0;let d=Nf(i+n,r[t]??0,a[t]??1/0),u=Nf(s-n,l,c);const h=s-u,p=Math.min(Math.abs(d-i),Math.abs(h));return n>0?(d=i+p,u=s-p):(d=i-p,u=s+p),o[t]=d,o[t+1]=u,o}function Af(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,snapPoints:o=[],snapTolerance:i=10,step:s,onResizeStart:l,onResize:c,onResizeEnd:d}=e,[u,h]=le(!1),[p,m]=le(n),f=se(null),g=se(null),v=se(!0),y=se(null),b=se(p);b.current=p;const x=se(d);x.current=d;const w=se(n);te(()=>{u||JSON.stringify(n)===JSON.stringify(w.current)||(w.current=n,m(n))},[n,u]),te(()=>(v.current=!0,()=>{v.current=!1,g.current&&(cancelAnimationFrame(g.current),g.current=null)}),[]);const S=Q((e,n)=>{if(!f.current||!v.current)return;const{dividerIndex:l,startPosition:d,startSizes:u,pointerType:h}=f.current;let p=("horizontal"===t?e:n)-d;s&&(p=function(e,t){return t>0?Math.round(e/t)*t:e}(p,s));let g=Tf(u,l,p,r,a);o.length>0&&(g=g.map(e=>function(e,t,n){for(const r of t)if(n>=Math.abs(e-r))return r;return e}(e,o,i))),m(g),c&&c(g,{sizes:g,source:"pointer",pointerType:h})},[t,s,r,a,o,i,c]),k=Q(e=>{f.current&&e.pointerId===f.current.pointerId&&(e.preventDefault(),y.current={x:e.clientX,y:e.clientY},g.current||(g.current=requestAnimationFrame(()=>{g.current=null,v.current&&y.current&&S(y.current.x,y.current.y)})))},[S]),C=Q(e=>{if(!f.current||e.pointerId!==f.current.pointerId)return;const{element:t,pointerId:n,pointerType:r}=f.current;t?.hasPointerCapture?.(n)&&t.releasePointerCapture(n),g.current&&(cancelAnimationFrame(g.current),g.current=null),h(!1);const a=b.current,o=x.current;o&&o(a,{sizes:a,source:"pointer",pointerType:r}),f.current=null},[]),N=Q(e=>n=>{n.preventDefault();const r="horizontal"===t?n.clientX:n.clientY,a=n.currentTarget;a.setPointerCapture(n.pointerId);const o=n.pointerType;f.current={dividerIndex:e,startPosition:r,startSizes:p,pointerId:n.pointerId,pointerType:o,element:a},h(!0),l&&l({sizes:p,source:"pointer",pointerType:o,originalEvent:n.nativeEvent})},[t,p,l]);return te(()=>{if(u)return document.addEventListener("pointermove",k),document.addEventListener("pointerup",C),document.addEventListener("pointercancel",C),()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",C),document.removeEventListener("pointercancel",C)}},[u,k,C]),{isDragging:u,currentSizes:p,handlePointerDown:N}}var If=10,Mf=50;function Df(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,step:o=If,largeStep:i=Mf,onResize:s,onResizeEnd:l}=e,c=se(null);return{handleKeyDown:Q(e=>d=>{if(!("horizontal"===t?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).includes(d.key)&&"Home"!==d.key&&"End"!==d.key&&"Escape"!==d.key)return;if(d.preventDefault(),"Escape"===d.key){if(c.current){const e=c.current;c.current=null,s&&s(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),wf("Pane sizes restored")}return}null===c.current&&(c.current=[...n]);let u=0,h=[...n],p="arrow";switch(d.key){case"ArrowLeft":case"ArrowUp":u=-(d.shiftKey?i:o);break;case"ArrowRight":case"ArrowDown":u=d.shiftKey?i:o;break;case"Home":{p="home";const t=e+1,a=r[e]??0,o=(n[e]??0)+(n[t]??0);h[e]=a,h[t]=o-a;break}case"End":{p="end";const t=e,o=e+1,i=(n[t]??0)+(n[o]??0);h[t]=Math.min(a[t]??1/0,i-(r[o]??0)),h[o]=i-h[t];break}}if(0!==u&&(h=Tf(n,e,u,r,a)),h=h.map((e,t)=>Nf(e,r[t]??0,a[t]??1/0)),s&&s(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),"home"===p)wf(`Pane ${e+1} minimized to ${Sf(h[e]??0)}`);else if("end"===p)wf(`Pane ${e+1} maximized to ${Sf(h[e]??0)}`);else{const t=u>0?e:e+1;wf(`Pane ${t+1} resized to ${Sf(h[t]??0)}`)}},[t,n,r,a,o,i,s,l])}}function Ef(e){const{direction:t="horizontal",resizable:n=!0,snapPoints:r,snapTolerance:a=10,step:o,onResizeStart:i,onResize:s,onResizeEnd:l,className:c,style:d,divider:u,dividerStyle:h,dividerClassName:p,dividerSize:m=1,children:f}=e,g=se(null),[v,y]=le(0),b=se(0),x=ie(()=>U.toArray(f).filter(e=>"object"==typeof e&&null!==e&&"props"in e).map(e=>({props:e.props,size:e.props.size,defaultSize:e.props.defaultSize,minSize:e.props.minSize??0,maxSize:e.props.maxSize??1/0})),[f]),w=x.length,S=se(!1);2>w&&!S.current&&(S.current=!0);const{minSizes:k,maxSizes:C}=ie(()=>{if(0===v)return{minSizes:Array(w).fill(0),maxSizes:Array(w).fill(1/0)};const e=[],t=[];return x.forEach(n=>{e.push(Cf(n.minSize,v)),t.push(n.maxSize===1/0?1/0:Cf(n.maxSize,v))}),{minSizes:e,maxSizes:t}},[v,w,x]),N=Q(e=>{if(0===e)return Array(w).fill(0);const t=e-m*(w-1),n=x.map(e=>{const n=e.size??e.defaultSize;return void 0!==n?Cf(n,t):null}),r=n.reduce((e,t)=>e+(t??0),0),a=n.filter(e=>null===e).length,o=a>0?(t-r)/a:0;return n.map(e=>null===e?o:e)},[w,x,m]),[T,A]=le(()=>N(v));te(()=>{if(0===v)return;if(!x.some(e=>void 0!==e.size))return;const e=N(v);A(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[v,x,N]);const I=Q(e=>{const t=b.current;if(b.current=e,0===e)return;const n=x.some(e=>void 0!==e.size),r=e-m*(w-1);A(a=>a.every(e=>0===e)||a.length!==w?N(e):t>0&&t!==e?n?N(e):function(e,t){const n=e.reduce((e,t)=>e+t,0);if(0===n){const n=t/e.length;return e.map(()=>n)}return e.map(e=>e/n*t)}(a,r):0===t?N(e):a)},[w,x,N,m]),M=se(0);te(()=>{const e=g.current;if(!e)return;const n=new ResizeObserver(e=>{const n=e[0];n&&(e=>{const n=Math.round("horizontal"===t?e.width:e.height);n>0&&n!==M.current&&(M.current=n,y(n),I(n))})(n.contentRect)});return n.observe(e),()=>{n.disconnect()}},[t,I]);const D=Q((e,t)=>{A(e),s?.(e,t)},[s]),{isDragging:E,currentSizes:R,handlePointerDown:_}=Af({direction:t,sizes:T,minSizes:k,maxSizes:C,snapPoints:r,snapTolerance:a,step:o,onResizeStart:i,onResize:D,onResizeEnd:l}),{handleKeyDown:z}=Df({direction:t,sizes:R,minSizes:k,maxSizes:C,step:o,onResize:D,onResizeEnd:l}),P=Q(e=>t=>{const n={...t,pointerId:1,pointerType:"mouse",nativeEvent:t.nativeEvent};_(e)(n)},[_]),O=Q(e=>t=>{const n=t.touches[0];if(!n)return;const r={...t,clientX:n.clientX,clientY:n.clientY,pointerId:n.identifier,pointerType:"touch",nativeEvent:t.nativeEvent};_(e)(r)},[_]),L=Q(()=>{},[]),F={display:"flex",flexDirection:"horizontal"===t?"row":"column",height:"100%",width:"100%",overflow:"hidden",position:"relative",...d},B=bf("split-pane",t,c);return pe("div",{ref:g,className:B,style:F,children:v>0&&(()=>{if(2>w)return null;const e=[];return x.forEach((r,a)=>{const o=R[a]??0,i={..."horizontal"===t?{width:o+"px",height:"100%"}:{height:o+"px",width:"100%"},...r.props.style};if(e.push(pe(xf,{...r.props,style:i,children:r.props.children},"pane-"+a)),w-1>a){const r=k[a],i=C[a];e.push(pe(u??kf,{direction:t,index:a,isDragging:E,disabled:!n,onPointerDown:_(a),onMouseDown:P(a),onTouchStart:O(a),onTouchEnd:L,onKeyDown:z(a),className:p,style:h,currentSize:o,minSize:r,maxSize:i===1/0?void 0:i},"divider-"+a))}}),e})()})}function Rf(e){const{key:t,storage:n=localStorage,debounce:r=300}=e,[a,o]=le(()=>{try{const e=n.getItem(t);return e?JSON.parse(e):[]}catch{return[]}});return te(()=>{if(0===a.length)return;const e=setTimeout(()=>{try{n.setItem(t,JSON.stringify(a))}catch(e){}},r);return()=>clearTimeout(e)},[a,t,n,r]),[a,o]}var _f="undefined"==typeof window?{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},key:()=>null,length:0}:window.localStorage,zf=({panels:e,split:t,persistenceKey:n,activeDocuments:r,activeId:a,activeDocument:o,headings:i=[],isMobile:s,onSelect:l,onAdd:c,onDelete:d,onDuplicate:u,onMove:h,onManageTags:p,onRename:m,onOpenChange:f,treeRef:g,outlineRef:v,editorRef:y,openTabs:b=[],activeTab:x,onTabChange:w,onTabClose:S,onTabRename:k,onSplitRight:C,onReopenLastClosed:N,canReopenLastClosed:T=!1,onNavigate:A,aiProps:I,tipsProps:M,tabItems:D,onNewChat:E})=>{const[R,_]=le(null),[z,P]=le(""),O=se(null),L=se(null),F=g??O,B=v??L,V=e=>{l(e),s&&f&&f(!1)},$=e=>{p?.(e),s&&f&&f(!1)},H=Q(e=>{_(e)},[]),q=Q(e=>{R&&u(R)},[R,u]),j=ie(()=>{const e=o?.content||"";if(!e)return[];const t=(new DOMParser).parseFromString(e,"text/html"),n=[];let r="",a=-1;for(const o of Array.from(t.body.children))/^h[1-6]$/i.test(o.tagName)?(a>=0&&(n[a]=r),a++,r=""):a>=0&&(r+=" "+(o.textContent||""));return a>=0&&(n[a]=r),n},[o?.content]),U=ie(()=>{const e=z.trim().toLowerCase();return e?i.filter(([,t],n)=>t.toLowerCase().includes(e)||(j[n]||"").toLowerCase().includes(e)):i},[z,i,j]),[G,W]=Rf({key:`sidebar-panels-${n}`,storage:_f}),K=D??b.map(e=>({id:e,title:r.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),Y=ie(()=>function(e,t,n=10){if(!t)return[];const r=cf(t),a=df(t);if(0===r.size&&0===a.size)return[];const o=[];for(const i of e){if(i.id===t.id||i.isFolder||i.isDeleted)continue;const e=cf(i);let n=0;for(const t of r)e.has(t)&&n++;const s=df(i);let l=0;for(const t of a)s.has(t)&&l++;(n>0||l>0)&&o.push({document:i,sharedKeywordCount:n,sharedTagCount:l})}return o.sort((e,t)=>{const n=e.sharedKeywordCount+5*e.sharedTagCount,r=t.sharedKeywordCount+5*t.sharedTagCount;return r!==n?r-n:e.document.title.localeCompare(t.document.title)}),o.slice(0,n)}(r,o),[r,o]),X=({document:e,sharedKeywordCount:t,sharedTagCount:n})=>/* @__PURE__ */me("div",{className:"group flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer transition-colors hover:bg-sidebar-accent",onClick:()=>V(e.id),children:[
234
+ return pe("input",{type:t,"data-slot":"input",className:Dl("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground flex h-11 w-full min-w-0 rounded-2xl border bg-card px-3 py-1 text-sm font-medium transition-[color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","focus:outline-none focus:ring-2 focus:ring-primary/50","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function bf(...e){return e.filter(Boolean).join(" ")}var xf=X(function(e,t){const{className:n,style:r,children:a,defaultSize:o,size:i,minSize:s,maxSize:l,...c}=e,d={position:"relative",outline:"none",overflow:"auto",flex:"none",...r},u=bf("split-pane-pane",n);return pe("div",{ref:t,className:u,style:d,"data-pane":"true",...c,children:a})});function wf(e,t="polite"){if("undefined"==typeof document)return;const n=document.createElement("div");n.setAttribute("role","status"),n.setAttribute("aria-live",t),n.setAttribute("aria-atomic","true"),n.style.position="absolute",n.style.left="-10000px",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n.textContent=e,document.body.appendChild(n),setTimeout(()=>{document.body.removeChild(n)},1e3)}function Sf(e){return 1e3>e?Math.round(e)+" pixels":Math.round(e/10)/100+" thousand pixels"}function kf(e){const{direction:t,index:n,isDragging:r,disabled:a,onPointerDown:o,onKeyDown:i,className:s,style:l,currentSize:c,minSize:d,maxSize:u,children:h}=e,p="horizontal"===t?"vertical":"horizontal",m={flex:"none",position:"relative",userSelect:"none",touchAction:"none",..."horizontal"===t?{width:"1px",cursor:a?"default":"col-resize"}:{height:"1px",cursor:a?"default":"row-resize"},...r&&{cursor:"horizontal"===t?"col-resize":"row-resize"},...l},f=bf("split-pane-divider",t,r&&"dragging",s),g=function(e,t){return`${"horizontal"===t?"vertical":"horizontal"} divider ${e+1}`}(n,t);return pe("div",{role:"separator","aria-orientation":p,"aria-label":g,"aria-valuenow":c,"aria-valuemin":d,"aria-valuemax":void 0===u||u===1/0?void 0:u,"aria-description":function(e){return`Use ${"horizontal"===e?"left and right arrow keys":"up and down arrow keys"} to resize. Hold Shift for larger steps. Press Home or End to minimize or maximize.`}(t),tabIndex:a?-1:0,className:f,style:m,onPointerDown:a?void 0:o,onKeyDown:a?void 0:i,"data-divider-index":n,children:h})}function Cf(e,t){if("number"==typeof e)return e;if(e.endsWith("%"))return parseFloat(e)/100*t;if(e.endsWith("px"))return parseFloat(e);const n=parseFloat(e);return isNaN(n)?0:n}function Nf(e,t,n){return Math.min(Math.max(e,t),n)}function Tf(e,t,n,r,a){const o=[...e],i=e[t]??0,s=e[t+1]??0,l=r[t+1]??0,c=a[t+1]??1/0;let d=Nf(i+n,r[t]??0,a[t]??1/0),u=Nf(s-n,l,c);const h=s-u,p=Math.min(Math.abs(d-i),Math.abs(h));return n>0?(d=i+p,u=s-p):(d=i-p,u=s+p),o[t]=d,o[t+1]=u,o}function Af(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,snapPoints:o=[],snapTolerance:i=10,step:s,onResizeStart:l,onResize:c,onResizeEnd:d}=e,[u,h]=le(!1),[p,m]=le(n),f=se(null),g=se(null),v=se(!0),y=se(null),b=se(p);b.current=p;const x=se(d);x.current=d;const w=se(n);te(()=>{u||JSON.stringify(n)===JSON.stringify(w.current)||(w.current=n,m(n))},[n,u]),te(()=>(v.current=!0,()=>{v.current=!1,g.current&&(cancelAnimationFrame(g.current),g.current=null)}),[]);const S=Q((e,n)=>{if(!f.current||!v.current)return;const{dividerIndex:l,startPosition:d,startSizes:u,pointerType:h}=f.current;let p=("horizontal"===t?e:n)-d;s&&(p=function(e,t){return t>0?Math.round(e/t)*t:e}(p,s));let g=Tf(u,l,p,r,a);o.length>0&&(g=g.map(e=>function(e,t,n){for(const r of t)if(n>=Math.abs(e-r))return r;return e}(e,o,i))),m(g),c&&c(g,{sizes:g,source:"pointer",pointerType:h})},[t,s,r,a,o,i,c]),k=Q(e=>{f.current&&e.pointerId===f.current.pointerId&&(e.preventDefault(),y.current={x:e.clientX,y:e.clientY},g.current||(g.current=requestAnimationFrame(()=>{g.current=null,v.current&&y.current&&S(y.current.x,y.current.y)})))},[S]),C=Q(e=>{if(!f.current||e.pointerId!==f.current.pointerId)return;const{element:t,pointerId:n,pointerType:r}=f.current;t?.hasPointerCapture?.(n)&&t.releasePointerCapture(n),g.current&&(cancelAnimationFrame(g.current),g.current=null),h(!1);const a=b.current,o=x.current;o&&o(a,{sizes:a,source:"pointer",pointerType:r}),f.current=null},[]),N=Q(e=>n=>{n.preventDefault();const r="horizontal"===t?n.clientX:n.clientY,a=n.currentTarget;a.setPointerCapture(n.pointerId);const o=n.pointerType;f.current={dividerIndex:e,startPosition:r,startSizes:p,pointerId:n.pointerId,pointerType:o,element:a},h(!0),l&&l({sizes:p,source:"pointer",pointerType:o,originalEvent:n.nativeEvent})},[t,p,l]);return te(()=>{if(u)return document.addEventListener("pointermove",k),document.addEventListener("pointerup",C),document.addEventListener("pointercancel",C),()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",C),document.removeEventListener("pointercancel",C)}},[u,k,C]),{isDragging:u,currentSizes:p,handlePointerDown:N}}var If=10,Mf=50;function Df(e){const{direction:t,sizes:n,minSizes:r,maxSizes:a,step:o=If,largeStep:i=Mf,onResize:s,onResizeEnd:l}=e,c=se(null);return{handleKeyDown:Q(e=>d=>{if(!("horizontal"===t?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"]).includes(d.key)&&"Home"!==d.key&&"End"!==d.key&&"Escape"!==d.key)return;if(d.preventDefault(),"Escape"===d.key){if(c.current){const e=c.current;c.current=null,s&&s(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(e,{sizes:e,source:"keyboard",originalEvent:d.nativeEvent}),wf("Pane sizes restored")}return}null===c.current&&(c.current=[...n]);let u=0,h=[...n],p="arrow";switch(d.key){case"ArrowLeft":case"ArrowUp":u=-(d.shiftKey?i:o);break;case"ArrowRight":case"ArrowDown":u=d.shiftKey?i:o;break;case"Home":{p="home";const t=e+1,a=r[e]??0,o=(n[e]??0)+(n[t]??0);h[e]=a,h[t]=o-a;break}case"End":{p="end";const t=e,o=e+1,i=(n[t]??0)+(n[o]??0);h[t]=Math.min(a[t]??1/0,i-(r[o]??0)),h[o]=i-h[t];break}}if(0!==u&&(h=Tf(n,e,u,r,a)),h=h.map((e,t)=>Nf(e,r[t]??0,a[t]??1/0)),s&&s(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),l&&l(h,{sizes:h,source:"keyboard",originalEvent:d.nativeEvent}),"home"===p)wf(`Pane ${e+1} minimized to ${Sf(h[e]??0)}`);else if("end"===p)wf(`Pane ${e+1} maximized to ${Sf(h[e]??0)}`);else{const t=u>0?e:e+1;wf(`Pane ${t+1} resized to ${Sf(h[t]??0)}`)}},[t,n,r,a,o,i,s,l])}}function Ef(e){const{direction:t="horizontal",resizable:n=!0,snapPoints:r,snapTolerance:a=10,step:o,onResizeStart:i,onResize:s,onResizeEnd:l,className:c,style:d,divider:u,dividerStyle:h,dividerClassName:p,dividerSize:m=1,children:f}=e,g=se(null),[v,y]=le(0),b=se(0),x=ie(()=>U.toArray(f).filter(e=>"object"==typeof e&&null!==e&&"props"in e).map(e=>({props:e.props,size:e.props.size,defaultSize:e.props.defaultSize,minSize:e.props.minSize??0,maxSize:e.props.maxSize??1/0})),[f]),w=x.length,S=se(!1);2>w&&!S.current&&(S.current=!0);const{minSizes:k,maxSizes:C}=ie(()=>{if(0===v)return{minSizes:Array(w).fill(0),maxSizes:Array(w).fill(1/0)};const e=[],t=[];return x.forEach(n=>{e.push(Cf(n.minSize,v)),t.push(n.maxSize===1/0?1/0:Cf(n.maxSize,v))}),{minSizes:e,maxSizes:t}},[v,w,x]),N=Q(e=>{if(0===e)return Array(w).fill(0);const t=e-m*(w-1),n=x.map(e=>{const n=e.size??e.defaultSize;return void 0!==n?Cf(n,t):null}),r=n.reduce((e,t)=>e+(t??0),0),a=n.filter(e=>null===e).length,o=a>0?(t-r)/a:0;return n.map(e=>null===e?o:e)},[w,x,m]),[T,A]=le(()=>N(v));te(()=>{if(0===v)return;if(!x.some(e=>void 0!==e.size))return;const e=N(v);A(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[v,x,N]);const I=Q(e=>{const t=b.current;if(b.current=e,0===e)return;const n=x.some(e=>void 0!==e.size),r=e-m*(w-1);A(a=>a.every(e=>0===e)||a.length!==w?N(e):t>0&&t!==e?n?N(e):function(e,t){const n=e.reduce((e,t)=>e+t,0);if(0===n){const n=t/e.length;return e.map(()=>n)}return e.map(e=>e/n*t)}(a,r):0===t?N(e):a)},[w,x,N,m]),M=se(0);te(()=>{const e=g.current;if(!e)return;const n=new ResizeObserver(e=>{const n=e[0];n&&(e=>{const n=Math.round("horizontal"===t?e.width:e.height);n>0&&n!==M.current&&(M.current=n,y(n),I(n))})(n.contentRect)});return n.observe(e),()=>{n.disconnect()}},[t,I]);const D=Q((e,t)=>{A(e),s?.(e,t)},[s]),{isDragging:E,currentSizes:R,handlePointerDown:_}=Af({direction:t,sizes:T,minSizes:k,maxSizes:C,snapPoints:r,snapTolerance:a,step:o,onResizeStart:i,onResize:D,onResizeEnd:l}),{handleKeyDown:z}=Df({direction:t,sizes:R,minSizes:k,maxSizes:C,step:o,onResize:D,onResizeEnd:l}),P=Q(e=>t=>{const n={...t,pointerId:1,pointerType:"mouse",nativeEvent:t.nativeEvent};_(e)(n)},[_]),O=Q(e=>t=>{const n=t.touches[0];if(!n)return;const r={...t,clientX:n.clientX,clientY:n.clientY,pointerId:n.identifier,pointerType:"touch",nativeEvent:t.nativeEvent};_(e)(r)},[_]),L=Q(()=>{},[]),F={display:"flex",flexDirection:"horizontal"===t?"row":"column",height:"100%",width:"100%",overflow:"hidden",position:"relative",...d},B=bf("split-pane",t,c);return pe("div",{ref:g,className:B,style:F,children:v>0&&(()=>{if(2>w)return null;const e=[];return x.forEach((r,a)=>{const o=R[a]??0,i={..."horizontal"===t?{width:o+"px",height:"100%"}:{height:o+"px",width:"100%"},...r.props.style};if(e.push(pe(xf,{...r.props,style:i,children:r.props.children},"pane-"+a)),w-1>a){const r=k[a],i=C[a];e.push(pe(u??kf,{direction:t,index:a,isDragging:E,disabled:!n,onPointerDown:_(a),onMouseDown:P(a),onTouchStart:O(a),onTouchEnd:L,onKeyDown:z(a),className:p,style:h,currentSize:o,minSize:r,maxSize:i===1/0?void 0:i},"divider-"+a))}}),e})()})}function Rf(e){const{key:t,storage:n=localStorage,debounce:r=300}=e,[a,o]=le(()=>{try{const e=n.getItem(t);return e?JSON.parse(e):[]}catch{return[]}});return te(()=>{if(0===a.length)return;const e=setTimeout(()=>{try{n.setItem(t,JSON.stringify(a))}catch(e){}},r);return()=>clearTimeout(e)},[a,t,n,r]),[a,o]}var _f="undefined"==typeof window?{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},key:()=>null,length:0}:window.localStorage,zf=({panels:e,split:t,persistenceKey:n,activeDocuments:r,activeId:a,activeDocument:o,headings:i=[],isMobile:s,onSelect:l,onAdd:c,onDelete:d,onDuplicate:u,onMove:h,onManageTags:p,onRename:m,onOpenChange:f,treeRef:g,outlineRef:v,editorRef:y,openTabs:b=[],activeTab:x,onTabChange:w,onTabClose:S,onTabRename:k,onSplitRight:C,onReopenLastClosed:N,canReopenLastClosed:T=!1,onNavigate:A,aiProps:I,tipsProps:M,topicsProps:D,tabItems:E,onNewChat:R})=>{const[_,z]=le(null),[P,O]=le(""),L=se(null),F=se(null),B=g??L,V=v??F,$=e=>{l(e),s&&f&&f(!1)},H=e=>{p?.(e),s&&f&&f(!1)},q=Q(e=>{z(e)},[]),j=Q(e=>{_&&u(_)},[_,u]),U=ie(()=>{const e=o?.content||"";if(!e)return[];const t=(new DOMParser).parseFromString(e,"text/html"),n=[];let r="",a=-1;for(const o of Array.from(t.body.children))/^h[1-6]$/i.test(o.tagName)?(a>=0&&(n[a]=r),a++,r=""):a>=0&&(r+=" "+(o.textContent||""));return a>=0&&(n[a]=r),n},[o?.content]),G=ie(()=>{const e=P.trim().toLowerCase();return e?i.filter(([,t],n)=>t.toLowerCase().includes(e)||(U[n]||"").toLowerCase().includes(e)):i},[P,i,U]),[W,K]=Rf({key:`sidebar-panels-${n}`,storage:_f}),Y=E??b.map(e=>({id:e,title:r.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),X=ie(()=>function(e,t,n=10){if(!t)return[];const r=cf(t),a=df(t);if(0===r.size&&0===a.size)return[];const o=[];for(const i of e){if(i.id===t.id||i.isFolder||i.isDeleted)continue;const e=cf(i);let n=0;for(const t of r)e.has(t)&&n++;const s=df(i);let l=0;for(const t of a)s.has(t)&&l++;(n>0||l>0)&&o.push({document:i,sharedKeywordCount:n,sharedTagCount:l})}return o.sort((e,t)=>{const n=e.sharedKeywordCount+5*e.sharedTagCount,r=t.sharedKeywordCount+5*t.sharedTagCount;return r!==n?r-n:e.document.title.localeCompare(t.document.title)}),o.slice(0,n)}(r,o),[r,o]),Z=({document:e,sharedKeywordCount:t,sharedTagCount:n})=>/* @__PURE__ */me("div",{className:"group flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer transition-colors hover:bg-sidebar-accent",onClick:()=>$(e.id),children:[
235
235
  /* @__PURE__ */pe(Ze,{className:"shrink-0 h-4 w-4 text-muted-foreground"}),
236
236
  /* @__PURE__ */pe("span",{className:"flex-1 truncate text-sm",children:e.title}),n>0&&/* @__PURE__ */me("span",{className:"shrink-0 flex items-center gap-0.5 text-xs text-muted-foreground",title:`${n} shared tag${1===n?"":"s"}`,children:[/* @__PURE__ */pe(xt,{className:"h-3 w-3"}),n]}),
237
- /* @__PURE__ */pe("span",{className:"shrink-0 text-xs text-muted-foreground",title:`${t} shared keyword${1===t?"":"s"}`,children:t})]},e.id),Z=e=>{switch(e){case"files":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */pe(tf,{ref:F,documents:r,activeId:a,onSelect:V,onMove:h,onRename:m,onDelete:d,onDuplicate:u,onAddChild:e=>c(e,!1),onAddChildFolder:e=>c(e,!0),onAddSibling:e=>{c(r.find(t=>t.id===e)?.parentId||null,!1)},onAddSiblingFolder:e=>{c(r.find(t=>t.id===e)?.parentId||null,!0)},onCopy:H,onPaste:q,onManageTags:$})});case"openTabs":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */me("div",{className:"px-1 py-1",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between px-2 py-1",children:[/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Open Tabs"}),/* @__PURE__ */me("div",{className:"flex items-center gap-0.5",children:[/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New File",onClick:()=>c(null,!1),children:/* @__PURE__ */pe(Be,{className:"h-3.5 w-3.5"})}),E&&/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New Chat",onClick:E,children:/* @__PURE__ */pe(at,{className:"h-3.5 w-3.5"})})]})]}),0===K.length?/* @__PURE__ */pe("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No open tabs"}):K.map(({id:e,title:t,kind:n})=>{const r="chat"===n;/* @__PURE__ */
237
+ /* @__PURE__ */pe("span",{className:"shrink-0 text-xs text-muted-foreground",title:`${t} shared keyword${1===t?"":"s"}`,children:t})]},e.id),J=()=>/* @__PURE__ */me("div",{className:"px-3 py-3 border-t border-sidebar-border shrink-0",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between mb-2 gap-2",children:[/* @__PURE__ */me("p",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:[/* @__PURE__ */pe(pt,{className:"h-3.5 w-3.5 text-primary"}),"Search topics"]}),D?.onGenerateTopics&&/* @__PURE__ */pe("button",{className:"shrink-0 text-xs font-medium text-primary hover:underline disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline",onClick:D.onGenerateTopics,disabled:D.isTopicsLoading,children:D.isTopicsLoading?"Generating…":D.topics?.length?"Regenerate":"Generate"})]}),D?.isTopicsLoading?/* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground",children:"Finding related searches…"}):D?.topics&&D.topics.length>0?/* @__PURE__ */pe("ul",{className:"space-y-1",children:D.topics.map((e,t)=>/* @__PURE__ */pe("li",{children:/* @__PURE__ */me("button",{type:"button",className:"w-full flex items-start gap-1.5 text-left text-xs text-muted-foreground rounded-md px-1 py-1 -mx-1 transition-colors hover:bg-sidebar-accent hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>D.onSearchTopic?.(e),disabled:!D.onSearchTopic,children:[/* @__PURE__ */pe(pt,{className:"shrink-0 h-3 w-3 mt-0.5 text-primary"}),/* @__PURE__ */pe("span",{children:e})]})},t))}):/* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground",children:'Click "Generate" for suggested searches about this page.'})]}),ee=e=>{switch(e){case"files":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */pe(tf,{ref:B,documents:r,activeId:a,onSelect:$,onMove:h,onRename:m,onDelete:d,onDuplicate:u,onAddChild:e=>c(e,!1),onAddChildFolder:e=>c(e,!0),onAddSibling:e=>{c(r.find(t=>t.id===e)?.parentId||null,!1)},onAddSiblingFolder:e=>{c(r.find(t=>t.id===e)?.parentId||null,!0)},onCopy:q,onPaste:j,onManageTags:H})});case"openTabs":/* @__PURE__ */return pe("div",{className:"h-full overflow-auto",children:/* @__PURE__ */me("div",{className:"px-1 py-1",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between px-2 py-1",children:[/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Open Tabs"}),/* @__PURE__ */me("div",{className:"flex items-center gap-0.5",children:[/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New File",onClick:()=>c(null,!1),children:/* @__PURE__ */pe(Be,{className:"h-3.5 w-3.5"})}),R&&/* @__PURE__ */pe("button",{className:"h-5 w-5 flex items-center justify-center rounded text-muted-foreground hover:bg-sidebar-accent hover:text-foreground",title:"New Chat",onClick:R,children:/* @__PURE__ */pe(at,{className:"h-3.5 w-3.5"})})]})]}),0===Y.length?/* @__PURE__ */pe("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No open tabs"}):Y.map(({id:e,title:t,kind:n})=>{const r="chat"===n;/* @__PURE__ */
238
238
  return me(qm,{children:[/* @__PURE__ */pe(jm,{children:/* @__PURE__ */me("div",{className:Dl("group flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer transition-colors hover:bg-sidebar-accent",e===x&&"bg-sidebar-accent text-blue-600 font-medium"),onClick:()=>w?.(e),children:[r?/* @__PURE__ */pe(rt,{className:"shrink-0 h-4 w-4 text-blue-500"}):/* @__PURE__ */pe(wp,{filename:t,size:16}),
239
239
  /* @__PURE__ */pe("span",{className:"flex-1 truncate text-sm",children:t}),S&&/* @__PURE__ */pe("button",{className:"shrink-0 h-4 w-4 flex items-center justify-center rounded opacity-0 group-hover:opacity-100 hover:bg-destructive/10 hover:text-destructive",onClick:t=>{t.stopPropagation(),S(e)},children:/* @__PURE__ */pe(Tt,{className:"h-3 w-3"})})]})}),/* @__PURE__ */me(Km,{children:[k&&!r&&/* @__PURE__ */me(Ym,{onClick:()=>{const n=window.prompt("Rename document",t);n?.trim()&&k(e,n.trim())},children:[/* @__PURE__ */pe(Pe,{className:"mr-2 h-4 w-4"}),"Rename"]}),S&&/* @__PURE__ */me(Ym,{onClick:()=>S(e),className:"text-destructive focus:text-destructive",children:[/* @__PURE__ */pe(Tt,{className:"mr-2 h-4 w-4"}),"Close"]}),!r&&(C||N)&&/* @__PURE__ */pe(Zm,{}),C&&!r&&/* @__PURE__ */me(Ym,{onClick:()=>C(e),children:[/* @__PURE__ */pe(yt,{className:"mr-2 h-4 w-4"}),"Split Right"]}),N&&!r&&/* @__PURE__ */me(Ym,{onClick:N,disabled:!T,children:[/* @__PURE__ */pe(ht,{className:"mr-2 h-4 w-4"}),"Reopen Last Closed"]})]})]},e)})]})});case"outline":/* @__PURE__ */return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */me("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:[/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Outline"}),/* @__PURE__ */me("div",{className:"relative",children:[
240
240
  /* @__PURE__ */pe(pt,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none"}),
241
- /* @__PURE__ */pe(yf,{value:z,onChange:e=>P(e.target.value),placeholder:"Filter headings & text…",className:"h-7 pl-7 pr-7 text-xs"}),z&&/* @__PURE__ */pe("button",{onClick:()=>P(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:/* @__PURE__ */pe(Tt,{className:"h-3 w-3"})})]})]}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-auto",children:/* @__PURE__ */pe(rf,{ref:B,headings:U,onNavigate:A,editorRef:y})})]});case"related":return(()=>{const{suggested:e,others:t}=function(e){if(0===e.length)return{suggested:null,others:[]};const[t,...n]=e;return{suggested:t,others:n}}(Y);/* @__PURE__ */
242
- return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Related"})}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-auto px-1 py-1",children:0===Y.length?/* @__PURE__ */pe("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No related documents found"}):/* @__PURE__ */me(he,{children:[e&&/* @__PURE__ */me("div",{className:"group flex items-center gap-2 px-2 py-2 mb-1 rounded-md cursor-pointer border border-primary/30 bg-accent/30 transition-all hover:border-primary hover:bg-primary/10",onClick:()=>V(e.document.id),children:[
241
+ /* @__PURE__ */pe(yf,{value:P,onChange:e=>O(e.target.value),placeholder:"Filter headings & text…",className:"h-7 pl-7 pr-7 text-xs"}),P&&/* @__PURE__ */pe("button",{onClick:()=>O(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:/* @__PURE__ */pe(Tt,{className:"h-3 w-3"})})]})]}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-auto",children:/* @__PURE__ */pe(rf,{ref:V,headings:G,onNavigate:A,editorRef:y})})]});case"related":return(()=>{const{suggested:e,others:t}=function(e){if(0===e.length)return{suggested:null,others:[]};const[t,...n]=e;return{suggested:t,others:n}}(X);/* @__PURE__ */
242
+ return me("div",{className:"h-full overflow-hidden flex flex-col",children:[
243
+ /* @__PURE__ */pe("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Related"})}),
244
+ /* @__PURE__ */pe("div",{className:"flex-1 overflow-auto px-1 py-1",children:0===X.length?/* @__PURE__ */pe("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:"No related documents found"}):/* @__PURE__ */me(he,{children:[e&&/* @__PURE__ */me("div",{className:"group flex items-center gap-2 px-2 py-2 mb-1 rounded-md cursor-pointer border border-primary/30 bg-accent/30 transition-all hover:border-primary hover:bg-primary/10",onClick:()=>$(e.document.id),children:[
243
245
  /* @__PURE__ */pe(vt,{className:"shrink-0 h-4 w-4 text-primary"}),
244
246
  /* @__PURE__ */me("div",{className:"flex-1 min-w-0",children:[/* @__PURE__ */pe("p",{className:"text-[10px] font-semibold text-primary uppercase tracking-wide",children:"Suggested next"}),/* @__PURE__ */pe("span",{className:"block truncate text-sm font-semibold",children:e.document.title})]}),e.sharedTagCount>0&&/* @__PURE__ */me("span",{className:"shrink-0 flex items-center gap-0.5 text-xs text-muted-foreground",title:`${e.sharedTagCount} shared tag${1===e.sharedTagCount?"":"s"}`,children:[/* @__PURE__ */pe(xt,{className:"h-3 w-3"}),e.sharedTagCount]}),
245
- /* @__PURE__ */pe("span",{className:"shrink-0 text-xs text-muted-foreground",title:`${e.sharedKeywordCount} shared keyword${1===e.sharedKeywordCount?"":"s"}`,children:e.sharedKeywordCount})]}),t.map(X)]})})]})})();case"ai":/* @__PURE__ */return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"AI Suggestions"})}),/* @__PURE__ */me("div",{className:"flex-1 overflow-auto flex flex-col",children:[/* @__PURE__ */pe("div",{className:M?"shrink-0":"flex-1",children:I?.isAiLoading?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6",children:/* @__PURE__ */me("div",{className:"text-center",children:[/* @__PURE__ */pe(Je,{className:"h-8 w-8 animate-spin text-muted-foreground mx-auto mb-3"}),/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Generating AI suggestion..."})]})}):I?.aiSuggestion?/* @__PURE__ */pe(vf,{originalText:I.aiSuggestion.originalText,suggestedText:I.aiSuggestion.suggestedText,onApprove:()=>I.onAiApprove?.(),onReject:()=>I.onAiReject?.(),onRegenerate:e=>I.onAiRegenerate?.(e),currentMode:I.aiSuggestion.mode,isLoading:!1}):/* @__PURE__ */pe("div",{className:"flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Select text and click the AI button to get suggestions"})})}),M&&/* @__PURE__ */me("div",{className:"px-3 py-3 border-t border-sidebar-border shrink-0",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between mb-2 gap-2",children:[/* @__PURE__ */me("p",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:[/* @__PURE__ */pe(Xe,{className:"h-3.5 w-3.5 text-primary"}),"Page tips"]}),M?.onGenerateTips&&/* @__PURE__ */pe("button",{className:"shrink-0 text-xs font-medium text-primary hover:underline disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline",onClick:M.onGenerateTips,disabled:M.isTipsLoading,children:M.isTipsLoading?"Generating…":M.tips?.length?"Regenerate":"Generate"})]}),M?.isTipsLoading?/* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground",children:"Generating tips about this page…"}):M?.tips&&M.tips.length>0?/* @__PURE__ */pe("ul",{className:"space-y-1.5",children:M.tips.map((e,t)=>/* @__PURE__ */me("li",{className:"flex items-start gap-1.5 text-xs text-muted-foreground",children:[/* @__PURE__ */pe("span",{className:"text-primary",children:"•"}),/* @__PURE__ */pe("span",{children:e})]},t))}):/* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground",children:'Click "Generate" for AI tips about this page.'})]})]})]})}};return 0===e.length?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"No panels enabled"})}):1!==e.length&&t?/* @__PURE__ */pe("div",{className:"h-full",children:/* @__PURE__ */pe(Ef,{direction:"vertical",onResize:W,children:e.map((t,n)=>/* @__PURE__ */pe(xf,{size:G?.[n]||`${Math.round(100/e.length)}%`,minSize:"0px",children:Z(t)},t))})}):/* @__PURE__ */pe("div",{className:"h-full",children:Z(e[0])})},Pf="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",Of=({documents:e,activeId:t,activeDocument:n,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onSearchFocus:d,isOpen:u,onOpenChange:h,isMobile:p,leftPanels:m,onLeftPanelsChange:f,leftSplit:g,onLeftSplitChange:v,rightPanels:y,onRightPanelsChange:b,rightSplit:x,onRightSplitChange:w,onSettingsClick:S,onRestore:k,newDocumentId:C,showDynamicIsland:N,onToggleDynamicIsland:T,activeFileSourceId:A="local-default",onFileSourceChange:I,headings:M=[],onNavigate:D,editorRef:E,openTabs:R=[],activeTab:_,onTabChange:z,onTabClose:P,onTabRename:O,onSplitRight:L,onReopenLastClosed:F,canReopenLastClosed:B=!1,aiProps:V,tipsProps:$,tabItems:H,onNewChat:q})=>{const j=e.filter(e=>e.isDeleted),U=e.filter(e=>!e.isDeleted),[G,W]=le(0),K=ie(()=>{const e=new Map(U.map(e=>[e.id,e]));let t=0;for(const n of U){if(!n.isFolder)continue;let r=1,a=n.parentId;const o=/* @__PURE__ */new Set;for(;a&&e.has(a)&&!o.has(a);)o.add(a),r++,a=e.get(a)?.parentId??null;t=Math.max(t,r)}return t},[U]);te(()=>{W(e=>Math.min(e,K))},[K]);const[Y,X]=le(!0),Z=se(null),J=se(null),[Q]=le(()=>$l()),[ee,ne]=le(()=>{const e=$l();return e.find(e=>e.id===A)||e[0]||null}),[re,ae]=le(!1);te(()=>{const e=Q.find(e=>e.id===A);e&&e.id!==ee?.id&&ne(e)},[A,ee?.id,Q]);const oe=G>0&&G>=K,ce=0===G?K>1?"Expand Level 1":"Expand All":oe?"Collapse All":`Expand Level ${G+1}`;te(()=>{if(C&&Z.current){const e=setTimeout(()=>{const e=Z.current;e&&"function"==typeof e.edit&&e.edit(C)},100);return()=>clearTimeout(e)}},[C]);const de={leftPanels:m,leftSplit:g,onLeftPanelsChange:f,onLeftSplitChange:v,rightPanels:y,rightSplit:x,onRightPanelsChange:b,onRightSplitChange:w,activeId:t,onAdd:a,onSearchFocus:d,onFileManagerOpen:()=>ae(!0),sources:Q,activeSource:ee,activeFileSourceId:A,onFileSourceChange:I,onSourceSelect:e=>{const t=Q.find(t=>t.id===e);t&&(ne(t),I?.(e))},allExpanded:oe,expandToggleLabel:ce,outlineExpanded:Y,onToggleAllExpanded:()=>{if(0===K)return;const e=G>=K?0:G+1;W(e),Z.current&&(0===e?(Z.current.cancelExpand?.(),Z.current.collapseAll()):Z.current.expandToLevel(e))},onToggleOutlineExpanded:()=>{const e=!Y;X(e),J.current&&(e?J.current.expandAll():J.current.collapseAll())},treeRef:Z,outlineRef:J,deletedDocs:j,onRestore:k,onSettingsClick:S,showDynamicIsland:N,onToggleDynamicIsland:T,isMobile:p,openTabs:R,activeTab:_,onTabChange:z,onTabClose:P,documents:e,tabItems:H},ue={panels:m,split:g,persistenceKey:"left",activeDocuments:U,activeId:t,activeDocument:n,headings:M,isMobile:p,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onOpenChange:h,treeRef:Z,outlineRef:J,editorRef:E,openTabs:R,activeTab:_,onTabChange:z,onTabClose:P,onTabRename:O,onSplitRight:L,onReopenLastClosed:F,canReopenLastClosed:B,onNavigate:D,aiProps:V,tipsProps:$,tabItems:H,onNewChat:q};return p?/* @__PURE__ */pe(El,{open:u,onOpenChange:h,children:/* @__PURE__ */pe(zl,{side:"left",className:Dl("w-80 p-0",Pf),children:/* @__PURE__ */me("aside",{className:"h-full flex flex-col",children:[
246
- /* @__PURE__ */pe(Sp,{...de}),
247
- /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(zf,{...ue})}),
248
- /* @__PURE__ */pe(ep,{open:re,onOpenChange:ae,documents:U,onSelectDocument:r})]})})}):/* @__PURE__ */me("aside",{className:Dl("h-screen w-full flex flex-col pt-14",Pf),children:[
249
- /* @__PURE__ */pe(Sp,{...de}),
250
- /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(zf,{...ue})}),
251
- /* @__PURE__ */pe(ep,{open:re,onOpenChange:ae,documents:U,onSelectDocument:r})]})},Lf=({editor:e,theme:t,setTheme:n})=>{const[r,a]=le(!1);return s(),H(),te(()=>{$.setColor("default"),a(e?.isEditable??!0)},[]),te(()=>(e&&e.on("update",()=>{a(e.isEditable)}),()=>{e&&e.off("update",()=>{a(e.isEditable)})}),[e]),null},Ff=C(S());function Bf({className:e,...t}){/* @__PURE__ */
247
+ /* @__PURE__ */pe("span",{className:"shrink-0 text-xs text-muted-foreground",title:`${e.sharedKeywordCount} shared keyword${1===e.sharedKeywordCount?"":"s"}`,children:e.sharedKeywordCount})]}),t.map(Z)]})}),D&&J()]})})();case"ai":/* @__PURE__ */return me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"px-3 py-2 border-b border-sidebar-border shrink-0",children:/* @__PURE__ */pe("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"AI Suggestions"})}),/* @__PURE__ */me("div",{className:"flex-1 overflow-auto flex flex-col",children:[/* @__PURE__ */pe("div",{className:M?"shrink-0":"flex-1",children:I?.isAiLoading?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6",children:/* @__PURE__ */me("div",{className:"text-center",children:[/* @__PURE__ */pe(Je,{className:"h-8 w-8 animate-spin text-muted-foreground mx-auto mb-3"}),/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Generating AI suggestion..."})]})}):I?.aiSuggestion?/* @__PURE__ */pe(vf,{originalText:I.aiSuggestion.originalText,suggestedText:I.aiSuggestion.suggestedText,onApprove:()=>I.onAiApprove?.(),onReject:()=>I.onAiReject?.(),onRegenerate:e=>I.onAiRegenerate?.(e),currentMode:I.aiSuggestion.mode,isLoading:!1}):/* @__PURE__ */pe("div",{className:"flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"Select text and click the AI button to get suggestions"})})}),M&&/* @__PURE__ */me("div",{className:"px-3 py-3 border-t border-sidebar-border shrink-0",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between mb-2 gap-2",children:[/* @__PURE__ */me("p",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:[/* @__PURE__ */pe(Xe,{className:"h-3.5 w-3.5 text-primary"}),"Page tips"]}),M?.onGenerateTips&&/* @__PURE__ */pe("button",{className:"shrink-0 text-xs font-medium text-primary hover:underline disabled:opacity-50 disabled:cursor-not-allowed disabled:no-underline",onClick:M.onGenerateTips,disabled:M.isTipsLoading,children:M.isTipsLoading?"Generating…":M.tips?.length?"Regenerate":"Generate"})]}),M?.isTipsLoading?/* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground",children:"Generating tips about this page…"}):M?.tips&&M.tips.length>0?/* @__PURE__ */pe("ul",{className:"space-y-1.5",children:M.tips.map((e,t)=>/* @__PURE__ */me("li",{className:"flex items-start gap-1.5 text-xs text-muted-foreground",children:[/* @__PURE__ */pe("span",{className:"text-primary",children:"•"}),/* @__PURE__ */pe("span",{children:e})]},t))}):/* @__PURE__ */pe("p",{className:"text-xs text-muted-foreground",children:'Click "Generate" for AI tips about this page.'})]})]})]})}};return 0===e.length?/* @__PURE__ */pe("div",{className:"h-full flex items-center justify-center p-6 text-center",children:/* @__PURE__ */pe("p",{className:"text-sm text-muted-foreground",children:"No panels enabled"})}):1!==e.length&&t?/* @__PURE__ */pe("div",{className:"h-full",children:/* @__PURE__ */pe(Ef,{direction:"vertical",onResize:K,children:e.map((t,n)=>/* @__PURE__ */pe(xf,{size:W?.[n]||`${Math.round(100/e.length)}%`,minSize:"0px",children:ee(t)},t))})}):/* @__PURE__ */pe("div",{className:"h-full",children:ee(e[0])})},Pf="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",Of=({documents:e,activeId:t,activeDocument:n,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onSearchFocus:d,isOpen:u,onOpenChange:h,isMobile:p,leftPanels:m,onLeftPanelsChange:f,leftSplit:g,onLeftSplitChange:v,rightPanels:y,onRightPanelsChange:b,rightSplit:x,onRightSplitChange:w,onSettingsClick:S,onRestore:k,newDocumentId:C,showDynamicIsland:N,onToggleDynamicIsland:T,activeFileSourceId:A="local-default",onFileSourceChange:I,headings:M=[],onNavigate:D,editorRef:E,openTabs:R=[],activeTab:_,onTabChange:z,onTabClose:P,onTabRename:O,onSplitRight:L,onReopenLastClosed:F,canReopenLastClosed:B=!1,aiProps:V,tipsProps:$,topicsProps:H,tabItems:q,onNewChat:j})=>{const U=e.filter(e=>e.isDeleted),G=e.filter(e=>!e.isDeleted),[W,K]=le(0),Y=ie(()=>{const e=new Map(G.map(e=>[e.id,e]));let t=0;for(const n of G){if(!n.isFolder)continue;let r=1,a=n.parentId;const o=/* @__PURE__ */new Set;for(;a&&e.has(a)&&!o.has(a);)o.add(a),r++,a=e.get(a)?.parentId??null;t=Math.max(t,r)}return t},[G]);te(()=>{K(e=>Math.min(e,Y))},[Y]);const[X,Z]=le(!0),J=se(null),Q=se(null),[ee]=le(()=>$l()),[ne,re]=le(()=>{const e=$l();return e.find(e=>e.id===A)||e[0]||null}),[ae,oe]=le(!1);te(()=>{const e=ee.find(e=>e.id===A);e&&e.id!==ne?.id&&re(e)},[A,ne?.id,ee]);const ce=W>0&&W>=Y,de=0===W?Y>1?"Expand Level 1":"Expand All":ce?"Collapse All":`Expand Level ${W+1}`;te(()=>{if(C&&J.current){const e=setTimeout(()=>{const e=J.current;e&&"function"==typeof e.edit&&e.edit(C)},100);return()=>clearTimeout(e)}},[C]);const ue={leftPanels:m,leftSplit:g,onLeftPanelsChange:f,onLeftSplitChange:v,rightPanels:y,rightSplit:x,onRightPanelsChange:b,onRightSplitChange:w,activeId:t,onAdd:a,onSearchFocus:d,onFileManagerOpen:()=>oe(!0),sources:ee,activeSource:ne,activeFileSourceId:A,onFileSourceChange:I,onSourceSelect:e=>{const t=ee.find(t=>t.id===e);t&&(re(t),I?.(e))},allExpanded:ce,expandToggleLabel:de,outlineExpanded:X,onToggleAllExpanded:()=>{if(0===Y)return;const e=W>=Y?0:W+1;K(e),J.current&&(0===e?(J.current.cancelExpand?.(),J.current.collapseAll()):J.current.expandToLevel(e))},onToggleOutlineExpanded:()=>{const e=!X;Z(e),Q.current&&(e?Q.current.expandAll():Q.current.collapseAll())},treeRef:J,outlineRef:Q,deletedDocs:U,onRestore:k,onSettingsClick:S,showDynamicIsland:N,onToggleDynamicIsland:T,isMobile:p,openTabs:R,activeTab:_,onTabChange:z,onTabClose:P,documents:e,tabItems:q},he={panels:m,split:g,persistenceKey:"left",activeDocuments:G,activeId:t,activeDocument:n,headings:M,isMobile:p,onSelect:r,onAdd:a,onDelete:o,onDuplicate:i,onMove:s,onManageTags:l,onRename:c,onOpenChange:h,treeRef:J,outlineRef:Q,editorRef:E,openTabs:R,activeTab:_,onTabChange:z,onTabClose:P,onTabRename:O,onSplitRight:L,onReopenLastClosed:F,canReopenLastClosed:B,onNavigate:D,aiProps:V,tipsProps:$,topicsProps:H,tabItems:q,onNewChat:j};return p?/* @__PURE__ */pe(El,{open:u,onOpenChange:h,children:/* @__PURE__ */pe(zl,{side:"left",className:Dl("w-80 p-0",Pf),children:/* @__PURE__ */me("aside",{className:"h-full flex flex-col",children:[
248
+ /* @__PURE__ */pe(Sp,{...ue}),
249
+ /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(zf,{...he})}),
250
+ /* @__PURE__ */pe(ep,{open:ae,onOpenChange:oe,documents:G,onSelectDocument:r})]})})}):/* @__PURE__ */me("aside",{className:Dl("h-screen w-full flex flex-col pt-14",Pf),children:[
251
+ /* @__PURE__ */pe(Sp,{...ue}),
252
+ /* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden",children:/* @__PURE__ */pe(zf,{...he})}),
253
+ /* @__PURE__ */pe(ep,{open:ae,onOpenChange:oe,documents:G,onSelectDocument:r})]})},Lf=({editor:e,theme:t,setTheme:n})=>{const[r,a]=le(!1);return s(),H(),te(()=>{$.setColor("default"),a(e?.isEditable??!0)},[]),te(()=>(e&&e.on("update",()=>{a(e.isEditable)}),()=>{e&&e.off("update",()=>{a(e.isEditable)})}),[e]),null},Ff=C(S());function Bf({className:e,...t}){/* @__PURE__ */
252
254
  return pe(m,{"data-slot":"avatar",className:Dl("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function Vf({className:e,...t}){/* @__PURE__ */
253
255
  return pe(g,{"data-slot":"avatar-image",className:Dl("aspect-square size-full",e),...t})}function $f({className:e,...t}){/* @__PURE__ */
254
256
  return pe(u,{"data-slot":"avatar-fallback",className:Dl("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}function Hf({className:e,...t}){/* @__PURE__ */
@@ -268,7 +270,7 @@ return me("div",{className:"flex h-full w-full flex-col bg-editor-bg",children:[
268
270
  /* @__PURE__ */pe("h2",{className:"text-2xl font-serif font-semibold text-foreground mb-2",children:"No Note Selected"}),
269
271
  /* @__PURE__ */pe("p",{className:"text-muted-foreground",children:a?"Tap the menu to select a note":"Select a note from the sidebar or create a new one"})]})});if(n&&n!==r){const r=t.find(e=>e.id===n);/* @__PURE__ */
270
272
  return pe("div",{className:"flex-1 h-full",children:/* @__PURE__ */me(Ef,{direction:"horizontal",children:[/* @__PURE__ */pe(xf,{minSize:"300px",children:/* @__PURE__ */pe("div",{className:"flex flex-col h-full border-r border-border",children:/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(yw,{ref:o,contentKey:e.id,content:e.content,onChange:t=>i(e.id,{content:t}),title:e.title,onTitleChange:t=>i(e.id,{title:t}),scrollToHeading:()=>{},onHeadingsChange:s,aiSuggestion:c,isAiLoading:d,onAiRewrite:u,onAiApprove:h,onAiReject:p,onAiRegenerate:m,onInviteClick:f,onShareClick:g,documentId:e.id})})})}),/* @__PURE__ */pe(xf,{minSize:"300px",children:/* @__PURE__ */pe("div",{className:"flex flex-col h-full",children:r?/* @__PURE__ */me(he,{children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-muted/30",children:[/* @__PURE__ */pe("span",{className:"text-sm font-medium",children:r.title}),/* @__PURE__ */pe(np,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:l,title:"Close split view",children:/* @__PURE__ */pe(Tt,{className:"h-3 w-3"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(yw,{content:r.content,onChange:e=>i(r.id,{content:e}),title:r.title,onTitleChange:e=>i(r.id,{title:e}),scrollToHeading:()=>{},onInviteClick:f,onShareClick:g,documentId:r.id})})]}):null})})]})})}/* @__PURE__ */
271
- return pe("div",{className:"h-full flex flex-col",children:/* @__PURE__ */pe(yw,{ref:o,contentKey:e.id,content:e.content,onChange:t=>i(e.id,{content:t}),title:e.title,onTitleChange:t=>i(e.id,{title:t}),scrollToHeading:()=>{},onHeadingsChange:s,aiSuggestion:c,isAiLoading:d,onAiRewrite:u,onAiApprove:h,onAiReject:p,onAiRegenerate:m,onInviteClick:f,onShareClick:g,documentId:e.id})})}yw.displayName="TiptapEditorWrapper";var xw="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",ww={top:!1,right:!1,bottom:!1,left:!0,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},Sw=Object.fromEntries(gp.map(({type:e,label:t})=>[e,t]));function kw({panels:e,split:t,documents:n,activeId:r,activeDocument:a,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,headings:h,onNavigate:p,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,outlineRef:S,editorRef:k,tabItems:C,onNewChat:N,aiProps:T,tipsProps:A,onClose:I,isMobile:M,isOpen:D,onOpenChange:E}){const[R,_]=le(320),z=1===e.length?Sw[e[0]]:"Right Panel",P=/* @__PURE__ */me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */me("div",{className:"px-3 py-2 border-b border-sidebar-border/60 flex items-center justify-between select-none shrink-0",children:[/* @__PURE__ */pe("h3",{className:"text-sm font-semibold text-sidebar-foreground",children:z}),/* @__PURE__ */pe(np,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:I,children:/* @__PURE__ */pe(Tt,{className:"h-4 w-4"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(zf,{panels:e,split:t,persistenceKey:"right",activeDocuments:n,activeId:r,activeDocument:a,headings:h,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,outlineRef:S,editorRef:k,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,onNavigate:p,tabItems:C,onNewChat:N,aiProps:T,tipsProps:A})})]});return M?/* @__PURE__ */pe(El,{open:D,onOpenChange:E,children:/* @__PURE__ */pe(zl,{side:"right",className:Dl("w-80 p-0",xw),children:/* @__PURE__ */pe("aside",{className:"h-full flex flex-col",children:P})})}):/* @__PURE__ */pe($t,{size:{width:R,height:"100%"},onResizeStop:(e,t,n)=>_(n.offsetWidth),minWidth:260,maxWidth:640,enable:ww,className:Dl("h-full flex flex-col border-l shrink-0",xw),children:P})}function Cw({className:e,children:t,...n}){/* @__PURE__ */
273
+ return pe("div",{className:"h-full flex flex-col",children:/* @__PURE__ */pe(yw,{ref:o,contentKey:e.id,content:e.content,onChange:t=>i(e.id,{content:t}),title:e.title,onTitleChange:t=>i(e.id,{title:t}),scrollToHeading:()=>{},onHeadingsChange:s,aiSuggestion:c,isAiLoading:d,onAiRewrite:u,onAiApprove:h,onAiReject:p,onAiRegenerate:m,onInviteClick:f,onShareClick:g,documentId:e.id})})}yw.displayName="TiptapEditorWrapper";var xw="bg-white/10 dark:bg-black/20 backdrop-blur-md border-white/15 dark:border-white/10",ww={top:!1,right:!1,bottom:!1,left:!0,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},Sw=Object.fromEntries(gp.map(({type:e,label:t})=>[e,t]));function kw({panels:e,split:t,documents:n,activeId:r,activeDocument:a,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,headings:h,onNavigate:p,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,outlineRef:S,editorRef:k,tabItems:C,onNewChat:N,aiProps:T,tipsProps:A,topicsProps:I,onClose:M,isMobile:D,isOpen:E,onOpenChange:R}){const[_,z]=le(320),P=1===e.length?Sw[e[0]]:"Right Panel",O=/* @__PURE__ */me("div",{className:"h-full overflow-hidden flex flex-col",children:[/* @__PURE__ */me("div",{className:"px-3 py-2 border-b border-sidebar-border/60 flex items-center justify-between select-none shrink-0",children:[/* @__PURE__ */pe("h3",{className:"text-sm font-semibold text-sidebar-foreground",children:P}),/* @__PURE__ */pe(np,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:M,children:/* @__PURE__ */pe(Tt,{className:"h-4 w-4"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 min-h-0",children:/* @__PURE__ */pe(zf,{panels:e,split:t,persistenceKey:"right",activeDocuments:n,activeId:r,activeDocument:a,headings:h,onSelect:o,onAdd:i,onDelete:s,onDuplicate:l,onMove:c,onManageTags:d,onRename:u,outlineRef:S,editorRef:k,openTabs:m,activeTab:f,onTabChange:g,onTabClose:v,onTabRename:y,onSplitRight:b,onReopenLastClosed:x,canReopenLastClosed:w,onNavigate:p,tabItems:C,onNewChat:N,aiProps:T,tipsProps:A,topicsProps:I})})]});return D?/* @__PURE__ */pe(El,{open:E,onOpenChange:R,children:/* @__PURE__ */pe(zl,{side:"right",className:Dl("w-80 p-0",xw),children:/* @__PURE__ */pe("aside",{className:"h-full flex flex-col",children:O})})}):/* @__PURE__ */pe($t,{size:{width:_,height:"100%"},onResizeStop:(e,t,n)=>z(n.offsetWidth),minWidth:260,maxWidth:640,enable:ww,className:Dl("h-full flex flex-col border-l shrink-0",xw),children:O})}function Cw({className:e,children:t,...n}){/* @__PURE__ */
272
274
  return me(Al,{"data-slot":"scroll-area",className:Dl("relative",e),...n,children:[
273
275
  /* @__PURE__ */pe(Il,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&>div]:!block",children:t}),
274
276
  /* @__PURE__ */pe(Nw,{}),
@@ -453,8 +455,8 @@ return me(he,{children:[/* @__PURE__ */pe(sD,{children:s&&/* @__PURE__ */pe(IE.d
453
455
  /* @__PURE__ */pe("div",{className:"h-2 w-2 shrink-0 rounded-full bg-foreground"}),
454
456
  /* @__PURE__ */pe("div",{className:"relative flex h-full flex-1 items-center overflow-hidden text-left",children:/* @__PURE__ */pe(sD,{mode:"popLayout",initial:!1,children:/* @__PURE__ */pe(IE.span,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},exit:{opacity:0,y:-15},transition:{duration:.35,ease:[.16,1,.3,1]},className:"block w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium text-foreground",children:f},r??"empty")})}),
455
457
  /* @__PURE__ */pe(DE,{percentage:c})]}),/* @__PURE__ */me(IE.div,{initial:!1,animate:{opacity:s?1:0,scale:s?1:1.05},transition:{...ME,delay:s?.1:0},className:Dl("absolute inset-0 flex flex-col",!s&&"pointer-events-none"),children:[/* @__PURE__ */me("div",{className:"flex shrink-0 items-center justify-between px-6 pb-3 pt-5",children:[/* @__PURE__ */pe("span",{className:"text-[11px] font-semibold tracking-[0.08em] text-muted-foreground",children:"TABLE OF CONTENTS"}),/* @__PURE__ */pe("button",{onClick:e=>{e.stopPropagation(),l(!1)},className:"text-muted-foreground transition-colors hover:text-foreground",children:/* @__PURE__ */pe(Tt,{className:"h-5 w-5"})})]}),/* @__PURE__ */pe("div",{className:"flex-1 overflow-y-auto px-3 pb-4",children:/* @__PURE__ */pe("div",{className:"flex flex-col gap-0.5",children:e.map(([e,n,a])=>{const s=parseInt(a[1],10),c=r===e,d=o===e,u=14*Math.max(0,s-m)+12;/* @__PURE__ */
456
- return me("button",{onMouseEnter:()=>i(e),onMouseLeave:()=>i(null),onClick:n=>{n.stopPropagation(),t(e),l(!1)},style:{paddingLeft:`${u}px`},className:Dl("group flex w-full shrink-0 cursor-pointer items-center rounded-lg border-none py-2 pr-3 text-left text-sm transition-all duration-300 ease-out",c&&"bg-foreground/10 font-medium text-foreground",!c&&d&&"bg-foreground/5 text-foreground/85",!c&&!d&&"bg-transparent text-foreground/45"),children:[/* @__PURE__ */pe("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap transition-transform duration-300 group-hover:translate-x-1",children:n}),/* @__PURE__ */pe(IE.div,{initial:!1,animate:{scale:c?1:0,opacity:c?1:0},transition:{duration:.3,ease:"easeOut"},className:"ml-3 h-1.5 w-1.5 shrink-0 rounded-full bg-foreground"})]},e)})})})]})]})})]})}var RE=({mainContent:e,belowMainContent:t,openFilesSidebarSignal:n,extraTabs:r,activeExtraTabId:a,onExtraTabSelect:o,onExtraTabClose:i,onExtraTabAdd:s,onFileTabSelect:l,initialDocId:c,onActiveDocumentChange:d,onGenerateTips:u})=>{const{theme:h,setTheme:p}=Xw(),m=VS(n),[f,g]=le(void 0),[v,y]=le([]),[b,x]=le(!1),w=se(!1);te(()=>{!w.current&&c&&m.documents.some(e=>e.id===c)&&(w.current=!0,c!==m.activeDocId&&m.handleSelectDocument(c))},[c,m.documents,m.activeDocId,m.handleSelectDocument]),te(()=>{d?.(m.activeDocId)},[m.activeDocId,d]),te(()=>{y([])},[m.activeDocId]);const S=u?{tips:v,isTipsLoading:b,onGenerateTips:async()=>{if(u&&m.activeDocument){x(!0);try{const e=await u(m.activeDocument.title,m.activeDocument.content||"");y(e)}catch{y([])}finally{x(!1)}}}}:void 0,[k,C]=Rf({key:"reason-docs-sidebar",storage:_f}),N=ie(()=>{const e=m.openTabs.map(e=>({id:e,title:m.documents.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),t=(r??[]).map(e=>({id:e.id,title:e.title,kind:e.kind}));return[...e,...t]},[m.openTabs,m.documents,r]),T=a??m.activeDocId,A=e=>{r?.some(t=>t.id===e)?o?.(e):(m.handleTabChange(e),l?.())},I=e=>{r?.some(t=>t.id===e)?i?.(e):m.handleTabClose(e)},M=(e,t)=>{m.handleAddDocument(e,t),t||l?.()},D=e=>{m.handleSelectDocument(e),l?.()},E={documents:m.documents,activeId:m.activeDocId,activeDocument:m.activeDocument,onSelect:D,onAdd:M,onDelete:m.handleDeleteDocument,onDuplicate:m.handleDuplicateDocument,onToggleExpand:m.handleToggleExpand,onMove:m.handleMoveDocument,onManageTags:m.handleManageTags,onRename:(e,t)=>m.handleUpdateDocument(e,{title:t}),searchQuery:m.searchQuery,onSearchChange:m.setSearchQuery,onSearchClear:()=>m.setSearchQuery(""),onSearchFocus:()=>m.setIsSearchModalOpen(!0),isOpen:m.isSidebarOpen,onOpenChange:m.setIsSidebarOpen,isMobile:m.isMobile,leftPanels:m.leftPanels,onLeftPanelsChange:m.setLeftPanels,leftSplit:m.leftSplit,onLeftSplitChange:m.setLeftSplit,rightPanels:m.rightPanels,onRightPanelsChange:m.setRightPanels,rightSplit:m.rightSplit,onRightSplitChange:m.setRightSplit,onSettingsClick:e=>{g(e),m.setIsSettingsOpen(!0)},onInviteClick:()=>m.setIsInviteModalOpen(!0),onRestore:m.handleRestoreDocument,onPermanentDelete:m.handlePermanentDelete,newDocumentId:m.newDocumentId,showDynamicIsland:m.showDynamicIsland,onToggleDynamicIsland:()=>m.setShowDynamicIsland(!m.showDynamicIsland),activeFileSourceId:m.activeFileSourceId,onFileSourceChange:m.handleFileSourceChange,onNavigate:e=>m.editorRef.current?.scrollToHeading(e),editorRef:m.editorRef,openTabs:m.openTabs,activeTab:T,onTabChange:A,onTabClose:I,onTabRename:(e,t)=>m.handleUpdateDocument(e,{title:t}),onSplitRight:m.handleSplitRight,onReopenLastClosed:m.handleReopenLastClosed,canReopenLastClosed:m.closedTabsHistory.length>0,tabItems:N,onNewChat:s,aiProps:{isAiLoading:m.isAiLoading,aiSuggestion:m.aiSuggestion,onAiApprove:m.handleAIApprove,onAiReject:m.handleAIReject,onAiRegenerate:m.handleAIRegenerate},tipsProps:S},R={activeDocument:m.activeDocument,documents:m.documents,splitViewDocId:m.splitViewDocId,activeDocId:m.activeDocId,isMobile:m.isMobile,editorRef:m.editorRef,onUpdateDocument:m.handleUpdateDocument,onHeadingsChange:m.setHeadings,onCloseSplitView:()=>m.setSplitViewDocId(null),aiSuggestion:m.aiSuggestion,isAiLoading:m.isAiLoading,onAiRewrite:m.handleAIRewrite,onAiApprove:m.handleAIApprove,onAiReject:m.handleAIReject,onAiRegenerate:m.handleAIRegenerate,onInviteClick:()=>m.setIsInviteModalOpen(!0),onShareClick:()=>m.setIsInviteModalOpen(!0)},_=m.rightPanels.length>0&&/* @__PURE__ */pe(kw,{panels:m.rightPanels,split:m.rightSplit,documents:m.documents,activeId:m.activeDocId,activeDocument:m.activeDocument,onSelect:D,onAdd:M,onDelete:m.handleDeleteDocument,onDuplicate:m.handleDuplicateDocument,onMove:m.handleMoveDocument,onManageTags:m.handleManageTags,onRename:(e,t)=>m.handleUpdateDocument(e,{title:t}),headings:m.headings,onNavigate:e=>m.editorRef.current?.scrollToHeading(e),editorRef:m.editorRef,openTabs:m.openTabs,activeTab:T,onTabChange:A,onTabClose:I,onTabRename:(e,t)=>m.handleUpdateDocument(e,{title:t}),onSplitRight:m.handleSplitRight,onReopenLastClosed:m.handleReopenLastClosed,canReopenLastClosed:m.closedTabsHistory.length>0,tabItems:N,onNewChat:s,aiProps:{isAiLoading:m.isAiLoading,aiSuggestion:m.aiSuggestion,onAiApprove:m.handleAIApprove,onAiReject:m.handleAIReject,onAiRegenerate:m.handleAIRegenerate},tipsProps:S,onClose:()=>m.setRightPanels([]),isMobile:m.isMobile,isOpen:m.isRightSidebarOpen,onOpenChange:m.setIsRightSidebarOpen});/* @__PURE__ */
457
- return me("div",{className:"h-screen w-screen flex flex-col overflow-hidden",children:[m.isMobile?/* @__PURE__ */me("div",{className:"flex-1 flex flex-col overflow-hidden",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between h-10 px-1 border-b border-sidebar-border/60 shrink-0",children:[/* @__PURE__ */pe(np,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:()=>m.setIsSidebarOpen(!0),"aria-label":"Open sidebar",children:/* @__PURE__ */pe(nt,{className:"h-5 w-5"})}),m.rightPanels.length>0&&/* @__PURE__ */pe(np,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:()=>m.setIsRightSidebarOpen(!0),"aria-label":"Open right panel",children:/* @__PURE__ */pe(ct,{className:"h-5 w-5"})})]}),/* @__PURE__ */me("div",{className:"flex-1 flex overflow-hidden",children:[
458
- /* @__PURE__ */pe(Of,{...E,headings:m.headings}),
459
- /* @__PURE__ */me("main",{className:"flex-1 overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:e??/* @__PURE__ */pe(bw,{...R})}),t&&/* @__PURE__ */pe("div",{className:"shrink-0 px-2 pt-1 pb-[60px] sm:pb-2 sm:pr-56",children:t})]}),_]})]}):/* @__PURE__ */pe("div",{className:"flex-1 overflow-hidden",children:/* @__PURE__ */me(Ef,{direction:"horizontal",onResize:C,children:[/* @__PURE__ */pe(xf,{size:k?.[0]||"250px",minSize:"0px",maxSize:"600px",children:/* @__PURE__ */pe("div",{className:"overflow-y-auto overflow-x-hidden bg-background",children:/* @__PURE__ */pe(Of,{...E,headings:m.headings})})}),/* @__PURE__ */pe(xf,{children:/* @__PURE__ */me("div",{className:"h-screen flex flex-col bg-background",children:[/* @__PURE__ */me("div",{className:"flex-1 flex min-h-0",children:[/* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-auto",children:e??/* @__PURE__ */pe(bw,{...R})}),_]}),t&&/* @__PURE__ */pe("div",{className:"shrink-0 px-2 pb-2",children:t})]})})]})}),m.headings.length>0&&0===m.rightPanels.length&&m.showDynamicIsland&&/* @__PURE__ */pe(EE,{headings:m.headings,onNavigate:e=>m.editorRef.current?.scrollToHeading(e),editorRef:m.editorRef}),
460
- /* @__PURE__ */pe(BS,{isSearchModalOpen:m.isSearchModalOpen,setIsSearchModalOpen:m.setIsSearchModalOpen,isSettingsOpen:m.isSettingsOpen,setIsSettingsOpen:m.setIsSettingsOpen,settingsInitialSection:f,isTeamsOpen:m.isTeamsOpen,setIsTeamsOpen:m.setIsTeamsOpen,isInviteModalOpen:m.isInviteModalOpen,setIsInviteModalOpen:m.setIsInviteModalOpen,isTagDialogOpen:m.isTagDialogOpen,setIsTagDialogOpen:m.setIsTagDialogOpen,documents:m.documents,activeDocument:m.activeDocument,tagManagementDocId:m.tagManagementDocId,defaultSidebarView:m.defaultSidebarView,setDefaultSidebarView:m.setDefaultSidebarView,enableDatabaseSync:m.enableDatabaseSync,setEnableDatabaseSync:m.setEnableDatabaseSync,setDocuments:m.setDocuments,onSelectDocument:D,onToggleTheme:()=>{p("dark"===h?"light":"dark")},currentTheme:h,onUpdateTags:m.handleUpdateTags})]})};export{RE as t};
458
+ return me("button",{onMouseEnter:()=>i(e),onMouseLeave:()=>i(null),onClick:n=>{n.stopPropagation(),t(e),l(!1)},style:{paddingLeft:`${u}px`},className:Dl("group flex w-full shrink-0 cursor-pointer items-center rounded-lg border-none py-2 pr-3 text-left text-sm transition-all duration-300 ease-out",c&&"bg-foreground/10 font-medium text-foreground",!c&&d&&"bg-foreground/5 text-foreground/85",!c&&!d&&"bg-transparent text-foreground/45"),children:[/* @__PURE__ */pe("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap transition-transform duration-300 group-hover:translate-x-1",children:n}),/* @__PURE__ */pe(IE.div,{initial:!1,animate:{scale:c?1:0,opacity:c?1:0},transition:{duration:.3,ease:"easeOut"},className:"ml-3 h-1.5 w-1.5 shrink-0 rounded-full bg-foreground"})]},e)})})})]})]})})]})}var RE=({mainContent:e,belowMainContent:t,openFilesSidebarSignal:n,extraTabs:r,activeExtraTabId:a,onExtraTabSelect:o,onExtraTabClose:i,onExtraTabAdd:s,onFileTabSelect:l,initialDocId:c,onActiveDocumentChange:d,onGenerateTips:u,onGenerateTopics:h,onSearchTopic:p})=>{const{theme:m,setTheme:f}=Xw(),g=VS(n),[v,y]=le(void 0),[b,x]=le([]),[w,S]=le(!1),[k,C]=le([]),[N,T]=le(!1),A=se(!1);te(()=>{!A.current&&c&&g.documents.some(e=>e.id===c)&&(A.current=!0,c!==g.activeDocId&&g.handleSelectDocument(c))},[c,g.documents,g.activeDocId,g.handleSelectDocument]),te(()=>{d?.(g.activeDocId)},[g.activeDocId,d]),te(()=>{x([]),C([])},[g.activeDocId]);const I=u?{tips:b,isTipsLoading:w,onGenerateTips:async()=>{if(u&&g.activeDocument){S(!0);try{const e=await u(g.activeDocument.title,g.activeDocument.content||"");x(e)}catch{x([])}finally{S(!1)}}}}:void 0,M=h?{topics:k,isTopicsLoading:N,onGenerateTopics:async()=>{if(h&&g.activeDocument){T(!0);try{const e=await h(g.activeDocument.title,g.activeDocument.content||"");C(e)}catch{C([])}finally{T(!1)}}},onSearchTopic:p}:void 0,[D,E]=Rf({key:"reason-docs-sidebar",storage:_f}),R=ie(()=>{const e=g.openTabs.map(e=>({id:e,title:g.documents.find(t=>t.id===e)?.title||"Untitled",kind:"file"})),t=(r??[]).map(e=>({id:e.id,title:e.title,kind:e.kind}));return[...e,...t]},[g.openTabs,g.documents,r]),_=a??g.activeDocId,z=e=>{r?.some(t=>t.id===e)?o?.(e):(g.handleTabChange(e),l?.())},P=e=>{r?.some(t=>t.id===e)?i?.(e):g.handleTabClose(e)},O=(e,t)=>{g.handleAddDocument(e,t),t||l?.()},L=e=>{g.handleSelectDocument(e),l?.()},F={documents:g.documents,activeId:g.activeDocId,activeDocument:g.activeDocument,onSelect:L,onAdd:O,onDelete:g.handleDeleteDocument,onDuplicate:g.handleDuplicateDocument,onToggleExpand:g.handleToggleExpand,onMove:g.handleMoveDocument,onManageTags:g.handleManageTags,onRename:(e,t)=>g.handleUpdateDocument(e,{title:t}),searchQuery:g.searchQuery,onSearchChange:g.setSearchQuery,onSearchClear:()=>g.setSearchQuery(""),onSearchFocus:()=>g.setIsSearchModalOpen(!0),isOpen:g.isSidebarOpen,onOpenChange:g.setIsSidebarOpen,isMobile:g.isMobile,leftPanels:g.leftPanels,onLeftPanelsChange:g.setLeftPanels,leftSplit:g.leftSplit,onLeftSplitChange:g.setLeftSplit,rightPanels:g.rightPanels,onRightPanelsChange:g.setRightPanels,rightSplit:g.rightSplit,onRightSplitChange:g.setRightSplit,onSettingsClick:e=>{y(e),g.setIsSettingsOpen(!0)},onInviteClick:()=>g.setIsInviteModalOpen(!0),onRestore:g.handleRestoreDocument,onPermanentDelete:g.handlePermanentDelete,newDocumentId:g.newDocumentId,showDynamicIsland:g.showDynamicIsland,onToggleDynamicIsland:()=>g.setShowDynamicIsland(!g.showDynamicIsland),activeFileSourceId:g.activeFileSourceId,onFileSourceChange:g.handleFileSourceChange,onNavigate:e=>g.editorRef.current?.scrollToHeading(e),editorRef:g.editorRef,openTabs:g.openTabs,activeTab:_,onTabChange:z,onTabClose:P,onTabRename:(e,t)=>g.handleUpdateDocument(e,{title:t}),onSplitRight:g.handleSplitRight,onReopenLastClosed:g.handleReopenLastClosed,canReopenLastClosed:g.closedTabsHistory.length>0,tabItems:R,onNewChat:s,aiProps:{isAiLoading:g.isAiLoading,aiSuggestion:g.aiSuggestion,onAiApprove:g.handleAIApprove,onAiReject:g.handleAIReject,onAiRegenerate:g.handleAIRegenerate},tipsProps:I,topicsProps:M},B={activeDocument:g.activeDocument,documents:g.documents,splitViewDocId:g.splitViewDocId,activeDocId:g.activeDocId,isMobile:g.isMobile,editorRef:g.editorRef,onUpdateDocument:g.handleUpdateDocument,onHeadingsChange:g.setHeadings,onCloseSplitView:()=>g.setSplitViewDocId(null),aiSuggestion:g.aiSuggestion,isAiLoading:g.isAiLoading,onAiRewrite:g.handleAIRewrite,onAiApprove:g.handleAIApprove,onAiReject:g.handleAIReject,onAiRegenerate:g.handleAIRegenerate,onInviteClick:()=>g.setIsInviteModalOpen(!0),onShareClick:()=>g.setIsInviteModalOpen(!0)},V=g.rightPanels.length>0&&/* @__PURE__ */pe(kw,{panels:g.rightPanels,split:g.rightSplit,documents:g.documents,activeId:g.activeDocId,activeDocument:g.activeDocument,onSelect:L,onAdd:O,onDelete:g.handleDeleteDocument,onDuplicate:g.handleDuplicateDocument,onMove:g.handleMoveDocument,onManageTags:g.handleManageTags,onRename:(e,t)=>g.handleUpdateDocument(e,{title:t}),headings:g.headings,onNavigate:e=>g.editorRef.current?.scrollToHeading(e),editorRef:g.editorRef,openTabs:g.openTabs,activeTab:_,onTabChange:z,onTabClose:P,onTabRename:(e,t)=>g.handleUpdateDocument(e,{title:t}),onSplitRight:g.handleSplitRight,onReopenLastClosed:g.handleReopenLastClosed,canReopenLastClosed:g.closedTabsHistory.length>0,tabItems:R,onNewChat:s,aiProps:{isAiLoading:g.isAiLoading,aiSuggestion:g.aiSuggestion,onAiApprove:g.handleAIApprove,onAiReject:g.handleAIReject,onAiRegenerate:g.handleAIRegenerate},tipsProps:I,topicsProps:M,onClose:()=>g.setRightPanels([]),isMobile:g.isMobile,isOpen:g.isRightSidebarOpen,onOpenChange:g.setIsRightSidebarOpen});/* @__PURE__ */
459
+ return me("div",{className:"h-screen w-screen flex flex-col overflow-hidden",children:[g.isMobile?/* @__PURE__ */me("div",{className:"flex-1 flex flex-col overflow-hidden",children:[/* @__PURE__ */me("div",{className:"flex items-center justify-between h-10 px-1 border-b border-sidebar-border/60 shrink-0",children:[/* @__PURE__ */pe(np,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:()=>g.setIsSidebarOpen(!0),"aria-label":"Open sidebar",children:/* @__PURE__ */pe(nt,{className:"h-5 w-5"})}),g.rightPanels.length>0&&/* @__PURE__ */pe(np,{variant:"ghost",size:"sm",className:"size-8 p-0",onClick:()=>g.setIsRightSidebarOpen(!0),"aria-label":"Open right panel",children:/* @__PURE__ */pe(ct,{className:"h-5 w-5"})})]}),/* @__PURE__ */me("div",{className:"flex-1 flex overflow-hidden",children:[
460
+ /* @__PURE__ */pe(Of,{...F,headings:g.headings}),
461
+ /* @__PURE__ */me("main",{className:"flex-1 overflow-hidden flex flex-col",children:[/* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:e??/* @__PURE__ */pe(bw,{...B})}),t&&/* @__PURE__ */pe("div",{className:"shrink-0 px-2 pt-1 pb-[60px] sm:pb-2 sm:pr-56",children:t})]}),V]})]}):/* @__PURE__ */pe("div",{className:"flex-1 overflow-hidden",children:/* @__PURE__ */me(Ef,{direction:"horizontal",onResize:E,children:[/* @__PURE__ */pe(xf,{size:D?.[0]||"250px",minSize:"0px",maxSize:"600px",children:/* @__PURE__ */pe("div",{className:"overflow-y-auto overflow-x-hidden bg-background",children:/* @__PURE__ */pe(Of,{...F,headings:g.headings})})}),/* @__PURE__ */pe(xf,{children:/* @__PURE__ */me("div",{className:"h-screen flex flex-col bg-background",children:[/* @__PURE__ */me("div",{className:"flex-1 flex min-h-0",children:[/* @__PURE__ */pe("div",{className:"flex-1 min-h-0 overflow-auto",children:e??/* @__PURE__ */pe(bw,{...B})}),V]}),t&&/* @__PURE__ */pe("div",{className:"shrink-0 px-2 pb-2",children:t})]})})]})}),g.headings.length>0&&0===g.rightPanels.length&&g.showDynamicIsland&&/* @__PURE__ */pe(EE,{headings:g.headings,onNavigate:e=>g.editorRef.current?.scrollToHeading(e),editorRef:g.editorRef}),
462
+ /* @__PURE__ */pe(BS,{isSearchModalOpen:g.isSearchModalOpen,setIsSearchModalOpen:g.setIsSearchModalOpen,isSettingsOpen:g.isSettingsOpen,setIsSettingsOpen:g.setIsSettingsOpen,settingsInitialSection:v,isTeamsOpen:g.isTeamsOpen,setIsTeamsOpen:g.setIsTeamsOpen,isInviteModalOpen:g.isInviteModalOpen,setIsInviteModalOpen:g.setIsInviteModalOpen,isTagDialogOpen:g.isTagDialogOpen,setIsTagDialogOpen:g.setIsTagDialogOpen,documents:g.documents,activeDocument:g.activeDocument,tagManagementDocId:g.tagManagementDocId,defaultSidebarView:g.defaultSidebarView,setDefaultSidebarView:g.setDefaultSidebarView,enableDatabaseSync:g.enableDatabaseSync,setEnableDatabaseSync:g.setEnableDatabaseSync,setDocuments:g.setDocuments,onSelectDocument:L,onToggleTheme:()=>{f("dark"===m?"light":"dark")},currentTheme:m,onUpdateTags:g.handleUpdateTags})]})};export{RE as t};
@@ -48,11 +48,24 @@ interface ReasonDocsProps {
48
48
  * the section is hidden entirely in that case.
49
49
  */
50
50
  onGenerateTips?: (title: string, contentHtml: string) => Promise<string[]>;
51
+ /**
52
+ * Generates short suggested search queries ("topics") related to the
53
+ * active document's content, given its title and HTML content. Powers
54
+ * the sidebar "related" panel's "Search topics" section. Omitted when
55
+ * the host app has no topics-generation capability to offer.
56
+ */
57
+ onGenerateTopics?: (title: string, contentHtml: string) => Promise<string[]>;
58
+ /**
59
+ * Runs a search for a generated topic (e.g. opens a new chat seeded with
60
+ * it as the first message). Omitted when the host app has no search
61
+ * capability to offer, hiding the "Search topics" section's click action.
62
+ */
63
+ onSearchTopic?: (topic: string) => void;
51
64
  }
52
65
  /**
53
66
  * Root application component that wires together all major UI regions.
54
67
  * Uses `useReasonDocsState` for shared state and `next-themes` for theme control.
55
68
  * Renders a resizable panel layout on desktop and a stacked layout on mobile.
56
69
  */
57
- declare const Index: ({ mainContent, belowMainContent, openFilesSidebarSignal, extraTabs, activeExtraTabId, onExtraTabSelect, onExtraTabClose, onExtraTabAdd, onFileTabSelect, initialDocId, onActiveDocumentChange, onGenerateTips, }: ReasonDocsProps) => import("react").JSX.Element;
70
+ declare const Index: ({ mainContent, belowMainContent, openFilesSidebarSignal, extraTabs, activeExtraTabId, onExtraTabSelect, onExtraTabClose, onExtraTabAdd, onFileTabSelect, initialDocId, onActiveDocumentChange, onGenerateTips, onGenerateTopics, onSearchTopic, }: ReasonDocsProps) => import("react").JSX.Element;
58
71
  export default Index;
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- import { SidebarPanelType, SidebarAiProps, SidebarTipsProps, OpenTabItem } from '../layout/sidebar/types';
2
+ import { SidebarPanelType, SidebarAiProps, SidebarTipsProps, SidebarTopicsProps, OpenTabItem } from '../layout/sidebar/types';
3
3
  import { OutlineViewHandle } from '../search/OutlineView';
4
4
  import { ActiveHeadingEditorHandle } from '../search/useActiveHeading';
5
5
  import { TocEntry } from '../app-types/toc';
@@ -37,6 +37,8 @@ interface RightPanelProps {
37
37
  aiProps: SidebarAiProps;
38
38
  /** AI-generated page tips state/handlers (used by the "ai" panel). */
39
39
  tipsProps?: SidebarTipsProps;
40
+ /** AI-generated search topics state/handlers (used by the "related" panel). */
41
+ topicsProps?: SidebarTopicsProps;
40
42
  /** Closes the panel by clearing the right sidebar's panel list. */
41
43
  onClose: () => void;
42
44
  /** Renders as a slide-in drawer instead of an inset resizable panel. */
@@ -51,5 +53,5 @@ interface RightPanelProps {
51
53
  * by dragging its left edge; its body renders whichever panels are enabled
52
54
  * for the right sidebar.
53
55
  */
54
- export declare function RightPanel({ panels, split, documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, headings, onNavigate, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, outlineRef, editorRef, tabItems, onNewChat, aiProps, tipsProps, onClose, isMobile, isOpen, onOpenChange, }: RightPanelProps): import("react").JSX.Element;
56
+ export declare function RightPanel({ panels, split, documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, headings, onNavigate, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, outlineRef, editorRef, tabItems, onNewChat, aiProps, tipsProps, topicsProps, onClose, isMobile, isOpen, onOpenChange, }: RightPanelProps): import("react").JSX.Element;
55
57
  export {};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./editorConfig-Cx4ilZJV.cjs"),o=require("./ReasonDocs-YyAZ8_Ks.cjs"),r=require("./RichTextProvider-CSKrKcEv.cjs"),t=require("./externalLibsMode-Dm8a-Jd9.cjs");exports.NovelEditor=e.NovelEditor,exports.ReasonDocs=o.Index,exports.RichTextProvider=r.RichTextProvider,exports.externalLibsModeActions=t.externalLibsModeActions,exports.getExternalLibsMode=t.getExternalLibsMode,exports.useExternalLibsMode=t.useExternalLibsMode,exports.useNovelEditor=e.useNovelEditor;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./editorConfig-Cx4ilZJV.cjs"),o=require("./ReasonDocs-B4rT3-HS.cjs"),r=require("./RichTextProvider-CSKrKcEv.cjs"),t=require("./externalLibsMode-Dm8a-Jd9.cjs");exports.NovelEditor=e.NovelEditor,exports.ReasonDocs=o.Index,exports.RichTextProvider=r.RichTextProvider,exports.externalLibsModeActions=t.externalLibsModeActions,exports.getExternalLibsMode=t.getExternalLibsMode,exports.useExternalLibsMode=t.useExternalLibsMode,exports.useNovelEditor=e.useNovelEditor;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as o,i as s}from"./editorConfig-BDVG1hyU.js";import{t as r}from"./ReasonDocs-B1yliWVq.js";import{t as a}from"./RichTextProvider-CHcaIPMd.js";import{n as t,r as i,t as e}from"./externalLibsMode-DEDBnK98.js";export{s as NovelEditor,r as ReasonDocs,a as RichTextProvider,e as externalLibsModeActions,t as getExternalLibsMode,i as useExternalLibsMode,o as useNovelEditor};
1
+ import{a as o,i as s}from"./editorConfig-BDVG1hyU.js";import{t as r}from"./ReasonDocs-DkUKYeNa.js";import{t as a}from"./RichTextProvider-CHcaIPMd.js";import{n as t,r as i,t as e}from"./externalLibsMode-DEDBnK98.js";export{s as NovelEditor,r as ReasonDocs,a as RichTextProvider,e as externalLibsModeActions,t as getExternalLibsMode,i as useExternalLibsMode,o as useNovelEditor};
@@ -1,2 +1,2 @@
1
1
  import { SidebarProps } from './types';
2
- export declare const Sidebar: ({ documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onSearchFocus, isOpen, onOpenChange, isMobile, leftPanels, onLeftPanelsChange, leftSplit, onLeftSplitChange, rightPanels, onRightPanelsChange, rightSplit, onRightSplitChange, onSettingsClick, onRestore, newDocumentId, showDynamicIsland, onToggleDynamicIsland, activeFileSourceId, onFileSourceChange, headings, onNavigate, editorRef, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, aiProps, tipsProps, tabItems, onNewChat, }: SidebarProps) => import("react").JSX.Element;
2
+ export declare const Sidebar: ({ documents, activeId, activeDocument, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onSearchFocus, isOpen, onOpenChange, isMobile, leftPanels, onLeftPanelsChange, leftSplit, onLeftSplitChange, rightPanels, onRightPanelsChange, rightSplit, onRightSplitChange, onSettingsClick, onRestore, newDocumentId, showDynamicIsland, onToggleDynamicIsland, activeFileSourceId, onFileSourceChange, headings, onNavigate, editorRef, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, aiProps, tipsProps, topicsProps, tabItems, onNewChat, }: SidebarProps) => import("react").JSX.Element;
@@ -2,7 +2,7 @@ import { RefObject } from 'react';
2
2
  import { OutlineViewHandle } from '../../search/OutlineView';
3
3
  import { ActiveHeadingEditorHandle } from '../../search/useActiveHeading';
4
4
  import { Document } from '../../documents/DocumentTree';
5
- import { SidebarPanelType, SidebarAiProps, SidebarTipsProps, OpenTabItem } from './types';
5
+ import { SidebarPanelType, SidebarAiProps, SidebarTipsProps, SidebarTopicsProps, OpenTabItem } from './types';
6
6
  import { TocEntry } from '../../app-types/toc';
7
7
  type DocumentTreeHandle = {
8
8
  collapseAll: () => void;
@@ -73,6 +73,8 @@ interface SidebarContentProps {
73
73
  aiProps?: SidebarAiProps;
74
74
  /** AI-generated page tips state/handlers (used by the "ai" panel). */
75
75
  tipsProps?: SidebarTipsProps;
76
+ /** AI-generated search topics state/handlers (used by the "related" panel). */
77
+ topicsProps?: SidebarTopicsProps;
76
78
  /** Unified tab list (files + chats). Overrides file-only tab derivation when set. */
77
79
  tabItems?: OpenTabItem[];
78
80
  /** Opens a new chat tab from the "Open Tabs" panel header. */
@@ -82,5 +84,5 @@ interface SidebarContentProps {
82
84
  * Renders the enabled panels for one side of the layout, stacked in a
83
85
  * resizable vertical split when more than one panel is active.
84
86
  */
85
- export declare const SidebarContent: ({ panels, split, persistenceKey, activeDocuments, activeId, activeDocument, headings, isMobile, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onOpenChange, treeRef, outlineRef, editorRef, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, onNavigate, aiProps, tipsProps, tabItems, onNewChat, }: SidebarContentProps) => import("react").JSX.Element;
87
+ export declare const SidebarContent: ({ panels, split, persistenceKey, activeDocuments, activeId, activeDocument, headings, isMobile, onSelect, onAdd, onDelete, onDuplicate, onMove, onManageTags, onRename, onOpenChange, treeRef, outlineRef, editorRef, openTabs, activeTab, onTabChange, onTabClose, onTabRename, onSplitRight, onReopenLastClosed, canReopenLastClosed, onNavigate, aiProps, tipsProps, topicsProps, tabItems, onNewChat, }: SidebarContentProps) => import("react").JSX.Element;
86
88
  export {};
@@ -45,6 +45,22 @@ export interface SidebarTipsProps {
45
45
  /** Requests (re)generation of tips for the active document. */
46
46
  onGenerateTips?: () => void;
47
47
  }
48
+ /**
49
+ * AI-generated suggested search queries ("topics") related to the currently
50
+ * active document, shown as a section of the "related" panel. Omitted
51
+ * entirely (and the section hidden) when the host app has no
52
+ * topics-generation capability to offer.
53
+ */
54
+ export interface SidebarTopicsProps {
55
+ /** Suggested search queries generated for the active document by the most recent request. */
56
+ topics?: string[];
57
+ /** Whether a topics-generation request is in flight. */
58
+ isTopicsLoading?: boolean;
59
+ /** Requests (re)generation of topics for the active document. */
60
+ onGenerateTopics?: () => void;
61
+ /** Runs a search for the given topic (e.g. opens a new chat seeded with it). */
62
+ onSearchTopic?: (topic: string) => void;
63
+ }
48
64
  export interface SidebarProps {
49
65
  documents: Document[];
50
66
  activeId: string | null;
@@ -96,4 +112,5 @@ export interface SidebarProps {
96
112
  onNewChat?: () => void;
97
113
  aiProps?: SidebarAiProps;
98
114
  tipsProps?: SidebarTipsProps;
115
+ topicsProps?: SidebarTopicsProps;
99
116
  }
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./ReasonDocs-YyAZ8_Ks.cjs");exports.ReasonDocs=e.Index;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./ReasonDocs-B4rT3-HS.cjs");exports.ReasonDocs=e.Index;
@@ -1 +1 @@
1
- import{t as o}from"./ReasonDocs-B1yliWVq.js";export{o as ReasonDocs};
1
+ import{t as o}from"./ReasonDocs-DkUKYeNa.js";export{o as ReasonDocs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-reason-editor",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React",
5
5
  "repository": {
6
6
  "type": "git",