@alwith/module-chat 0.1.28 → 0.1.30
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.
- package/dist/activity-host.js +1 -1
- package/dist/approval/choice-elicitation-form.js +1 -1
- package/dist/approval/choice-schema.js +1 -1
- package/dist/approval/permission-options.js +1 -1
- package/dist/approval/permission-view.js +1 -1
- package/dist/approval/schema-elicitation-form.js +1 -1
- package/dist/approval/url-elicitation-card.js +1 -1
- package/dist/chunk-11n6ah6p.js +2 -0
- package/dist/chunk-15a7wypc.js +2 -0
- package/dist/{chunk-s0nhgptn.js → chunk-2kjmc9hg.js} +1 -1
- package/dist/chunk-2sc7ppw2.js +1 -0
- package/dist/chunk-51qk29t6.js +2 -0
- package/dist/{chunk-v4p0qwmj.js → chunk-5hqv4m75.js} +1 -1
- package/dist/{chunk-dekjd5sf.js → chunk-67gms74t.js} +2 -2
- package/dist/{chunk-s3z33k7f.js → chunk-7471tnsq.js} +2 -2
- package/dist/{chunk-hy1x2td2.js → chunk-85y9tqsd.js} +2 -2
- package/dist/{chunk-src2j5cw.js → chunk-98t2nc02.js} +2 -2
- package/dist/{chunk-gycty1x1.js → chunk-99xmegcw.js} +2 -2
- package/dist/{chunk-70sfgw0j.js → chunk-9cdspnb1.js} +2 -2
- package/dist/{chunk-9me7jmzd.js → chunk-aaybyhdj.js} +2 -2
- package/dist/{chunk-m8gejgjs.js → chunk-ake02dgs.js} +1 -1
- package/dist/{chunk-8zs8vy0q.js → chunk-b5srhd6k.js} +1 -1
- package/dist/{chunk-7gh078gc.js → chunk-bbnrzw5x.js} +2 -2
- package/dist/{chunk-skx67pc6.js → chunk-bgj6z7z4.js} +1 -1
- package/dist/{chunk-8bdd6q4w.js → chunk-d1xydh51.js} +2 -2
- package/dist/chunk-dvfka70p.js +2 -0
- package/dist/chunk-eyn3tdcs.js +2 -0
- package/dist/{chunk-etvhn65g.js → chunk-h310nm02.js} +2 -2
- package/dist/{chunk-rakd7vzb.js → chunk-h7y6vmb3.js} +1 -1
- package/dist/{chunk-s28x10qd.js → chunk-j63t6dxg.js} +1 -1
- package/dist/{chunk-25na55ve.js → chunk-kew8ef6z.js} +2 -2
- package/dist/{chunk-y2xbq7rb.js → chunk-nvtvm7jc.js} +3 -3
- package/dist/chunk-nx3k6k2p.js +2 -0
- package/dist/{chunk-swg5v7sg.js → chunk-p4c1w6qx.js} +2 -2
- package/dist/chunk-p6kymvjw.js +2 -0
- package/dist/{chunk-ghfbzhnb.js → chunk-pkxfrrwf.js} +1 -1
- package/dist/chunk-q00ycy4m.js +7 -0
- package/dist/chunk-qf9n7v84.js +1 -0
- package/dist/{chunk-kj1wrn2j.js → chunk-s4w6yjc0.js} +1 -1
- package/dist/{chunk-6x9vcfpg.js → chunk-t83jwyey.js} +1 -1
- package/dist/{chunk-0e1pdbec.js → chunk-ta690ra0.js} +2 -2
- package/dist/{chunk-bhvtt6tv.js → chunk-tbr607hk.js} +2 -2
- package/dist/chunk-tm40sncc.js +2 -0
- package/dist/chunk-twww750f.js +2 -0
- package/dist/chunk-wbpw278r.js +2 -0
- package/dist/{chunk-qj8r5xvx.js → chunk-wf194rae.js} +2 -2
- package/dist/{chunk-f20xh0z9.js → chunk-x6jyxw9c.js} +1 -1
- package/dist/{chunk-ynga7fm4.js → chunk-xc6fz2xk.js} +3 -3
- package/dist/{chunk-7pr2j1zb.js → chunk-xgy0heva.js} +1 -1
- package/dist/{chunk-341yykkp.js → chunk-y1cbwywe.js} +1 -1
- package/dist/{chunk-ax9ganqr.js → chunk-ytqka33j.js} +2 -2
- package/dist/chunk-z3gwnjmk.js +2 -0
- package/dist/codex/activity-group.js +1 -1
- package/dist/codex/assistant-message.js +2 -2
- package/dist/codex/async-question-card.js +1 -1
- package/dist/codex/edited-files-card.js +1 -1
- package/dist/codex/image-view-activity.js +1 -1
- package/dist/codex/markdown-renderer.js +5 -5
- package/dist/codex/navigation-preview.js +1 -1
- package/dist/codex/navigation-rail.js +1 -1
- package/dist/codex/plan.js +1 -1
- package/dist/codex/styles.css +1 -1
- package/dist/codex/thread-virtualizer.js +1 -1
- package/dist/codex/user-message.js +1 -1
- package/dist/codex/virtualized-turn-list.js +1 -1
- package/dist/composer/completion-filter.js +1 -1
- package/dist/composer/completion-menu.js +2 -2
- package/dist/composer/completion-trigger.js +1 -1
- package/dist/composer/effort-slider.js +1 -1
- package/dist/composer/menu-radio.js +1 -1
- package/dist/composer/model-select.js +1 -1
- package/dist/composer/permission-mode-select.js +1 -1
- package/dist/composer/prompt-input-attachments.js +1 -1
- package/dist/composer/prompt-input-clipboard.js +1 -1
- package/dist/composer/prompt-input-context.js +1 -1
- package/dist/composer/prompt-input-textarea.js +3 -3
- package/dist/composer/prompt-input.js +1 -1
- package/dist/image-lightbox.js +1 -1
- package/dist/image-preview-dialog.js +1 -1
- package/dist/lib/code-highlighter.js +1 -1
- package/dist/lib/fuzzy.js +1 -1
- package/dist/lib/group-blocks.js +1 -1
- package/dist/lib/image-encode.js +1 -1
- package/dist/lib/limits.js +1 -1
- package/dist/lib/markdown-parser.js +1 -1
- package/dist/lib/markdown-rules.js +1 -1
- package/dist/lib/model-name.js +1 -1
- package/dist/lib/pointer-centered-zoom.js +1 -1
- package/dist/lib/prepare-prompt-files.js +1 -1
- package/dist/lib/stream-style.js +1 -1
- package/dist/lib/streaming-markdown.js +1 -1
- package/dist/search/chat-search.js +1 -1
- package/dist/search/dom-matches.js +1 -1
- package/dist/search/find-bar.js +1 -1
- package/dist/search/literal-matches.js +1 -1
- package/dist/ui/badge.js +1 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/card.js +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/dialog.js +1 -1
- package/dist/ui/dropdown-menu.js +1 -1
- package/dist/ui/field.js +1 -1
- package/dist/ui/hover-card.js +1 -1
- package/dist/ui/input-group.js +1 -1
- package/dist/ui/input.js +1 -1
- package/dist/ui/separator.js +1 -1
- package/dist/ui/switch.js +1 -1
- package/dist/ui/tooltip.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-74phx7h8.js +0 -2
- package/dist/chunk-7tj0a2na.js +0 -2
- package/dist/chunk-awbgf3hp.js +0 -2
- package/dist/chunk-darkfx1b.js +0 -2
- package/dist/chunk-g20b01rn.js +0 -2
- package/dist/chunk-hnt4tt1n.js +0 -2
- package/dist/chunk-k1c0jrk1.js +0 -1
- package/dist/chunk-kzccs8ak.js +0 -2
- package/dist/chunk-p9wpghey.js +0 -2
- package/dist/chunk-qyhgwc51.js +0 -2
- package/dist/chunk-reqrpvyy.js +0 -2
- package/dist/chunk-wc3patey.js +0 -7
- package/dist/chunk-wtkv29ba.js +0 -1
- package/dist/chunk-yk52gm8x.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Menu as n}from"@base-ui/react/menu";import{cn as i}from"cn";import{CheckIcon as c,ChevronRightIcon as p}from"lucide-react";import{jsxDEV as t}from"react/jsx-dev-runtime";function
|
|
1
|
+
import{Menu as n}from"@base-ui/react/menu";import{cn as i}from"cn";import{CheckIcon as c,ChevronRightIcon as p}from"lucide-react";import{jsxDEV as t}from"react/jsx-dev-runtime";function v({...e}){return t(n.Root,{"data-slot":"dropdown-menu",...e},void 0,!1,void 0,this)}function Et({...e}){return t(n.Portal,{"data-slot":"dropdown-menu-portal",...e},void 0,!1,void 0,this)}function b({...e}){return t(n.Trigger,{"data-slot":"dropdown-menu-trigger",...e},void 0,!1,void 0,this)}function m({align:e="start",alignOffset:o=0,side:a="bottom",sideOffset:r=4,className:d,...u}){return t(n.Portal,{children:t(n.Positioner,{className:"isolate z-50 outline-none",align:e,alignOffset:o,side:a,sideOffset:r,children:t(n.Popup,{"data-slot":"dropdown-menu-content",className:i("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",d),...u},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function y({...e}){return t(n.Group,{"data-slot":"dropdown-menu-group",...e},void 0,!1,void 0,this)}function D({className:e,inset:o,...a}){return t(n.GroupLabel,{"data-slot":"dropdown-menu-label","data-inset":o,className:i("text-muted-foreground px-2 py-1.5 text-xs font-medium data-inset:pl-8",e),...a},void 0,!1,void 0,this)}function w({className:e,inset:o,variant:a="default",...r}){return t(n.Item,{"data-slot":"dropdown-menu-item","data-inset":o,"data-variant":a,className:i("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),...r},void 0,!1,void 0,this)}function N({...e}){return t(n.SubmenuRoot,{"data-slot":"dropdown-menu-sub",...e},void 0,!1,void 0,this)}function S({className:e,inset:o,children:a,...r}){return t(n.SubmenuTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":o,className:i("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),...r,children:[a,t(p,{className:"ml-auto"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function E({align:e="start",alignOffset:o=-3,side:a="right",sideOffset:r=0,className:d,...u}){return t(m,{"data-slot":"dropdown-menu-sub-content",className:i("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",d),align:e,alignOffset:o,side:a,sideOffset:r,...u},void 0,!1,void 0,this)}function J({className:e,children:o,checked:a,inset:r,...d}){return t(n.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":r,className:i("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,...d,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,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),o]},void 0,!0,void 0,this)}function $e({...e}){return t(n.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...e},void 0,!1,void 0,this)}function Ue({className:e,children:o,inset:a,...r}){return t(n.RadioItem,{"data-slot":"dropdown-menu-radio-item","data-inset":a,className:i("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),...r,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,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),o]},void 0,!0,void 0,this)}function s({className:e,...o}){return t(n.Separator,{"data-slot":"dropdown-menu-separator",className:i("bg-border -mx-1 my-1 h-px",e),...o},void 0,!1,void 0,this)}function Rt({className:e,...o}){return t("span",{"data-slot":"dropdown-menu-shortcut",className:i("text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest",e),...o},void 0,!1,void 0,this)}export{v,Et,b,m,y,D,w,N,S,E,J,$e,Ue,s,Rt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PreviewCard as e}from"@base-ui/react/preview-card";import{cn as s}from"cn";import{jsxDEV as r}from"react/jsx-dev-runtime";function
|
|
1
|
+
import{PreviewCard as e}from"@base-ui/react/preview-card";import{cn as s}from"cn";import{jsxDEV as r}from"react/jsx-dev-runtime";function Xe({...i}){return r(e.Root,{"data-slot":"hover-card",...i},void 0,!1,void 0,this)}function Ze({...i}){return r(e.Trigger,{"data-slot":"hover-card-trigger",...i},void 0,!1,void 0,this)}function Ye({className:i,side:o="bottom",sideOffset:t=4,align:a="center",alignOffset:d=4,...n}){return r(e.Portal,{"data-slot":"hover-card-portal",children:r(e.Positioner,{align:a,alignOffset:d,side:o,sideOffset:t,className:"isolate z-50",children:r(e.Popup,{"data-slot":"hover-card-content",className:s("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 w-64 origin-(--transform-origin) rounded-lg p-4 text-sm shadow-md ring-1 outline-hidden duration-100",i),...n},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}export{Xe,Ze,Ye};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
async function
|
|
2
|
-
export{
|
|
1
|
+
async function Ee(g,u){try{let a=await(await fetch(g)).blob(),s=u??a.type??"";if(!s.startsWith("image/"))return new Promise((e)=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(a)});let w=s.includes("svg"),n,r,o;if(w){let e=new Image,t=URL.createObjectURL(a);e.src=t;try{await new Promise((h,f)=>{e.onload=()=>h(),e.onerror=()=>f(Error("svg load failed"))})}finally{URL.revokeObjectURL(t)}r=e.naturalWidth||1024,o=e.naturalHeight||1024,n=e}else{let e=await createImageBitmap(a);r=e.width,o=e.height,n=e}let i=Math.min(1,2000/Math.max(r,o)),c=Math.round(r*i),l=Math.round(o*i),d=new OffscreenCanvas(c,l),m=d.getContext("2d");if(!m)throw Error("image-encode: OffscreenCanvas 2d context 不可用");if(m.drawImage(n,0,0,c,l),n instanceof ImageBitmap)n.close();let b=await d.convertToBlob({type:"image/webp",quality:0.85});return new Promise((e)=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(b)})}catch{return null}}
|
|
2
|
+
export{Ee};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Le(t,e){if(e===0)return null;let r=e-1;while(r>=0){let n=t[r];if(n===" "||n==="\t"||n===`
|
|
2
2
|
`)return null;if(n==="@"||n==="/"){let i=r===0?"":t[r-1],s=r===0||i===`
|
|
3
3
|
`;if(n==="/"?s&&!/[/\\]/.test(t.slice(r+1,e)):s||i===" "||i==="\t")return{kind:n==="/"?"slash":"at",start:r,end:e,query:t.slice(r+1,e)}}r-=1}return null}
|
|
4
|
-
export{
|
|
4
|
+
export{Le};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var t=new Map;var a=0;function K(e,n){let r=n?void 0:t.get(e);if(r===void 0)return null;return t.delete(e),t.set(e,r),{...r,tokens:structuredClone(r.tokens)}}function c(e){if(e.isStreaming||e.text.length>1048576)return;if(t.delete(e.text))a-=e.text.length;t.set(e.text,{...e,tokens:structuredClone(e.tokens)}),a+=e.text.length;while(a>2097152||t.size>200){let n=t.keys().next().value;a-=n.length,t.delete(n)}}class l{worker=new Worker(new URL("@alwith/module-chat/markdown-parser.worker",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,r=this.active;if(n.clientId!==r?.clientId||n.revision!==r.revision){this.fail(Error("Markdown worker returned an unexpected request"));return}if(this.active=null,!n.ok){this.fail(Error(n.error));return}let i={...r.input,tokens:n.tokens};c(i);let s=this.clients.get(r.clientId),o=this.pending.get(r.clientId),u=o!==void 0&&r.input.isStreaming&&o.input.isStreaming&&o.input.text.startsWith(r.input.text);if(s!==void 0&&(s.revision===r.revision||u))s.onResult(i);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 r=++this.nextClientId,i={revision:0,onResult:e,onError:n};return this.clients.set(r,i),{update:(s)=>{if(this.failure!==null)throw this.failure;i.revision+=1;let o=K(s.text,s.isStreaming);if(o!==null){this.pending.delete(r),i.onResult(o);return}this.pending.set(r,{clientId:r,revision:i.revision,input:s}),this.dispatch()},dispose:()=>{if(!this.clients.delete(r))return;if(this.pending.delete(r),this.clients.size===0)this.worker.terminate(),d=void 0;else if(this.failure===null)this.send({type:"dispose",clientId:r})}}}}var d;function we(e,n){return d??=new l,d.connect(e,n)}
|
|
2
|
+
export{K,we};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createContext as d,useCallback as n,useContext as i,useEffect as et,useMemo as D,useRef as I,useState as B}from"react";import{jsxDEV as G}from"react/jsx-dev-runtime";var A=d(null),X=d(null);function Pt(){return i(X)}var Z=d(null);function It(){return i(Z)}var C=d(null);function _e(){let r=i(A);if(!r)throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");return r}var T=()=>i(A);function Mt(){let r=i(C);if(!r)throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");return r}var nt=()=>i(C);function Nt({initialInput:r="",revision:l,onSubmittedClear:c,onRemoveAttachment:R,attachmentPolicy:f,value:y,onValueChange:U,attachments:L,onAttachmentsChange:S,children:J}){let W=n((t)=>{if(t.type)return t.type;let e=(t.name||"").toLowerCase();if(e.endsWith(".png"))return"image/png";if(e.endsWith(".jpg")||e.endsWith(".jpeg"))return"image/jpeg";if(e.endsWith(".webp"))return"image/webp";if(e.endsWith(".gif"))return"image/gif";if(e.endsWith(".bmp"))return"image/bmp";if(e.endsWith(".svg"))return"image/svg+xml";return""},[]),j=y!==void 0,[K,N]=B(r),p=y??K,o=I({value:p,external:l,revision:0});if(o.current.value!==p||o.current.external!==l)o.current={value:p,external:l,revision:o.current.revision+1};let w=n(()=>o.current.revision,[]),P=n((t)=>{if(o.current.value=t,o.current.revision++,j)U?.(t);else N(t)},[j,U]),g=n(()=>P(""),[P]),x=L!==void 0,[Q,V]=B([]),v=L??Q,b=I(v);b.current=v;let s=n((t)=>{let e=typeof t==="function"?t(b.current):t;if(x)S?.(e);else V(e)},[x,S]),O=I(null),M=I(()=>{}),E=n((t)=>{let e=[...t];if(e.length===0)return;s((a)=>{let m=f===void 0?e:f.uniqueFiles(e,a);return[...a,...m.map((u)=>{let z=f?.sourcePath(u);return{id:crypto.randomUUID(),type:"file",url:URL.createObjectURL(u),mediaType:W(u),filename:u.name,size:u.size,lastModified:u.lastModified,...z===void 0?{}:{sourcePath:z}}})]})},[f,W,s]),k=n((t)=>{s((e)=>{let a=e.find((m)=>m.id===t);if(a?.url)URL.revokeObjectURL(a.url);return e.filter((m)=>m.id!==t)}),R?.()},[R,s]),H=n(()=>{s((t)=>{for(let e of t)if(e.url)URL.revokeObjectURL(e.url);return[]})},[s]);et(()=>{if(x)return;return()=>{for(let t of b.current)if(t.url)URL.revokeObjectURL(t.url)}},[x]);let _=n(()=>{M.current?.()},[]),F=D(()=>({files:v,add:E,remove:k,clear:H,openFileDialog:_,fileInputRef:O}),[v,E,k,H,_]),q=n((t,e)=>{O.current=t.current,M.current=e},[]),tt=D(()=>({textInput:{value:p,setInput:P,clear:g,getRevision:w,clearSubmitted:c??g},attachments:F,__registerFileInput:q}),[p,P,g,w,c,F,q]);return G(A.Provider,{value:tt,children:G(C.Provider,{value:F,children:J},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var Y=d(null);function h(){let r=nt(),l=i(Y),c=r??l;if(!c)throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");return c}
|
|
2
|
+
export{X,Pt,Z,It,C,_e,T,Mt,Nt,Y,h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
export{
|
|
1
|
+
function Fe({container:i,target:f,clientX:e,clientY:n,currentScale:r,nextScale:s}){if(r<=0||s<=0)return null;let o=i.getBoundingClientRect(),t=f.getBoundingClientRect();if(t.width===0||t.height===0)return null;let h=e>=t.left&&e<=t.right&&n>=t.top&&n<=t.bottom,l=h?(e-t.left)/t.width:0.5,a=h?(n-t.top)/t.height:0.5,c=t.width/r,g=t.height/r,m=c*s,u=g*s,d=e-o.left,p=n-o.top,P=i.scrollLeft+(t.left-o.left)+t.width/2,b=i.scrollTop+(t.top-o.top)+t.height/2,C=(l-0.5)*m,x=(a-0.5)*u;return{left:Math.max(0,P+C-d),top:Math.max(0,b+x-p)}}
|
|
2
|
+
export{Fe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as r}from"cn";import{jsxDEV as d}from"react/jsx-dev-runtime";function
|
|
1
|
+
import{cn as r}from"cn";import{jsxDEV as d}from"react/jsx-dev-runtime";function Ve({className:a,size:t="default",...o}){return d("div",{"data-slot":"card","data-size":t,className:r("group/card bg-card text-card-foreground ring-foreground/10 flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl py-(--card-spacing) text-sm shadow-xs ring-1 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",a),...o},void 0,!1,void 0,this)}function Ke({className:a,...t}){return d("div",{"data-slot":"card-header",className:r("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",a),...t},void 0,!1,void 0,this)}function We({className:a,...t}){return d("div",{"data-slot":"card-title",className:r("font-heading text-base leading-normal font-medium group-data-[size=sm]/card:text-sm",a),...t},void 0,!1,void 0,this)}function qe({className:a,...t}){return d("div",{"data-slot":"card-description",className:r("text-muted-foreground text-sm",a),...t},void 0,!1,void 0,this)}function Lt({className:a,...t}){return d("div",{"data-slot":"card-action",className:r("col-start-2 row-span-2 row-start-1 self-start justify-self-end",a),...t},void 0,!1,void 0,this)}function Ge({className:a,...t}){return d("div",{"data-slot":"card-content",className:r("flex flex-col gap-3 px-(--card-spacing)",a),...t},void 0,!1,void 0,this)}function je({className:a,...t}){return d("div",{"data-slot":"card-footer",className:r("flex items-center rounded-b-xl px-(--card-spacing) [.border-t]:pt-(--card-spacing)",a),...t},void 0,!1,void 0,this)}export{Ve,Ke,We,qe,Lt,Ge,je};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t}from"./chunk-
|
|
2
|
-
`).length}function
|
|
3
|
-
export{
|
|
1
|
+
import{t}from"./chunk-99xmegcw.js";import{ChevronDownIcon as g,ChevronUpIcon as b,FileDiffIcon as v}from"lucide-react";import{useState as p}from"react";import{jsxDEV as e}from"react/jsx-dev-runtime";function m(n){if(n===null||n.length===0)return 0;return n.split(`
|
|
2
|
+
`).length}function it(n){let c=new Map;for(let r of n)for(let d of r.content){if(d.type!=="diff")continue;let u=d,l=u._meta?.alwith?.hunks??[],f=l.reduce((i,s)=>i+m(s.newText),0),a=l.reduce((i,s)=>i+m(s.oldText),0);for(let i of u.changes){let s=c.get(i.path);if(s)s.additions+=f,s.deletions+=a;else c.set(i.path,{path:i.path,additions:f,deletions:a})}}return[...c.values()]}function ye({blocks:n}){return e(at,{files:it(n)},void 0,!1,void 0,this)}function at({files:n,onOpen:c,renderPath:r}){let{t:d,openLink:u}=t(),[l,f]=p(!0),[a,i]=p(!1);if(n.length===0)return null;let s=n.reduce((o,h)=>o+h.additions,0),x=n.reduce((o,h)=>o+h.deletions,0);return e("section",{className:"codex-edited-files-card",children:[e("div",{className:"codex-edited-files-header",children:[e("div",{className:"codex-edited-files-icon","aria-hidden":"true",children:e(v,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),e("div",{className:"codex-edited-files-summary",children:[e("strong",{children:d("stream.codex.editedFilesCount",{count:n.length})},void 0,!1,void 0,this),e("button",{type:"button","data-codex-disclosure":"",onClick:()=>{f((o)=>!o),i(!1)},"aria-expanded":l,children:d(l?"stream.codex.hideChanges":"stream.codex.viewChanges")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e("div",{className:"codex-edited-files-total",title:d("stream.codex.changedLines"),children:[e("span",{className:"codex-diff-additions",children:["+",s]},void 0,!0,void 0,this),e("span",{className:"codex-diff-deletions",children:["-",x]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l&&e("div",{className:"codex-edited-files-list",children:[(a?n:n.slice(0,3)).map((o)=>e("div",{className:"codex-edited-file-row",children:[e("button",{type:"button",className:"codex-edited-file-path",title:o.path,onClick:()=>c===void 0?u(o.path):c(o),children:r===void 0?o.path:r(o)},void 0,!1,void 0,this),e("span",{className:"codex-edited-file-counts",children:[e("span",{className:"codex-diff-additions",children:["+",o.additions]},void 0,!0,void 0,this),e("span",{className:"codex-diff-deletions",children:["-",o.deletions]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},o.path,!0,void 0,this)),n.length>3&&e("button",{type:"button",className:"codex-edited-files-more","aria-expanded":a,onClick:()=>i((o)=>!o),children:[d(a?"stream.codex.showFewerFiles":"stream.codex.showMoreFiles",{count:n.length-3}),a?e(b,{size:16,"aria-hidden":"true"},void 0,!1,void 0,this):e(g,{size:16,"aria-hidden":"true"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}
|
|
3
|
+
export{it,ye,at};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Button as n}from"@base-ui/react/button";import{cva as d}from"class-variance-authority";import{cn as o}from"cn";import{jsxDEV as s}from"react/jsx-dev-runtime";var
|
|
1
|
+
import{Button as n}from"@base-ui/react/button";import{cva as d}from"class-variance-authority";import{cn as o}from"cn";import{jsxDEV as s}from"react/jsx-dev-runtime";var mt=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 e({className:r,variant:t="default",size:i="default",...a}){return s(n,{"data-slot":"button",className:o(mt({variant:t,size:i,className:r})),...a},void 0,!1,void 0,this)}export{mt,e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{mergeProps as a}from"@base-ui/react/merge-props";import{useRender as n}from"@base-ui/react/use-render";import{cva as o}from"class-variance-authority";import{cn as d}from"cn";var
|
|
1
|
+
import{mergeProps as a}from"@base-ui/react/merge-props";import{useRender as n}from"@base-ui/react/use-render";import{cva as o}from"class-variance-authority";import{cn as d}from"cn";var ut=o("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 ze({className:r,variant:e="default",render:t,...i}){return n({defaultTagName:"span",props:a({className:d(ut({variant:e}),r)},i),render:t,state:{slot:"badge",variant:e}})}export{ut,ze};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{
|
|
1
|
+
import{Re}from"./chunk-d1xydh51.js";import{CheckIcon as M,ChevronDownIcon as N,CopyIcon as E,FileIcon as w}from"lucide-react";import{useEffect as k,useLayoutEffect as H,useRef as I,useState as x}from"react";import{jsxDEV as e,Fragment as h}from"react/jsx-dev-runtime";var T=20,A='a[href], area[href], button, input, select, textarea, summary, audio[controls], video[controls], iframe, [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';function v(n,o,s){if(n.toggleAttribute("inert",!o),!o){n.setAttribute("aria-hidden","true");return}if(s===null)n.removeAttribute("aria-hidden");else n.setAttribute("aria-hidden",s)}function L(n,o){let s=n.getBoundingClientRect(),i=o.getBoundingClientRect();return s.top>=i.top&&s.right<=i.right&&s.bottom<=i.bottom&&s.left>=i.left}function C({text:n,host:o}){let{t:s,Markdown:i}=o,c=I(null),[l,g]=x(!1),[d,b]=x(!1);return H(()=>{let r=c.current;if(!r)throw Error("Codex user message content is missing");let t=()=>{if(r.scrollHeight===0){g(!1);return}let p=Number.parseFloat(getComputedStyle(r).lineHeight);if(!Number.isFinite(p))throw Error("Codex user message line height is invalid");g(r.scrollHeight>T*p+1)};t();let u=new ResizeObserver(t);return u.observe(r),()=>u.disconnect()},[]),k(()=>{if(!l||d)return;let r=c.current;if(!r)throw Error("Codex user message content is missing");let t=new Map,u=typeof IntersectionObserver>"u"?null:new IntersectionObserver((a)=>{for(let m of a){let f=m.target;if(!t.has(f))continue;v(f,m.isIntersecting&&m.intersectionRatio>=1,t.get(f))}},{root:r,rootMargin:"0px",threshold:1}),p=()=>{for(let a of t.keys()){if(r.contains(a))continue;u?.unobserve(a),t.delete(a)}for(let a of r.querySelectorAll(A)){if(t.has(a)||a.hasAttribute("inert"))continue;let m=a.getAttribute("aria-hidden");t.set(a,m),v(a,u===null&&L(a,r),m),u?.observe(a)}};p();let y=new MutationObserver(p);return y.observe(r,{childList:!0,subtree:!0}),()=>{u?.disconnect(),y.disconnect();for(let[a,m]of t)v(a,!0,m)}},[l,d]),e("div",{className:"codex-user-message-content",children:[e("div",{ref:c,className:l&&!d?"codex-user-message-text codex-user-message-text-collapsed":"codex-user-message-text",children:e(i,{text:n,streaming:!1},void 0,!1,void 0,this)},void 0,!1,void 0,this),l&&!d&&e("span",{className:"codex-user-message-ellipsis","aria-hidden":"true",children:"…"},void 0,!1,void 0,this),l&&e("button",{type:"button","aria-expanded":d,className:"codex-user-message-collapse-trigger",onClick:()=>{b((r)=>!r)},children:[e("span",{children:d?s("stream.codex.showLess"):s("stream.codex.showMore")},void 0,!1,void 0,this),e(N,{className:d?"codex-user-message-collapse-chevron codex-user-message-collapse-chevron-expanded":"codex-user-message-collapse-chevron","aria-hidden":"true"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function U({text:n,label:o}){let[s,i]=x(!1);return e("button",{type:"button",className:"codex-message-action","aria-label":o,title:o,onClick:()=>{navigator.clipboard.writeText(n),i(!0),setTimeout(()=>i(!1),2000)},children:s?e(M,{className:"codex-message-action-confirmed"},void 0,!1,void 0,this):e(E,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function R({image:n,openImage:o}){let[s,i]=x(!1),c=`data:${n.mimeType};base64,${n.data}`;return e(h,{children:[e("button",{type:"button",className:"codex-user-image",onClick:()=>o===void 0?i(!0):o(c),children:e("img",{src:c,alt:""},void 0,!1,void 0,this)},void 0,!1,void 0,this),s&&e(Re,{src:c,alt:"",onClose:()=>i(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function xt({message:n,text:o,textParts:s,mentions:i,images:c,messageTime:l,host:g,bubbleStyle:d}){let{t:b,openImage:r}=g;return e("div",{"data-content-search-unit-key":n.id,"data-message-id":n.id,className:"timeline-break codex-user-message scroll-mt-4",children:e("div",{className:"group/codex-user codex-user-message-group",children:[i.length>0&&e("div",{className:"codex-user-mentions",children:i.map((t)=>e("span",{className:"codex-user-mention",title:t.title,children:[e(w,{"aria-hidden":"true"},void 0,!1,void 0,this),e("span",{className:"codex-user-mention-label",children:t.label},void 0,!1,void 0,this)]},t.key,!0,void 0,this))},void 0,!1,void 0,this),c.length>0&&e("div",{className:"codex-user-images",children:c.map((t)=>e(R,{image:t,openImage:r},`${t.mimeType}:${t.data}`,!1,void 0,this))},void 0,!1,void 0,this),o.length>0&&e(h,{children:e("div",{"data-user-message-bubble":!0,tabIndex:0,className:"codex-user-bubble",style:d,children:s?s.map((t,u)=>e("div",{className:"codex-user-text-part",children:t.question===void 0?e(C,{text:t.text,host:g},void 0,!1,void 0,this):e(h,{children:[e("div",{className:"codex-user-question-summary",title:t.question,children:t.question},void 0,!1,void 0,this),e("div",{className:"codex-user-question-answer",children:t.text},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},u,!1,void 0,this)):e(C,{text:o,host:g},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),e("div",{className:"codex-user-actions",children:[e(U,{text:o,label:b("actions.copy")},void 0,!1,void 0,this),l&&e("span",{className:"codex-user-time",title:l.full,children:l.short},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
|
|
2
|
+
export{U,xt};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var z=/[\\/._\- ]/;function h(r,n){if(n===0)return!0;let s=r[n-1];if(z.test(s))return!0;let c=r[n];if(s===s.toLowerCase()&&c!==c.toLowerCase())return!0;return!1}function G(r,n){if(!n)return{score:0,indices:[]};let s=r.toLowerCase(),c=n.toLowerCase(),i=[],t=0,e=0,u=-2;for(let l of c.split("")){let o=-1;while(t<s.length){if(s[t]===l){o=t;break}t++}if(o<0)return null;if(e+=1,o===u+1)e+=4;if(h(r,o))e+=5;let f=r.lastIndexOf("/");if(f!==-1&&o>f)e+=2;i.push(o),u=o,t=o+1}if(e-=Math.floor(r.length/50),r.includes(n))e+=3;return{score:e,indices:i}}function Pe(r,n,s,c=100){if(!n)return r.slice(0,c).map((t)=>({item:t,score:0,indices:[]}));let i=[];for(let t of r){let e=G(s(t),n);if(!e)continue;i.push({item:t,score:e.score,indices:e.indices})}return i.sort((t,e)=>e.score-t.score),i.slice(0,c)}
|
|
2
|
+
export{G,Pe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{he,xe}from"../chunk-q00ycy4m.js";import"../chunk-eyn3tdcs.js";import"../chunk-nvtvm7jc.js";import"../chunk-85y9tqsd.js";import"../chunk-pve9b7z3.js";import"../chunk-bbnrzw5x.js";import"../chunk-99xmegcw.js";export{xe as CodexActivityGroup,he as CodexWorkSection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t,u}from"../chunk-
|
|
2
|
-
`),M=!e.streaming&&C.trim().length>0?n(S,{text:C,isMostRecentTurn:s,beforeCopy:a,afterCopy:x,time:r},void 0,!1,void 0,this):null,
|
|
1
|
+
import{t,u}from"../chunk-99xmegcw.js";import{l}from"../chunk-nvtvm7jc.js";import{fe}from"../chunk-7471tnsq.js";import"../chunk-eyn3tdcs.js";import"../chunk-pve9b7z3.js";import"../chunk-85y9tqsd.js";import{k}from"../chunk-bbnrzw5x.js";import{he,xe}from"../chunk-q00ycy4m.js";import{ye}from"../chunk-xc6fz2xk.js";import"../chunk-d1xydh51.js";import{U}from"../chunk-ytqka33j.js";import{cn as w}from"cn";import{jsxDEV as n}from"react/jsx-dev-runtime";var R=new WeakMap,P=1;function N(e){if(e.type==="tool_use"||e.type==="subagent"||e.type==="collab")return`${e.type}:${e.id}`;let s=R.get(e);if(s!==void 0)return`${e.type}:${s}`;let i=P++;return R.set(e,i),`${e.type}:${i}`}function I({block:e,streaming:s,actions:i}){if(e.isApiError)return n("div",{className:"codex-stream-error",children:e.text},void 0,!1,void 0,this);return n("div",{className:"codex-assistant-message",children:[n(u,{text:e.text,streaming:s},void 0,!1,void 0,this),i]},void 0,!0,void 0,this)}function E({block:e,streaming:s,actions:i,renderText:r}){switch(e.type){case"text":return r===void 0?n(I,{block:e,streaming:s,actions:i},void 0,!1,void 0,this):r({block:e,streaming:s,actions:i});case"thinking":return e.thinking.length>0?n(u,{text:e.thinking,streaming:!e.isComplete},void 0,!1,void 0,this):null;case"plan":return n(k,{entries:e.entries},void 0,!1,void 0,this);case"image":return n("img",{src:`data:${e.source.media_type};base64,${e.source.data}`,className:"max-h-64 rounded",alt:""},void 0,!1,void 0,this);case"tool_use":case"subagent":case"collab":return null}}var _=new Set;function q({message:e,isMostRecentTurn:s,hiddenTools:i=_,time:r,beforeCopy:a,afterCopy:x,providerIcon:T,renderText:B,renderEditedFiles:y}){if(e.streaming===!0&&e.content.every((o)=>o.type==="text"?o.text.length===0:o.type==="thinking"?o.thinking.length===0:!1))return n(A,{},void 0,!1,void 0,this);let C=e.content.filter((o)=>o.type==="text").map((o)=>o.text).join(`
|
|
2
|
+
`),M=!e.streaming&&C.trim().length>0?n(S,{text:C,isMostRecentTurn:s,beforeCopy:a,afterCopy:x,time:r},void 0,!1,void 0,this):null,d=fe(e.content,"compact"),f=d.reduce((o,c,p)=>c.kind==="codexActivityGroup"?p:o,-1),h=d.findIndex((o,c)=>c>f&&o.kind==="block"&&o.block.type==="text"),b=[...e.content].toReversed().find((o)=>o.type==="text"),m=e.content.filter((o)=>o.type==="tool_use"&&l(o).category==="edit"),v=(o)=>{if(o.kind==="codexActivityGroup"){let c=o.blocks.filter((p)=>p.type!=="tool_use"||!i.has(p.name));return c.length===0?null:n(xe,{blocks:c},`activity:${N(c[0])}`,!1,void 0,this)}if(o.kind!=="block")throw Error(`Codex received an incompatible grouped entry: ${o.kind}`);return n(E,{block:o.block,streaming:Boolean(e.streaming),actions:o.block===b?M:void 0,renderText:B},N(o.block),!1,void 0,this)},g=f===-1?0:h===-1?d.length:h;return n(O,{stateKey:e.id,active:Boolean(e.streaming),startedAt:e.startedAt,durationMs:e.durationMs,providerId:e.providerId,providerIcon:T,work:d.slice(0,g).map(v),answer:d.length>g?d.slice(g).map(v):null,footer:f!==-1&&m.length>0&&(y===void 0?n(ye,{blocks:m},void 0,!1,void 0,this):y(m))},void 0,!1,void 0,this)}function S({text:e,isMostRecentTurn:s=!1,beforeCopy:i,afterCopy:r,time:a}){let{t:x}=t();return n("div",{className:w("mt-1.5 flex h-5 w-fit -translate-x-1 items-center justify-start gap-0.5 [&_*]:transition-none",s?"opacity-100":"opacity-0 group-focus-within/am:opacity-100 group-hover/am:opacity-100"),children:[i,n(U,{text:e,label:x("actions.copy")},void 0,!1,void 0,this),r,a&&n("span",{className:"codex-user-time ms-1",title:a.full,children:a.short},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function A(){let{t:e}=t();return n("div",{className:"codex-pending-message py-2",role:"status",children:n("span",{className:"codex-activity-running",children:e("message.thinking")},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function O({work:e,answer:s,footer:i,loading:r=!1,...a}){if(r)return n(A,{},void 0,!1,void 0,this);return n("div",{className:"group/am codex-assistant-turn",children:[e.length>0&&n(he,{...a,children:e},void 0,!1,void 0,this),s!==null&&(e.length===0?s:n("div",{"data-local-conversation-final-assistant":!0,"data-testid":"codex-final-answer",className:"codex-final-answer",children:s},void 0,!1,void 0,this)),i]},void 0,!0,void 0,this)}export{q as CodexAssistantMessage,O as CodexAssistantTurn,S as CodexMessageActions};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e}from"../chunk-
|
|
1
|
+
import{e}from"../chunk-xgy0heva.js";import{r}from"../chunk-pnncsvbz.js";import{c,a}from"../chunk-rka1mc9r.js";import{o}from"../chunk-r9k7kszp.js";import{useId as k}from"react";import{jsxDEV as i,Fragment as A}from"react/jsx-dev-runtime";function p(n){return n!==null&&typeof n==="object"&&!Array.isArray(n)}function I(n){if(!p(n)||!p(n.codex))return[];let s=n.codex,l=s.questions;if(s.delivery!=="async"||!Array.isArray(l))return[];if(!l.every((t)=>p(t)&&typeof t.title==="string"&&t.title.trim().length>0&&(t.options===null||Array.isArray(t.options)&&t.options.every((d)=>typeof d==="string"))))return[];return l}function D(n,s){return JSON.stringify(["request_user_input_async",n,s])}function S(n){return{selected:n.options?.length?0:null,text:""}}function h(n,s){return s.selected===null?s.text:n.options?.[s.selected]??""}function C(n){return`<send_user_message_question_reply>
|
|
2
2
|
${JSON.stringify([n])}
|
|
3
3
|
</send_user_message_question_reply>`}function B(n){if(!p(n)||!p(n.codex))return[];let s=n.codex;return(Array.isArray(s.questionReplyParts)?s.questionReplyParts.map((t)=>p(t)?{...t,answer:t.text}:t):[s.questionReply]).filter((t)=>p(t)&&typeof t.questionItemId==="string"&&typeof t.question==="string"&&typeof t.answer==="string").map(({questionItemId:t,question:d,answer:g})=>({questionItemId:t,question:d,answer:g}))}function G({question:n,draft:s,status:l,answer:t,error:d,onChange:g,onSubmit:b,onSkip:w,t:u}){let x=k(),m=l==="pending",Q=l==="answered"||l==="skipped";return i("section",{"aria-labelledby":`${x}-title`,className:"border-border bg-card text-card-foreground flex min-w-0 flex-col gap-3 rounded-xl border p-4",children:[i("h3",{id:`${x}-title`,className:"text-sm font-medium whitespace-pre-wrap",children:n.title},void 0,!1,void 0,this),Q?i("p",{className:"text-sm whitespace-pre-wrap",children:l==="answered"?t:u("asyncQuestion.skipped")},void 0,!1,void 0,this):i(A,{children:[(n.options?.length??0)>0&&i(c,{"aria-labelledby":`${x}-title`,disabled:!m,value:s.selected===null?"other":String(s.selected),onValueChange:(y)=>g({...s,selected:y==="other"?null:Number(y)}),children:[n.options?.map((y,f)=>i(r,{className:"flex items-start gap-2 text-sm",children:[i(a,{value:String(f)},void 0,!1,void 0,this),i("span",{className:"whitespace-pre-wrap",children:y},void 0,!1,void 0,this)]},f,!0,void 0,this)),i(r,{className:"flex items-center gap-2 text-sm",children:[i(a,{value:"other"},void 0,!1,void 0,this),u("asyncQuestion.other")]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i(o,{"aria-label":u("asyncQuestion.answer"),placeholder:u("asyncQuestion.answer"),value:s.text,readOnly:!m,onChange:(y)=>g({selected:null,text:y.target.value})},void 0,!1,void 0,this),d&&i("p",{role:"alert",className:"text-destructive text-sm",children:d},void 0,!1,void 0,this),i("div",{className:"flex flex-wrap items-center gap-2",children:[i(e,{size:"sm",disabled:!m||h(n,s).trim().length===0,onClick:b,children:u(l==="submitting"?"asyncQuestion.submitting":"asyncQuestion.submit")},void 0,!1,void 0,this),i(e,{size:"sm",variant:"ghost",disabled:!m,onClick:w,children:u("asyncQuestion.skip")},void 0,!1,void 0,this),(l==="closed"||l==="unavailable")&&i("span",{role:"status",className:"text-muted-foreground text-xs",children:u(`asyncQuestion.${l}`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{G as AsyncQuestionCard,D as asyncQuestionId,I as asyncQuestions,S as initialQuestionDraft,h as questionAnswer,B as questionReplies,C as questionReplyEnvelope};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{it,ye,at}from"../chunk-xc6fz2xk.js";import"../chunk-99xmegcw.js";export{ye as CodexEditedFilesCard,at as EditedFilesCard,it as fileChanges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f,
|
|
1
|
+
import{f,be}from"../chunk-85y9tqsd.js";import"../chunk-pve9b7z3.js";import"../chunk-99xmegcw.js";export{be as ImageViewActivity,f as isImageView};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ke}from"../chunk-kew8ef6z.js";import{K,we}from"../chunk-tm40sncc.js";import{W}from"../chunk-aaybyhdj.js";import{decodeHTMLAttribute as T,decodeHTMLStrict as E}from"entities";import ae from"katex";import{CheckIcon as U,ChevronLeftIcon as se,ChevronRightIcon as ie,CopyIcon as ce,DownloadIcon as de,FileIcon as le,LinkIcon as ue,MailIcon as me,XIcon as ge}from"lucide-react";import"katex/dist/katex.min.css";import{createContext as fe,createElement as B,memo as D,startTransition as he,useContext as pe,useEffect as h,useLayoutEffect as X,useMemo as G,useRef as p,useState as f}from"react";import{jsxDEV as a,Fragment as re}from"react/jsx-dev-runtime";var J=fe(null);function v(){let e=pe(J);if(e===null)throw Error("Markdown host is missing");return e}var be=80,F=/\[([^\]\n]+)\]\(([^)\n]+)$/,xe=/(^|\n)[^\S\n]*!\[[^\]\n]*(?:\](?:\([^\n]*)?)?\s*$/,Te=/\uE200[^\uE201]*$/,ve=4,Ce=new Set("7zipx.accdb.asarpack.asciidoc.backup.backupdb.bundle.ccproj.cdrdao.code-workspace.config.debugin.deploy.design.docbook.dockerfile.dockerignore.editorconfig.eslintignore.gitattributes.gitignore.gitignore.gitkeep.gradle.graphqls.ignore.ipynb.keychain.keynote.licensee.lockfile.lockfile.markdown.markup.matlab.mkdocs.models.module.msstyle.notebook.npmignore.output.packageinfo.parquet.pickle.plistx.policy.postcssrc.prettierignore.projectfile.python.readme.review.robots.schema.search.series.settingsjson.shader.sqlite.sqlite3.storyboard.styles.system.target.terraform.update.vertex.webapp.webdoc.webpackrc.widget.workspace.xcodeproj.yarnlock".split("."));function C(e,n){let t=0;for(let r=n-1;r>=0&&e[r]==="\\";r-=1)t+=1;return t%2===1}function V(e,n,t){if(t.length!==1)return!1;return e[n-1]===t||e[n+1]===t}function ye(e,n){let t=0;for(let r=0;r<=e.length-n.length;){if(e.startsWith(n,r)&&!C(e,r)&&!V(e,r,n)){t+=1,r+=n.length;continue}r+=1}return t}function Ne(e,n){for(let t=e.length-n.length;t>=0;t-=1)if(e.startsWith(n,t)&&!C(e,t)&&!V(e,t,n))return t;return-1}function Me(e,n){let t=0;for(let r=0;r<=e.length-n.length;){if(e.startsWith(n,r)&&!C(e,r)){t+=1,r+=n.length;continue}r+=1}return t}function Le(e){return Me(e,"```")%2===1}function Z(e){let n=0;for(let t=0;t<e.length;){if(e.startsWith("```",t)){for(t+=3;t<e.length&&!e.startsWith("```",t);)t+=1;if(t<e.length)t+=3;continue}if(e[t]==="`"&&!C(e,t))n+=1;t+=1}return n%2===1}function Ee(e){return e.endsWith(`
|
|
2
2
|
`)?`${e}\`\`\``:`${e}
|
|
3
|
-
\`\`\``}function A(e,n){if(!e.includes(n)||
|
|
4
|
-
`)||
|
|
5
|
-
`),t.raw=e.slice(n,s).map((i)=>i.raw).join(""),e.splice(n+1,s-n-1)}}function _(e){return{type:"text",raw:e,text:e}}function
|
|
6
|
-
`,1)[0];if(t===void 0)throw Error("Codex Markdown token has no first line");return(t.match(/\S+/)?.[0]??t).slice(0,
|
|
3
|
+
\`\`\``}function A(e,n){if(!e.includes(n)||ye(e,n)%2===0)return e;let t=Ne(e,n);if(t<0)return e;let r=e.slice(t+n.length);if(r.length===0||/^\s/.test(r)||r.includes(`
|
|
4
|
+
`)||Z(r))return e;return`${e}${n}`}function Ie(e){return e.startsWith("/")&&!e.startsWith("//")||/^[A-Za-z]:[\\/]/.test(e)||/^\\\\[^\\]+\\[^\\]+/.test(e)||/^\/\/[^/]+\/[^/]+/.test(e)}function Y(e){let n=e.replaceAll("`","").trim(),t=n.match(/^(.*?):(\d+)(?::(\d+))?(?:[-–](\d+)(?::(\d+))?)?$/);if(t!==null){let[,o,s,i,c,d]=t;if(o===void 0||s===void 0)throw Error("Codex file location is incomplete");return{path:o,line:Number.parseInt(s,10),column:i===void 0?void 0:Number.parseInt(i,10),endLine:c===void 0?void 0:Number.parseInt(c,10),endColumn:d===void 0?void 0:Number.parseInt(d,10)}}let r=n.match(/^(.*?)#L(\d+)(?:C(\d+))?(?:-L(\d+)(?:C(\d+))?)?$/);if(r!==null){let[,o,s,i,c,d]=r;if(o===void 0||s===void 0)throw Error("Codex hash file location is incomplete");return{path:o,line:Number.parseInt(s,10),column:i===void 0?void 0:Number.parseInt(i,10),endLine:c===void 0?void 0:Number.parseInt(c,10),endColumn:d===void 0?void 0:Number.parseInt(d,10)}}return{path:n}}function $e(e){let{path:n,line:t,column:r,endLine:o,endColumn:s}=Y(e);if(/^[a-z][a-z0-9+.-]*:\/\//i.test(n)||/^www\./i.test(n)||/^(mailto|tel):/i.test(n))return!1;if(t!==void 0||r!==void 0||o!==void 0||s!==void 0)return!0;if(!/(?:^|[\\/])[^\\/]+\.(?!\d+$)[^\\/.]+$/i.test(n))return!1;let i=/[\\/]/.test(n),c=n.split(/[\\/]/).at(-1);if(c===void 0)throw Error("Codex streaming link target has no file name");let d=c.split(".").at(-1);if(d===void 0||d.length===0)return!1;if(!i&&/[a-z]/.test(d)&&/[A-Z]/.test(d.slice(1)))return!1;if(!i){let u=d.toLowerCase();if(u.length>ve&&!Ce.has(u))return!1}return!0}function Re(e){let{path:n}=Y(e);if(Ie(n))return!0;try{return new URL(n).protocol==="file:"}catch{return!1}}function Pe(e){let n=e.match(F);if(n===null)return e;let t=n[2];if(t===void 0)throw Error("Codex streaming link target is missing");return $e(t)||Re(t)?e.replace(F,"$1"):`${e})`}function Se(e){let n=e.replace(Te,"");if(n.length===0||n.includes("`")&&Z(n))return{isCodeFenceOpen:!1,markdown:n};if(n.includes("```")&&Le(n))return{isCodeFenceOpen:!0,markdown:Ee(n)};if(n.includes(")n=Pe(n);return n=A(n,"**"),n=A(n,"*"),{isCodeFenceOpen:!1,markdown:n}}function Fe(e){return e?.type==="paragraph"&&"tokens"in e&&Array.isArray(e.tokens)}function H(e){return Fe(e)&&e.tokens.length===1&&e.tokens[0]?.type==="image"}function Q(e){for(let n=0;n<e.length;n+=1){let t=e[n];if(t===void 0)throw Error(`Codex Markdown token is missing at index ${n}`);if("tokens"in t&&Array.isArray(t.tokens))Q(t.tokens);if(!H(t))continue;let r=[...t.tokens],o=n+1,s=o;for(;;){while(e[o]?.type==="space")o+=1;let i=e[o];if(!H(i))break;r.push(...i.tokens),o+=1,s=o}if(s===n+1)continue;t.tokens=r,t.text=r.map((i)=>i.raw).join(`
|
|
5
|
+
`),t.raw=e.slice(n,s).map((i)=>i.raw).join(""),e.splice(n+1,s-n-1)}}function _(e){return{type:"text",raw:e,text:e}}function Ae(e){return{type:"paragraph",raw:e.raw,text:e.text,tokens:e.tokens??[e]}}function L(e){for(let n of e){if(n.type==="list")for(let t of n.items){let r=t.tokens[0];if(r?.type==="heading"){let o=r,s=o.raw.trimEnd(),i=s.match(/^#{1,6}\s+/)?.[0];if(i!==void 0)t.tokens[0]={type:"paragraph",raw:o.raw,text:s,tokens:o.tokens===void 0?[_(s)]:[_(i),...o.tokens]}}if(t.loose)t.tokens=t.tokens.map((o)=>o.type==="text"?Ae(o):o);L(t.tokens)}if("tokens"in n&&Array.isArray(n.tokens))L(n.tokens)}}function He(e,n,t){e.preventDefault(),e.stopPropagation(),t.openLink(n)}function _e(e){try{let n=new URL(e);return n.protocol!=="http:"&&n.protocol!=="https:"?null:`${n.origin}/favicon.ico`}catch{return null}}function Oe(e){let n=_e(e);return n===null?[]:[n,`https://www.google.com/s2/favicons?domain=${new URL(e).origin}&sz=32`]}function je({href:e}){let n=G(()=>Oe(e),[e]),[t,r]=f(),o=n.length===0&&!/^[a-z][a-z0-9+.-]*:/i.test(e),s=e.toLowerCase().startsWith("mailto:")?me:o?le:ue;return a("span",{className:"codex-markdown-favicon",children:[t===void 0?a("span",{className:"codex-markdown-favicon-fallback",children:a(s,{"aria-hidden":!0},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,n.map((i)=>a("img",{alt:"",className:t===i?"codex-markdown-favicon-image-loaded":void 0,decoding:"async",draggable:!1,referrerPolicy:"no-referrer",src:i,onLoad:()=>r((c)=>c!==void 0&&n.includes(c)?c:i)},i,!1,void 0,this))]},void 0,!0,void 0,this)}function We({children:e,href:n,title:t}){let r=v();if(r.preview)return a("span",{children:e},void 0,!1,void 0,this);return a("a",{className:"codex-markdown-link","data-inline-mention-interactive":"",href:n,title:t,onClick:(o)=>He(o,n,r),children:a("span",{className:"codex-markdown-link-mention","data-layout":"inline-flow","data-interactive":"","data-underline-on-hover":"",children:[a("span",{className:"codex-markdown-link-icon-container","data-markdown-copy":"exclude",children:a(je,{href:n},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("span",{className:"codex-markdown-link-label",children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function qe({code:e,language:n}){let{theme:t,copyLabel:r}=v(),o=p(null),[s,i]=f(null),[c,d]=f(null),[u,k]=f(!1);if(h(()=>{let g=ke(i,d);return o.current=g,()=>{g.dispose(),o.current=null}},[]),h(()=>{let g=o.current;if(g===null)throw Error("Code highlighter is not mounted");g.update(e,n)},[e,n]),c!==null)throw c;let b=s!==null&&s.code===e&&s.language===n?s.html:null;return a("div",{className:"codex-markdown-code-block","data-markdown-copy":"code-block","data-markdown-copy-text":e,"data-theme":t==="dark"?"dark":"light",children:[a("div",{className:"codex-markdown-code-header","data-markdown-copy":"exclude",children:[a("div",{className:"codex-markdown-code-title",children:n},void 0,!1,void 0,this),a("div",{className:"codex-markdown-code-actions",children:a("button",{type:"button",className:"codex-markdown-code-copy",title:r,onClick:()=>{navigator.clipboard.writeText(e),k(!0),window.setTimeout(()=>k(!1),2000)},children:u?a(U,{},void 0,!1,void 0,this):a(ce,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a("div",{className:"codex-markdown-code-container",dir:"ltr",children:a("code",{className:"codex-markdown-code-content hljs",...b===null?{children:e}:{dangerouslySetInnerHTML:{__html:b}}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ke({code:e,language:n}){return v().preview?a("span",{children:e},void 0,!1,void 0,this):a(ze,{code:e,language:n},void 0,!1,void 0,this)}function ze({code:e,language:n}){let t=p(null),[r,o]=f(!1);if(h(()=>{if(r)return;let s=t.current;if(s===null)throw Error("Codex code block placeholder is not mounted");if(typeof IntersectionObserver>"u"){let c=window.setTimeout(()=>o(!0),0);return()=>window.clearTimeout(c)}let i=new IntersectionObserver((c)=>{if(!c.some((d)=>d.isIntersecting))return;o(!0),i.disconnect()},{rootMargin:"600px 0px"});return i.observe(s),()=>i.disconnect()},[r]),r)return a(qe,{code:e,language:n},void 0,!1,void 0,this);return a("div",{ref:t,className:"codex-markdown-code-block",children:a("pre",{className:"codex-markdown-code-placeholder",children:a("code",{children:e},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Ue(e){let n=[...document.body.querySelectorAll('[data-markdown-image-preview-trigger="true"]')],t=n.map((o)=>{let s=o.querySelector("img");if(s===null)throw Error("Codex image preview trigger has no image");return{src:s.currentSrc||s.src,alt:s.alt}}),r=n.indexOf(e);if(r===-1)throw Error("Codex image preview trigger is outside the document");return{images:t,index:r}}function Be({preview:e,setPreview:n}){let t=e.images[e.index];if(t===void 0)throw Error(`Codex image preview index is out of range: ${e.index}`);return a("div",{className:"codex-markdown-image-preview",children:[a("img",{src:t.src,alt:t.alt},void 0,!1,void 0,this),a("div",{className:"codex-markdown-image-preview-actions",children:[a("button",{type:"button","aria-label":"Previous image",disabled:e.index===0,onClick:()=>n({...e,index:e.index-1}),children:a(se,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("a",{href:t.src,download:!0,"aria-label":"Download image",children:a(de,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("button",{type:"button","aria-label":"Next image",disabled:e.index===e.images.length-1,onClick:()=>n({...e,index:e.index+1}),children:a(ie,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("button",{type:"button","aria-label":"Close image preview",onClick:()=>n(void 0),children:a(ge,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function De(e){return v().preview?a(re,{children:e.alt},void 0,!1,void 0,this):a(Xe,{...e},void 0,!1,void 0,this)}function Xe({src:e,alt:n,title:t,allowWide:r}){let o=p(null),[s,i]=f();h(()=>{let d=o.current;if(d===null)throw Error("Codex image preview dialog is not mounted");if(s===void 0){if(d.open)d.close();return}if(!d.open)d.showModal()},[s]);let c=n.length===0?"Open image preview":n;return a(re,{children:[a("button",{type:"button",className:`codex-markdown-image-trigger${r?"codex-markdown-image-trigger-wide":""}`,"aria-label":c,"data-markdown-image-preview-trigger":"true",onClick:(d)=>i(Ue(d.currentTarget)),children:a("img",{className:`codex-markdown-image${r?"codex-markdown-image-wide":""}`,src:e,alt:n,title:t,loading:"lazy"},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("dialog",{ref:o,className:"codex-markdown-image-dialog","aria-label":c,onClose:()=>i(void 0),children:s===void 0?null:a(Be,{preview:s,setPreview:i},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ge({value:e,display:n}){let t=p(null);return X(()=>{if(t.current===null)throw Error("Codex math root is not mounted");ae.render(e,t.current,{displayMode:n,throwOnError:!1})},[n,e]),a("span",{ref:t,className:n?"codex-markdown-math-block":"codex-markdown-inline-math"},void 0,!1,void 0,this)}var Je=150,x=null;function O(e,n){let t=x;if(t===null)return e;let r=t.cursor,o=r+e.length;t.cursor=o;let s=[],i=r;for(let c of t.runs){if(c.end<=r)continue;if(c.start>=o)break;let d=Math.max(r,c.start),u=Math.min(o,c.end);if(i<d)s.push(e.slice(i-r,d-r));s.push(a("span",{className:"codex-markdown-fade",children:e.slice(d-r,u-r)},`${n}:${t.generation}:${c.start}`,!1,void 0,this)),i=u}if(i<o)s.push(e.slice(i-r));return s}function ee(e){let n=5381;for(let t=0;t<e.length;t+=1)n=(n*33+e.charCodeAt(t))%4294967296;return n.toString(36)}function j(e){let n=e.trim();if(n.length===0)return"";let t=n.split(`
|
|
6
|
+
`,1)[0];if(t===void 0)throw Error("Codex Markdown token has no first line");return(t.match(/\S+/)?.[0]??t).slice(0,be)}function Ve(e){switch(e.type){case"code":return e.raw.trimStart().match(/^(```|~~~)/)?.[1]??"";case"link":return e.href;case"image":{let n=e;return`${n.href}:${j(n.text)}`}case"html":case"space":case"br":case"hr":case"def":return e.raw;case"math":return j(e.text);default:return""}}function ne(e){return`${e.type==="math"?`math-${e.display?"block":"inline"}`:e.type}-${ee(Ve(e))}`}function m(e,n){let t=new Map;return e.map((r)=>{let o=ne(r),s=t.get(o)??0;return t.set(o,s+1),te(r,`${n}-${o}-${s}`)})}function Ze(e,n){let t=e.task?e.tokens.filter((r)=>r.type!=="checkbox"):e.tokens;return a("li",{className:`codex-markdown-list-item${e.task?"codex-markdown-task-list-item":""}`,children:[e.task?a("div",{className:"codex-markdown-task-checkbox",children:[a("input",{type:"checkbox",className:"codex-markdown-checkbox",checked:e.checked,"data-state":e.checked?"checked":"unchecked",readOnly:!0,disabled:!0},void 0,!1,void 0,this),e.checked?a(U,{},void 0,!1,void 0,this):null]},void 0,!0,void 0,this):null,m(t,n)]},n,!0,void 0,this)}function Ye(e,n){let r=`codex-markdown-list ${e.items.some((s)=>s.task)?"codex-markdown-task-list":e.ordered?"codex-markdown-ordered-list":"codex-markdown-unordered-list"}`,o=m(e.items,n);return e.ordered?a("ol",{className:r,start:e.start===""?void 0:e.start,children:o},n,!1,void 0,this):a("ul",{className:r,children:o},n,!1,void 0,this)}function q(e,n,t){let r=t?"th":"td",o=/^\d+$/.test(e.text);return B(r,{key:n,className:`${t?"codex-markdown-table-header":"codex-markdown-table-cell"}${o?" codex-markdown-numeric-table-cell":""}`,align:e.align??void 0},...m(e.tokens,n))}function Qe(e,n){let t=new Map;return a("div",{className:"codex-markdown-table-container","data-markdown-table":!0,tabIndex:-1,children:a("div",{className:"codex-markdown-table-scroller",children:a("div",{className:"codex-markdown-table-wrapper",children:a("table",{className:"codex-markdown-table",children:[a("thead",{children:a("tr",{className:"codex-markdown-table-row",children:e.header.map((r,o)=>q(r,`${n}-header-${o}`,!0))},void 0,!1,void 0,this)},void 0,!1,void 0,this),a("tbody",{className:"codex-markdown-table-body",children:e.rows.map((r)=>{let o=ee(r.map((c)=>c.text).join("\x00")),s=t.get(o)??0;t.set(o,s+1);let i=`${n}-row-${o}-${s}`;return a("tr",{className:"codex-markdown-table-row",children:r.map((c,d)=>q(c,`${i}-cell-${d}`,!1))},i,!1,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},n,!1,void 0,this)}function z(e,n,t){let r=T(e.href);if(!W(r))return null;return a(De,{src:r,alt:E(e.text),title:e.title==null?void 0:T(e.title),allowWide:t},n,!1,void 0,this)}function te(e,n){switch(e.type){case"space":case"def":case"internalMessage":return null;case"hr":return a("hr",{className:"codex-markdown-horizontal-rule"},n,!1,void 0,this);case"heading":{let t=e,o={1:"h1",2:"h2",3:"h3",4:"h4",5:"h5",6:"h6"}[t.depth];if(o===void 0)throw Error(`Unsupported Codex Markdown heading depth: ${t.depth}`);return B(o,{key:n,className:`codex-markdown-heading codex-markdown-heading-${t.depth}`},...m(t.tokens,n))}case"paragraph":{let t=e,r=t.tokens.filter((i)=>i.type!=="space"&&i.type!=="br"),o=r.length>0&&r.every((i)=>i.type==="image"),s=o&&r.length>1;return a("p",{className:`codex-markdown-paragraph${o?"codex-markdown-media-paragraph codex-markdown-media-wide-block":""}${s?"codex-markdown-media-grid-paragraph":""}`,"data-markdown-image-grid":s?"true":void 0,"data-wide-markdown-block":o?"true":void 0,"data-wide-markdown-block-kind":o?"image":void 0,children:o?r.map((i,c)=>z(i,`${n}-image-${c}`,!0)):m(t.tokens,n)},n,!1,void 0,this)}case"text":{let t=e;return t.tokens===void 0?O(E(t.text),n):m(t.tokens,n)}case"escape":return O(e.text,n);case"strong":return a("strong",{className:"codex-markdown-strong",children:m(e.tokens,n)},n,!1,void 0,this);case"em":return a("em",{children:m(e.tokens,n)},n,!1,void 0,this);case"del":return a("del",{children:m(e.tokens,n)},n,!1,void 0,this);case"codespan":return a("span",{className:"codex-markdown-inline-code",dir:"ltr","data-markdown-copy":"inline-code",children:e.text},n,!1,void 0,this);case"br":return a("br",{},n,!1,void 0,this);case"link":{let t=e,r=m(t.tokens,n),o=T(t.href);return W(o)?a(We,{href:o,title:t.title==null?void 0:T(t.title),children:r},n,!1,void 0,this):a("span",{children:r},n,!1,void 0,this)}case"image":return z(e,n,!1);case"code":{let t=e;return a(Ke,{code:t.text,language:t.lang},n,!1,void 0,this)}case"blockquote":return a("blockquote",{className:"codex-markdown-blockquote",children:m(e.tokens,n)},n,!1,void 0,this);case"list":return Ye(e,n);case"list_item":return Ze(e,n);case"table":return Qe(e,n);case"html":{let t=e;return/^<br\s*\/?>$/i.test(t.raw.trim())?a("br",{},n,!1,void 0,this):t.raw}case"math":{let t=e;return a(Ge,{value:t.text,display:t.display},n,!1,void 0,this)}default:throw Error(`Unsupported Codex Markdown token: ${JSON.stringify(e)}`)}}function w(e){switch(e.type){case"text":{let n=e;return n.tokens===void 0?E(n.text):n.tokens.map(w).join("")}case"escape":return e.text;case"paragraph":case"heading":case"strong":case"em":case"del":case"link":case"blockquote":case"list_item":return e.tokens.map(w).join("");case"list":return e.items.map(w).join("");case"table":{let n=e;return[n.header,...n.rows].map((t)=>t.map((r)=>r.tokens.map(w).join("")).join("")).join("")}default:return""}}function en({token:e,tokenKey:n,offset:t,runs:r,generation:o}){let s=x;try{return x={cursor:t,runs:r,generation:o},te(e,n)}finally{x=s}}var nn=D(function({result:n}){let{text:t,isStreaming:r}=n,o=G(()=>{let l=n.tokens;if(n.source.includes("!["))Q(l);L(l);let I=new Map,R=0;return l.map((N)=>{let M=ne(N),P=I.get(M)??0;I.set(M,P+1);let S=w(N),oe={token:N,tokenKey:`root-${M}-${P}`,offset:R,visibleText:S};return R+=S.length,oe})},[n]),s=o.map((l)=>l.visibleText).join(""),i=p({text:"",visibleText:"",runs:[],generation:0}),c=i.current,d=t.startsWith(c.text)||s.startsWith(c.visibleText),u=d?c.visibleText.length:0,k=performance.now(),b=r&&d?c.runs.filter((l)=>k-l.firstSeenAtMs<Je):[],y=c.generation+(d?0:1),g={text:t,visibleText:s,runs:b.filter((l)=>l.start<s.length).map((l)=>({...l,end:Math.min(l.end,s.length)})),generation:y};if(r&&s.length>u)g.runs.push({start:u,end:s.length,firstSeenAtMs:k});return X(()=>{i.current=g}),a("div",{dir:"auto",className:"codex-markdown-content codex-markdown-root","data-streaming":r?"true":void 0,children:o.map((l)=>a(en,{token:l.token,tokenKey:l.tokenKey,offset:l.offset,runs:g.runs,generation:y},l.tokenKey,!1,void 0,this))},void 0,!1,void 0,this)}),tn=D(function({text:n,isStreaming:t}){let r=p(null),[o,s]=f(()=>K(n,t)),[i,c]=f(null);if(h(()=>{let d=we((u)=>{he(()=>s(u))},c);return r.current=d,()=>{d.dispose(),r.current=null}},[]),h(()=>{let d=r.current;if(d===null)throw Error("Markdown parser is not mounted");let u=t?Se(n).markdown:n;d.update({source:u,text:n,isStreaming:t})},[t,n]),i!==null)throw i;return o===null?a("div",{"data-markdown-pending":!0},void 0,!1,void 0,this):a(nn,{result:o},void 0,!1,void 0,this)});function mn({text:e,streaming:n,host:t}){let r=n===!0,[o,s]=f(e);return h(()=>{if(o===e)return;if(!r){s(e);return}let i=requestAnimationFrame(()=>s(e));return()=>cancelAnimationFrame(i)},[o,r,e]),a(J.Provider,{value:t,children:a(tn,{text:r?o:e,isStreaming:r},void 0,!1,void 0,this)},void 0,!1,void 0,this)}export{mn as CodexMarkdownRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Te}from"../chunk-67gms74t.js";export{Te as NavigationPreview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Te}from"../chunk-67gms74t.js";import{useCallback as xe,useEffect as P,useLayoutEffect as ye,useMemo as Q,useRef as I,useState as E}from"react";import"@alwith/module-chat/navigation-rail.css";import{jsxDEV as h,Fragment as Ne}from"react/jsx-dev-runtime";var we=4,ge=10;function Se(T,x){let v=new Map(x.flatMap((c)=>c.itemIds.map((w)=>[w,c.key]))),p=Array(T.length),C;for(let c=T.length-1;c>=0;c--)C=v.get(T[c])??C,p[c]=C;let O=Math.max(-1,...x.map((c)=>c.key))+1,B=new Set,n=[];for(let[c,w]of T.entries()){let S=v.get(w),g=n.at(-1);if(!g||S!==void 0&&S!==g.key||S===void 0&&g.itemIds.length>=64&&p[c]!==g.key){let y=S!==void 0&&!B.has(S)?S:O++;g={key:y,startIndex:c,itemIds:[]},n.push(g),B.add(y)}g.itemIds.push(w)}return n}function me(T,x){if(T.size!==x.size)return!1;for(let v of T)if(!x.has(v))return!1;return!0}function Le({audio:T,beforeReveal:x,ensureItemMounted:v,items:p,onPreviewItem:C,renderPreview:O,onRevealError:B,scrollRoot:n,targetTopMarginPx:c=16}){let[w,S]=E(()=>{let e=p.at(-1);return new Set(e===void 0?[]:[e.id])}),[g,y]=E(null),[W,A]=E(null),[X,U]=E(!1),[_,fe]=E(()=>new Set),[pe,ve]=E(!0),[be,j]=E(null),{installUnlock:Z,preload:ee,playSequence:te}=T,K=I(null),M=I(null),R=I(!1),H=I(null),L=I(0),N=I(null),G=I(new Set),V=Q(()=>p.map((e)=>e.id).join("\x00"),[p]),F=I(p);F.current=p;let ne=I(_),re=I(w),ie=I({itemIdsKey:V,scrollRoot:n});if(ie.current.scrollRoot!==n)L.current+=1,ie.current={itemIdsKey:V,scrollRoot:n};let m=Q(()=>v===void 0?p.filter((e)=>_.has(e.id)):p,[v,p,_]),se=Q(()=>m.map((e)=>({inputTokens:e.inputTokens,outputTokens:e.outputTokens})),[m]),z=I({ids:"",groups:[]}),ae=m.map((e)=>e.id).join("\x00");if(z.current.ids!==ae)z.current={ids:ae,groups:Se(m.map((e)=>e.id),z.current.groups)};P(()=>Z(),[Z]),P(()=>()=>{if(L.current+=1,N.current!==null)clearTimeout(N.current)},[]),P(()=>{y(null),U(!1),A(null),M.current=null,R.current=!1,H.current=null,j(null),G.current.clear()},[n]),P(()=>{ee()},[ee]),P(()=>{if(n===null)return;let e=new Set,t=new Map,r=new Set(F.current.map((o)=>o.id)),i=()=>{let o=new Set(t.values()),l=F.current.filter((f)=>o.has(f.id)).map((f)=>f.id),u=l.findIndex((f)=>e.has(f));if(u===-1)return;let b=u;for(let f=u+1;f<l.length;f++)if(e.has(l[f]))b=f;let k=new Set(l.slice(u,b+1));if(me(re.current,k))return;re.current=k,S(k)},s=new IntersectionObserver((o)=>{for(let l of o){let u=t.get(l.target);if(l.isIntersecting)e.add(u);else e.delete(u)}i()},{root:n,rootMargin:`-${c}px 0px 0px 0px`}),a=()=>{let o=new Set,l=new Set;for(let u of n.querySelectorAll("[data-content-search-unit-key]")){let b=u.dataset.contentSearchUnitKey;if(b===void 0||!r.has(b)||o.has(b))continue;o.add(b);let k=u.closest("[data-turn-key]"),f=k===null||l.has(k)?u:k;if(l.add(f),t.has(f))continue;t.set(f,b),s.observe(f)}for(let u of t.keys()){if(l.has(u))continue;s.unobserve(u),e.delete(t.get(u)),t.delete(u)}if(i(),me(ne.current,o))return;ne.current=o,fe(o)};a();let d=new MutationObserver((o)=>{if(o.some((u)=>[...u.addedNodes,...u.removedNodes].some((b)=>b instanceof Element&&(b.matches("[data-turn-key], [data-content-search-unit-key]")||b.querySelector("[data-turn-key], [data-content-search-unit-key]")!==null))))a()});return d.observe(n,{childList:!0,subtree:!0}),()=>{d.disconnect(),s.disconnect()}},[V,n,c]);let J=m.find((e)=>w.has(e.id))?.id??m.at(-1)?.id;ye(()=>{let e=K.current;if(e===null||M.current!==null||J===void 0)return;let t=e.querySelector(`[data-thread-user-message-navigation-item-id="${CSS.escape(J)}"]`);if(t===null)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(i.top<r.top)e.scrollTop+=i.top-r.top;else if(i.bottom>r.bottom)e.scrollTop+=i.bottom-r.bottom+1},[J,V]),P(()=>{let e=n?.querySelector("[data-thread-user-message-navigation-content]");if(!n||!e)return;let t=()=>{let i=n.getBoundingClientRect(),s=e.getBoundingClientRect();if(i.width===0||s.width===0)return;let a=n.offsetWidth>0?i.width/n.offsetWidth:1;ve((s.left-i.left)/a>=48)},r=new ResizeObserver(t);return r.observe(n),r.observe(e),t(),()=>r.disconnect()},[n]);let Ie=xe(async(e,t="smooth")=>{if(n===null)throw Error("Thread user-message navigation scroll root is missing");let r=L.current+1;L.current=r,x();let i=()=>n.querySelector(`[data-content-search-unit-key="${CSS.escape(e.id)}"]`),s=i(),a=s!==null&&n.clientHeight>0&&s.closest("[data-turn-key]")!==null&&Math.abs(s.getBoundingClientRect().top-n.getBoundingClientRect().top)>n.clientHeight*2;if((s===null||a)&&v!==void 0){if(t==="instant"&&e.isLoaded===!1)return;s=await v(e,()=>L.current===r)??i(),t="instant"}if(L.current!==r)return;if(s===null)return;let d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;s.scrollIntoView({behavior:d?"instant":t,block:"start"}),s.querySelector("[data-user-message-bubble], [data-composer-attachment-pill]")?.animate?.([{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)"},{backgroundColor:"color-mix(in srgb, var(--foreground) 14%, transparent)",offset:0.35},{backgroundColor:"transparent"}],{duration:d?0:1000,easing:"cubic-bezier(0.23, 1, 0.32, 1)"})},[x,v,n]);if(m.length<we||!pe)return null;let Y=()=>{if(N.current!==null)clearTimeout(N.current);N.current=null},oe=(e,t=!1)=>{if(Y(),C===void 0||e.isLoaded!==!1||G.current.has(e.turnKey))return;let r=()=>{N.current=null,G.current.add(e.turnKey),C(e).catch(()=>G.current.delete(e.turnKey))};if(t)r();else N.current=setTimeout(r,150)},q=g===null?null:m.find((e)=>e.id===g.item.id)??m.find((e)=>e.nativeTurnId!==void 0&&e.nativeTurnId===g.item.nativeTurnId)??g.item,ue=(e,t="smooth")=>{Ie(e,t).catch((r)=>{if(B)B(r);else throw r})},de=m.findIndex((e)=>e.id===(W??be)),le=K.current,he=g===null||!le?.contains(g.button)?0:Me(le,g.button),ce=(e)=>{let t=e?.closest("[data-thread-user-message-navigation-item-id]"),r=K.current;if(t===void 0||t===null||!r.contains(t))return null;let i=t.dataset.threadUserMessageNavigationItemId,s=m.findIndex((a)=>a.id===i);return{button:t,item:m[s],index:s}},D=(e)=>{let t=M.current;if(t?.pointerId!==e.pointerId)return;if(M.current=null,A(null),t.captureTarget.hasPointerCapture(e.pointerId))t.captureTarget.releasePointerCapture(e.pointerId)};return h("nav",{"aria-label":"User messages",className:"thread-user-message-navigation absolute start-4 top-1/2 z-20 -translate-y-1/2",children:h(Te,{open:X,onOpenChange:U,side:"inline-end",sideOffset:0,align:"center",alignOffset:he,trigger:h("div",{ref:K,"data-thread-user-message-navigation-rail-list":!0,"data-scrubbing":W===null?void 0:"",className:"thread-user-message-navigation-rail-list",onPointerEnter:()=>{H.current=null},onPointerDown:(e)=>{if(e.button!==0)return;Y();let t=ce(e.target instanceof Element?e.target:null);if(t===null)return;R.current=!1,M.current={pointerId:e.pointerId,itemId:t.item.id,itemIndex:t.index,captureTarget:t.button},t.button.setPointerCapture(e.pointerId),A(t.item.id),y(t),U(!0)},onPointerMove:(e)=>{let t=M.current;if(t===null){let d=ce(e.target instanceof Element?e.target:null);if(d!==null){j(d.item.id);let o=H.current;if(o!==null&&o!==d.index)te(o,d.index,se);H.current=d.index,y((l)=>l?.item.id===d.item.id?l:d),oe(d.item)}return}if(t.pointerId!==e.pointerId)return;if((e.buttons&1)===0){D(e);return}let r=e.currentTarget.getBoundingClientRect(),i=Math.max(0,Math.min(m.length-1,Math.floor((e.clientY-r.top+e.currentTarget.scrollTop)/ge))),a={button:e.currentTarget.querySelectorAll("[data-thread-user-message-navigation-item-id]")[i],item:m[i],index:i};if(a.item.id===t.itemId)return;te(t.itemIndex,a.index,se),H.current=a.index,M.current={...t,itemId:a.item.id,itemIndex:a.index},R.current=!0,A(a.item.id),y(a),ue(a.item,"instant")},onPointerUp:D,onPointerCancel:D,onLostPointerCapture:D,onPointerLeave:()=>{if(Y(),j(null),H.current=null,M.current===null&&!X)y(null)},children:h("div",{className:"flex flex-col",children:z.current.groups.map((e)=>h("div",{className:"flex w-9 shrink-0 flex-col [content-visibility:auto]",style:{height:e.itemIds.length*ge},children:m.slice(e.startIndex,e.startIndex+e.itemIds.length).map((t,r)=>{let i=e.startIndex+r,s=Math.abs(i-de),a=de===-1||s>3?void 0:[1,0.7,0.4,0.2][s];return h("button",{type:"button","data-thread-user-message-navigation-item-id":t.id,"data-scrub-target":W===t.id?"":void 0,"aria-current":w.has(t.id)?"true":void 0,"aria-label":`Jump to user message ${i+1}`,className:"thread-user-message-navigation-row",onClick:(d)=>{if(R.current){R.current=!1;return}let o={button:d.currentTarget,item:t,index:i};y(o),U(!0),ue(t)},onFocus:(d)=>{oe(t,!0),y({button:d.currentTarget,item:t,index:i}),U(!0)},children:h("span",{className:"flex h-0.5 w-[30px] items-center",children:h("span",{className:"thread-user-message-navigation-marker",style:a===void 0?void 0:{"--marker-progress":a}},void 0,!1,void 0,this)},void 0,!1,void 0,this)},t.id,!1,void 0,this)})},e.key,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),children:q!==null&&h("div",{className:"bg-popover/95 text-popover-foreground ring-border w-80 max-w-[calc(100vw-1rem)] overflow-hidden rounded-xl p-2 text-sm leading-5 shadow-xl ring-[0.5px] backdrop-blur-sm",children:O?O(q):h(Ne,{children:[h("div",{className:"min-w-0 truncate font-medium",children:q.label},void 0,!1,void 0,this),q.response.length>0&&h("div",{className:"text-muted-foreground mt-1 line-clamp-3",children:q.response},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Me(T,x){let v=T.getBoundingClientRect(),p=x.getBoundingClientRect();return p.top+p.height/2-(v.top+v.height/2)}export{Le as ThreadUserMessageNavigationRail};
|
package/dist/codex/plan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k}from"../chunk-bbnrzw5x.js";export{k as CodexPlan};
|
package/dist/codex/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ht,ue,g,z,me,pe,ge}from"../chunk-p4c1w6qx.js";export{ht as CODEX_UNKNOWN_TURN_HEIGHT,g as calculateCodexThreadVirtualRange,pe as calculateCodexTurnCenterDistanceFromBottom,ge as calculateCodexTurnTargetDistanceFromBottom,ue as createCodexThreadVirtualLayout,me as preserveCodexThreadDistanceFromBottom,z as preserveCodexThreadRenderedWindow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{U,xt}from"../chunk-ytqka33j.js";import"../chunk-d1xydh51.js";export{xt as CodexUserMessage,U as CopyAction};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ue,g,z,me,pe,ge}from"../chunk-p4c1w6qx.js";import{forwardRef as Te,useCallback as w,useEffect as xe,useImperativeHandle as be,useLayoutEffect as L,useMemo as ie,useRef as s,useState as N}from"react";import{jsxDEV as m}from"react/jsx-dev-runtime";var Pe=12,J=2,W=800,ye=new Map;function Be({turnKey:_,heightPx:v,placeholder:U=!1,deferUntilReady:n=!1,observe:T,onReady:M,children:k}){let f=s(null),[b,G]=N(!1),X=w((x)=>{f.current=x,T(_,x)},[T,_]);return L(()=>{let x=f.current;if(x===null)throw Error("Codex turn element is missing");let P=()=>{M(x),G(!0)};if(x.querySelector("[data-markdown-pending]")===null){P();return}let d=new MutationObserver(()=>{if(x.querySelector("[data-markdown-pending]")!==null)return;d.disconnect(),P()});return d.observe(x,{childList:!0,subtree:!0}),()=>d.disconnect()},[M]),m("div",{style:b?void 0:{position:"relative",height:v,overflow:"hidden"},children:[m("div",{ref:X,className:"[&_[data-virtualized-turn-content]]:[content-visibility:visible]","data-turn-key":_,"aria-busy":!b||void 0,style:!b&&!U&&n?{visibility:"hidden"}:void 0,"data-turn-ready":b?"":void 0,children:k},void 0,!1,void 0,this),!b&&!U&&n&&m("div",{"aria-hidden":"true",className:"codex-turn-loading",children:m("div",{className:"codex-turn-loading-lines",children:[m("span",{},void 0,!1,void 0,this),m("span",{},void 0,!1,void 0,this),m("span",{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Me=Te(function({entries:v,renderTurn:U,scrollElement:n,sessionKey:T,leadingContent:M,leadingInsetPx:k=0,preserveViewport:f=!1},b){let G=s(null),[X,x]=N(k),P=M!==void 0&&M!==null;L(()=>{let e=G.current;if(e===null)return;let t=()=>x(e.getBoundingClientRect().height);t();let o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[P]);let d=ie(()=>ye.get(T),[T]),[Q,Y]=N(()=>d?.turnHeightsByKey??{}),i=ie(()=>ue({entries:v,gapPx:Pe,measuredHeightsByKey:Q,leadingInsetPx:P?X:k}),[v,Q,P,X,k]),ve=ie(()=>{let e=g({distanceFromBottomPx:d?.distanceFromBottomPx??0,layout:i,overscanCount:J,viewportHeightPx:W}),t=d?.renderedWindow;if(t===void 0||t===null)return e;return z({anchorKey:t.anchorKey,layout:i,previousRange:{startIndex:0,endIndex:Math.min(t.count,e.endIndex-e.startIndex)}})??e},[d,i]),[C,oe]=N(ve),[p,ae]=N(W),[c,se]=N(null),S=s(d?.distanceFromBottomPx??0),E=s(C),ce=s(i.turnKeys),l=s(Q),D=s(i),de=s(i),B=s(new Map),R=s(null),I=s(null),O=s(null),A=s(new Map),Z=s(!1),le=s(()=>{}),V=s(null),he=w(()=>{if(!f||n===null||R.current!==null||V.current!==null)return;let e=n.getBoundingClientRect();if(e.height<=0)return;let t=[...B.current].filter(([,r])=>r.hasAttribute("data-turn-ready")).map(([r,u])=>{let a=u.getBoundingClientRect(),h=D.current.turnIndexByKey.get(r),K=h===void 0?a.height:D.current.heightsPx[h];return{key:r,element:u,rect:a,bottom:a.top+K}}).filter(({rect:r,bottom:u})=>u>e.top&&r.top<e.bottom).toSorted((r,u)=>r.rect.top-u.rect.top),o=t.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>=e.top&&u.top<e.bottom)).toSorted((r,u)=>r.rect.top-u.rect.top)[0]??t[0];if(o)V.current={key:o.key,element:o.element,top:o.rect.top-e.top,scrollTop:n.scrollTop}},[f,n]),ee=s(he);ee.current=he;let H=w((e,t)=>{let o=Math.min(e,i.totalHeightPx),r=g({distanceFromBottomPx:o,layout:i,overscanCount:J,viewportHeightPx:t}),u=E.current,a=u.startIndex<=r.startIndex&&u.endIndex>=r.endIndex?u:r;if(S.current=o,E.current=a,ce.current=i.turnKeys,ae(t),a!==u)oe(a)},[i]),q=w((e)=>{let t=Math.max(0,e.scrollHeight-i.totalHeightPx);return Math.max(0,e.scrollHeight-e.clientHeight-e.scrollTop-t)},[i.totalHeightPx]),Re=w((e)=>{let t=e.dataset.turnKey;if(t===void 0)throw Error("Codex measured turn is missing its key");let o=Math.max(1,e.getBoundingClientRect().height);if(l.current[t]===o)return;ee.current();let r={...l.current,[t]:o};l.current=r,Y(r)},[]),te=w(()=>{if(I.current!==null)return I.current;return I.current=new ResizeObserver((e)=>{for(let t of e){let o=t.target;if(!("turnReady"in o.dataset)&&o.querySelector("[data-markdown-pending]")!==null)continue;let r=o.dataset.turnKey;if(r===void 0)throw Error("Codex measured turn is missing its key");let u=Math.max(1,t.borderBoxSize[0]?.blockSize??t.contentRect.height);A.current.set(r,u)}if(O.current!==null||A.current.size===0)return;O.current=requestAnimationFrame(()=>{O.current=null;let t=[...A.current].filter(([r,u])=>l.current[r]!==u);if(A.current.clear(),t.length===0)return;ee.current();let o={...l.current,...Object.fromEntries(t)};l.current=o,Y(o)})}),I.current},[]),He=w((e,t)=>{let o=B.current.get(e);if(o!==void 0)te().unobserve(o),B.current.delete(e);if(t===null)return;if(t.dataset.turnKey!==e)throw Error(`Codex turn key does not match its element: ${e}`);B.current.set(e,t),te().observe(t)},[te]);xe(()=>()=>{if(I.current?.disconnect(),O.current!==null)cancelAnimationFrame(O.current);A.current.clear(),I.current=null,B.current.clear()},[]),L(()=>{le.current=()=>{if(n===null)return;let e=q(n);if(R.current!==null){S.current=e,ae(n.clientHeight||W);return}H(e,n.clientHeight||W)}},[q,n,H]),L(()=>{if(n===null)return;if(!Z.current){Z.current=!0;let o=d?.distanceFromBottomPx??0;n.scrollTo({behavior:"instant",top:Math.max(0,o>0?D.current.totalHeightPx-n.clientHeight-o:n.scrollHeight-n.clientHeight)})}let e=()=>le.current();e(),n.addEventListener("scroll",e,{passive:!0});let t=new ResizeObserver(e);return t.observe(n),()=>{n.removeEventListener("scroll",e),t.disconnect()}},[d,n]),L(()=>{if(n===null||c===null)return;let e=B.current.get(c.turnKey);if(e?.querySelector("[data-markdown-pending]")!==null)return;let t=e.offsetHeight;if(t<=0)return;if(l.current[c.turnKey]!==t){let h={...l.current,[c.turnKey]:t};l.current=h,Y(h);return}let o=c.getTargetElement(e)??e,r=e.getBoundingClientRect(),u=o.getBoundingClientRect(),a=ge({align:c.align,layout:i,targetHeightPx:u.height,targetOffsetPx:u.top-r.top,turnKey:c.turnKey,viewportHeightPx:n.clientHeight});if(a===null)throw Error(`Codex virtual turn is missing: ${c.turnKey}`);n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-a)}),H(a,n.clientHeight||W),queueMicrotask(()=>{if(R.current!==c)return;c.complete(),R.current=null,se(null)})},[i,c,n,H]),L(()=>{let e=de.current;if(de.current=i,D.current=i,n===null||c!==null){V.current=null;return}let t=V.current;V.current=null;let o=t===null?void 0:n.contains(t.element)?t.element:B.current.get(t.key);if(f&&e!==i&&t!==null&&o!==void 0){let u=o.getBoundingClientRect().top-n.getBoundingClientRect().top,a=n.scrollTop-t.scrollTop;n.scrollTop+=u-t.top+a,H(q(n),n.clientHeight);return}let r=S.current;if(f&&e!==i&&Z.current)r=Math.max(0,e.totalHeightPx-n.clientHeight-n.scrollTop);if((r>24||f)&&e!==i){let u=q(n);if(u<=96&&!f){H(u,p);return}let a=g({distanceFromBottomPx:r,layout:e,overscanCount:0,viewportHeightPx:p}),h=e.turnKeys.slice(a.startIndex,a.endIndex).filter((y)=>i.turnIndexByKey.has(y)),K=h.find((y)=>l.current[y]!==void 0)??h[0];if(K!==void 0){let y=me({anchorKey:K,distanceFromBottomPx:r,nextLayout:i,previousLayout:e});if(y===null)throw Error(`Codex viewport anchor is missing: ${K}`);r=y,n.scrollTo({behavior:"instant",top:Math.max(0,i.totalHeightPx-n.clientHeight-r)})}}H(r,p)},[i,c,q,n,H,p,f]),L(()=>{E.current=C},[C]),xe(()=>()=>{R.current?.complete(),R.current=null;let e=E.current,o=D.current.turnKeys[e.startIndex];ye.set(T,{distanceFromBottomPx:S.current,renderedWindow:o===void 0?null:{anchorKey:o,count:e.endIndex-e.startIndex},turnHeightsByKey:l.current})},[T]),be(b,()=>({scrollToKey(e,t=(r)=>r,o={align:"center"}){R.current?.complete();let r=i.turnIndexByKey.get(e);if(r===void 0)throw Error(`Codex virtual turn is missing: ${e}`);let u=i.turnKeys[r],a=pe({layout:i,turnKey:e,viewportHeightPx:p});if(a===null)throw Error(`Codex virtual turn is missing: ${e}`);let h=g({distanceFromBottomPx:a,layout:i,overscanCount:J,viewportHeightPx:p});return E.current=h,oe(h),new Promise((K)=>{let y={align:o.align,complete:K,getTargetElement:t,turnKey:u};R.current=y,se(y)})}}),[i,p]);let F=C,j=ce.current;if(!(j===i.turnKeys||j.length===i.turnKeys.length&&j.every((e,t)=>e===i.turnKeys[t]))){let e=j[C.startIndex];F=(e===void 0?null:z({anchorKey:e,layout:i,previousRange:C}))??g({distanceFromBottomPx:S.current,layout:i,overscanCount:J,viewportHeightPx:p})}let ne=v.length-1,fe=v[ne],re=v.slice(F.startIndex,Math.min(F.endIndex,ne)).map((e,t)=>({entry:e,index:F.startIndex+t}));if(fe!==void 0)re.push({entry:fe,index:ne});return m("div",{"data-codex-thread":!0,"data-codex-virtualized-pending-key":c?.turnKey,"data-codex-virtualized-range":`${F.startIndex}:${F.endIndex}`,"data-codex-virtualized-total-count":v.length,"data-codex-virtualized-turn-count":re.length,className:"relative shrink-0",style:{height:i.totalHeightPx},children:[P&&m("div",{ref:G,"data-codex-thread-leading":!0,className:"absolute inset-x-0 top-0",children:M},void 0,!1,void 0,this),re.map(({entry:e,index:t})=>m("div",{className:"absolute inset-x-0",style:{top:i.topOffsetsPx[t]??0},children:m(Be,{turnKey:e.turnKey,heightPx:i.heightsPx[t],placeholder:e.placeholder,deferUntilReady:e.deferUntilReady,observe:He,onReady:Re,children:U(e,t)},void 0,!1,void 0,this)},e.turnKey,!1,void 0,this))]},void 0,!0,void 0,this)});export{Me as VirtualizedTurnList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{q,wt}from"../chunk-15a7wypc.js";import"../chunk-z3gwnjmk.js";export{wt as filterFiles,q as filterSlashCommands};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{e}from"../chunk-
|
|
1
|
+
import{e}from"../chunk-xgy0heva.js";import{R}from"../chunk-b5srhd6k.js";import"../chunk-z3gwnjmk.js";import{q}from"../chunk-15a7wypc.js";import{Le}from"../chunk-tbr607hk.js";import{_e}from"../chunk-twww750f.js";import{autoUpdate as rt}from"@floating-ui/dom";import{cn as J}from"cn";import{BookOpenTextIcon as st,FileIcon as it,StoreIcon as lt}from"lucide-react";import{useCallback as ut,useEffect as v,useLayoutEffect as X,useMemo as Y,useRef as Z,useState as g}from"react";import{createPortal as at}from"react-dom";import{jsxDEV as i,Fragment as ct}from"react/jsx-dev-runtime";function wt({handleRef:c,anchorRef:m,commands:T,searchFiles:a,onMention:_,onSearchError:H,fileSearchDebounceMs:C=0,bashMode:A=!1,forcedOpen:l=!1,onForcedOpenChange:f,emptyLabel:F,fileStatusLabels:E,morePlugins:M}){let j=_e(),u=j.textInput.value,[z,K]=g(0),[y,D]=g(null),[b,h]=g(0),U=Z(null);v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=()=>K(t.selectionStart??0),o=()=>{if(document.activeElement===t)n()};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("input",n),t.addEventListener("select",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("input",n),t.removeEventListener("select",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",o)}});let V=Y(()=>A&&u.startsWith("!")?null:Le(u,z),[u,z,A]),r=V?.kind==="at"&&!a?null:V,P=`${r?.kind??"forced"}:${r?.query??""}:${l}`,[O,tt]=g(P);if(O!==P)tt(P),h(0);let L=Z(null);v(()=>{if(!l){L.current=null;return}if(L.current===null)L.current=u;else if(u!==L.current)f?.(!1)},[l,u,f]);let x=r?.kind==="at"?r.query:null;v(()=>{if(x===null||!a){D(null);return}let t=!0,n=()=>{a(x).then((s)=>{if(t)D({query:x,search:a,items:s})},(s)=>{if(t)D({query:x,search:a,items:[]}),H(s)})},o=C>0?window.setTimeout(n,C):null;if(o===null)n();return()=>{if(t=!1,o!==null)window.clearTimeout(o)}},[x,a,C,H]);let d=Y(()=>{if(r?.kind==="at")return y?.query===r.query&&y.search===a?y.items:[];if(r)return q(T,r.query);if(l)return q(T,"");return[]},[r,l,T,y,a]),[et,N]=g(!1);v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=()=>N(!0),o=()=>{if(N(!1),l)f?.(!1)};return N(document.activeElement===t),t.addEventListener("focus",n),t.addEventListener("blur",o),()=>{t.removeEventListener("focus",n),t.removeEventListener("blur",o)}},[c,l,f]),v(()=>{if(l)c.current?.getTextarea()?.focus()},[l,c]);let p=et&&(r!==null?r.kind==="slash"||d.length>0||!!E:l);v(()=>{if(!p)return;U.current?.querySelector(`[data-idx="${b}"]`)?.scrollIntoView({block:"nearest"})},[b,p]);function W(t){let n=c.current?.getTextarea();if(!n)return;let o,s;if(r){let B=r.kind==="slash"?`/${t.payload} `:`@${t.label} `;if(o=u.slice(0,r.start)+B+u.slice(r.end),r.kind==="at")_?.(t.payload);s=r.start+B.length}else if(l)o=`${u.length===0||u.endsWith(`
|
|
2
2
|
`)?u:`${u}
|
|
3
|
-
`}/${t.payload} `,s=o.length,f?.(!1);else return;j.textInput.setInput(o),requestAnimationFrame(()=>{n.focus(),n.setSelectionRange(s,s)})}v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=(o)=>{if(!p)return;if(c.current?.isComposing()||o.isComposing||o.keyCode===229)return;if(o.key==="ArrowDown")o.preventDefault(),o.stopPropagation(),h((s)=>d.length===0?0:Math.min(d.length-1,s+1));else if(o.key==="ArrowUp")o.preventDefault(),o.stopPropagation(),h((s)=>Math.max(0,s-1));else if(o.key==="Enter"||o.key==="Tab"){o.preventDefault(),o.stopPropagation();let s=d[b];if(s)
|
|
3
|
+
`}/${t.payload} `,s=o.length,f?.(!1);else return;j.textInput.setInput(o),requestAnimationFrame(()=>{n.focus(),n.setSelectionRange(s,s)})}v(()=>{let t=c.current?.getTextarea();if(!t)return;let n=(o)=>{if(!p)return;if(c.current?.isComposing()||o.isComposing||o.keyCode===229)return;if(o.key==="ArrowDown")o.preventDefault(),o.stopPropagation(),h((s)=>d.length===0?0:Math.min(d.length-1,s+1));else if(o.key==="ArrowUp")o.preventDefault(),o.stopPropagation(),h((s)=>Math.max(0,s-1));else if(o.key==="Enter"||o.key==="Tab"){o.preventDefault(),o.stopPropagation();let s=d[b];if(s)W(s)}else if(o.key==="Escape")if(o.preventDefault(),o.stopPropagation(),r)K(Math.max(0,r.start-1)),t.setSelectionRange(r.start,r.start);else f?.(!1)};return t.addEventListener("keydown",n,!0),()=>t.removeEventListener("keydown",n,!0)});let[k,Q]=g(null),[S,nt]=g(null),I=ut(()=>{let t=m?.current;if(!t)return;let n=t.getBoundingClientRect();Q({left:n.left,width:n.width,bottom:window.innerHeight-n.top+8})},[m]);if(X(()=>{if(!p){Q(null);return}I()},[p,I]),X(()=>{let t=m?.current;if(!p||!t||!S)return;return rt(t,S,I,{animationFrame:!0})},[p,S,m,I]),!p||m&&!k)return null;let w=r?r.kind==="slash":l,ot=w?st:it,G=i("div",{ref:nt,className:m?"fixed z-50":"absolute inset-x-0 bottom-full z-50 mb-2",style:m&&k?{left:k.left,width:k.width,bottom:k.bottom}:void 0,children:i("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:[i("div",{className:"max-h-72 overflow-y-auto",children:[d.length===0&&w&&i("div",{className:"text-muted-foreground px-2 py-3 text-xs",children:F},void 0,!1,void 0,this),d.length===0&&!w&&E&&i("div",{role:"status",className:"text-muted-foreground px-2 py-3 text-xs",children:y?.query===x&&y.search===a?E.empty:E.loading},void 0,!1,void 0,this),d.map((t,n)=>i(e,{type:"button",variant:"ghost",role:"option","aria-selected":n===b,"data-idx":n,onMouseDown:(o)=>{o.preventDefault(),W(t)},onMouseEnter:()=>h(n),className:J("flex h-auto w-full items-center justify-start gap-2.5 rounded-md px-2.5 py-2 text-start",n===b&&"bg-muted"),children:[i(ot,{className:J("size-4 shrink-0",w?"text-blue-500":"text-muted-foreground")},void 0,!1,void 0,this),i("span",{className:"text-foreground shrink-0 text-sm font-medium",children:t.label},void 0,!1,void 0,this),t.description&&i("span",{className:"text-muted-foreground min-w-0 flex-1 truncate text-xs",children:t.description},void 0,!1,void 0,this)]},t.key,!0,void 0,this))]},void 0,!0,void 0,this),w&&M&&i(ct,{children:[i(R,{},void 0,!1,void 0,this),i(e,{type:"button",variant:"ghost",onMouseDown:(t)=>{t.preventDefault(),f?.(!1),M.open()},className:"h-auto w-full justify-start px-2.5 py-2",children:[i(lt,{"data-icon":"inline-start"},void 0,!1,void 0,this),M.label]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return m?at(G,document.body):G}export{wt as CompletionMenu};
|