@alwith/module-chat 0.1.17 → 0.1.19

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.
Files changed (44) hide show
  1. package/dist/approval/choice-elicitation-form.js +1 -1
  2. package/dist/approval/choice-schema.d.ts +1 -1
  3. package/dist/approval/choice-schema.js +1 -1
  4. package/dist/approval/permission-view.js +1 -1
  5. package/dist/approval/schema-elicitation-form.d.ts +1 -1
  6. package/dist/approval/schema-elicitation-form.js +1 -1
  7. package/dist/codex/activity-group.js +6 -6
  8. package/dist/codex/assistant-message.js +2 -2
  9. package/dist/codex/markdown-renderer.d.ts +1 -0
  10. package/dist/codex/markdown-renderer.js +5 -5
  11. package/dist/codex/navigation-rail.d.ts +10 -2
  12. package/dist/codex/navigation-rail.js +1 -1
  13. package/dist/codex/styles.css +32 -0
  14. package/dist/codex/thread-virtualizer.d.ts +3 -1
  15. package/dist/codex/thread-virtualizer.js +1 -1
  16. package/dist/codex/virtualized-turn-list.d.ts +6 -0
  17. package/dist/codex/virtualized-turn-list.js +1 -1
  18. package/dist/composer/completion-menu.js +2 -2
  19. package/dist/composer/completion-trigger.js +1 -1
  20. package/dist/composer/menu-radio.js +1 -1
  21. package/dist/composer/model-select.d.ts +2 -2
  22. package/dist/composer/model-select.js +1 -1
  23. package/dist/composer/prompt-input-attachments.js +1 -1
  24. package/dist/composer/prompt-input-clipboard.d.ts +0 -1
  25. package/dist/composer/prompt-input-clipboard.js +1 -1
  26. package/dist/composer/prompt-input-textarea.js +2 -2
  27. package/dist/composer/prompt-input.js +1 -1
  28. package/dist/image-preview-dialog.js +1 -1
  29. package/dist/lib/markdown-parser.d.ts +1 -0
  30. package/dist/lib/markdown-parser.js +1 -1
  31. package/dist/lib/streaming-markdown.js +1 -1
  32. package/dist/search/chat-search.js +1 -1
  33. package/dist/search/find-bar.js +1 -1
  34. package/dist/types.d.ts +2 -2
  35. package/dist/ui/badge.js +1 -1
  36. package/dist/ui/button.js +1 -1
  37. package/dist/ui/dialog.d.ts +1 -1
  38. package/dist/ui/dialog.js +1 -1
  39. package/dist/ui/dropdown-menu.d.ts +1 -1
  40. package/dist/ui/dropdown-menu.js +1 -1
  41. package/dist/ui/field.js +1 -1
  42. package/dist/ui/input-group.d.ts +2 -2
  43. package/dist/ui/input-group.js +1 -1
  44. package/package.json +6 -4
@@ -1,6 +1,7 @@
1
1
  export declare const CODEX_UNKNOWN_TURN_HEIGHT = 280;
2
2
  export interface CodexThreadVirtualEntry {
3
3
  turnKey: string;
4
+ aliases?: string[];
4
5
  estimatedHeightPx?: number;
5
6
  }
6
7
  export interface CodexThreadVirtualLayout {
@@ -15,10 +16,11 @@ export interface CodexThreadVirtualRange {
15
16
  startIndex: number;
16
17
  endIndex: number;
17
18
  }
18
- export declare function createCodexThreadVirtualLayout({ entries, gapPx, measuredHeightsByKey }: {
19
+ export declare function createCodexThreadVirtualLayout({ entries, gapPx, measuredHeightsByKey, leadingInsetPx }: {
19
20
  entries: CodexThreadVirtualEntry[];
20
21
  gapPx: number;
21
22
  measuredHeightsByKey: Record<string, number>;
23
+ leadingInsetPx?: number;
22
24
  }): CodexThreadVirtualLayout;
23
25
  export declare function calculateCodexThreadVirtualRange({ distanceFromBottomPx, layout, overscanCount, viewportHeightPx }: {
24
26
  distanceFromBottomPx: number;
@@ -1 +1 @@
1
- var m=280;function g({entries:o,gapPx:e,measuredHeightsByKey:d}){let t=[],n=[],r=new Map,s=[],i=0;for(let[f,x]of o.entries()){r.set(x.turnKey,f),s.push(x.turnKey),n.push(i);let h=d[x.turnKey]??x.estimatedHeightPx??280;if(t.push(h),i+=h,f<o.length-1)i+=e}return{bottomOffsetsPx:n.map((f,x)=>{let h=t[x];if(h===void 0)throw Error(`Codex turn height is missing at index ${x}`);return i-f-h}),heightsPx:t,topOffsetsPx:n,totalHeightPx:i,turnIndexByKey:r,turnKeys:s}}function a({distanceFromBottomPx:o,layout:e,overscanCount:d,viewportHeightPx:t}){if(e.turnKeys.length===0)return{startIndex:0,endIndex:0};let n=Math.min(Math.max(0,o),e.totalHeightPx),r=Math.min(n+Math.max(0,t),e.totalHeightPx),s=u(e.bottomOffsetsPx,r),i=c(e.bottomOffsetsPx,e.heightsPx,n);return{startIndex:Math.max(0,s-d),endIndex:Math.min(e.turnKeys.length,Math.max(i,s+1)+d)}}function P({anchorKey:o,layout:e,previousRange:d}){let t=e.turnIndexByKey.get(o);if(t===void 0)return null;return{startIndex:t,endIndex:Math.min(e.turnKeys.length,t+d.endIndex-d.startIndex)}}function I({anchorKey:o,distanceFromBottomPx:e,nextLayout:d,previousLayout:t}){let n=t.turnIndexByKey.get(o),r=d.turnIndexByKey.get(o);if(n===void 0||r===void 0)return null;let s=t.bottomOffsetsPx[n],i=t.heightsPx[n],f=d.bottomOffsetsPx[r],x=d.heightsPx[r];if(s===void 0||i===void 0||f===void 0||x===void 0)throw Error(`Codex turn geometry is missing: ${o}`);return Math.max(0,e+f+x-s-i)}function l({layout:o,turnKey:e,viewportHeightPx:d}){let t=o.turnIndexByKey.get(e);if(t===void 0)return null;let n=o.bottomOffsetsPx[t],r=o.heightsPx[t];if(n===void 0||r===void 0)throw Error(`Codex turn geometry is missing: ${e}`);return Math.max(0,n-d/2+r/2)}function p({align:o,layout:e,targetHeightPx:d,targetOffsetPx:t,turnKey:n,viewportHeightPx:r}){let s=e.turnIndexByKey.get(n);if(s===void 0)return null;let i=e.bottomOffsetsPx[s],f=e.heightsPx[s];if(i===void 0||f===void 0)throw Error(`Codex turn geometry is missing: ${n}`);let x=i+f-t;return o==="top"?Math.max(0,x-r+10):Math.max(0,x-d/2-r/2)}function u(o,e){let d=0,t=o.length;while(d<t){let n=Math.floor((d+t)/2),r=o[n];if(r===void 0)throw Error(`Codex bottom offset is missing at index ${n}`);if(r<e)t=n;else d=n+1}return d}function c(o,e,d){let t=0,n=o.length;while(t<n){let r=Math.floor((t+n)/2),s=o[r],i=e[r];if(s===void 0||i===void 0)throw Error(`Codex turn geometry is missing at index ${r}`);if(s+i<=d)n=r;else t=r+1}return t}export{m as CODEX_UNKNOWN_TURN_HEIGHT,a as calculateCodexThreadVirtualRange,l as calculateCodexTurnCenterDistanceFromBottom,p as calculateCodexTurnTargetDistanceFromBottom,g as createCodexThreadVirtualLayout,I as preserveCodexThreadDistanceFromBottom,P as preserveCodexThreadRenderedWindow};
1
+ var l=280;function P({entries:i,gapPx:e,measuredHeightsByKey:r,leadingInsetPx:t=0}){let n=[],o=[],s=new Map,d=[],x=t;for(let[f,h]of i.entries()){s.set(h.turnKey,f);for(let u of h.aliases??[])s.set(u,f);d.push(h.turnKey),o.push(x);let a=h.aliases?.map((u)=>r[u]).find((u)=>u!==void 0),c=r[h.turnKey]??a??h.estimatedHeightPx??280;if(n.push(c),x+=c,f<i.length-1)x+=e}return{bottomOffsetsPx:o.map((f,h)=>{let a=n[h];if(a===void 0)throw Error(`Codex turn height is missing at index ${h}`);return x-f-a}),heightsPx:n,topOffsetsPx:o,totalHeightPx:x,turnIndexByKey:s,turnKeys:d}}function I({distanceFromBottomPx:i,layout:e,overscanCount:r,viewportHeightPx:t}){if(e.turnKeys.length===0)return{startIndex:0,endIndex:0};let n=Math.min(Math.max(0,i),e.totalHeightPx),o=Math.min(n+Math.max(0,t),e.totalHeightPx),s=m(e.bottomOffsetsPx,o),d=g(e.bottomOffsetsPx,e.heightsPx,n);return{startIndex:Math.max(0,s-r),endIndex:Math.min(e.turnKeys.length,Math.max(d,s+1)+r)}}function p({anchorKey:i,layout:e,previousRange:r}){let t=e.turnIndexByKey.get(i);if(t===void 0)return null;return{startIndex:t,endIndex:Math.min(e.turnKeys.length,t+r.endIndex-r.startIndex)}}function w({anchorKey:i,distanceFromBottomPx:e,nextLayout:r,previousLayout:t}){let n=t.turnIndexByKey.get(i),o=r.turnIndexByKey.get(i);if(n===void 0||o===void 0)return null;let s=t.bottomOffsetsPx[n],d=t.heightsPx[n],x=r.bottomOffsetsPx[o],f=r.heightsPx[o];if(s===void 0||d===void 0||x===void 0||f===void 0)throw Error(`Codex turn geometry is missing: ${i}`);return Math.max(0,e+x+f-s-d)}function O({layout:i,turnKey:e,viewportHeightPx:r}){let t=i.turnIndexByKey.get(e);if(t===void 0)return null;let n=i.bottomOffsetsPx[t],o=i.heightsPx[t];if(n===void 0||o===void 0)throw Error(`Codex turn geometry is missing: ${e}`);return Math.max(0,n-r/2+o/2)}function C({align:i,layout:e,targetHeightPx:r,targetOffsetPx:t,turnKey:n,viewportHeightPx:o}){let s=e.turnIndexByKey.get(n);if(s===void 0)return null;let d=e.bottomOffsetsPx[s],x=e.heightsPx[s];if(d===void 0||x===void 0)throw Error(`Codex turn geometry is missing: ${n}`);let f=d+x-t;return i==="top"?Math.max(0,f-o+10):Math.max(0,f-r/2-o/2)}function m(i,e){let r=0,t=i.length;while(r<t){let n=Math.floor((r+t)/2),o=i[n];if(o===void 0)throw Error(`Codex bottom offset is missing at index ${n}`);if(o<e)t=n;else r=n+1}return r}function g(i,e,r){let t=0,n=i.length;while(t<n){let o=Math.floor((t+n)/2),s=i[o],d=e[o];if(s===void 0||d===void 0)throw Error(`Codex turn geometry is missing at index ${o}`);if(s+d<=r)n=o;else t=o+1}return t}export{l as CODEX_UNKNOWN_TURN_HEIGHT,I as calculateCodexThreadVirtualRange,O as calculateCodexTurnCenterDistanceFromBottom,C as calculateCodexTurnTargetDistanceFromBottom,P as createCodexThreadVirtualLayout,w as preserveCodexThreadDistanceFromBottom,p as preserveCodexThreadRenderedWindow};
@@ -1,7 +1,10 @@
1
1
  import { type ReactNode } from "react";
2
2
  export interface VirtualizedTurnListEntry {
3
3
  turnKey: string;
4
+ aliases?: string[];
4
5
  estimatedHeightPx?: number;
6
+ placeholder?: boolean;
7
+ deferUntilReady?: boolean;
5
8
  }
6
9
  export interface VirtualizedTurnListApi {
7
10
  scrollToKey: (turnKey: string, getTargetElement?: (turnElement: HTMLElement) => HTMLElement | null, options?: {
@@ -13,4 +16,7 @@ export declare const VirtualizedTurnList: import("react").ForwardRefExoticCompon
13
16
  renderTurn: (entry: VirtualizedTurnListEntry, index: number) => ReactNode;
14
17
  scrollElement: HTMLElement | null;
15
18
  sessionKey: string;
19
+ leadingContent?: ReactNode;
20
+ leadingInsetPx?: number;
21
+ preserveViewport?: boolean;
16
22
  } & import("react").RefAttributes<VirtualizedTurnListApi>>;
@@ -1 +1 @@
1
- import{jsx as M}from"react/jsx-runtime";import{forwardRef as ut,useCallback as B,useEffect as nt,useImperativeHandle as st,useLayoutEffect as v,useMemo as j,useRef as c,useState as H}from"react";import{calculateCodexThreadVirtualRange as F,calculateCodexTurnCenterDistanceFromBottom as ct,calculateCodexTurnTargetDistanceFromBottom as dt,createCodexThreadVirtualLayout as lt,preserveCodexThreadDistanceFromBottom as gt,preserveCodexThreadRenderedWindow as rt}from"./thread-virtualizer.js";var ht=12,O=2,C=800,ot=new Map;function xt({turnKey:z,heightPx:h,observe:S,onReady:r,children:p}){let L=c(null),[d,I]=H(!1),K=B((n)=>{L.current=n,S(z,n)},[S,z]);return v(()=>{let n=L.current;if(n===null)throw Error("Codex turn element is missing");let k=()=>{r(n),I(!0)};if(n.querySelector("[data-markdown-pending]")===null){k();return}let l=new MutationObserver(()=>{if(n.querySelector("[data-markdown-pending]")!==null)return;l.disconnect(),k()});return l.observe(n,{childList:!0,subtree:!0}),()=>l.disconnect()},[r]),M("div",{style:d?void 0:{height:h,overflow:"hidden"},children:M("div",{ref:K,className:"[&_[data-virtualized-turn-content]]:[content-visibility:visible]","data-turn-key":z,"data-turn-ready":d?"":void 0,children:p})})}var pt=ut(function({entries:h,renderTurn:S,scrollElement:r,sessionKey:p},L){let d=j(()=>ot.get(p),[p]),[I,K]=H(()=>d?.turnHeightsByKey??{}),n=j(()=>lt({entries:h,gapPx:ht,measuredHeightsByKey:I}),[h,I]),k=j(()=>{let t=F({distanceFromBottomPx:d?.distanceFromBottomPx??0,layout:n,overscanCount:O,viewportHeightPx:C}),e=d?.renderedWindow;if(e===void 0||e===null)return t;return rt({anchorKey:e.anchorKey,layout:n,previousRange:{startIndex:0,endIndex:Math.min(e.count,t.endIndex-t.startIndex)}})??t},[d,n]),[l,G]=H(k),[x,U]=H(C),[V,X]=H(d?.distanceFromBottomPx??0),[s,E]=H(null),R=c(V),T=c(l),J=c(n.turnKeys),g=c(I),_=c(n),Q=c(n),b=c(new Map),f=c(null),P=c(null),Y=c(!1),Z=c(()=>{}),m=B((t,e)=>{let o=Math.min(t,n.totalHeightPx),a=F({distanceFromBottomPx:o,layout:n,overscanCount:O,viewportHeightPx:e}),u=T.current,i=u.startIndex<=a.startIndex&&u.endIndex>=a.endIndex?u:a;R.current=o,T.current=i,J.current=n.turnKeys,X(o),U(e),G(i)},[n]),D=B((t)=>{let e=Math.max(0,t.scrollHeight-n.totalHeightPx);return Math.max(0,t.scrollHeight-t.clientHeight-t.scrollTop-e)},[n.totalHeightPx]),it=B((t)=>{let e=t.dataset.turnKey;if(e===void 0)throw Error("Codex measured turn is missing its key");let o=Math.max(1,t.getBoundingClientRect().height);if(g.current[e]===o)return;let a={...g.current,[e]:o};g.current=a,K(a)},[]),W=B(()=>{if(P.current!==null)return P.current;return P.current=new ResizeObserver((t)=>{let e={...g.current},o=!1;for(let a of t){let u=a.target;if(!("turnReady"in u.dataset)&&u.querySelector("[data-markdown-pending]")!==null)continue;let i=u.dataset.turnKey;if(i===void 0)throw Error("Codex measured turn is missing its key");let y=Math.max(1,a.borderBoxSize[0]?.blockSize??a.contentRect.height);if(e[i]===y)continue;e[i]=y,o=!0}if(!o)return;g.current=e,K(e)}),P.current},[]),at=B((t,e)=>{let o=b.current.get(t);if(o!==void 0)W().unobserve(o),b.current.delete(t);if(e===null)return;if(e.dataset.turnKey!==t)throw Error(`Codex turn key does not match its element: ${t}`);b.current.set(t,e),W().observe(e)},[W]);nt(()=>()=>{P.current?.disconnect(),P.current=null,b.current.clear()},[]),v(()=>{Z.current=()=>{if(r===null)return;let t=D(r);if(f.current!==null){R.current=t,X(t),U(r.clientHeight||C);return}m(t,r.clientHeight||C)}},[D,r,m]),v(()=>{if(r===null)return;if(!Y.current){Y.current=!0;let o=d?.distanceFromBottomPx??0;r.scrollTo({behavior:"instant",top:Math.max(0,o>0?_.current.totalHeightPx-r.clientHeight-o:r.scrollHeight-r.clientHeight)})}let t=()=>Z.current();t(),r.addEventListener("scroll",t,{passive:!0});let e=new ResizeObserver(t);return e.observe(r),()=>{r.removeEventListener("scroll",t),e.disconnect()}},[d,r]),v(()=>{if(r===null||s===null)return;let t=b.current.get(s.turnKey);if(t===void 0||t.querySelector("[data-markdown-pending]")!==null)return;let e=t.offsetHeight;if(e<=0)return;if(g.current[s.turnKey]!==e){let y={...g.current,[s.turnKey]:e};g.current=y,K(y);return}let o=s.getTargetElement(t)??t,a=t.getBoundingClientRect(),u=o.getBoundingClientRect(),i=dt({align:s.align,layout:n,targetHeightPx:u.height,targetOffsetPx:u.top-a.top,turnKey:s.turnKey,viewportHeightPx:r.clientHeight});if(i===null)throw Error(`Codex virtual turn is missing: ${s.turnKey}`);r.scrollTo({behavior:"instant",top:Math.max(0,n.totalHeightPx-r.clientHeight-i)}),m(i,r.clientHeight||C),queueMicrotask(()=>{if(f.current!==s)return;s.complete(),f.current=null,E(null)})},[n,s,r,m]),v(()=>{let t=Q.current;if(Q.current=n,_.current=n,r===null||s!==null)return;let e=R.current;if(e>24&&t!==n){let o=D(r);if(o<=96){m(o,x);return}let a=F({distanceFromBottomPx:e,layout:t,overscanCount:0,viewportHeightPx:x}),u=t.turnKeys.slice(a.startIndex,a.endIndex).find((i)=>g.current[i]!==void 0&&n.turnIndexByKey.has(i));if(u!==void 0){let i=gt({anchorKey:u,distanceFromBottomPx:e,nextLayout:n,previousLayout:t});if(i===null)throw Error(`Codex viewport anchor is missing: ${u}`);e=i,r.scrollTo({behavior:"instant",top:Math.max(0,n.totalHeightPx-r.clientHeight-e)})}}m(e,x)},[n,s,D,r,m,x]),v(()=>{T.current=l},[l]),v(()=>{R.current=V},[V]),nt(()=>()=>{f.current?.complete(),f.current=null;let t=T.current,o=_.current.turnKeys[t.startIndex];ot.set(p,{distanceFromBottomPx:R.current,renderedWindow:o===void 0?null:{anchorKey:o,count:t.endIndex-t.startIndex},turnHeightsByKey:g.current})},[p]),st(L,()=>({scrollToKey(t,e=(a)=>a,o={align:"center"}){if(f.current?.complete(),n.turnIndexByKey.get(t)===void 0)throw Error(`Codex virtual turn is missing: ${t}`);let u=ct({layout:n,turnKey:t,viewportHeightPx:x});if(u===null)throw Error(`Codex virtual turn is missing: ${t}`);let i=F({distanceFromBottomPx:u,layout:n,overscanCount:O,viewportHeightPx:x});return T.current=i,G(i),new Promise((y)=>{let et={align:o.align,complete:y,getTargetElement:e,turnKey:t};f.current=et,E(et)})}}),[n,x]);let w=l,N=J.current;if(!(N===n.turnKeys||N.length===n.turnKeys.length&&N.every((t,e)=>t===n.turnKeys[e]))){let t=N[l.startIndex];w=(t===void 0?null:rt({anchorKey:t,layout:n,previousRange:l}))??F({distanceFromBottomPx:R.current,layout:n,overscanCount:O,viewportHeightPx:x})}let q=h.length-1,tt=h[q],A=h.slice(w.startIndex,Math.min(w.endIndex,q)).map((t,e)=>({entry:t,index:w.startIndex+e}));if(tt!==void 0)A.push({entry:tt,index:q});return M("div",{"data-codex-thread":!0,"data-codex-virtualized-pending-key":s?.turnKey,"data-codex-virtualized-range":`${w.startIndex}:${w.endIndex}`,"data-codex-virtualized-total-count":h.length,"data-codex-virtualized-turn-count":A.length,className:"relative shrink-0",style:{height:n.totalHeightPx},children:A.map(({entry:t,index:e})=>M("div",{className:"absolute inset-x-0",style:{top:n.topOffsetsPx[e]??0},children:M(xt,{turnKey:t.turnKey,heightPx:n.heightsPx[e],observe:at,onReady:it,children:S(t,e)})},t.turnKey))})});export{pt as VirtualizedTurnList};
1
+ import{jsx as R,jsxs as ot}from"react/jsx-runtime";import{forwardRef as vt,useCallback as K,useEffect as ht,useImperativeHandle as Rt,useLayoutEffect as T,useMemo as rt,useRef as a,useState as k}from"react";import{calculateCodexThreadVirtualRange as q,calculateCodexTurnCenterDistanceFromBottom as Pt,calculateCodexTurnTargetDistanceFromBottom as Bt,createCodexThreadVirtualLayout as Ht,preserveCodexThreadDistanceFromBottom as bt,preserveCodexThreadRenderedWindow as xt}from"./thread-virtualizer.js";var wt=12,J=2,W=800,ft=new Map;function Kt({turnKey:j,heightPx:m,placeholder:V=!1,deferUntilReady:n=!1,observe:P,onReady:C,children:z}){let h=a(null),[B,U]=k(!1),G=K((x)=>{h.current=x,P(j,x)},[P,j]);return T(()=>{let x=h.current;if(x===null)throw Error("Codex turn element is missing");let H=()=>{C(x),U(!0)};if(x.querySelector("[data-markdown-pending]")===null){H();return}let d=new MutationObserver(()=>{if(x.querySelector("[data-markdown-pending]")!==null)return;d.disconnect(),H()});return d.observe(x,{childList:!0,subtree:!0}),()=>d.disconnect()},[C]),ot("div",{style:B?void 0:{position:"relative",height:m,overflow:"hidden"},children:[R("div",{ref:G,className:"[&_[data-virtualized-turn-content]]:[content-visibility:visible]","data-turn-key":j,"aria-busy":!B||void 0,style:!B&&!V&&n?{visibility:"hidden"}:void 0,"data-turn-ready":B?"":void 0,children:z}),!B&&!V&&n&&R("div",{"aria-hidden":"true",className:"codex-turn-loading",children:ot("div",{className:"codex-turn-loading-lines",children:[R("span",{}),R("span",{}),R("span",{})]})})]})}var Mt=vt(function({entries:m,renderTurn:V,scrollElement:n,sessionKey:P,leadingContent:C,leadingInsetPx:z=0,preserveViewport:h=!1},B){let U=a(null),[G,x]=k(z),H=C!==void 0&&C!==null;T(()=>{let t=U.current;if(t===null)return;let e=()=>x(t.getBoundingClientRect().height);e();let i=new ResizeObserver(e);return i.observe(t),()=>i.disconnect()},[H]);let d=rt(()=>ft.get(P),[P]),[Q,Y]=k(()=>d?.turnHeightsByKey??{}),o=rt(()=>Ht({entries:m,gapPx:wt,measuredHeightsByKey:Q,leadingInsetPx:H?G:z}),[m,Q,H,G,z]),mt=rt(()=>{let t=q({distanceFromBottomPx:d?.distanceFromBottomPx??0,layout:o,overscanCount:J,viewportHeightPx:W}),e=d?.renderedWindow;if(e===void 0||e===null)return t;return xt({anchorKey:e.anchorKey,layout:o,previousRange:{startIndex:0,endIndex:Math.min(e.count,t.endIndex-t.startIndex)}})??t},[d,o]),[I,it]=k(mt),[y,ut]=k(W),[s,ct]=k(null),L=a(d?.distanceFromBottomPx??0),S=a(I),at=a(o.turnKeys),l=a(Q),N=a(o),st=a(o),b=a(new Map),p=a(null),F=a(null),O=a(null),D=a(new Map),Z=a(!1),dt=a(()=>{}),A=a(null),lt=K(()=>{if(!h||n===null||p.current!==null||A.current!==null)return;let t=n.getBoundingClientRect();if(t.height<=0)return;let e=[...b.current].filter(([,r])=>r.hasAttribute("data-turn-ready")).map(([r,u])=>{let c=u.getBoundingClientRect(),g=N.current.turnIndexByKey.get(r),w=g===void 0?c.height:N.current.heightsPx[g];return{key:r,element:u,rect:c,bottom:c.top+w}}).filter(({rect:r,bottom:u})=>u>t.top&&r.top<t.bottom).sort((r,u)=>r.rect.top-u.rect.top),i=e.flatMap((r)=>[...r.element.querySelectorAll("[data-user-message-bubble], .codex-markdown-root > *")].filter((u)=>!u.closest('[aria-hidden="true"], [inert]')).map((u)=>({key:r.key,element:u,rect:u.getBoundingClientRect()})).filter(({rect:u})=>u.height>0&&u.top>=t.top&&u.top<t.bottom)).sort((r,u)=>r.rect.top-u.rect.top)[0]??e[0];if(i)A.current={key:i.key,element:i.element,top:i.rect.top-t.top,scrollTop:n.scrollTop}},[h,n]),E=a(lt);E.current=lt;let v=K((t,e)=>{let i=Math.min(t,o.totalHeightPx),r=q({distanceFromBottomPx:i,layout:o,overscanCount:J,viewportHeightPx:e}),u=S.current,c=u.startIndex<=r.startIndex&&u.endIndex>=r.endIndex?u:r;if(L.current=i,S.current=c,at.current=o.turnKeys,ut(e),c!==u)it(c)},[o]),_=K((t)=>{let e=Math.max(0,t.scrollHeight-o.totalHeightPx);return Math.max(0,t.scrollHeight-t.clientHeight-t.scrollTop-e)},[o.totalHeightPx]),yt=K((t)=>{let e=t.dataset.turnKey;if(e===void 0)throw Error("Codex measured turn is missing its key");let i=Math.max(1,t.getBoundingClientRect().height);if(l.current[e]===i)return;E.current();let r={...l.current,[e]:i};l.current=r,Y(r)},[]),tt=K(()=>{if(F.current!==null)return F.current;return F.current=new ResizeObserver((t)=>{for(let e of t){let i=e.target;if(!("turnReady"in i.dataset)&&i.querySelector("[data-markdown-pending]")!==null)continue;let r=i.dataset.turnKey;if(r===void 0)throw Error("Codex measured turn is missing its key");let u=Math.max(1,e.borderBoxSize[0]?.blockSize??e.contentRect.height);D.current.set(r,u)}if(O.current!==null||D.current.size===0)return;O.current=requestAnimationFrame(()=>{O.current=null;let e=[...D.current].filter(([r,u])=>l.current[r]!==u);if(D.current.clear(),e.length===0)return;E.current();let i={...l.current,...Object.fromEntries(e)};l.current=i,Y(i)})}),F.current},[]),pt=K((t,e)=>{let i=b.current.get(t);if(i!==void 0)tt().unobserve(i),b.current.delete(t);if(e===null)return;if(e.dataset.turnKey!==t)throw Error(`Codex turn key does not match its element: ${t}`);b.current.set(t,e),tt().observe(e)},[tt]);ht(()=>()=>{if(F.current?.disconnect(),O.current!==null)cancelAnimationFrame(O.current);D.current.clear(),F.current=null,b.current.clear()},[]),T(()=>{dt.current=()=>{if(n===null)return;let t=_(n);if(p.current!==null){L.current=t,ut(n.clientHeight||W);return}v(t,n.clientHeight||W)}},[_,n,v]),T(()=>{if(n===null)return;if(!Z.current){Z.current=!0;let i=d?.distanceFromBottomPx??0;n.scrollTo({behavior:"instant",top:Math.max(0,i>0?N.current.totalHeightPx-n.clientHeight-i:n.scrollHeight-n.clientHeight)})}let t=()=>dt.current();t(),n.addEventListener("scroll",t,{passive:!0});let e=new ResizeObserver(t);return e.observe(n),()=>{n.removeEventListener("scroll",t),e.disconnect()}},[d,n]),T(()=>{if(n===null||s===null)return;let t=b.current.get(s.turnKey);if(t===void 0||t.querySelector("[data-markdown-pending]")!==null)return;let e=t.offsetHeight;if(e<=0)return;if(l.current[s.turnKey]!==e){let g={...l.current,[s.turnKey]:e};l.current=g,Y(g);return}let i=s.getTargetElement(t)??t,r=t.getBoundingClientRect(),u=i.getBoundingClientRect(),c=Bt({align:s.align,layout:o,targetHeightPx:u.height,targetOffsetPx:u.top-r.top,turnKey:s.turnKey,viewportHeightPx:n.clientHeight});if(c===null)throw Error(`Codex virtual turn is missing: ${s.turnKey}`);n.scrollTo({behavior:"instant",top:Math.max(0,o.totalHeightPx-n.clientHeight-c)}),v(c,n.clientHeight||W),queueMicrotask(()=>{if(p.current!==s)return;s.complete(),p.current=null,ct(null)})},[o,s,n,v]),T(()=>{let t=st.current;if(st.current=o,N.current=o,n===null||s!==null){A.current=null;return}let e=A.current;A.current=null;let i=e===null?void 0:n.contains(e.element)?e.element:b.current.get(e.key);if(h&&t!==o&&e!==null&&i!==void 0){let u=i.getBoundingClientRect().top-n.getBoundingClientRect().top,c=n.scrollTop-e.scrollTop;n.scrollTop+=u-e.top+c,v(_(n),n.clientHeight);return}let r=L.current;if(h&&t!==o&&Z.current)r=Math.max(0,t.totalHeightPx-n.clientHeight-n.scrollTop);if((r>24||h)&&t!==o){let u=_(n);if(u<=96&&!h){v(u,y);return}let c=q({distanceFromBottomPx:r,layout:t,overscanCount:0,viewportHeightPx:y}),g=t.turnKeys.slice(c.startIndex,c.endIndex).filter((f)=>o.turnIndexByKey.has(f)),w=g.find((f)=>l.current[f]!==void 0)??g[0];if(w!==void 0){let f=bt({anchorKey:w,distanceFromBottomPx:r,nextLayout:o,previousLayout:t});if(f===null)throw Error(`Codex viewport anchor is missing: ${w}`);r=f,n.scrollTo({behavior:"instant",top:Math.max(0,o.totalHeightPx-n.clientHeight-r)})}}v(r,y)},[o,s,_,n,v,y,h]),T(()=>{S.current=I},[I]),ht(()=>()=>{p.current?.complete(),p.current=null;let t=S.current,i=N.current.turnKeys[t.startIndex];ft.set(P,{distanceFromBottomPx:L.current,renderedWindow:i===void 0?null:{anchorKey:i,count:t.endIndex-t.startIndex},turnHeightsByKey:l.current})},[P]),Rt(B,()=>({scrollToKey(t,e=(r)=>r,i={align:"center"}){p.current?.complete();let r=o.turnIndexByKey.get(t);if(r===void 0)throw Error(`Codex virtual turn is missing: ${t}`);let u=o.turnKeys[r],c=Pt({layout:o,turnKey:t,viewportHeightPx:y});if(c===null)throw Error(`Codex virtual turn is missing: ${t}`);let g=q({distanceFromBottomPx:c,layout:o,overscanCount:J,viewportHeightPx:y});return S.current=g,it(g),new Promise((w)=>{let f={align:i.align,complete:w,getTargetElement:e,turnKey:u};p.current=f,ct(f)})}}),[o,y]);let M=I,X=at.current;if(!(X===o.turnKeys||X.length===o.turnKeys.length&&X.every((t,e)=>t===o.turnKeys[e]))){let t=X[I.startIndex];M=(t===void 0?null:xt({anchorKey:t,layout:o,previousRange:I}))??q({distanceFromBottomPx:L.current,layout:o,overscanCount:J,viewportHeightPx:y})}let et=m.length-1,gt=m[et],nt=m.slice(M.startIndex,Math.min(M.endIndex,et)).map((t,e)=>({entry:t,index:M.startIndex+e}));if(gt!==void 0)nt.push({entry:gt,index:et});return ot("div",{"data-codex-thread":!0,"data-codex-virtualized-pending-key":s?.turnKey,"data-codex-virtualized-range":`${M.startIndex}:${M.endIndex}`,"data-codex-virtualized-total-count":m.length,"data-codex-virtualized-turn-count":nt.length,className:"relative shrink-0",style:{height:o.totalHeightPx},children:[H&&R("div",{ref:U,"data-codex-thread-leading":!0,className:"absolute inset-x-0 top-0",children:C}),nt.map(({entry:t,index:e})=>R("div",{className:"absolute inset-x-0",style:{top:o.topOffsetsPx[e]??0},children:R(Kt,{turnKey:t.turnKey,heightPx:o.heightsPx[e],placeholder:t.placeholder,deferUntilReady:t.deferUntilReady,observe:pt,onReady:yt,children:V(t,e)})},t.turnKey))]})});export{Mt as VirtualizedTurnList};
@@ -1,3 +1,3 @@
1
- import{jsx as c,jsxs as E,Fragment as ot}from"react/jsx-runtime";import{autoUpdate as st}from"@floating-ui/dom";import{BookOpenTextIcon as it,FileIcon as lt,StoreIcon as ut}from"lucide-react";import{useCallback as at,useEffect as p,useLayoutEffect as Q,useMemo as G,useRef as J,useState as v}from"react";import{createPortal as ct}from"react-dom";import{Button as X}from"../ui/button.js";import{Separator as dt}from"../ui/separator.js";import{cn as Y}from"cn";import{filterSlashCommands as Z}from"./completion-filter.js";import{detectTrigger as ft}from"./completion-trigger.js";import{usePromptInputController as mt}from"./prompt-input-context.js";function It({handleRef:d,anchorRef:u,commands:T,searchFiles:l,onMention:F,onSearchError:A,fileSearchDebounceMs:q=0,bashMode:B=!1,forcedOpen:s=!1,onForcedOpenChange:f,emptyLabel:R,fileStatusLabels:h,morePlugins:D}){let S=mt(),i=S.textInput.value,[z,_]=v(0),[x,N]=v(null),[y,L]=v(0),U=J(null);p(()=>{let t=d.current?.getTextarea();if(!t)return;let e=()=>_(t.selectionStart??0),n=()=>{if(document.activeElement===t)e()};return t.addEventListener("keyup",e),t.addEventListener("click",e),t.addEventListener("input",e),t.addEventListener("select",e),t.addEventListener("focus",e),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",e),t.removeEventListener("click",e),t.removeEventListener("input",e),t.removeEventListener("select",e),t.removeEventListener("focus",e),document.removeEventListener("selectionchange",n)}});let V=G(()=>B&&i.startsWith("!")?null:ft(i,z),[i,z,B]),r=V?.kind==="at"&&!l?null:V,P=`${r?.kind??"forced"}:${r?.query??""}:${s}`,[O,tt]=v(P);if(O!==P)tt(P),L(0);let b=J(null);p(()=>{if(!s){b.current=null;return}if(b.current===null)b.current=i;else if(i!==b.current)f?.(!1)},[s,i,f]);let g=r?.kind==="at"?r.query:null;p(()=>{if(g===null||!l){N(null);return}let t=!0,e=()=>{l(g).then((o)=>{if(t)N({query:g,search:l,items:o})},(o)=>{if(t)N({query:g,search:l,items:[]}),A(o)})},n=q>0?window.setTimeout(e,q):null;if(n===null)e();return()=>{if(t=!1,n!==null)window.clearTimeout(n)}},[g,l,q,A]);let m=G(()=>{if(r?.kind==="at")return x?.query===r.query&&x.search===l?x.items:[];if(r)return Z(T,r.query);if(s)return Z(T,"");return[]},[r,s,T,x,l]),[et,j]=v(!1);p(()=>{let t=d.current?.getTextarea();if(!t)return;let e=()=>j(!0),n=()=>{if(j(!1),s)f?.(!1)};return j(document.activeElement===t),t.addEventListener("focus",e),t.addEventListener("blur",n),()=>{t.removeEventListener("focus",e),t.removeEventListener("blur",n)}},[d,s,f]),p(()=>{if(s)d.current?.getTextarea()?.focus()},[s,d]);let a=et&&(r!==null?r.kind==="slash"||m.length>0||!!h:s);p(()=>{if(!a)return;U.current?.querySelector(`[data-idx="${y}"]`)?.scrollIntoView({block:"nearest"})},[y,a]);function W(t){let e=d.current?.getTextarea();if(!e)return;let n,o;if(r){let M=r.kind==="slash"?`/${t.payload} `:`@${t.label} `;if(n=i.slice(0,r.start)+M+i.slice(r.end),r.kind==="at")F?.(t.payload);o=r.start+M.length}else if(s)n=`${i.length===0||i.endsWith(`
1
+ import{jsx as c,jsxs as E,Fragment as ot}from"react/jsx-runtime";import{autoUpdate as st}from"@floating-ui/dom";import{cn as Q}from"cn";import{BookOpenTextIcon as it,FileIcon as lt,StoreIcon as ut}from"lucide-react";import{useCallback as at,useEffect as p,useLayoutEffect as G,useMemo as J,useRef as X,useState as v}from"react";import{createPortal as ct}from"react-dom";import{Button as Y}from"../ui/button.js";import{Separator as dt}from"../ui/separator.js";import{filterSlashCommands as Z}from"./completion-filter.js";import{detectTrigger as ft}from"./completion-trigger.js";import{usePromptInputController as mt}from"./prompt-input-context.js";function It({handleRef:d,anchorRef:u,commands:T,searchFiles:l,onMention:F,onSearchError:A,fileSearchDebounceMs:q=0,bashMode:B=!1,forcedOpen:s=!1,onForcedOpenChange:f,emptyLabel:R,fileStatusLabels:h,morePlugins:D}){let S=mt(),i=S.textInput.value,[z,_]=v(0),[x,N]=v(null),[y,L]=v(0),U=X(null);p(()=>{let t=d.current?.getTextarea();if(!t)return;let e=()=>_(t.selectionStart??0),n=()=>{if(document.activeElement===t)e()};return t.addEventListener("keyup",e),t.addEventListener("click",e),t.addEventListener("input",e),t.addEventListener("select",e),t.addEventListener("focus",e),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",e),t.removeEventListener("click",e),t.removeEventListener("input",e),t.removeEventListener("select",e),t.removeEventListener("focus",e),document.removeEventListener("selectionchange",n)}});let V=J(()=>B&&i.startsWith("!")?null:ft(i,z),[i,z,B]),r=V?.kind==="at"&&!l?null:V,P=`${r?.kind??"forced"}:${r?.query??""}:${s}`,[O,tt]=v(P);if(O!==P)tt(P),L(0);let b=X(null);p(()=>{if(!s){b.current=null;return}if(b.current===null)b.current=i;else if(i!==b.current)f?.(!1)},[s,i,f]);let g=r?.kind==="at"?r.query:null;p(()=>{if(g===null||!l){N(null);return}let t=!0,e=()=>{l(g).then((o)=>{if(t)N({query:g,search:l,items:o})},(o)=>{if(t)N({query:g,search:l,items:[]}),A(o)})},n=q>0?window.setTimeout(e,q):null;if(n===null)e();return()=>{if(t=!1,n!==null)window.clearTimeout(n)}},[g,l,q,A]);let m=J(()=>{if(r?.kind==="at")return x?.query===r.query&&x.search===l?x.items:[];if(r)return Z(T,r.query);if(s)return Z(T,"");return[]},[r,s,T,x,l]),[et,j]=v(!1);p(()=>{let t=d.current?.getTextarea();if(!t)return;let e=()=>j(!0),n=()=>{if(j(!1),s)f?.(!1)};return j(document.activeElement===t),t.addEventListener("focus",e),t.addEventListener("blur",n),()=>{t.removeEventListener("focus",e),t.removeEventListener("blur",n)}},[d,s,f]),p(()=>{if(s)d.current?.getTextarea()?.focus()},[s,d]);let a=et&&(r!==null?r.kind==="slash"||m.length>0||!!h:s);p(()=>{if(!a)return;U.current?.querySelector(`[data-idx="${y}"]`)?.scrollIntoView({block:"nearest"})},[y,a]);function W(t){let e=d.current?.getTextarea();if(!e)return;let n,o;if(r){let M=r.kind==="slash"?`/${t.payload} `:`@${t.label} `;if(n=i.slice(0,r.start)+M+i.slice(r.end),r.kind==="at")F?.(t.payload);o=r.start+M.length}else if(s)n=`${i.length===0||i.endsWith(`
2
2
  `)?i:`${i}
3
- `}/${t.payload} `,o=n.length,f?.(!1);else return;S.textInput.setInput(n),requestAnimationFrame(()=>{e.focus(),e.setSelectionRange(o,o)})}p(()=>{let t=d.current?.getTextarea();if(!t)return;let e=(n)=>{if(!a)return;if(n.isComposing||n.keyCode===229)return;if(n.key==="ArrowDown")n.preventDefault(),n.stopPropagation(),L((o)=>m.length===0?0:Math.min(m.length-1,o+1));else if(n.key==="ArrowUp")n.preventDefault(),n.stopPropagation(),L((o)=>Math.max(0,o-1));else if(n.key==="Enter"||n.key==="Tab"){n.preventDefault(),n.stopPropagation();let o=m[y];if(o)W(o)}else if(n.key==="Escape")if(n.preventDefault(),n.stopPropagation(),r)_(Math.max(0,r.start-1)),t.setSelectionRange(r.start,r.start);else f?.(!1)};return t.addEventListener("keydown",e,!0),()=>t.removeEventListener("keydown",e,!0)});let[w,H]=v(null),[C,nt]=v(null),I=at(()=>{let t=u?.current;if(!t)return;let e=t.getBoundingClientRect();H({left:e.left,width:e.width,bottom:window.innerHeight-e.top+8})},[u]);if(Q(()=>{if(!a){H(null);return}I()},[a,I]),Q(()=>{let t=u?.current;if(!a||!t||!C)return;return st(t,C,I,{animationFrame:!0})},[a,C,u,I]),!a||u&&!w)return null;let k=r?r.kind==="slash":s,rt=k?it:lt,K=c("div",{ref:nt,className:u?"fixed z-50":"absolute inset-x-0 bottom-full z-50 mb-2",style:u&&w?{left:w.left,width:w.width,bottom:w.bottom}:void 0,children:E("div",{ref:U,role:"listbox",onMouseDown:(t)=>t.preventDefault(),className:"bg-popover text-popover-foreground ring-foreground/10 pointer-events-auto w-full overflow-hidden rounded-lg p-1 shadow-md ring-1 outline-hidden",children:[E("div",{className:"max-h-72 overflow-y-auto",children:[m.length===0&&k&&c("div",{className:"text-muted-foreground px-2 py-3 text-xs",children:R}),m.length===0&&!k&&h&&c("div",{role:"status",className:"text-muted-foreground px-2 py-3 text-xs",children:x?.query===g&&x.search===l?h.empty:h.loading}),m.map((t,e)=>E(X,{type:"button",variant:"ghost",role:"option","aria-selected":e===y,"data-idx":e,onMouseDown:(n)=>{n.preventDefault(),W(t)},onMouseEnter:()=>L(e),className:Y("flex h-auto w-full items-center justify-start gap-2.5 rounded-md px-2.5 py-2 text-start",e===y&&"bg-muted"),children:[c(rt,{className:Y("size-4 shrink-0",k?"text-blue-500":"text-muted-foreground")}),c("span",{className:"text-foreground shrink-0 text-sm font-medium",children:t.label}),t.description&&c("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:t.description})]},t.key))]}),k&&D&&E(ot,{children:[c(dt,{}),E(X,{type:"button",variant:"ghost",onMouseDown:(t)=>{t.preventDefault(),f?.(!1),D.open()},className:"h-auto w-full justify-start px-2.5 py-2",children:[c(ut,{"data-icon":"inline-start"}),D.label]})]})]})});return u?ct(K,document.body):K}export{It as CompletionMenu};
3
+ `}/${t.payload} `,o=n.length,f?.(!1);else return;S.textInput.setInput(n),requestAnimationFrame(()=>{e.focus(),e.setSelectionRange(o,o)})}p(()=>{let t=d.current?.getTextarea();if(!t)return;let e=(n)=>{if(!a)return;if(n.isComposing||n.keyCode===229)return;if(n.key==="ArrowDown")n.preventDefault(),n.stopPropagation(),L((o)=>m.length===0?0:Math.min(m.length-1,o+1));else if(n.key==="ArrowUp")n.preventDefault(),n.stopPropagation(),L((o)=>Math.max(0,o-1));else if(n.key==="Enter"||n.key==="Tab"){n.preventDefault(),n.stopPropagation();let o=m[y];if(o)W(o)}else if(n.key==="Escape")if(n.preventDefault(),n.stopPropagation(),r)_(Math.max(0,r.start-1)),t.setSelectionRange(r.start,r.start);else f?.(!1)};return t.addEventListener("keydown",e,!0),()=>t.removeEventListener("keydown",e,!0)});let[w,H]=v(null),[C,nt]=v(null),I=at(()=>{let t=u?.current;if(!t)return;let e=t.getBoundingClientRect();H({left:e.left,width:e.width,bottom:window.innerHeight-e.top+8})},[u]);if(G(()=>{if(!a){H(null);return}I()},[a,I]),G(()=>{let t=u?.current;if(!a||!t||!C)return;return st(t,C,I,{animationFrame:!0})},[a,C,u,I]),!a||u&&!w)return null;let k=r?r.kind==="slash":s,rt=k?it:lt,K=c("div",{ref:nt,className:u?"fixed z-50":"absolute inset-x-0 bottom-full z-50 mb-2",style:u&&w?{left:w.left,width:w.width,bottom:w.bottom}:void 0,children:E("div",{ref:U,role:"listbox",onMouseDown:(t)=>t.preventDefault(),className:"bg-popover text-popover-foreground ring-foreground/10 pointer-events-auto w-full overflow-hidden rounded-lg p-1 shadow-md ring-1 outline-hidden",children:[E("div",{className:"max-h-72 overflow-y-auto",children:[m.length===0&&k&&c("div",{className:"text-muted-foreground px-2 py-3 text-xs",children:R}),m.length===0&&!k&&h&&c("div",{role:"status",className:"text-muted-foreground px-2 py-3 text-xs",children:x?.query===g&&x.search===l?h.empty:h.loading}),m.map((t,e)=>E(Y,{type:"button",variant:"ghost",role:"option","aria-selected":e===y,"data-idx":e,onMouseDown:(n)=>{n.preventDefault(),W(t)},onMouseEnter:()=>L(e),className:Q("flex h-auto w-full items-center justify-start gap-2.5 rounded-md px-2.5 py-2 text-start",e===y&&"bg-muted"),children:[c(rt,{className:Q("size-4 shrink-0",k?"text-blue-500":"text-muted-foreground")}),c("span",{className:"text-foreground shrink-0 text-sm font-medium",children:t.label}),t.description&&c("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:t.description})]},t.key))]}),k&&D&&E(ot,{children:[c(dt,{}),E(Y,{type:"button",variant:"ghost",onMouseDown:(t)=>{t.preventDefault(),f?.(!1),D.open()},className:"h-auto w-full justify-start px-2.5 py-2",children:[c(ut,{"data-icon":"inline-start"}),D.label]})]})]})});return u?ct(K,document.body):K}export{It as CompletionMenu};
@@ -1,3 +1,3 @@
1
1
  function u(r,e){if(e===0)return null;let n=e-1;while(n>=0){let t=r[n];if(t===" "||t==="\t"||t===`
2
2
  `)return null;if(t==="@"||t==="/"){let i=n===0?"":r[n-1],l=n===0||i===`
3
- `;if(t==="/"?l&&!/[\/\\]/.test(r.slice(n+1,e)):l||i===" "||i==="\t")return{kind:t==="/"?"slash":"at",start:n,end:e,query:r.slice(n+1,e)}}n-=1}return null}export{u as detectTrigger};
3
+ `;if(t==="/"?l&&!/[/\\]/.test(r.slice(n+1,e)):l||i===" "||i==="\t")return{kind:t==="/"?"slash":"at",start:n,end:e,query:r.slice(n+1,e)}}n-=1}return null}export{u as detectTrigger};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as i}from"react/jsx-runtime";import{DropdownMenuRadioGroup as s,DropdownMenuRadioItem as d}from"../ui/dropdown-menu.js";import{cn as c}from"cn";function p({value:a,onValueChange:n,options:l,itemClassName:r}){return t(s,{value:a,onValueChange:(e)=>n(String(e)),children:l.map((e)=>i(d,{value:e.value,disabled:e.disabled,title:e.title,closeOnClick:!0,className:c("gap-2",e.description?"items-start":"items-center",r),children:[e.icon,e.description?i("div",{className:"min-w-0 flex-1",children:[t("div",{className:"text-xs font-medium",children:e.label}),t("div",{className:"text-muted-foreground text-[11px] font-normal",children:e.description})]}):t("span",{className:"min-w-0 flex-1 truncate text-start",children:e.label})]},e.value))})}export{p as MenuRadioSelect};
1
+ import{jsx as t,jsxs as i}from"react/jsx-runtime";import{cn as s}from"cn";import{DropdownMenuRadioGroup as d,DropdownMenuRadioItem as c}from"../ui/dropdown-menu.js";function p({value:a,onValueChange:n,options:l,itemClassName:r}){return t(d,{value:a,onValueChange:(e)=>n(String(e)),children:l.map((e)=>i(c,{value:e.value,disabled:e.disabled,title:e.title,closeOnClick:!0,className:s("gap-2",e.description?"items-start":"items-center",r),children:[e.icon,e.description?i("div",{className:"min-w-0 flex-1",children:[t("div",{className:"text-xs font-medium",children:e.label}),t("div",{className:"text-muted-foreground text-[11px] font-normal",children:e.description})]}):t("span",{className:"min-w-0 flex-1 truncate text-start",children:e.label})]},e.value))})}export{p as MenuRadioSelect};
@@ -1,7 +1,7 @@
1
1
  import { type ComponentProps, type ReactNode } from "react";
2
- import { type MenuRadioOption } from "./menu-radio.js";
3
- import { EffortSlider } from "./effort-slider.js";
4
2
  import { Button } from "../ui/button.js";
3
+ import { EffortSlider } from "./effort-slider.js";
4
+ import { type MenuRadioOption } from "./menu-radio.js";
5
5
  export interface ChatModelOption {
6
6
  api_id: string;
7
7
  label: string;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as a,Fragment as u}from"react/jsx-runtime";import{ArrowUpRight as se,ChevronUp as T,Loader2Icon as A}from"lucide-react";import{Fragment as te,useState as F}from"react";import{cn as g}from"cn";import{MenuRadioSelect as d}from"./menu-radio.js";import{EffortSlider as le}from"./effort-slider.js";import{Button as S}from"../ui/button.js";import{Switch as re}from"../ui/switch.js";import{Tooltip as I,TooltipContent as R,TooltipTrigger as U}from"../ui/tooltip.js";import{DropdownMenu as B,DropdownMenuContent as E,DropdownMenuGroup as y,DropdownMenuItem as z,DropdownMenuLabel as L,DropdownMenuSeparator as c,DropdownMenuSub as W,DropdownMenuSubContent as q,DropdownMenuSubTrigger as H,DropdownMenuTrigger as J}from"../ui/dropdown-menu.js";function Ne({value:h,onChange:K,models:p,modelGroups:b,providerMenu:r,header:w,className:_,condensed:C,stripLabelPrefix:D,showDescription:Q,showModelList:X=!0,loading:Y,switching:M,isLoading:Z,effortConfig:t,booleanOptions:k,onBooleanChange:G,selectOptions:P=[],t:l,...x}){let[ee,ne]=F(!1),[ae,ie]=F(!1),V=(n)=>D&&n.startsWith(D)?n.slice(D.length):n;if(Y)return e("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:a(S,{variant:"ghost",disabled:!0,className:g("h-7 min-w-0 shrink gap-1.5 rounded-md px-2 text-xs font-normal",_),children:[e(A,{className:"size-3 animate-spin"}),e("span",{className:"text-muted-foreground truncate",children:l("model.loadingModels")})]})});return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:[r&&a(B,{open:ee,onOpenChange:ne,children:[a(I,{children:[e(U,{render:e(J,{render:a(S,{"data-testid":"provider-trigger",variant:"ghost",disabled:x.disabled,className:g("h-7 shrink-0 gap-1 rounded-md px-1.5","hover:bg-accent"),children:[r.icon,e(T,{className:"size-2.5 shrink-0 opacity-60"})]})})}),e(R,{children:l("model.switchProvider")})]}),a(E,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[r.groups.map((n,s)=>a(te,{children:[s>0&&n.length>0&&e(c,{}),e(d,{value:r.value,onValueChange:r.onChange,options:n})]},s)),r.moreAction&&a(u,{children:[e(c,{}),a(z,{onClick:r.moreAction,className:"whitespace-nowrap",children:[e("span",{className:"min-w-0 flex-1 truncate",children:l("model.moreModels")}),e(se,{className:"size-4"})]})]})]})]}),a(B,{open:ae,onOpenChange:ie,children:[a(I,{children:[e(U,{render:e(J,{render:a(S,{"data-testid":"model-trigger","aria-busy":M,variant:"ghost",className:g("h-7 gap-1.5 rounded-md px-2 text-xs font-normal","hover:bg-accent","max-w-full min-w-0 shrink",C&&"h-7 gap-1 px-1.5 text-[11px]",_),...x,children:[e("span",{className:g("min-w-0 flex-1 truncate text-start",C&&"text-[11px]"),children:V(h.label)||l("model.selectModel")}),t&&a("span",{className:"text-muted-foreground grid shrink-0 justify-items-center",children:[e("span",{className:"invisible col-start-1 row-start-1",children:t.sizer??t.levels.reduce((n,s)=>s.name.length>n.length?s.name:n,"")}),e("span",{className:"col-start-1 row-start-1",children:t.levels.find((n)=>n.value===t.value)?.name??t.value})]}),M?e(A,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"}):e(T,{className:g("size-3 shrink-0",C&&"size-2.5")})]})})}),e(R,{children:l("model.switchModel")})]}),a(E,{side:"top",align:"end",sideOffset:4,className:"z-100 w-auto max-w-[min(24rem,calc(100vw-1rem))] min-w-[14rem]",children:[w&&a(u,{children:[a("div",{className:"flex items-center gap-2 px-2 py-2",children:[w.icon,e("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:w.name}),w.action]}),e(c,{})]}),a(y,{children:[X&&(Z?e(z,{disabled:!0,className:"text-muted-foreground",children:l("model.loadingModels")}):p.length===0?e(z,{disabled:!0,className:"text-muted-foreground",children:l("model.noModelsAvailable")}):(()=>{let n=p.filter((i)=>!i.more),s=p.filter((i)=>i.more),O=n.length>0&&s.length>0,N=(i,m)=>({value:i.api_id,label:V(i.label),description:m?.noDescription?void 0:Q?i.description:void 0}),f=(i)=>{let m=p.find((v)=>v.api_id===i);if(m)K(m)};return a(u,{children:[b?b.map((i)=>{let m=i.models.filter((o)=>!o.more),v=i.models.filter((o)=>o.more),j=m.length>0&&v.length>0;return a(y,{children:[e(L,{className:"text-muted-foreground text-xs font-normal",children:i.name}),e(d,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:(j?m:i.models).map((o)=>N(o))}),j&&a(W,{children:[e(H,{className:"font-medium whitespace-nowrap",children:l("model.moreModels")}),e(q,{children:e(d,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:v.map((o)=>N(o,{noDescription:!0}))})})]})]},i.id)}):e(d,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:(O?n:p).map((i)=>N(i))}),!b&&O&&a(W,{children:[e(H,{className:"font-medium whitespace-nowrap",children:l("model.moreModels")}),e(q,{children:e(d,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:s.map((i)=>N(i,{noDescription:!0}))})})]})]})})()),t&&a(u,{children:[e(c,{}),e(le,{...t,disabled:x.disabled})]}),P.map((n)=>a(y,{children:[e(c,{}),e(L,{children:n.name}),e(d,{value:n.value,onValueChange:n.onChange,options:n.options,itemClassName:"whitespace-nowrap"})]},n.id)),k&&k.length>0&&a(u,{children:[!t&&e(c,{}),k.map((n)=>a("div",{className:"flex items-center justify-between gap-3 px-2 py-2.5",children:[e("span",{className:"text-sm font-medium",children:n.name}),e(re,{"aria-label":n.name,disabled:x.disabled,checked:n.currentValue,onCheckedChange:(s)=>G?.(n.id,s)})]},n.id))]})]})]})]})]})}export{Ne as ModelSelect};
1
+ import{jsx as e,jsxs as a,Fragment as u}from"react/jsx-runtime";import{cn as g}from"cn";import{ArrowUpRight as se,ChevronUp as T,Loader2Icon as A}from"lucide-react";import{Fragment as te,useState as F}from"react";import{Button as S}from"../ui/button.js";import{DropdownMenu as I,DropdownMenuContent as R,DropdownMenuGroup as y,DropdownMenuItem as z,DropdownMenuLabel as U,DropdownMenuSeparator as d,DropdownMenuSub as B,DropdownMenuSubContent as E,DropdownMenuSubTrigger as L,DropdownMenuTrigger as W}from"../ui/dropdown-menu.js";import{Switch as le}from"../ui/switch.js";import{Tooltip as q,TooltipContent as H,TooltipTrigger as J}from"../ui/tooltip.js";import{EffortSlider as re}from"./effort-slider.js";import{MenuRadioSelect as c}from"./menu-radio.js";function Ne({value:h,onChange:K,models:p,modelGroups:b,providerMenu:r,header:w,className:_,condensed:C,stripLabelPrefix:D,showDescription:Q,showModelList:X=!0,loading:Y,switching:M,isLoading:Z,effortConfig:t,booleanOptions:k,onBooleanChange:G,selectOptions:P=[],t:l,...x}){let[ee,ne]=F(!1),[ae,ie]=F(!1),V=(n)=>D&&n.startsWith(D)?n.slice(D.length):n;if(Y)return e("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:a(S,{variant:"ghost",disabled:!0,className:g("h-7 min-w-0 shrink gap-1.5 rounded-md px-2 text-xs font-normal",_),children:[e(A,{className:"size-3 animate-spin"}),e("span",{className:"text-muted-foreground truncate",children:l("model.loadingModels")})]})});return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:[r&&a(I,{open:ee,onOpenChange:ne,children:[a(q,{children:[e(J,{render:e(W,{render:a(S,{"data-testid":"provider-trigger",variant:"ghost",disabled:x.disabled,className:g("h-7 shrink-0 gap-1 rounded-md px-1.5","hover:bg-accent"),children:[r.icon,e(T,{className:"size-2.5 shrink-0 opacity-60"})]})})}),e(H,{children:l("model.switchProvider")})]}),a(R,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[r.groups.map((n,s)=>a(te,{children:[s>0&&n.length>0&&e(d,{}),e(c,{value:r.value,onValueChange:r.onChange,options:n})]},s)),r.moreAction&&a(u,{children:[e(d,{}),a(z,{onClick:r.moreAction,className:"whitespace-nowrap",children:[e("span",{className:"min-w-0 flex-1 truncate",children:l("model.moreModels")}),e(se,{className:"size-4"})]})]})]})]}),a(I,{open:ae,onOpenChange:ie,children:[a(q,{children:[e(J,{render:e(W,{render:a(S,{"data-testid":"model-trigger","aria-busy":M,variant:"ghost",className:g("h-7 gap-1.5 rounded-md px-2 text-xs font-normal","hover:bg-accent","max-w-full min-w-0 shrink",C&&"h-7 gap-1 px-1.5 text-[11px]",_),...x,children:[e("span",{className:g("min-w-0 flex-1 truncate text-start",C&&"text-[11px]"),children:V(h.label)||l("model.selectModel")}),t&&a("span",{className:"text-muted-foreground grid shrink-0 justify-items-center",children:[e("span",{className:"invisible col-start-1 row-start-1",children:t.sizer??t.levels.reduce((n,s)=>s.name.length>n.length?s.name:n,"")}),e("span",{className:"col-start-1 row-start-1",children:t.levels.find((n)=>n.value===t.value)?.name??t.value})]}),M?e(A,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"}):e(T,{className:g("size-3 shrink-0",C&&"size-2.5")})]})})}),e(H,{children:l("model.switchModel")})]}),a(R,{side:"top",align:"end",sideOffset:4,className:"z-100 w-auto max-w-[min(24rem,calc(100vw-1rem))] min-w-[14rem]",children:[w&&a(u,{children:[a("div",{className:"flex items-center gap-2 px-2 py-2",children:[w.icon,e("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:w.name}),w.action]}),e(d,{})]}),a(y,{children:[X&&(Z?e(z,{disabled:!0,className:"text-muted-foreground",children:l("model.loadingModels")}):p.length===0?e(z,{disabled:!0,className:"text-muted-foreground",children:l("model.noModelsAvailable")}):(()=>{let n=p.filter((i)=>!i.more),s=p.filter((i)=>i.more),O=n.length>0&&s.length>0,N=(i,m)=>({value:i.api_id,label:V(i.label),description:m?.noDescription?void 0:Q?i.description:void 0}),f=(i)=>{let m=p.find((v)=>v.api_id===i);if(m)K(m)};return a(u,{children:[b?b.map((i)=>{let m=i.models.filter((o)=>!o.more),v=i.models.filter((o)=>o.more),j=m.length>0&&v.length>0;return a(y,{children:[e(U,{className:"text-muted-foreground text-xs font-normal",children:i.name}),e(c,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:(j?m:i.models).map((o)=>N(o))}),j&&a(B,{children:[e(L,{className:"font-medium whitespace-nowrap",children:l("model.moreModels")}),e(E,{children:e(c,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:v.map((o)=>N(o,{noDescription:!0}))})})]})]},i.id)}):e(c,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:(O?n:p).map((i)=>N(i))}),!b&&O&&a(B,{children:[e(L,{className:"font-medium whitespace-nowrap",children:l("model.moreModels")}),e(E,{children:e(c,{value:h.api_id,onValueChange:f,itemClassName:"font-medium whitespace-nowrap",options:s.map((i)=>N(i,{noDescription:!0}))})})]})]})})()),t&&a(u,{children:[e(d,{}),e(re,{...t,disabled:x.disabled})]}),P.map((n)=>a(y,{children:[e(d,{}),e(U,{children:n.name}),e(c,{value:n.value,onValueChange:n.onChange,options:n.options,itemClassName:"whitespace-nowrap"})]},n.id)),k&&k.length>0&&a(u,{children:[!t&&e(d,{}),k.map((n)=>a("div",{className:"flex items-center justify-between gap-3 px-2 py-2.5",children:[e("span",{className:"text-sm font-medium",children:n.name}),e(le,{"aria-label":n.name,disabled:x.disabled,checked:n.currentValue,onCheckedChange:(s)=>G?.(n.id,s)})]},n.id))]})]})]})]})]})}export{Ne as ModelSelect};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r,Fragment as z}from"react/jsx-runtime";import{PaperclipIcon as A,XIcon as T}from"lucide-react";import{Fragment as H,useEffect as M,useRef as R,useState as b}from"react";import{cn as h}from"cn";import{Button as N}from"../ui/button.js";import{HoverCard as S,HoverCardContent as _,HoverCardTrigger as D}from"../ui/hover-card.js";import{ImagePreviewDialog as E}from"../image-preview-dialog.js";import{usePromptInputAttachments as C}from"./prompt-input-context.js";function F(t){return e(_,{align:"start",...t})}function U({data:t,t:n,className:p,...c}){let l=C(),[u,f]=b(!1),[P,d]=b(1),I=R(null),a=t.filename||"",i=(t.mediaType?.startsWith("image/")&&t.url?"image":"file")==="image",k=a||(i?n("input.image"):n("input.attachment"));return M(()=>{if(!u)return;let m=0.1,g=(o)=>Math.min(10,Math.max(0.1,o)),v=(o)=>{if(!(o.ctrlKey||o.metaKey))return;let s=o.key,x=s==="+"||s==="=",j=s==="-"||s==="_",w=s==="0";if(!x&&!j&&!w)return;o.preventDefault(),d((y)=>{if(w)return 1;if(x)return g(y+m);return g(y-m)})};return window.addEventListener("keydown",v,{passive:!1}),()=>window.removeEventListener("keydown",v)},[u]),r(z,{children:[r(S,{children:[e(D,{render:r("div",{className:h("group border-border hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent relative flex h-8 cursor-pointer items-center gap-1.5 rounded-md border px-1.5 text-sm font-medium transition-all select-none",p),...c,children:[r("div",{className:"relative size-5 shrink-0",children:[i?e(N,{type:"button",variant:"ghost",size:"icon-xs","aria-label":n("input.image"),className:"bg-background absolute inset-0 size-5 overflow-hidden rounded p-0 transition-opacity group-hover:opacity-0",onClick:()=>{d(1),f(!0)},children:e("img",{alt:a||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20})}):e("div",{className:"bg-background text-muted-foreground absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded transition-opacity group-hover:opacity-0",children:e(A,{className:"size-3"})}),r(N,{"aria-label":n("input.removeAttachment"),className:h("absolute -top-1 -right-1 size-4 rounded-full p-0 opacity-0 transition-opacity [&>svg]:size-3","pointer-events-none group-hover:pointer-events-auto group-hover:opacity-100"),onClick:(m)=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e(T,{}),e("span",{className:"sr-only",children:n("input.removeAttachment")})]})]}),!i&&e("span",{className:"max-w-40 flex-1 truncate text-xs",children:k})]})}),e(F,{className:"w-auto p-2",children:r("div",{className:"w-auto space-y-3",children:[i&&e("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e("img",{alt:a||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e("div",{className:"flex items-center gap-2.5",children:r("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e("h4",{className:"truncate text-sm leading-none font-semibold",children:a||(i?"Image":"Attachment")}),t.mediaType&&e("p",{className:"text-muted-foreground truncate font-mono text-xs",children:t.mediaType})]})})]})})]}),i&&t.url&&e(E,{containerRef:I,filename:a||n("input.image"),onOpenChange:f,onScaleChange:d,open:u,scale:P,url:t.url})]})}function V({children:t,className:n,...p}){let c=C();if(!c.files.length)return null;return e("div",{className:h("flex w-full flex-wrap items-center gap-1",n),...p,children:c.files.map((l)=>e(H,{children:t(l)},l.id))})}export{U as PromptInputAttachment,V as PromptInputAttachments};
1
+ import{jsx as e,jsxs as r,Fragment as z}from"react/jsx-runtime";import{cn as h}from"cn";import{PaperclipIcon as A,XIcon as T}from"lucide-react";import{Fragment as H,useEffect as M,useRef as R,useState as b}from"react";import{ImagePreviewDialog as S}from"../image-preview-dialog.js";import{Button as N}from"../ui/button.js";import{HoverCard as _,HoverCardContent as D,HoverCardTrigger as E}from"../ui/hover-card.js";import{usePromptInputAttachments as C}from"./prompt-input-context.js";function F(t){return e(D,{align:"start",...t})}function U({data:t,t:n,className:p,...c}){let l=C(),[u,f]=b(!1),[P,d]=b(1),I=R(null),a=t.filename||"",i=(t.mediaType?.startsWith("image/")&&t.url?"image":"file")==="image",k=a||(i?n("input.image"):n("input.attachment"));return M(()=>{if(!u)return;let m=0.1,g=(o)=>Math.min(10,Math.max(0.1,o)),v=(o)=>{if(!(o.ctrlKey||o.metaKey))return;let s=o.key,x=s==="+"||s==="=",j=s==="-"||s==="_",w=s==="0";if(!x&&!j&&!w)return;o.preventDefault(),d((y)=>{if(w)return 1;if(x)return g(y+m);return g(y-m)})};return window.addEventListener("keydown",v,{passive:!1}),()=>window.removeEventListener("keydown",v)},[u]),r(z,{children:[r(_,{children:[e(E,{render:r("div",{className:h("group border-border hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent relative flex h-8 cursor-pointer items-center gap-1.5 rounded-md border px-1.5 text-sm font-medium transition-all select-none",p),...c,children:[r("div",{className:"relative size-5 shrink-0",children:[i?e(N,{type:"button",variant:"ghost",size:"icon-xs","aria-label":n("input.image"),className:"bg-background absolute inset-0 size-5 overflow-hidden rounded p-0 transition-opacity group-hover:opacity-0",onClick:()=>{d(1),f(!0)},children:e("img",{alt:a||"attachment",className:"size-5 object-cover",height:20,src:t.url,width:20})}):e("div",{className:"bg-background text-muted-foreground absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded transition-opacity group-hover:opacity-0",children:e(A,{className:"size-3"})}),r(N,{"aria-label":n("input.removeAttachment"),className:h("absolute -top-1 -right-1 size-4 rounded-full p-0 opacity-0 transition-opacity [&>svg]:size-3","pointer-events-none group-hover:pointer-events-auto group-hover:opacity-100"),onClick:(m)=>{m.stopPropagation(),l.remove(t.id)},type:"button",variant:"ghost",children:[e(T,{}),e("span",{className:"sr-only",children:n("input.removeAttachment")})]})]}),!i&&e("span",{className:"max-w-40 flex-1 truncate text-xs",children:k})]})}),e(F,{className:"w-auto p-2",children:r("div",{className:"w-auto space-y-3",children:[i&&e("div",{className:"flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",children:e("img",{alt:a||"attachment preview",className:"max-h-full max-w-full object-contain",height:384,src:t.url,width:448})}),e("div",{className:"flex items-center gap-2.5",children:r("div",{className:"min-w-0 flex-1 space-y-1 px-0.5",children:[e("h4",{className:"truncate text-sm leading-none font-semibold",children:a||(i?"Image":"Attachment")}),t.mediaType&&e("p",{className:"text-muted-foreground truncate font-mono text-xs",children:t.mediaType})]})})]})})]}),i&&t.url&&e(S,{containerRef:I,filename:a||n("input.image"),onOpenChange:f,onScaleChange:d,open:u,scale:P,url:t.url})]})}function V({children:t,className:n,...p}){let c=C();if(!c.files.length)return null;return e("div",{className:h("flex w-full flex-wrap items-center gap-1",n),...p,children:c.files.map((l)=>e(H,{children:t(l)},l.id))})}export{U as PromptInputAttachment,V as PromptInputAttachments};
@@ -4,7 +4,6 @@ export declare function scanClipboardForImageFiles(items: DataTransferItemList):
4
4
  sawNonImageFile: boolean;
5
5
  };
6
6
  export declare function clipboardHasStringItem(items: DataTransferItemList): boolean;
7
- export declare const INPUT_CONTROL_CHARS_REGEX: RegExp;
8
7
  export declare function sanitizeTextareaValue(value: string): string;
9
8
  export declare function countControlCharsBeforeIndex(value: string, endExclusive: number): number;
10
9
  export declare function sanitizeTextareaTargetValue(target: HTMLTextAreaElement): string;
@@ -1 +1 @@
1
- function u(e,n){if(e.type||!n.type)return e;let o=n.type.split("/")[1],i=o!==void 0&&o!==""?`pasted-${Date.now()}.${o==="jpeg"?"jpg":o}`:"";return new File([e],e.name||i||`pasted-${Date.now()}`,{type:n.type})}function p(e){let n=[],o=!1;for(let i of e){if(i.kind!=="file")continue;let t=i.getAsFile();if(!t)continue;if(!(t.type||i.type).startsWith("image/")){o=!0;continue}n.push(u(t,i))}return{imageFiles:n,sawNonImageFile:o}}function f(e){return Array.from(e).some((n)=>n.kind==="string")}var c=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g;function l(e){return e.replace(c,"")}function a(e,n){let o=0;for(let i=0;i<n;i++){let t=e.charCodeAt(i);if(t>=0&&t<=8||t===11||t===12||t>=14&&t<=31||t===127)o++}return o}function m(e){let{value:n,selectionStart:o,selectionEnd:i}=e,t=l(n);if(t===n)return t;if(e.value=t,o!==null&&i!==null){let r=Math.max(0,o-a(n,o)),s=Math.max(0,i-a(n,i));requestAnimationFrame(()=>{e.setSelectionRange(r,s)})}return t}export{c as INPUT_CONTROL_CHARS_REGEX,f as clipboardHasStringItem,a as countControlCharsBeforeIndex,u as normalizePastedImageFile,m as sanitizeTextareaTargetValue,l as sanitizeTextareaValue,p as scanClipboardForImageFiles};
1
+ function c(t,e){if(t.type||!e.type)return t;let o=e.type.split("/")[1],i=o!==void 0&&o!==""?`pasted-${Date.now()}.${o==="jpeg"?"jpg":o}`:"";return new File([t],t.name||i||`pasted-${Date.now()}`,{type:e.type})}function p(t){let e=[],o=!1;for(let i of t){if(i.kind!=="file")continue;let n=i.getAsFile();if(!n)continue;if(!(n.type||i.type).startsWith("image/")){o=!0;continue}e.push(c(n,i))}return{imageFiles:e,sawNonImageFile:o}}function f(t){return Array.from(t).some((e)=>e.kind==="string")}function u(t){let e=t.codePointAt(0);return e<32&&e!==9&&e!==10&&e!==13||e===127}function l(t){return[...t].filter((e)=>!u(e)).join("")}function a(t,e){let o=0;for(let i=0;i<e;i++){let n=t.charCodeAt(i);if(n>=0&&n<=8||n===11||n===12||n>=14&&n<=31||n===127)o++}return o}function d(t){let{value:e,selectionStart:o,selectionEnd:i}=t,n=l(e);if(n===e)return n;if(t.value=n,o!==null&&i!==null){let r=Math.max(0,o-a(e,o)),s=Math.max(0,i-a(e,i));requestAnimationFrame(()=>{t.setSelectionRange(r,s)})}return n}export{f as clipboardHasStringItem,a as countControlCharsBeforeIndex,c as normalizePastedImageFile,d as sanitizeTextareaTargetValue,l as sanitizeTextareaValue,p as scanClipboardForImageFiles};
@@ -1,3 +1,3 @@
1
- import{jsx as D}from"react/jsx-runtime";import{forwardRef as E,useCallback as P,useEffect as R,useImperativeHandle as F,useRef as m}from"react";import{InputGroupTextarea as A}from"../ui/input-group-textarea.js";import{cn as H}from"cn";import{clipboardHasStringItem as j,sanitizeTextareaTargetValue as g,scanClipboardForImageFiles as q}from"./prompt-input-clipboard.js";import{useOptionalPromptInputController as z,usePromptInputAttachments as N}from"./prompt-input-context.js";var B=(o)=>!o.shiftKey,K=()=>!1,V=E(({onChange:o,className:v,placeholder:x,bashMode:y=!1,isSendShortcut:I=B,isNewlineShortcut:b=K,...k},T)=>{let n=z(),i=N(),l=m(!1),u=m(!1),a=m(null),s=P(()=>{let t=a.current;if(!t)return;t.style.height="auto",t.style.height=`${t.scrollHeight}px`},[]);R(()=>{let t=a.current;if(!t)return;let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>e.disconnect()},[s]);let p=y&&(n?.textInput.value??"").startsWith("!"),C=(t)=>{if(l.current||t.nativeEvent.isComposing||t.nativeEvent.keyCode===229||u.current)return;if(t.key.length===1&&t.key.charCodeAt(0)<32&&t.key!==`
1
+ import{jsx as D}from"react/jsx-runtime";import{cn as E}from"cn";import{forwardRef as P,useCallback as R,useEffect as F,useImperativeHandle as A,useRef as m}from"react";import{InputGroupTextarea as H}from"../ui/input-group-textarea.js";import{clipboardHasStringItem as j,sanitizeTextareaTargetValue as g,scanClipboardForImageFiles as q}from"./prompt-input-clipboard.js";import{useOptionalPromptInputController as z,usePromptInputAttachments as N}from"./prompt-input-context.js";var B=(o)=>!o.shiftKey,K=()=>!1,V=P(({onChange:o,className:v,placeholder:x,bashMode:y=!1,isSendShortcut:I=B,isNewlineShortcut:b=K,...k},T)=>{let n=z(),i=N(),l=m(!1),u=m(!1),a=m(null),s=R(()=>{let t=a.current;if(!t)return;t.style.height="auto",t.style.height=`${t.scrollHeight}px`},[]);F(()=>{let t=a.current;if(!t)return;let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>e.disconnect()},[s]);let p=y&&(n?.textInput.value??"").startsWith("!"),C=(t)=>{if(l.current||t.nativeEvent.isComposing||t.nativeEvent.keyCode===229||u.current)return;if(t.key.length===1&&t.key.charCodeAt(0)<32&&t.key!==`
2
2
  `&&t.key!=="\r"&&t.key!=="\t"){t.preventDefault();return}if(p&&n){let e=t.currentTarget.selectionStart===0&&t.currentTarget.selectionEnd===0;if(t.key==="Escape"||(t.key==="Backspace"||t.key==="Delete")&&e){t.preventDefault(),n.textInput.setInput(n.textInput.value.slice(1));return}}if(t.key==="Enter"){if(b(t.nativeEvent)){t.preventDefault();let e=t.currentTarget,{selectionStart:r,selectionEnd:f,value:c}=e,h=`${c.substring(0,r)}
3
- ${c.substring(f)}`;if(n)n.textInput.setInput(h);else e.value=h;let d=r+1;e.setSelectionRange(d,d),s();return}if(I(t.nativeEvent)){t.preventDefault();let e=t.currentTarget.form;if(!e)return;let r=e.querySelector('button[type="submit"]');if(!r||r.disabled)return;e.requestSubmit(r)}}if(t.key==="Backspace"&&t.currentTarget.value===""&&i.files.length>0){t.preventDefault();let e=i.files.at(-1);if(e)i.remove(e.id)}},S=(t)=>{let e=t.clipboardData?.items;if(!e)return;let{imageFiles:r,sawNonImageFile:f}=q(e),c=j(e);if(r.length>0)t.preventDefault(),i.add(r);else if(f&&!c)t.preventDefault()},w=n?{value:p?n.textInput.value.slice(1):n.textInput.value,onChange:(t)=>{let e=g(t.currentTarget);n.textInput.setInput(p?`!${e}`:e),s(),o?.(t)}}:{onChange:(t)=>{g(t.currentTarget),s(),o?.(t)}};return F(T,()=>({resetHeight:()=>{if(a.current)a.current.style.height="auto"},focus:()=>{a.current?.focus()},getTextarea:()=>a.current}),[]),D(A,{"data-chat-input":!0,ref:a,rows:3,className:H("field-sizing-content max-h-(--chat-input-max-height) min-h-[calc(var(--chat-input-line-height)*3)] min-w-0 flex-1 overflow-x-hidden","leading-(--chat-input-line-height)","placeholder:text-chat-input-placeholder p-0 pe-2.5","bg-chat-input-bg",v),name:"message",onCompositionEnd:()=>{l.current=!1,u.current=!0,requestAnimationFrame(()=>{u.current=!1})},onCompositionStart:()=>{u.current=!1,l.current=!0},onKeyDown:C,onPaste:S,placeholder:x,...k,...w})});V.displayName="PromptInputTextarea";export{V as PromptInputTextarea};
3
+ ${c.substring(f)}`;if(n)n.textInput.setInput(h);else e.value=h;let d=r+1;e.setSelectionRange(d,d),s();return}if(I(t.nativeEvent)){t.preventDefault();let e=t.currentTarget.form;if(!e)return;let r=e.querySelector('button[type="submit"]');if(!r||r.disabled)return;e.requestSubmit(r)}}if(t.key==="Backspace"&&t.currentTarget.value===""&&i.files.length>0){t.preventDefault();let e=i.files.at(-1);if(e)i.remove(e.id)}},S=(t)=>{let e=t.clipboardData?.items;if(!e)return;let{imageFiles:r,sawNonImageFile:f}=q(e),c=j(e);if(r.length>0)t.preventDefault(),i.add(r);else if(f&&!c)t.preventDefault()},w=n?{value:p?n.textInput.value.slice(1):n.textInput.value,onChange:(t)=>{let e=g(t.currentTarget);n.textInput.setInput(p?`!${e}`:e),s(),o?.(t)}}:{onChange:(t)=>{g(t.currentTarget),s(),o?.(t)}};return A(T,()=>({resetHeight:()=>{if(a.current)a.current.style.height="auto"},focus:()=>{a.current?.focus()},getTextarea:()=>a.current}),[]),D(H,{"data-chat-input":!0,ref:a,rows:3,className:E("field-sizing-content max-h-(--chat-input-max-height) min-h-[calc(var(--chat-input-line-height)*3)] min-w-0 flex-1 overflow-x-hidden","leading-(--chat-input-line-height)","placeholder:text-chat-input-placeholder p-0 pe-2.5","bg-chat-input-bg",v),name:"message",onCompositionEnd:()=>{l.current=!1,u.current=!0,requestAnimationFrame(()=>{u.current=!1})},onCompositionStart:()=>{u.current=!1,l.current=!0},onKeyDown:C,onPaste:S,placeholder:x,...k,...w})});V.displayName="PromptInputTextarea";export{V as PromptInputTextarea};
@@ -1 +1 @@
1
- import{jsx as o,jsxs as me}from"react/jsx-runtime";import{ArrowUpIcon as pe,Loader2Icon as ge,SquareIcon as he,XIcon as be}from"lucide-react";import{Children as V,useCallback as v,useEffect as z,useMemo as ve,useRef as _,useState as xe}from"react";import{flushSync as Ie}from"react-dom";import{cn as x}from"cn";import{InputGroup as ye,InputGroupAddon as Y,InputGroupButton as Z}from"../ui/input-group.js";import{exceedsImageLimit as Le,MAX_TOTAL_IMAGE_MB as we}from"../lib/limits.js";import{preparePromptFiles as Te}from"../lib/prepare-prompt-files.js";import{LocalAttachmentsContext as ze,PromptInputSubmitContext as _e,PromptInputSubmissionContext as ke,ProviderAttachmentsContext as Ae,useOptionalPromptInputController as Pe}from"./prompt-input-context.js";import{MAX_TOTAL_IMAGE_MB as Je}from"../lib/limits.js";var Fe=({className:c,bashMode:l=!1,attachmentPolicy:I,onCommand:m,onSubmitError:y,canSubmit:p,onSubmitAsync:g,accept:k,multiple:ee,globalDrop:A,syncHiddenInput:D,maxFiles:S,maxFileSize:j,onError:h,onSubmit:te,children:re,...ne})=>{let s=Pe(),a=!!s,se=l&&a&&s.textInput.value.startsWith("!"),L=_(null),P=_(null),M=_(!1),[ie,U]=xe([]),d=a?s.attachments.files:ie,F=_(d);F.current=d;let oe=v(()=>{L.current?.click()},[]),O=v((e)=>{if(!k||k.trim()==="")return!0;return k.split(",").map((t)=>t.trim()).filter(Boolean).some((t)=>{if(t.endsWith("/*")){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t})},[k]),B=v((e)=>{if(e.type)return e.type;let r=(e.name||"").toLowerCase();if(r.endsWith(".png"))return"image/png";if(r.endsWith(".jpg")||r.endsWith(".jpeg"))return"image/jpeg";if(r.endsWith(".webp"))return"image/webp";if(r.endsWith(".gif"))return"image/gif";if(r.endsWith(".bmp"))return"image/bmp";if(r.endsWith(".svg"))return"image/svg+xml";return""},[]),ae=v((e)=>{let r=Array.from(e),t=r.filter((i)=>O(i));if(r.length&&t.length===0){h?.({code:"accept",message:"No files match the accepted types."});return}let n=(i)=>j?i.size<=j:!0,f=t.filter(n);if(t.length>0&&f.length===0){h?.({code:"max_file_size",message:"All files exceed the maximum size."});return}U((i)=>{let b=I?I.uniqueFiles(f,i):f,u=typeof S==="number"?Math.max(0,S-i.length):void 0,N=typeof u==="number"?b.slice(0,u):b;if(typeof u==="number"&&b.length>u)h?.({code:"max_files",message:"Too many files. Some were not added."});let K=[];for(let T of N){let Q=I?.sourcePath(T);K.push({id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(T),mediaType:B(T),filename:T.name,size:T.size,lastModified:T.lastModified,...Q===void 0?{}:{sourcePath:Q}})}return i.concat(K)})},[I,B,O,S,j,h]),ue=v((e)=>U((r)=>{let t=r.find((n)=>n.id===e);if(t?.url)URL.revokeObjectURL(t.url);return r.filter((n)=>n.id!==e)}),[]),ce=v(()=>U((e)=>{for(let r of e)if(r.url)URL.revokeObjectURL(r.url);return[]}),[]),q=a?s.attachments.add:ae,w=v((e)=>{let r=Array.from(e),t=r.filter((f)=>!(f.type??"").toLowerCase().startsWith("image/"));if(t.length>0){h?.({code:"unsupported_type",message:`Only image attachments are supported. ${t.length} non-image file(s) were ignored.`});return}let n=r.reduce((f,i)=>f+i.size,0);if(n>0){let f=d.filter((i)=>(i.mediaType??"").toLowerCase().startsWith("image/")).reduce((i,b)=>i+(b.size??0),0);if(Le(f,n)){h?.({code:"max_total_size",message:`Total image size must not exceed ${we}MB.`});return}}q(r)},[d,q,h]),E=a?s.attachments.remove:ue,W=a?s.attachments.clear:ce,G=a?s.attachments.openFileDialog:oe;z(()=>{if(!a)return;s.__registerFileInput(L,()=>L.current?.click())},[a,s]),z(()=>{if(D&&L.current&&d.length===0)L.current.value=""},[d,D]),z(()=>{let e=P.current;if(!e)return;if(A)return;let r=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault()},t=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault();if(n.dataTransfer?.files&&n.dataTransfer.files.length>0)w(n.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",t),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",t)}},[w,A]),z(()=>{if(!A)return;let e=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault()},r=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault();if(t.dataTransfer?.files&&t.dataTransfer.files.length>0)w(t.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[w,A]),z(()=>()=>{if(!a){for(let e of F.current)if(e.url)URL.revokeObjectURL(e.url)}},[a]);let le=(e)=>{if(e.currentTarget.files)w(e.currentTarget.files);e.currentTarget.value=""},X=ve(()=>({files:d.map((e)=>({...e,id:e.id})),add:w,remove:E,clear:W,openFileDialog:G,fileInputRef:L}),[d,w,E,W,G]),R=_({controller:s,files:d,canSubmit:p});R.current={controller:s,files:d,canSubmit:p};let C=_(!0);z(()=>(C.current=!0,()=>{C.current=!1}),[]);let H=async(e)=>{let r=p===void 0?!0:p();if(r!==!0)return{status:"blocked",reason:r};if(M.current)return{status:"blocked",reason:"submission_pending"};if(e===null&&g===void 0)throw Error("Awaitable submission requires onSubmitAsync");let t=P.current;if(t===null)return{status:"blocked",reason:"form_unmounted"};let n=a?s.textInput.value:String(new FormData(t).get("message")??""),f=s?.textInput.getRevision?.(),i=d,b=()=>{if(!C.current)return;let u=R.current;if(u.files!==i)return;if(a){if(f===void 0||u.controller===null||u.controller.textInput.getRevision?.()!==f)return;if(u.controller.textInput.clearSubmitted===void 0)u.controller.textInput.clear();else u.controller.textInput.clearSubmitted()}else if(String(new FormData(t).get("message")??"")===n)t.reset();W()};M.current=!0;try{if(m?.(n.trim()))return b(),{status:"accepted"};let u=await Te(i),N=R.current.canSubmit===void 0?!0:R.current.canSubmit();if(N!==!0)return{status:"blocked",reason:N};if(!C.current)return{status:"blocked",reason:"form_unmounted"};if(u.rejectedCount>0)h?.({code:"accept",message:"One or more images are corrupted and were removed before sending."});if(g!==void 0)await g({text:n,files:u.files});else if(e!==null)await te({text:n,files:u.files},e);return b(),{status:"accepted"}}finally{M.current=!1}},fe=(e)=>{e.preventDefault(),H(e).catch(y)},de=v((e)=>{if(!e.trim())return;if(a&&s)Ie(()=>{s.textInput.setInput(e)});P.current?.requestSubmit()},[s,a]),J=o(ke.Provider,{value:()=>H(null),children:me(_e.Provider,{value:de,children:[o("input",{accept:k,"aria-label":"Upload files",className:"hidden",multiple:ee,onChange:le,ref:L,title:"Upload files",type:"file"}),o("form",{className:x("w-full",c),onSubmit:fe,ref:P,"data-tour":"chat-input",...ne,children:o(ye,{className:x("codex-composer-surface overflow-y-auto has-[[data-slot=input-group-control]:focus-visible]:ring-0",se&&"border! border-[rgb(255,0,135)] has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(255,0,135)] dark:border-[rgb(253,93,177)] dark:has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(253,93,177)]"),children:re})})]})});return a?o(Ae.Provider,{value:X,children:J}):o(ze.Provider,{value:X,children:J})};function Oe({className:c,...l}){return o("div",{className:x("flex w-full min-w-0 flex-row items-end gap-2",c),...l})}function Be({className:c,...l}){return o(Y,{align:"block-end",className:x("order-first flex-wrap gap-1 p-2 pb-1.5",c),...l})}function qe({className:c,...l}){return o(Y,{align:"block-end",className:x("mt-3.5 justify-between gap-1 p-0",c),...l})}function Ee({className:c,...l}){return o("div",{className:x("flex items-center gap-1",c),...l})}var Ge=({variant:c="ghost",className:l,size:I,collapsed:m=!1,...y})=>{let p=m||V.count(y.children)<=1?"icon-xs":"xs";return o(Z,{className:x("h-7 rounded-full text-xs font-medium hover:bg-transparent dark:hover:bg-transparent",(m||V.count(y.children)<=1)&&"size-7",l),size:p,type:"button",variant:c,...y})},Xe=({className:c,variant:l="ghost",size:I="icon-xs",status:m,children:y,...p})=>{let g=o(pe,{className:"size-4"});if(m==="submitted")g=o(ge,{className:"size-4 animate-spin"});else if(m==="streaming")g=o(he,{className:"size-3 fill-current"});else if(m==="error")g=o(be,{className:"size-4"});return o(Z,{"aria-label":"Submit",className:x("bg-foreground text-background hover:bg-foreground/70 size-7 rounded-full p-0 transition-opacity disabled:opacity-50",c),size:I,type:"submit",variant:l,...p,children:y??g})};export{Je as MAX_TOTAL_IMAGE_MB,Fe as PromptInput,Oe as PromptInputBody,Ge as PromptInputButton,qe as PromptInputFooter,Be as PromptInputHeader,Xe as PromptInputSubmit,Ee as PromptInputTools};
1
+ import{jsx as a,jsxs as pe}from"react/jsx-runtime";import{cn as x}from"cn";import{ArrowUpIcon as ge,Loader2Icon as he,SquareIcon as be,XIcon as ve}from"lucide-react";import{Children as V,useCallback as v,useEffect as z,useMemo as xe,useRef as _,useState as Ie}from"react";import{flushSync as ye}from"react-dom";import{exceedsImageLimit as Le,MAX_TOTAL_IMAGE_MB as we}from"../lib/limits.js";import{preparePromptFiles as Te}from"../lib/prepare-prompt-files.js";import{InputGroup as ze,InputGroupAddon as Z,InputGroupButton as ee}from"../ui/input-group.js";import{LocalAttachmentsContext as _e,PromptInputSubmissionContext as ke,PromptInputSubmitContext as Ae,ProviderAttachmentsContext as Pe,useOptionalPromptInputController as Re}from"./prompt-input-context.js";import{MAX_TOTAL_IMAGE_MB as Ke}from"../lib/limits.js";function Y(u){let s=new FormData(u).get("message");return typeof s==="string"?s:""}var Fe=({className:u,bashMode:s=!1,attachmentPolicy:I,onCommand:m,onSubmitError:y,canSubmit:p,onSubmitAsync:g,accept:k,multiple:te,globalDrop:A,syncHiddenInput:D,maxFiles:N,maxFileSize:j,onError:h,onSubmit:re,children:ne,...se})=>{let o=Re(),c=!!o,oe=s&&c&&o.textInput.value.startsWith("!"),L=_(null),P=_(null),U=_(!1),[ie,W]=Ie([]),d=c?o.attachments.files:ie,O=_(d);O.current=d;let ae=v(()=>{L.current?.click()},[]),F=v((e)=>{if(!k||k.trim()==="")return!0;return k.split(",").map((t)=>t.trim()).filter(Boolean).some((t)=>{if(t.endsWith("/*")){let n=t.slice(0,-1);return e.type.startsWith(n)}return e.type===t})},[k]),B=v((e)=>{if(e.type)return e.type;let r=(e.name||"").toLowerCase();if(r.endsWith(".png"))return"image/png";if(r.endsWith(".jpg")||r.endsWith(".jpeg"))return"image/jpeg";if(r.endsWith(".webp"))return"image/webp";if(r.endsWith(".gif"))return"image/gif";if(r.endsWith(".bmp"))return"image/bmp";if(r.endsWith(".svg"))return"image/svg+xml";return""},[]),ue=v((e)=>{let r=Array.from(e),t=r.filter((i)=>F(i));if(r.length&&t.length===0){h?.({code:"accept",message:"No files match the accepted types."});return}let n=(i)=>j?i.size<=j:!0,f=t.filter(n);if(t.length>0&&f.length===0){h?.({code:"max_file_size",message:"All files exceed the maximum size."});return}W((i)=>{let b=I?I.uniqueFiles(f,i):f,l=typeof N==="number"?Math.max(0,N-i.length):void 0,M=typeof l==="number"?b.slice(0,l):b;if(typeof l==="number"&&b.length>l)h?.({code:"max_files",message:"Too many files. Some were not added."});let K=[];for(let T of M){let Q=I?.sourcePath(T);K.push({id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(T),mediaType:B(T),filename:T.name,size:T.size,lastModified:T.lastModified,...Q===void 0?{}:{sourcePath:Q}})}return i.concat(K)})},[I,B,F,N,j,h]),ce=v((e)=>W((r)=>{let t=r.find((n)=>n.id===e);if(t?.url)URL.revokeObjectURL(t.url);return r.filter((n)=>n.id!==e)}),[]),le=v(()=>W((e)=>{for(let r of e)if(r.url)URL.revokeObjectURL(r.url);return[]}),[]),q=c?o.attachments.add:ue,w=v((e)=>{let r=Array.from(e),t=r.filter((f)=>!(f.type??"").toLowerCase().startsWith("image/"));if(t.length>0){h?.({code:"unsupported_type",message:`Only image attachments are supported. ${t.length} non-image file(s) were ignored.`});return}let n=r.reduce((f,i)=>f+i.size,0);if(n>0){let f=d.filter((i)=>(i.mediaType??"").toLowerCase().startsWith("image/")).reduce((i,b)=>i+(b.size??0),0);if(Le(f,n)){h?.({code:"max_total_size",message:`Total image size must not exceed ${we}MB.`});return}}q(r)},[d,q,h]),E=c?o.attachments.remove:ce,S=c?o.attachments.clear:le,G=c?o.attachments.openFileDialog:ae;z(()=>{if(!c)return;o.__registerFileInput(L,()=>L.current?.click())},[c,o]),z(()=>{if(D&&L.current&&d.length===0)L.current.value=""},[d,D]),z(()=>{let e=P.current;if(!e)return;if(A)return;let r=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault()},t=(n)=>{if(n.dataTransfer?.types?.includes("Files"))n.preventDefault();if(n.dataTransfer?.files&&n.dataTransfer.files.length>0)w(n.dataTransfer.files)};return e.addEventListener("dragover",r),e.addEventListener("drop",t),()=>{e.removeEventListener("dragover",r),e.removeEventListener("drop",t)}},[w,A]),z(()=>{if(!A)return;let e=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault()},r=(t)=>{if(t.dataTransfer?.types?.includes("Files"))t.preventDefault();if(t.dataTransfer?.files&&t.dataTransfer.files.length>0)w(t.dataTransfer.files)};return document.addEventListener("dragover",e),document.addEventListener("drop",r),()=>{document.removeEventListener("dragover",e),document.removeEventListener("drop",r)}},[w,A]),z(()=>()=>{if(!c){for(let e of O.current)if(e.url)URL.revokeObjectURL(e.url)}},[c]);let fe=(e)=>{if(e.currentTarget.files)w(e.currentTarget.files);e.currentTarget.value=""},X=xe(()=>({files:d.map((e)=>({...e,id:e.id})),add:w,remove:E,clear:S,openFileDialog:G,fileInputRef:L}),[d,w,E,S,G]),R=_({controller:o,files:d,canSubmit:p});R.current={controller:o,files:d,canSubmit:p};let C=_(!0);z(()=>(C.current=!0,()=>{C.current=!1}),[]);let H=async(e)=>{let r=p===void 0?!0:p();if(r!==!0)return{status:"blocked",reason:r};if(U.current)return{status:"blocked",reason:"submission_pending"};if(e===null&&g===void 0)throw Error("Awaitable submission requires onSubmitAsync");let t=P.current;if(t===null)return{status:"blocked",reason:"form_unmounted"};let n=c?o.textInput.value:Y(t),f=o?.textInput.getRevision?.(),i=d,b=()=>{if(!C.current)return;let l=R.current;if(l.files!==i)return;if(c){if(f===void 0||l.controller===null||l.controller.textInput.getRevision?.()!==f)return;if(l.controller.textInput.clearSubmitted===void 0)l.controller.textInput.clear();else l.controller.textInput.clearSubmitted()}else if(Y(t)===n)t.reset();S()};U.current=!0;try{if(m?.(n.trim()))return b(),{status:"accepted"};let l=await Te(i),M=R.current.canSubmit===void 0?!0:R.current.canSubmit();if(M!==!0)return{status:"blocked",reason:M};if(!C.current)return{status:"blocked",reason:"form_unmounted"};if(l.rejectedCount>0)h?.({code:"accept",message:"One or more images are corrupted and were removed before sending."});if(g!==void 0)await g({text:n,files:l.files});else if(e!==null)await re({text:n,files:l.files},e);return b(),{status:"accepted"}}finally{U.current=!1}},de=(e)=>{e.preventDefault(),H(e).catch(y)},me=v((e)=>{if(!e.trim())return;if(c&&o)ye(()=>{o.textInput.setInput(e)});P.current?.requestSubmit()},[o,c]),J=a(ke.Provider,{value:()=>H(null),children:pe(Ae.Provider,{value:me,children:[a("input",{accept:k,"aria-label":"Upload files",className:"hidden",multiple:te,onChange:fe,ref:L,title:"Upload files",type:"file"}),a("form",{className:x("w-full",u),onSubmit:de,ref:P,"data-tour":"chat-input",...se,children:a(ze,{className:x("codex-composer-surface overflow-y-auto has-[[data-slot=input-group-control]:focus-visible]:ring-0",oe&&"border! border-[rgb(255,0,135)] has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(255,0,135)] dark:border-[rgb(253,93,177)] dark:has-[[data-slot=input-group-control]:focus-visible]:border-[rgb(253,93,177)]"),children:ne})})]})});return c?a(Pe.Provider,{value:X,children:J}):a(_e.Provider,{value:X,children:J})};function Be({className:u,...s}){return a("div",{className:x("flex w-full min-w-0 flex-row items-end gap-2",u),...s})}function qe({className:u,...s}){return a(Z,{align:"block-end",className:x("order-first flex-wrap gap-1 p-2 pb-1.5",u),...s})}function Ee({className:u,...s}){return a(Z,{align:"block-end",className:x("mt-3.5 justify-between gap-1 p-0",u),...s})}function Ge({className:u,...s}){return a("div",{className:x("flex items-center gap-1",u),...s})}var Xe=({variant:u="ghost",className:s,size:I,collapsed:m=!1,...y})=>{let p=m||V.count(y.children)<=1?"icon-xs":"xs";return a(ee,{className:x("h-7 rounded-full text-xs font-medium hover:bg-transparent dark:hover:bg-transparent",(m||V.count(y.children)<=1)&&"size-7",s),size:p,type:"button",variant:u,...y})},$e=({className:u,variant:s="ghost",size:I="icon-xs",status:m,children:y,...p})=>{let g=a(ge,{className:"size-4"});if(m==="submitted")g=a(he,{className:"size-4 animate-spin"});else if(m==="streaming")g=a(be,{className:"size-3 fill-current"});else if(m==="error")g=a(ve,{className:"size-4"});return a(ee,{"aria-label":"Submit",className:x("bg-foreground text-background hover:bg-foreground/70 size-7 rounded-full p-0 transition-opacity disabled:opacity-50",u),size:I,type:"submit",variant:s,...p,children:y??g})};export{Ke as MAX_TOTAL_IMAGE_MB,Fe as PromptInput,Be as PromptInputBody,Xe as PromptInputButton,Ee as PromptInputFooter,qe as PromptInputHeader,$e as PromptInputSubmit,Ge as PromptInputTools};
@@ -1 +1 @@
1
- import{jsx as n,jsxs as _}from"react/jsx-runtime";import{XIcon as j}from"lucide-react";import{useCallback as p,useEffect as N,useMemo as X,useRef as y,useState as v}from"react";import{Dialog as E,DialogClose as A,DialogContent as F,DialogTitle as Y}from"./ui/dialog.js";import{getPointerCenteredScrollPosition as K}from"./lib/pointer-centered-zoom.js";import{cn as b}from"cn";function te({open:s,onOpenChange:C,url:h,filename:x,scale:g,onScaleChange:f,containerRef:W,containerClassName:H,dialogContentClassName:Z,imageClassName:k}){let d=p((e)=>Math.min(4,Math.max(0.25,e)),[]),[D,M]=v(1),r=d(g??D),I=y(null),c=W??I,O=y(null),[u,S]=v({width:0,height:0}),[z,P]=v({width:0,height:0}),w=p((e)=>{let i=d(e);if(typeof f==="function"){f(i);return}M(i)},[f,d]);N(()=>{if(!s)return;if(!h)return;if(typeof g==="number")return;M(1)},[s,h,g]),N(()=>{if(!s)return;let e=c.current;if(!e)return;let i=()=>{S({width:e.clientWidth,height:e.clientHeight})};i();let t=new ResizeObserver(i);return t.observe(e),()=>{t.disconnect()}},[c,s]);let R=p(()=>{w(1)},[w]),a=X(()=>{let{width:e,height:i}=z,{width:t,height:o}=u;if(e===0||i===0)return{width:0,height:0};if(t===0||o===0)return{width:0,height:0};let l=Math.min(t/e,o/i,1),m=e*l,T=i*l;return{width:m*r,height:T*r}},[r,z,u]);if(!h)return null;return n(E,{open:s,onOpenChange:C,children:_(F,{className:b("top-1/2 left-1/2 h-[90vh] max-h-[90vh] w-[90vw]! max-w-[90vw]! -translate-x-1/2 -translate-y-1/2 gap-0 rounded-none bg-transparent p-0 ring-0 sm:w-[90vw]! sm:max-w-[90vw]!",Z),showCloseButton:!1,children:[n(Y,{className:"sr-only",children:x||"Image preview"}),n(A,{"aria-label":"Close",className:"absolute top-3 right-3 z-10 flex size-10 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur-sm transition-colors hover:bg-black/75",children:n(j,{className:"size-5"})}),n("div",{ref:c,onWheel:(e)=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let i=e.deltaY>0?r-0.2:r+0.2,t=d(Number.parseFloat(i.toFixed(2)));if(t===r)return;let o=c.current,l=O.current,m=o&&l?K({container:o,target:l,clientX:e.clientX,clientY:e.clientY,currentScale:r,nextScale:t}):null;if(w(t),o&&m)requestAnimationFrame(()=>{o.scrollTo(m)})},className:b("scrollbar-thin h-full w-full overflow-auto",H),children:n("div",{className:"grid min-h-full min-w-full place-items-center",style:{width:Math.max(u.width,a.width),height:Math.max(u.height,a.height)},children:n("div",{className:"shrink-0",children:n("img",{alt:x||"image preview",className:b("block object-contain select-none",k),decoding:"async",draggable:!1,ref:O,onDoubleClick:R,onLoad:(e)=>{let i=e.currentTarget;P({width:i.naturalWidth,height:i.naturalHeight});let t=c.current;if(t&&(t.clientWidth||t.clientHeight))S({width:t.clientWidth,height:t.clientHeight})},style:{imageRendering:"auto",width:a.width||void 0,height:a.height||void 0,maxWidth:a.width?"none":"90vw",maxHeight:a.height?"none":"90vh"},src:h})})})})]})})}export{te as ImagePreviewDialog};
1
+ import{jsx as n,jsxs as _}from"react/jsx-runtime";import{cn as p}from"cn";import{XIcon as j}from"lucide-react";import{useCallback as v,useEffect as N,useMemo as X,useRef as y,useState as b}from"react";import{getPointerCenteredScrollPosition as E}from"./lib/pointer-centered-zoom.js";import{Dialog as A,DialogClose as F,DialogContent as Y,DialogTitle as K}from"./ui/dialog.js";function te({open:s,onOpenChange:C,url:h,filename:x,scale:g,onScaleChange:f,containerRef:W,containerClassName:H,dialogContentClassName:Z,imageClassName:k}){let d=v((e)=>Math.min(4,Math.max(0.25,e)),[]),[D,M]=b(1),r=d(g??D),I=y(null),c=W??I,O=y(null),[u,S]=b({width:0,height:0}),[z,P]=b({width:0,height:0}),w=v((e)=>{let i=d(e);if(typeof f==="function"){f(i);return}M(i)},[f,d]);N(()=>{if(!s)return;if(!h)return;if(typeof g==="number")return;M(1)},[s,h,g]),N(()=>{if(!s)return;let e=c.current;if(!e)return;let i=()=>{S({width:e.clientWidth,height:e.clientHeight})};i();let t=new ResizeObserver(i);return t.observe(e),()=>{t.disconnect()}},[c,s]);let R=v(()=>{w(1)},[w]),a=X(()=>{let{width:e,height:i}=z,{width:t,height:o}=u;if(e===0||i===0)return{width:0,height:0};if(t===0||o===0)return{width:0,height:0};let l=Math.min(t/e,o/i,1),m=e*l,T=i*l;return{width:m*r,height:T*r}},[r,z,u]);if(!h)return null;return n(A,{open:s,onOpenChange:C,children:_(Y,{className:p("top-1/2 left-1/2 h-[90vh] max-h-[90vh] w-[90vw]! max-w-[90vw]! -translate-x-1/2 -translate-y-1/2 gap-0 rounded-none bg-transparent p-0 ring-0 sm:w-[90vw]! sm:max-w-[90vw]!",Z),showCloseButton:!1,children:[n(K,{className:"sr-only",children:x||"Image preview"}),n(F,{"aria-label":"Close",className:"absolute top-3 right-3 z-10 flex size-10 items-center justify-center rounded-full bg-black/55 text-white backdrop-blur-sm transition-colors hover:bg-black/75",children:n(j,{className:"size-5"})}),n("div",{ref:c,onWheel:(e)=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let i=e.deltaY>0?r-0.2:r+0.2,t=d(Number.parseFloat(i.toFixed(2)));if(t===r)return;let o=c.current,l=O.current,m=o&&l?E({container:o,target:l,clientX:e.clientX,clientY:e.clientY,currentScale:r,nextScale:t}):null;if(w(t),o&&m)requestAnimationFrame(()=>{o.scrollTo(m)})},className:p("h-full w-full scrollbar-thin overflow-auto",H),children:n("div",{className:"grid min-h-full min-w-full place-items-center",style:{width:Math.max(u.width,a.width),height:Math.max(u.height,a.height)},children:n("div",{className:"shrink-0",children:n("img",{alt:x||"image preview",className:p("block object-contain select-none",k),decoding:"async",draggable:!1,ref:O,onDoubleClick:R,onLoad:(e)=>{let i=e.currentTarget;P({width:i.naturalWidth,height:i.naturalHeight});let t=c.current;if(t&&(t.clientWidth||t.clientHeight))S({width:t.clientWidth,height:t.clientHeight})},style:{imageRendering:"auto",width:a.width||void 0,height:a.height||void 0,maxWidth:a.width?"none":"90vw",maxHeight:a.height?"none":"90vh"},src:h})})})})]})})}export{te as ImagePreviewDialog};
@@ -31,4 +31,5 @@ export interface MarkdownParser {
31
31
  update: (input: MarkdownParseInput) => void;
32
32
  dispose: () => void;
33
33
  }
34
+ export declare function cachedMarkdown(text: string, isStreaming: boolean): MarkdownParseResult | null;
34
35
  export declare function createMarkdownParser(onResult: (result: MarkdownParseResult) => void, onError: (error: Error) => void): MarkdownParser;
@@ -1 +1 @@
1
- class o{worker=new Worker(new URL("./markdown-parser.worker.js",import.meta.url),{type:"module"});clients=new Map;pending=new Map;active=null;failure=null;nextClientId=0;constructor(){this.worker.onmessage=(e)=>{let t=e.data,i=this.active;if(i===null||t.clientId!==i.clientId||t.revision!==i.revision){this.fail(Error("Markdown worker returned an unexpected request"));return}if(this.active=null,!t.ok){this.fail(Error(t.error));return}let n=this.clients.get(i.clientId),r=this.pending.get(i.clientId),l=r!==void 0&&i.input.isStreaming&&r.input.isStreaming&&r.input.text.startsWith(i.input.text);if(n!==void 0&&(n.revision===i.revision||l))n.onResult({...i.input,tokens:t.tokens});this.dispatch()},this.worker.onerror=(e)=>this.fail(Error(e.message)),this.worker.onmessageerror=()=>this.fail(Error("Cannot deserialize Markdown parsing result"))}fail(e){this.failure=e,this.worker.terminate(),this.pending.clear(),this.active=null;for(let t of this.clients.values())t.onError(e)}send(e){try{this.worker.postMessage(e)}catch(t){this.fail(t instanceof Error?t:Error(String(t)))}}dispatch(){if(this.active!==null||this.pending.size===0)return;let e=this.pending.values().next().value;this.pending.delete(e.clientId),this.active=e,this.send({type:"parse",clientId:e.clientId,revision:e.revision,source:e.input.source})}connect(e,t){if(this.failure!==null)throw this.failure;let i=++this.nextClientId,n={revision:0,onResult:e,onError:t};return this.clients.set(i,n),{update:(r)=>{if(this.failure!==null)throw this.failure;n.revision+=1,this.pending.set(i,{clientId:i,revision:n.revision,input:r}),this.dispatch()},dispose:()=>{if(!this.clients.delete(i))return;if(this.pending.delete(i),this.clients.size===0)this.worker.terminate(),s=void 0;else if(this.failure===null)this.send({type:"dispose",clientId:i})}}}}var s;function a(e,t){if(s===void 0)s=new o;return s.connect(e,t)}export{a as createMarkdownParser};
1
+ var i=new Map;var l=0;function u(e,n){let t=n?void 0:i.get(e);if(t===void 0)return null;return i.delete(e),i.set(e,t),{...t,tokens:structuredClone(t.tokens)}}function h(e){if(e.isStreaming||e.text.length>1048576)return;if(i.delete(e.text))l-=e.text.length;i.set(e.text,{...e,tokens:structuredClone(e.tokens)}),l+=e.text.length;while(l>2097152||i.size>200){let n=i.keys().next().value;l-=n.length,i.delete(n)}}class a{worker=new Worker(new URL("./markdown-parser.worker.js",import.meta.url),{type:"module"});clients=new Map;pending=new Map;active=null;failure=null;nextClientId=0;constructor(){this.worker.onmessage=(e)=>{let n=e.data,t=this.active;if(t===null||n.clientId!==t.clientId||n.revision!==t.revision){this.fail(Error("Markdown worker returned an unexpected request"));return}if(this.active=null,!n.ok){this.fail(Error(n.error));return}let r={...t.input,tokens:n.tokens};h(r);let s=this.clients.get(t.clientId),o=this.pending.get(t.clientId),d=o!==void 0&&t.input.isStreaming&&o.input.isStreaming&&o.input.text.startsWith(t.input.text);if(s!==void 0&&(s.revision===t.revision||d))s.onResult(r);this.dispatch()},this.worker.onerror=(e)=>this.fail(Error(e.message)),this.worker.onmessageerror=()=>this.fail(Error("Cannot deserialize Markdown parsing result"))}fail(e){this.failure=e,this.worker.terminate(),this.pending.clear(),this.active=null;for(let n of this.clients.values())n.onError(e)}send(e){try{this.worker.postMessage(e)}catch(n){this.fail(n instanceof Error?n:Error(String(n)))}}dispatch(){if(this.active!==null||this.pending.size===0)return;let e=this.pending.values().next().value;this.pending.delete(e.clientId),this.active=e,this.send({type:"parse",clientId:e.clientId,revision:e.revision,source:e.input.source})}connect(e,n){if(this.failure!==null)throw this.failure;let t=++this.nextClientId,r={revision:0,onResult:e,onError:n};return this.clients.set(t,r),{update:(s)=>{if(this.failure!==null)throw this.failure;r.revision+=1;let o=u(s.text,s.isStreaming);if(o!==null){this.pending.delete(t),r.onResult(o);return}this.pending.set(t,{clientId:t,revision:r.revision,input:s}),this.dispatch()},dispose:()=>{if(!this.clients.delete(t))return;if(this.pending.delete(t),this.clients.size===0)this.worker.terminate(),c=void 0;else if(this.failure===null)this.send({type:"dispose",clientId:t})}}}}var c;function f(e,n){if(c===void 0)c=new a;return c.connect(e,n)}export{u as cachedMarkdown,f as createMarkdownParser};
@@ -1,2 +1,2 @@
1
1
  import{createChatMarkdown as w}from"./markdown-rules.js";function g(e,s){let l=Object.keys(e);return l.length===Object.keys(s).length&&l.every((r)=>{let i=s[r];return i!==void 0&&e[r].href===i.href&&e[r].title===i.title})}function b(e,s){let l=2,r=0;for(let n=e.length-1;n>=0;n-=1){if(e[n].type==="space")continue;if(l-=1,l===0){r=n;break}}let i=0;for(let n=0;n<r;n+=1){let a=e[n];if(a.type==="def"||/^ {0,3}(?:\[|<|\$\$|\\\[)/.test(a.raw))return i;let o=!1;if(s.walkTokens([e[n]],(c)=>{if(c.type==="html"&&(("inLink"in c)&&c.inLink||("inRawBlock"in c)&&c.inRawBlock))o=!0}),o)return i;if(/\n[\t ]*\n$/.test(e[n].raw))i=n+1}return i}function x(e=w()){let s="",l=[],r={},i={};return{parse(n){let a=n.replace(/\r\n|\r/g,`
2
- `);if(!a.startsWith(s))s="",l=[],r={},i={};let o=new e.Lexer(e.defaults);o.tokens.links={...r};let c=o.lex(a.slice(s.length)),f=[...l,...c],u=c.links;if(l.length>0&&!g(i,u)){let t=e.lexer(a);f=Array.from(t),u=t.links}i=u;let k=0,h=[];for(let t of f){if(!a.startsWith(t.raw,k))break;h.push(t),k+=t.raw.length}return l=h.slice(0,b(h,e)),s=a.slice(0,l.reduce((t,d)=>t+d.raw.length,0)),r=Object.create(null),e.walkTokens(l,(t)=>{if(t.type==="def"&&!Object.hasOwn(r,t.tag))r[t.tag]={href:t.href,title:t.title}}),structuredClone(f)}}}export{x as createStreamingMarkdownLexer};
2
+ `);if(!a.startsWith(s))s="",l=[],r={},i={};let o=new e.Lexer(e.defaults);o.tokens.links={...r};let c=o.lex(a.slice(s.length)),f=[...l,...c],u=c.links;if(l.length>0&&!g(i,u)){let t=e.lexer(a);f=Array.from(t),u=t.links}i=u;let d=0,h=[];for(let t of f){if(!a.startsWith(t.raw,d))break;h.push(t),d+=t.raw.length}return l=h.slice(0,b(h,e)),s=a.slice(0,l.reduce((t,k)=>t+k.raw.length,0)),r=Object.create(null),e.walkTokens(l,(t)=>{if(t.type==="def"&&!Object.hasOwn(r,t.tag))r[t.tag]={href:t.href,title:t.title}}),structuredClone(f)}}}export{x as createStreamingMarkdownLexer};
@@ -1 +1 @@
1
- import{jsx as b,jsxs as G,Fragment as Y}from"react/jsx-runtime";import{SearchIcon as Z}from"lucide-react";import{useCallback as N,useEffect as f,useMemo as O,useRef as S,useState as E}from"react";import{Button as V}from"../ui/button.js";import{FindBar as tt}from"./find-bar.js";import{cn as et}from"cn";import{collectMatches as P}from"./dom-matches.js";import{collectMatches as mt}from"./dom-matches.js";var z="chat-search",K="chat-search-current",D=150;function at(e){let r=e===null?"":e;return[...document.querySelectorAll("[data-chat-scroll]")].find((c)=>c.dataset.chatScroll===r)??null}var rt=12;function Q(e,r="center"){let c=e.closest("[data-chat-scroll]");if(!c)return;let d=e.getBoundingClientRect(),g=c.getBoundingClientRect(),y=r==="start"?rt:(c.clientHeight-d.height)/2;c.scrollTo({top:c.scrollTop+(d.top-g.top)-y,behavior:"smooth"})}function B(e){let r=e.startContainer.parentElement;if(!r)return;Q(r)}var R=new Map;function U(){if(typeof CSS>"u"||!("highlights"in CSS)||typeof Highlight>"u")return;if(R.size===0){CSS.highlights.delete(z),CSS.highlights.delete(K);return}let e=[...R.values()];CSS.highlights.set(z,new Highlight(...e.flatMap((r)=>r.all))),CSS.highlights.set(K,new Highlight(...e.flatMap((r)=>r.current?[r.current]:[])))}function nt(){let e=Symbol();return{clearHighlights(){R.delete(e),U()},applyHighlights(r,c){R.set(e,{all:r,current:c}),U()}}}function ft({getViewport:e,findSourceMatches:r,revealTurn:c,subscribeOpen:d,labels:g,placement:y="header"}){let{clearHighlights:h,applyHighlights:T}=O(nt,[]),m=r!==void 0,[i,I]=E(!1),[l,L]=E(""),u=O(()=>i&&l.trim()&&r?r(l.trim()):[],[r,i,l]),[F,M]=E(0),[J,x]=E(0),p=S([]),w=S(0),s=S(null),j=S(null),q=S(null);f(()=>{if(!d)return;return d(()=>{I(!0);let t=q.current;if(t!==null)t.focus(),t.select()})},[d]);let _=N(async(o,t)=>{let n=u[o];if(n===void 0)return;let a=e();if(a===null)throw Error("Chat scroll container is missing");if(c)await c(n.turnKey,t);if(t.aborted)return;let C=a.querySelector(`[data-turn-key="${CSS.escape(n.turnKey)}"]`);if(C===null)throw Error(`Codex turn is missing: ${n.turnKey}`);if(!c)Q(C,"start");if(await new Promise((X)=>requestAnimationFrame(()=>X())),t.aborted)return;let k=P(C,l.trim());p.current=k;let H=k[n.occurrenceInTurn];if(T(k,H===void 0?null:H),H!==void 0)B(H)},[u,e,l,c]),A=S(_);f(()=>{A.current=_},[_]);let v=N(()=>{I(!1),L(""),w.current=0,s.current?.abort(),s.current=null,h(),p.current=[]},[]);f(()=>{if(!i)return;let o=(t)=>{if(t.key==="Escape"&&j.current?.contains(document.activeElement))t.preventDefault(),v()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[i,v]),f(()=>{if(!i||!l.trim()){h(),p.current=[],M(0),x(0),w.current=0;return}let o=setTimeout(()=>{if(m)return;let t=e();if(!t)return;let n=P(t,l);if(p.current=n,M(n.length),x(0),T(n,n[0]??null),n[0])B(n[0])},D);return()=>{clearTimeout(o),h()}},[m,i,l,e]),f(()=>{if(!i||!m||!l.trim())return;let o=new AbortController;s.current?.abort(),s.current=o;let t=setTimeout(()=>{p.current=[],w.current=0,M(u.length),x(0),h(),A.current(0,o.signal)},D);return()=>{if(o.abort(),s.current===o)s.current=null;clearTimeout(t),h()}},[u.length,m,i,l]),f(()=>()=>{s.current?.abort(),h()},[]),f(()=>{if(!i)h()},[i]);let W=N((o)=>{if(m){if(u.length===0)return;let n=(w.current+(o?-1:1)+u.length)%u.length;w.current=n,x(n),s.current?.abort();let a=new AbortController;s.current=a,A.current(n,a.signal);return}let t=p.current;if(!t.length)return;x((n)=>{let a=(n+(o?-1:1)+t.length)%t.length,C=t[a];return T(t,C),B(C),a})},[u.length,m]);return G(Y,{children:[y==="header"&&b(V,{variant:"ghost",size:"icon-sm",title:g.search,onClick:()=>i?v():I(!0),children:b(Z,{})}),i&&G("div",{"data-chat-search":!0,ref:j,className:et("bg-background border-b",y==="body"?"relative shrink-0":"absolute inset-x-0 top-full z-30"),children:[b(tt,{ref:q,value:l,onChange:L,onFind:W,onClose:v,placeholder:g.placeholder,prevTitle:g.previous,nextTitle:g.next}),l.trim()&&b("div",{className:"text-muted-foreground border-border border-t px-3 py-1 text-[11px]",children:F===0?"0 / 0":`${J+1} / ${F}`})]})]})}export{ft as ChatSearch,mt as collectMatches,at as findChatScrollContainer,Q as scrollChatElementIntoView};
1
+ import{jsx as b,jsxs as G,Fragment as Y}from"react/jsx-runtime";import{cn as Z}from"cn";import{SearchIcon as V}from"lucide-react";import{useCallback as N,useEffect as f,useMemo as O,useRef as S,useState as E}from"react";import{Button as tt}from"../ui/button.js";import{FindBar as et}from"./find-bar.js";import{collectMatches as P}from"./dom-matches.js";import{collectMatches as mt}from"./dom-matches.js";var z="chat-search",K="chat-search-current",D=150;function at(e){let r=e===null?"":e;return[...document.querySelectorAll("[data-chat-scroll]")].find((c)=>c.dataset.chatScroll===r)??null}var rt=12;function Q(e,r="center"){let c=e.closest("[data-chat-scroll]");if(!c)return;let d=e.getBoundingClientRect(),g=c.getBoundingClientRect(),y=r==="start"?rt:(c.clientHeight-d.height)/2;c.scrollTo({top:c.scrollTop+(d.top-g.top)-y,behavior:"smooth"})}function B(e){let r=e.startContainer.parentElement;if(!r)return;Q(r)}var R=new Map;function U(){if(typeof CSS>"u"||!("highlights"in CSS)||typeof Highlight>"u")return;if(R.size===0){CSS.highlights.delete(z),CSS.highlights.delete(K);return}let e=[...R.values()];CSS.highlights.set(z,new Highlight(...e.flatMap((r)=>r.all))),CSS.highlights.set(K,new Highlight(...e.flatMap((r)=>r.current?[r.current]:[])))}function nt(){let e=Symbol();return{clearHighlights(){R.delete(e),U()},applyHighlights(r,c){R.set(e,{all:r,current:c}),U()}}}function ft({getViewport:e,findSourceMatches:r,revealTurn:c,subscribeOpen:d,labels:g,placement:y="header"}){let{clearHighlights:h,applyHighlights:T}=O(nt,[]),m=r!==void 0,[i,I]=E(!1),[l,L]=E(""),u=O(()=>i&&l.trim()&&r?r(l.trim()):[],[r,i,l]),[F,M]=E(0),[J,x]=E(0),p=S([]),w=S(0),s=S(null),j=S(null),q=S(null);f(()=>{if(!d)return;return d(()=>{I(!0);let t=q.current;if(t!==null)t.focus(),t.select()})},[d]);let _=N(async(o,t)=>{let n=u[o];if(n===void 0)return;let a=e();if(a===null)throw Error("Chat scroll container is missing");if(c)await c(n.turnKey,t);if(t.aborted)return;let C=a.querySelector(`[data-turn-key="${CSS.escape(n.turnKey)}"]`);if(C===null)throw Error(`Codex turn is missing: ${n.turnKey}`);if(!c)Q(C,"start");if(await new Promise((X)=>requestAnimationFrame(()=>X())),t.aborted)return;let k=P(C,l.trim());p.current=k;let H=k[n.occurrenceInTurn];if(T(k,H===void 0?null:H),H!==void 0)B(H)},[u,e,l,c]),A=S(_);f(()=>{A.current=_},[_]);let v=N(()=>{I(!1),L(""),w.current=0,s.current?.abort(),s.current=null,h(),p.current=[]},[]);f(()=>{if(!i)return;let o=(t)=>{if(t.key==="Escape"&&j.current?.contains(document.activeElement))t.preventDefault(),v()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[i,v]),f(()=>{if(!i||!l.trim()){h(),p.current=[],M(0),x(0),w.current=0;return}let o=setTimeout(()=>{if(m)return;let t=e();if(!t)return;let n=P(t,l);if(p.current=n,M(n.length),x(0),T(n,n[0]??null),n[0])B(n[0])},D);return()=>{clearTimeout(o),h()}},[m,i,l,e]),f(()=>{if(!i||!m||!l.trim())return;let o=new AbortController;s.current?.abort(),s.current=o;let t=setTimeout(()=>{p.current=[],w.current=0,M(u.length),x(0),h(),A.current(0,o.signal)},D);return()=>{if(o.abort(),s.current===o)s.current=null;clearTimeout(t),h()}},[u.length,m,i,l]),f(()=>()=>{s.current?.abort(),h()},[]),f(()=>{if(!i)h()},[i]);let W=N((o)=>{if(m){if(u.length===0)return;let n=(w.current+(o?-1:1)+u.length)%u.length;w.current=n,x(n),s.current?.abort();let a=new AbortController;s.current=a,A.current(n,a.signal);return}let t=p.current;if(!t.length)return;x((n)=>{let a=(n+(o?-1:1)+t.length)%t.length,C=t[a];return T(t,C),B(C),a})},[u.length,m]);return G(Y,{children:[y==="header"&&b(tt,{variant:"ghost",size:"icon-sm",title:g.search,onClick:()=>i?v():I(!0),children:b(V,{})}),i&&G("div",{"data-chat-search":!0,ref:j,className:Z("bg-background border-b",y==="body"?"relative shrink-0":"absolute inset-x-0 top-full z-30"),children:[b(et,{ref:q,value:l,onChange:L,onFind:W,onClose:v,placeholder:g.placeholder,prevTitle:g.previous,nextTitle:g.next}),l.trim()&&b("div",{className:"text-muted-foreground border-border border-t px-3 py-1 text-[11px]",children:F===0?"0 / 0":`${J+1} / ${F}`})]})]})}export{ft as ChatSearch,mt as collectMatches,at as findChatScrollContainer,Q as scrollChatElementIntoView};
@@ -1 +1 @@
1
- import{jsx as r,jsxs as h}from"react/jsx-runtime";import{ChevronDownIcon as z,ChevronUpIcon as v,XIcon as x}from"lucide-react";import{useEffect as N,useImperativeHandle as b,useRef as g}from"react";import{Button as i}from"../ui/button.js";import{Input as k}from"../ui/input.js";import{cn as w}from"cn";function D({ref:f,value:s,onChange:m,onFind:n,onClose:o,placeholder:d,autoFocusOpen:a=!0,prevTitle:c,nextTitle:l,className:p}){let t=g(null);b(f,()=>{if(t.current===null)throw Error("FindBar input is not mounted");return t.current},[]),N(()=>{if(!a)return;let e=t.current;if(e===null)throw Error("FindBar input is not mounted");e.focus(),e.select()},[a]);let u=!s;return h("div",{className:w("border-border flex h-9 shrink-0 items-center gap-1 border-b px-2",p),children:[r(k,{ref:t,value:s,onChange:(e)=>m(e.target.value),placeholder:d,className:"h-7 text-xs",onKeyDown:(e)=>{if(e.key==="Escape"){e.preventDefault(),o();return}if(e.key==="Enter"){if(e.preventDefault(),s)n(e.shiftKey)}}}),r(i,{size:"icon",variant:"ghost",className:"size-6",disabled:u,onClick:()=>n(!0),title:c?`${c} (⇧↵)`:"⇧↵",children:r(v,{className:"size-3.5"})}),r(i,{size:"icon",variant:"ghost",className:"size-6",disabled:u,onClick:()=>n(!1),title:l?`${l} (↵)`:"↵",children:r(z,{className:"size-3.5"})}),r(i,{size:"icon",variant:"ghost",className:"size-6",onClick:o,title:"Esc",children:r(x,{className:"size-3.5"})})]})}export{D as FindBar};
1
+ import{jsx as r,jsxs as h}from"react/jsx-runtime";import{cn as z}from"cn";import{ChevronDownIcon as v,ChevronUpIcon as x,XIcon as N}from"lucide-react";import{useEffect as b,useImperativeHandle as g,useRef as k}from"react";import{Button as i}from"../ui/button.js";import{Input as w}from"../ui/input.js";function D({ref:f,value:s,onChange:m,onFind:n,onClose:o,placeholder:d,autoFocusOpen:a=!0,prevTitle:c,nextTitle:l,className:p}){let t=k(null);g(f,()=>{if(t.current===null)throw Error("FindBar input is not mounted");return t.current},[]),b(()=>{if(!a)return;let e=t.current;if(e===null)throw Error("FindBar input is not mounted");e.focus(),e.select()},[a]);let u=!s;return h("div",{className:z("border-border flex h-9 shrink-0 items-center gap-1 border-b px-2",p),children:[r(w,{ref:t,value:s,onChange:(e)=>m(e.target.value),placeholder:d,className:"h-7 text-xs",onKeyDown:(e)=>{if(e.key==="Escape"){e.preventDefault(),o();return}if(e.key==="Enter"){if(e.preventDefault(),s)n(e.shiftKey)}}}),r(i,{size:"icon",variant:"ghost",className:"size-6",disabled:u,onClick:()=>n(!0),title:c?`${c} (⇧↵)`:"⇧↵",children:r(x,{className:"size-3.5"})}),r(i,{size:"icon",variant:"ghost",className:"size-6",disabled:u,onClick:()=>n(!1),title:l?`${l} (↵)`:"↵",children:r(v,{className:"size-3.5"})}),r(i,{size:"icon",variant:"ghost",className:"size-6",onClick:o,title:"Esc",children:r(N,{className:"size-3.5"})})]})}export{D as FindBar};
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Cost, ElicitationSchema, PlanEntry, ToolCallContent, ToolCallLocation, ToolCallStatus } from "@agentclientprotocol/sdk/experimental/v2";
2
- export type { Cost, PlanEntry, ToolCallContent, ToolCallLocation, ToolCallStatus } from "@agentclientprotocol/sdk/experimental/v2";
1
+ import type { Cost, ElicitationSchema, PlanEntry, ToolCallContent, ToolCallLocation, ToolCallStatus } from "@agentclientprotocol/sdk/experimental/v2/unstable";
2
+ export type { Cost, PlanEntry, ToolCallContent, ToolCallLocation, ToolCallStatus } from "@agentclientprotocol/sdk/experimental/v2/unstable";
3
3
  export type MentionUri = {
4
4
  kind: "file";
5
5
  absPath: string;
package/dist/ui/badge.js CHANGED
@@ -1 +1 @@
1
- import{mergeProps as a}from"@base-ui/react/merge-props";import{useRender as o}from"@base-ui/react/use-render";import{cva as n}from"class-variance-authority";import{cn as d}from"cn";var s=n("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function l({className:r,variant:e="default",render:t,...i}){return o({defaultTagName:"span",props:a({className:d(s({variant:e}),r)},i),render:t,state:{slot:"badge",variant:e}})}export{l as Badge,s as badgeVariants};
1
+ import{mergeProps as a}from"@base-ui/react/merge-props";import{useRender as o}from"@base-ui/react/use-render";import{cva as n}from"class-variance-authority";import{cn as d}from"cn";var s=n("group/badge focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:ring-[3px] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function l({className:r,variant:e="default",render:t,...i}){return o({defaultTagName:"span",props:a({className:d(s({variant:e}),r)},i),render:t,state:{slot:"badge",variant:e}})}export{l as Badge,s as badgeVariants};
package/dist/ui/button.js CHANGED
@@ -1 +1 @@
1
- import{jsx as a}from"react/jsx-runtime";import{Button as n}from"@base-ui/react/button";import{cva as d}from"class-variance-authority";import{cn as o}from"cn";var s=d("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",lg:"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-9","icon-xs":"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function g({className:e,variant:r="default",size:i="default",...t}){return a(n,{"data-slot":"button",className:o(s({variant:r,size:i,className:e})),...t})}export{g as Button,s as buttonVariants};
1
+ import{jsx as a}from"react/jsx-runtime";import{Button as n}from"@base-ui/react/button";import{cva as d}from"class-variance-authority";import{cn as o}from"cn";var s=d("group/button focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:ring-3 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50 shadow-xs",secondary:"bg-secondary text-secondary-foreground aria-expanded:bg-secondary aria-expanded:text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",lg:"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-9","icon-xs":"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function g({className:e,variant:r="default",size:i="default",...t}){return a(n,{"data-slot":"button",className:o(s({variant:r,size:i,className:e})),...t})}export{g as Button,s as buttonVariants};
@@ -1,5 +1,5 @@
1
- import * as React from "react";
2
1
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
2
+ import * as React from "react";
3
3
  declare function Dialog({ ...props }: DialogPrimitive.Root.Props): React.JSX.Element;
4
4
  declare function DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props): React.JSX.Element;
5
5
  declare function DialogPortal({ ...props }: DialogPrimitive.Portal.Props): React.JSX.Element;
package/dist/ui/dialog.js CHANGED
@@ -1 +1 @@
1
- import{jsx as a,jsxs as l}from"react/jsx-runtime";import{Dialog as e}from"@base-ui/react/dialog";import{cn as r}from"cn";import{Button as d}from"./button.js";import{XIcon as s}from"lucide-react";function D({...o}){return a(e.Root,{"data-slot":"dialog",...o})}function h({...o}){return a(e.Trigger,{"data-slot":"dialog-trigger",...o})}function c({...o}){return a(e.Portal,{"data-slot":"dialog-portal",...o})}function v({...o}){return a(e.Close,{"data-slot":"dialog-close",...o})}function u({className:o,...t}){return a(e.Backdrop,{"data-slot":"dialog-overlay",className:r("data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs",o),...t})}function N({className:o,children:t,showCloseButton:n=!0,...i}){return l(c,{children:[a(u,{}),l(e.Popup,{"data-slot":"dialog-content",className:r("bg-popover text-popover-foreground ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl p-6 text-sm ring-1 duration-100 outline-none sm:max-w-md",o),...i,children:[t,n&&l(e.Close,{"data-slot":"dialog-close",render:a(d,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[a(s,{}),a("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:o,...t}){return a("div",{"data-slot":"dialog-header",className:r("flex flex-col gap-2",o),...t})}function C({className:o,showCloseButton:t=!1,children:n,...i}){return l("div",{"data-slot":"dialog-footer",className:r("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",o),...i,children:[n,t&&a(e.Close,{render:a(d,{variant:"outline"}),children:"Close"})]})}function j({className:o,...t}){return a(e.Title,{"data-slot":"dialog-title",className:r("font-heading leading-none font-medium",o),...t})}function y({className:o,...t}){return a(e.Description,{"data-slot":"dialog-description",className:r("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3",o),...t})}export{D as Dialog,v as DialogClose,N as DialogContent,y as DialogDescription,C as DialogFooter,b as DialogHeader,u as DialogOverlay,c as DialogPortal,j as DialogTitle,h as DialogTrigger};
1
+ import{jsx as a,jsxs as l}from"react/jsx-runtime";import{Dialog as e}from"@base-ui/react/dialog";import{cn as r}from"cn";import{XIcon as s}from"lucide-react";import{Button as d}from"./button.js";function D({...o}){return a(e.Root,{"data-slot":"dialog",...o})}function h({...o}){return a(e.Trigger,{"data-slot":"dialog-trigger",...o})}function c({...o}){return a(e.Portal,{"data-slot":"dialog-portal",...o})}function v({...o}){return a(e.Close,{"data-slot":"dialog-close",...o})}function u({className:o,...t}){return a(e.Backdrop,{"data-slot":"dialog-overlay",className:r("data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs",o),...t})}function N({className:o,children:t,showCloseButton:n=!0,...i}){return l(c,{children:[a(u,{}),l(e.Popup,{"data-slot":"dialog-content",className:r("bg-popover text-popover-foreground ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl p-6 text-sm ring-1 duration-100 outline-none sm:max-w-md",o),...i,children:[t,n&&l(e.Close,{"data-slot":"dialog-close",render:a(d,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[a(s,{}),a("span",{className:"sr-only",children:"Close"})]})]})]})}function b({className:o,...t}){return a("div",{"data-slot":"dialog-header",className:r("flex flex-col gap-2",o),...t})}function C({className:o,showCloseButton:t=!1,children:n,...i}){return l("div",{"data-slot":"dialog-footer",className:r("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",o),...i,children:[n,t&&a(e.Close,{render:a(d,{variant:"outline"}),children:"Close"})]})}function j({className:o,...t}){return a(e.Title,{"data-slot":"dialog-title",className:r("font-heading leading-none font-medium",o),...t})}function y({className:o,...t}){return a(e.Description,{"data-slot":"dialog-description",className:r("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3",o),...t})}export{D as Dialog,v as DialogClose,N as DialogContent,y as DialogDescription,C as DialogFooter,b as DialogHeader,u as DialogOverlay,c as DialogPortal,j as DialogTitle,h as DialogTrigger};
@@ -1,5 +1,5 @@
1
- import * as React from "react";
2
1
  import { Menu as MenuPrimitive } from "@base-ui/react/menu";
2
+ import * as React from "react";
3
3
  declare function DropdownMenu({ ...props }: MenuPrimitive.Root.Props): React.JSX.Element;
4
4
  declare function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props): React.JSX.Element;
5
5
  declare function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props): React.JSX.Element;
@@ -1 +1 @@
1
- import{jsx as t,jsxs as u}from"react/jsx-runtime";import{Menu as n}from"@base-ui/react/menu";import{cn as r}from"cn";import{ChevronRightIcon as l,CheckIcon as c}from"lucide-react";function x({...e}){return t(n.Root,{"data-slot":"dropdown-menu",...e})}function h({...e}){return t(n.Portal,{"data-slot":"dropdown-menu-portal",...e})}function w({...e}){return t(n.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function p({align:e="start",alignOffset:o=0,side:a="bottom",sideOffset:d=4,className:i,...s}){return t(n.Portal,{children:t(n.Positioner,{className:"isolate z-50 outline-none",align:e,alignOffset:o,side:a,sideOffset:d,children:t(n.Popup,{"data-slot":"dropdown-menu-content",className:r("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md p-1 shadow-md ring-1 duration-100 outline-none data-closed:overflow-hidden",i),...s})})})}function b({...e}){return t(n.Group,{"data-slot":"dropdown-menu-group",...e})}function M({className:e,inset:o,...a}){return t(n.GroupLabel,{"data-slot":"dropdown-menu-label","data-inset":o,className:r("text-muted-foreground px-2 py-1.5 text-xs font-medium data-inset:pl-8",e),...a})}function D({className:e,inset:o,variant:a="default",...d}){return t(n.Item,{"data-slot":"dropdown-menu-item","data-inset":o,"data-variant":a,className:r("group/dropdown-menu-item focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:*:[svg]:text-destructive relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d})}function z({...e}){return t(n.SubmenuRoot,{"data-slot":"dropdown-menu-sub",...e})}function _({className:e,inset:o,children:a,...d}){return u(n.SubmenuTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":o,className:r("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d,children:[a,t(l,{className:"ml-auto"})]})}function k({align:e="start",alignOffset:o=-3,side:a="right",sideOffset:d=0,className:i,...s}){return t(p,{"data-slot":"dropdown-menu-sub-content",className:r("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 w-auto min-w-[96px] rounded-md p-1 shadow-lg ring-1 duration-100",i),align:e,alignOffset:o,side:a,sideOffset:d,...s})}function N({className:e,children:o,checked:a,inset:d,...i}){return u(n.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":d,className:r("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...i,children:[t("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:t(n.CheckboxItemIndicator,{children:t(c,{})})}),o]})}function y({...e}){return t(n.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...e})}function I({className:e,children:o,inset:a,...d}){return u(n.RadioItem,{"data-slot":"dropdown-menu-radio-item","data-inset":a,className:r("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d,children:[t("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:t(n.RadioItemIndicator,{children:t(c,{})})}),o]})}function R({className:e,...o}){return t(n.Separator,{"data-slot":"dropdown-menu-separator",className:r("bg-border -mx-1 my-1 h-px",e),...o})}function S({className:e,...o}){return t("span",{"data-slot":"dropdown-menu-shortcut",className:r("text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",e),...o})}export{x as DropdownMenu,N as DropdownMenuCheckboxItem,p as DropdownMenuContent,b as DropdownMenuGroup,D as DropdownMenuItem,M as DropdownMenuLabel,h as DropdownMenuPortal,y as DropdownMenuRadioGroup,I as DropdownMenuRadioItem,R as DropdownMenuSeparator,S as DropdownMenuShortcut,z as DropdownMenuSub,k as DropdownMenuSubContent,_ as DropdownMenuSubTrigger,w as DropdownMenuTrigger};
1
+ import{jsx as t,jsxs as u}from"react/jsx-runtime";import{Menu as n}from"@base-ui/react/menu";import{cn as r}from"cn";import{CheckIcon as c,ChevronRightIcon as l}from"lucide-react";function x({...e}){return t(n.Root,{"data-slot":"dropdown-menu",...e})}function h({...e}){return t(n.Portal,{"data-slot":"dropdown-menu-portal",...e})}function w({...e}){return t(n.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function p({align:e="start",alignOffset:o=0,side:a="bottom",sideOffset:d=4,className:i,...s}){return t(n.Portal,{children:t(n.Positioner,{className:"isolate z-50 outline-none",align:e,alignOffset:o,side:a,sideOffset:d,children:t(n.Popup,{"data-slot":"dropdown-menu-content",className:r("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md p-1 shadow-md ring-1 duration-100 outline-none data-closed:overflow-hidden",i),...s})})})}function b({...e}){return t(n.Group,{"data-slot":"dropdown-menu-group",...e})}function M({className:e,inset:o,...a}){return t(n.GroupLabel,{"data-slot":"dropdown-menu-label","data-inset":o,className:r("text-muted-foreground px-2 py-1.5 text-xs font-medium data-inset:pl-8",e),...a})}function D({className:e,inset:o,variant:a="default",...d}){return t(n.Item,{"data-slot":"dropdown-menu-item","data-inset":o,"data-variant":a,className:r("group/dropdown-menu-item focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:*:[svg]:text-destructive relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d})}function z({...e}){return t(n.SubmenuRoot,{"data-slot":"dropdown-menu-sub",...e})}function _({className:e,inset:o,children:a,...d}){return u(n.SubmenuTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":o,className:r("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d,children:[a,t(l,{className:"ml-auto"})]})}function k({align:e="start",alignOffset:o=-3,side:a="right",sideOffset:d=0,className:i,...s}){return t(p,{"data-slot":"dropdown-menu-sub-content",className:r("bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 w-auto min-w-[96px] rounded-md p-1 shadow-lg ring-1 duration-100",i),align:e,alignOffset:o,side:a,sideOffset:d,...s})}function N({className:e,children:o,checked:a,inset:d,...i}){return u(n.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":d,className:r("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...i,children:[t("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:t(n.CheckboxItemIndicator,{children:t(c,{})})}),o]})}function y({...e}){return t(n.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...e})}function I({className:e,children:o,inset:a,...d}){return u(n.RadioItem,{"data-slot":"dropdown-menu-radio-item","data-inset":a,className:r("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...d,children:[t("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-radio-item-indicator",children:t(n.RadioItemIndicator,{children:t(c,{})})}),o]})}function R({className:e,...o}){return t(n.Separator,{"data-slot":"dropdown-menu-separator",className:r("bg-border -mx-1 my-1 h-px",e),...o})}function S({className:e,...o}){return t("span",{"data-slot":"dropdown-menu-shortcut",className:r("text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",e),...o})}export{x as DropdownMenu,N as DropdownMenuCheckboxItem,p as DropdownMenuContent,b as DropdownMenuGroup,D as DropdownMenuItem,M as DropdownMenuLabel,h as DropdownMenuPortal,y as DropdownMenuRadioGroup,I as DropdownMenuRadioItem,R as DropdownMenuSeparator,S as DropdownMenuShortcut,z as DropdownMenuSub,k as DropdownMenuSubContent,_ as DropdownMenuSubTrigger,w as DropdownMenuTrigger};
package/dist/ui/field.js CHANGED
@@ -1 +1 @@
1
- import{jsx as t,jsxs as f}from"react/jsx-runtime";import{useMemo as u}from"react";import{cva as c}from"class-variance-authority";import{cn as l}from"cn";import{Label as m}from"./label.js";import{Separator as p}from"./separator.js";function k({className:a,...e}){return t("fieldset",{"data-slot":"field-set",className:l("flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",a),...e})}function y({className:a,variant:e="legend",...o}){return t("legend",{"data-slot":"field-legend","data-variant":e,className:l("mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",a),...o})}function F({className:a,...e}){return t("div",{"data-slot":"field-group",className:l("group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",a),...e})}var g=c("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function j({className:a,orientation:e="vertical",...o}){return t("div",{role:"group","data-slot":"field","data-orientation":e,className:l(g({orientation:e}),a),...o})}function L({className:a,...e}){return t("div",{"data-slot":"field-content",className:l("group/field-content flex flex-1 flex-col gap-1 leading-snug",a),...e})}function S({className:a,...e}){return t(m,{"data-slot":"field-label",className:l("group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-3","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",a),...e})}function z({className:a,...e}){return t("div",{"data-slot":"field-label",className:l("flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",a),...e})}function E({className:a,...e}){return t("p",{"data-slot":"field-description",className:l("text-muted-foreground text-left text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",a),...e})}function M({children:a,className:e,...o}){return f("div",{"data-slot":"field-separator","data-content":!!a,className:l("relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",e),...o,children:[t(p,{className:"absolute inset-0 top-1/2"}),a&&t("span",{className:"bg-background text-muted-foreground relative mx-auto block w-fit px-2","data-slot":"field-separator-content",children:a})]})}function V({className:a,children:e,errors:o,...s}){let r=u(()=>{if(e)return e;if(!o?.length)return null;let i=[...new Map(o.map((d)=>[d?.message,d])).values()];if(i?.length==1)return i[0]?.message;return t("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:i.map((d,n)=>d?.message&&t("li",{children:d.message},n))})},[e,o]);if(!r)return null;return t("div",{role:"alert","data-slot":"field-error",className:l("text-destructive text-sm font-normal",a),...s,children:r})}export{j as Field,L as FieldContent,E as FieldDescription,V as FieldError,F as FieldGroup,S as FieldLabel,y as FieldLegend,M as FieldSeparator,k as FieldSet,z as FieldTitle};
1
+ import{jsx as t,jsxs as f}from"react/jsx-runtime";import{cva as u}from"class-variance-authority";import{cn as l}from"cn";import{useMemo as c}from"react";import{Label as m}from"./label.js";import{Separator as p}from"./separator.js";function k({className:a,...e}){return t("fieldset",{"data-slot":"field-set",className:l("flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",a),...e})}function y({className:a,variant:e="legend",...o}){return t("legend",{"data-slot":"field-legend","data-variant":e,className:l("mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",a),...o})}function F({className:a,...e}){return t("div",{"data-slot":"field-group",className:l("group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",a),...e})}var g=u("group/field data-[invalid=true]:text-destructive flex w-full gap-3",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function j({className:a,orientation:e="vertical",...o}){return t("div",{role:"group","data-slot":"field","data-orientation":e,className:l(g({orientation:e}),a),...o})}function L({className:a,...e}){return t("div",{"data-slot":"field-content",className:l("group/field-content flex flex-1 flex-col gap-1 leading-snug",a),...e})}function S({className:a,...e}){return t(m,{"data-slot":"field-label",className:l("group/field-label peer/field-label has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 *:data-[slot=field]:p-3","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",a),...e})}function z({className:a,...e}){return t("div",{"data-slot":"field-label",className:l("flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",a),...e})}function E({className:a,...e}){return t("p",{"data-slot":"field-description",className:l("text-muted-foreground text-left text-sm leading-normal font-normal group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",a),...e})}function M({children:a,className:e,...o}){return f("div",{"data-slot":"field-separator","data-content":!!a,className:l("relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",e),...o,children:[t(p,{className:"absolute inset-0 top-1/2"}),a&&t("span",{className:"bg-background text-muted-foreground relative mx-auto block w-fit px-2","data-slot":"field-separator-content",children:a})]})}function V({className:a,children:e,errors:o,...s}){let r=c(()=>{if(e)return e;if(!o?.length)return null;let i=[...new Map(o.map((d)=>[d?.message,d])).values()];if(i?.length==1)return i[0]?.message;return t("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:i.map((d,n)=>d?.message&&t("li",{children:d.message},n))})},[e,o]);if(!r)return null;return t("div",{role:"alert","data-slot":"field-error",className:l("text-destructive text-sm font-normal",a),...s,children:r})}export{j as Field,L as FieldContent,E as FieldDescription,V as FieldError,F as FieldGroup,S as FieldLabel,y as FieldLegend,M as FieldSeparator,k as FieldSet,z as FieldTitle};