meshy-node 0.4.1 → 0.4.2
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/README.md +1 -1
- package/dashboard/assets/DashboardPage-DaZ-EQZ4.js +124 -0
- package/dashboard/assets/{DashboardShared-BSDgKTOF.js → DashboardShared-CKWmFD7i.js} +4 -4
- package/dashboard/assets/{DiffTab-_2QRJdG0.js → DiffTab-HUpulZ_U.js} +2 -2
- package/dashboard/assets/{FilesTab-_pFba0dN.js → FilesTab-vVa4GgR5.js} +2 -2
- package/dashboard/assets/{PreviewTab-C5UehUZ1.js → PreviewTab-DRyl2BmE.js} +2 -2
- package/dashboard/assets/{SharedConversationPage-e35GHbGI.js → SharedConversationPage-B4sLTwC9.js} +3 -3
- package/dashboard/assets/{file-3EwPAA-4.js → file-BXP_hlLG.js} +1 -1
- package/dashboard/assets/folder-B3put-Ay.js +6 -0
- package/dashboard/assets/index-Bg0PqgJi.js +291 -0
- package/dashboard/assets/index-BzzXPy7Y.css +1 -0
- package/dashboard/assets/{input-DMp80MWI.js → input-DH4KoLjb.js} +1 -1
- package/dashboard/index.html +2 -2
- package/main.cjs +268 -37
- package/package.json +1 -1
- package/runtime-metadata.json +5 -5
- package/dashboard/assets/DashboardPage-BUtwv0kD.js +0 -124
- package/dashboard/assets/folder-B6d9_x4J.js +0 -11
- package/dashboard/assets/index-6tOxJBZf.js +0 -276
- package/dashboard/assets/index-Ch6zIZ6Y.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as h,r as g,j as n,i as P,C as T,b as E,X as oe,
|
|
1
|
+
import{c as h,r as g,j as n,i as P,C as T,b as E,X as oe,y as ie,I as Q,b1 as ae,z as ce,B as le}from"./index-Bg0PqgJi.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -44,11 +44,11 @@ import{c as h,r as g,j as n,i as P,C as T,b as E,X as oe,x as ie,H as Q,b0 as ae
|
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
46
|
*/const $e=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],ee=h("wrench",$e);function I(e){return typeof e=="object"&&e!==null}function ve(e){if(!I(e))return null;if(e.type==="text"&&typeof e.text=="string"){const t=e.text.trim();return t?{type:"text",text:t}:null}if(e.type==="image"&&typeof e.mediaType=="string"&&typeof e.data=="string"){const t=e.mediaType.trim(),r=e.data;return!t||!r?null:{type:"image",mediaType:t,data:r,...typeof e.filename=="string"&&e.filename.trim()?{filename:e.filename.trim()}:{}}}if(e.type==="tool_result"&&typeof e.toolUseId=="string"&&typeof e.content=="string"){const t=e.toolUseId.trim(),r=e.content.trim();return!t||!r?null:{type:"tool_result",toolUseId:t,content:r,...typeof e.isError=="boolean"?{isError:e.isError}:{}}}return null}function Ce(e){if(!I(e))return null;if(e.type==="text"&&typeof e.text=="string"){const s=e.text.trim();return s?{type:"text",text:s}:null}if(e.type!=="image"||!I(e.source)){if(e.type==="tool_result"&&typeof e.tool_use_id=="string"&&typeof e.content=="string"){const s=e.tool_use_id.trim(),o=e.content.trim();return!s||!o?null:{type:"tool_result",toolUseId:s,content:o,...typeof e.is_error=="boolean"?{isError:e.is_error}:{}}}return null}const t=typeof e.source.media_type=="string"?e.source.media_type.trim():"",r=typeof e.source.data=="string"?e.source.data:"";return!t||!r?null:{type:"image",mediaType:t,data:r}}function U(e){if(typeof e=="string"){const t=e.trim();return t?[{type:"text",text:t}]:[]}return Array.isArray(e)?e.map(t=>ve(t)??Ce(t)).filter(t=>t!==null):[]}function mt(e,t){const r=e.trim();return[...r?[{type:"text",text:r}]:[],...t]}function Ae(e){return{role:"user",content:e.map(t=>t.type==="text"?{type:"text",text:t.text}:t.type==="tool_result"?{type:"tool_result",tool_use_id:t.toolUseId,content:t.content,...typeof t.isError=="boolean"?{is_error:t.isError}:{}}:{type:"image",source:{type:"base64",media_type:t.mediaType,data:t.data}})}}function ft(e,t=new Date().toISOString()){return{type:"user",message:Ae(e),timestamp:t}}function _(e){if(e.type!=="user"||e.isSynthetic===!0)return null;if(typeof e.message=="string"){const t=U(e.message);return t.length>0?t:null}if(I(e.message)&&Array.isArray(e.message.content)){const t=U(e.message.content);return t.length>0?t:null}if(Array.isArray(e.content)){const t=U(e.content);return t.length>0?t:null}return null}function pt(e){return U(e.payload.initialMessage)}function b(e){return e.map(t=>{if(t.type==="text")return`t:${t.text}`;if(t.type==="tool_result")return`r:${t.toolUseId}:${t.isError===!0?"1":"0"}:${t.content}`;const r=t.data.slice(0,32),s=t.data.slice(-32);return`i:${t.mediaType}:${t.data.length}:${r}:${s}`}).join("|")}function Te(e){return e.map(t=>t.type==="text"?t.text:t.type==="tool_result"?t.content:"").filter(Boolean).join(`
|
|
47
|
-
`)}function Me(e){return`data:${e.mediaType};base64,${e.data}`}function xt(e){var o,i;if(!e)return[];const t=[],r=e.items;if(r)for(const a of Array.from(r)){if((a==null?void 0:a.kind)!=="file"||!((o=a.type)!=null&&o.startsWith("image/")))continue;const c=(i=a.getAsFile)==null?void 0:i.call(a);c&&c.type.startsWith("image/")&&t.push(c)}if(t.length>0)return t;const s=e.files;return s?Array.from(s).filter(a=>a.type.startsWith("image/")):[]}function Ue(e){return new Promise((t,r)=>{const s=new FileReader;s.onload=()=>{if(typeof s.result!="string"){r(new Error(`Failed to read ${e.name}`));return}t(s.result)},s.onerror=()=>r(s.error??new Error(`Failed to read ${e.name}`)),s.readAsDataURL(e)})}async function gt(e){return Promise.all(Array.from(e).map(async t=>{if(!t.type.startsWith("image/"))throw new Error(`${t.name} is not an image`);const r=await Ue(t),s=r.indexOf(",");if(s===-1)throw new Error(`Failed to parse ${t.name}`);return{type:"image",mediaType:t.type||"image/png",data:r.slice(s+1),filename:t.name}}))}function M(e){return typeof e=="object"&&e!==null}function Pe(e){return M(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function Ee(e){return!M(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function Ie(e){if(!M(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(Ee).filter(r=>r!==null):[];return t.length===0?null:{header:typeof e.header=="string"&&e.header.trim()?e.header.trim():void 0,question:e.question.trim(),multiSelect:e.multiSelect===!0,options:t}}function
|
|
48
|
-
`);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function C(e){return typeof e=="object"&&e!==null}function ze(e){if(!e)return;const t=["file_path","path","command"].map(r=>e[r]).find(r=>typeof r=="string"&&r.trim().length>0);return t==null?void 0:t.trim()}function Je(e){const t=e.toLowerCase();return t.includes(" permission to write ")?"Write":t.includes(" permission to edit ")?"Edit":t.includes(" permission to run ")||t.includes(" permission to execute ")?"Bash":"Action"}function J(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const r=t.match(/`([^`]+)`/);return{requests:[{toolName:Je(t),target:r==null?void 0:r[1],summary:t}]}}function Le(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const r of e.permission_denials){if(!C(r)||typeof r.tool_name!="string")continue;const s=C(r.tool_input)?r.tool_input:void 0,o=ze(s),i=typeof e.result=="string"&&e.result.trim().length>0?e.result.trim():`Awaiting your permission to use ${r.tool_name}${o?` on \`${o}\``:""}.`;t.push({toolName:r.tool_name,...typeof r.tool_use_id=="string"?{toolUseId:r.tool_use_id}:{},...o?{target:o}:{},summary:i})}return t.length>0?{requests:t}:null}function K(e){if(!Array.isArray(e))return null;for(const t of e){if(!C(t)||t.type!=="text"||typeof t.text!="string")continue;const r=J(t.text);if(r)return r}return null}function V(e){if(!C(e))return null;const t=Le(e);if(t)return t;if(typeof e.result=="string"){const s=J(e.result);if(s)return s}if(typeof e.message=="string"){const s=J(e.message);if(s)return s}if(C(e.message)){const s=V(e.message);if(s)return s;const o=K(e.message.content);if(o)return o}const r=K(e.content);return r||null}function Re(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function We(e,t){return e.requests.map(r=>{const s=r.target?` for \`${r.target}\``:"",o=t==="approve"?`Approved. Proceed with the requested ${r.toolName} action${s}.`:`Denied. Do not proceed with the requested ${r.toolName} action${s}. Ask for another approach if needed.`;return r.toolUseId?{type:"tool_result",toolUseId:r.toolUseId,content:o,isError:t==="deny"}:t==="approve"?{type:"text",text:o}:{type:"text",text:o}})}function Ve(e){return _(e)!==null}function L(e){return typeof e=="object"&&e!==null}function X(e){if(e.type==="user"){const t=_(e),r=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${r}:${b(t)}`}return JSON.stringify(e)}function $(e){return Array.isArray(e)?e.map(t=>$(t)):L(e)?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,$(r)])):e}function Y(e){const t=_(e);if(t)return`user:${b(t)}`;if(e.type==="assistant"){if(typeof e.message=="string")return`assistant:${JSON.stringify(e.message)}`;if(L(e.message)&&"content"in e.message)return`assistant:${JSON.stringify($(e.message.content))}`;if(Array.isArray(e.content))return`assistant:${JSON.stringify($(e.content))}`;if(L(e.message))return`assistant:${JSON.stringify($(e.message))}`}return JSON.stringify(e)}function G(e){if(typeof e.timestamp!="string")return null;const t=Date.parse(e.timestamp);return Number.isNaN(t)?null:t}function R(e){const t=O(e);return t?`question:${S(t)}`:null}function De(e){const t=V(e);return t?`permission:${Re(t)}`:null}function Z(e){if(!Array.isArray(e))return null;const t=new Set;for(const r of e){const s=R(r);if(s){t.add(s);continue}if(typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"){const o=B(r.text);o&&t.add(S(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function He(e){const t=R(e);if(t)return t;if(typeof e.message=="string"){const r=B(e.message);return r?S(r):null}if(typeof e.message=="object"&&e.message!==null){const r=R(e.message);return r||Z(e.message.content)}return Z(e.content)}function Ke(e){return De(e)}function ht(e,t,r){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${r}`}function yt(e,t){const r=new Map;for(const o of t){const i=Y(o);r.set(i,(r.get(i)??0)+1)}const s=[];for(let o=e.length-1;o>=0;o-=1){const i=e[o];if(!i)continue;const a=Y(i),c=r.get(a)??0;if(c>0){r.set(a,c-1);continue}s.push({...i})}return[...s.reverse(),...t.map(o=>({...o}))].map((o,i)=>({event:o,order:i})).sort((o,i)=>{const a=G(o.event),c=G(i.event);return a!==null&&c!==null&&a!==c?a-c:o.order-i.order}).map(o=>o.event)}function bt(e,t){const r=X(t);return e.some(s=>X(s)===r)?e:[...e,{...t}]}function jt(e,t){const r=new Map;for(const s of t){const o=_(s);if(!o)continue;const i=b(o);r.set(i,(r.get(i)??0)+1)}return e.filter(s=>{const o=b(s.content),i=r.get(o)??0;return i<=0?!0:(r.set(o,i-1),!1)})}function Nt(e,t){const r=b(t),s=e.findIndex(o=>b(o.content)===r);return s===-1?e:e.filter((o,i)=>i!==s)}function wt(e,t){const r=b(t);return e.some(s=>{const o=_(s);return o!==null&&b(o)===r})}function kt(e){const t=[];let r=null;for(const s of e){if(Ve(s)){r=null,t.push(s);continue}const o=Ke(s)??He(s);o&&o===r||(t.push(s),o&&(r=o))}return t}function A({payload:e,disabled:t=!1,bypassEnabled:r=!1,onBypassChange:s,onSubmit:o}){const[i,a]=g.useState(()=>r?Be(e):e.questions.map(()=>[])),[c,u]=g.useState(!1),[d,m]=g.useState(!1);g.useEffect(()=>{r&&a(l=>l.map((f,y)=>{var p;return f.length>0?f:(p=e.questions[y])!=null&&p.options.length?[0]:[]}))},[r,e]);const x=qe(e,i)&&!t&&!c&&!d&&!!o,j=(l,f)=>{t||d||c||a(y=>y.map((p,N)=>{if(N!==l)return p;const w=e.questions[N];return w?w.multiSelect?p.includes(f)?p.filter(q=>q!==f):[...p,f].sort((q,se)=>q-se):[f]:p}))},H=async()=>{if(!x||!o)return;u(!0);const l=await o(Fe(e,i));u(!1),l&&m(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:n.jsx(fe,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),n.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),n.jsxs(P,{type:"button",variant:r?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!r),className:"rounded-[14px]",children:[n.jsx(ke,{className:"h-4 w-4"}),r?"Bypass on":"Bypass future questions"]})]}),n.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((l,f)=>{const y=i[f]??[];return n.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[n.jsxs("div",{children:[l.header&&n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:l.header}),n.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:l.question}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.multiSelect?"Select one or more options.":"Select one option."})]}),n.jsx("div",{className:"space-y-2",children:l.options.map((p,N)=>{const w=y.includes(N);return n.jsxs("button",{type:"button",onClick:()=>j(f,N),disabled:t||c||d,"aria-pressed":w,className:E("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[n.jsx("span",{className:E("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:n.jsx(T,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium leading-5",children:p.label}),p.description&&n.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:p.description})]})]},`${p.label}-${N}`)})})]},`${l.header??"question"}-${f}`)})}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:r?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),n.jsx(P,{type:"button",onClick:()=>void H(),disabled:!x,className:"rounded-[16px] px-5",children:d?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function Xe({payload:e,disabled:t=!1,onSubmit:r}){const[s,o]=g.useState(null),[i,a]=g.useState(!1),c=!t&&!i&&!!r,u=async d=>{if(!c||!r)return;o(d);const m=await r(We(e,d));o(null),m&&a(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-amber-500/25 bg-amber-500/10 text-amber-600 shadow-sm dark:text-amber-400",children:n.jsx(Ne,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),n.jsx("div",{className:"mt-1 space-y-3",children:e.requests.map((d,m)=>n.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[n.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:d.summary}),(d.toolName||d.target)&&n.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[n.jsx("span",{children:d.toolName}),d.target&&n.jsx("span",{className:"font-mono normal-case tracking-normal",children:d.target})]})]},`${d.toolUseId??d.toolName}-${m}`))})]})]}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[n.jsxs(P,{type:"button",variant:"outline",onClick:()=>void u("deny"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(oe,{className:"h-4 w-4"}),i?"Sent":s==="deny"?"Sending...":"Deny"]}),n.jsxs(P,{type:"button",onClick:()=>void u("approve"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(T,{className:"h-4 w-4"}),i?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function _t({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const i=e.type,a=V(e),c=O(e);if(a)return n.jsx(v,{children:n.jsx(Xe,{payload:a,onSubmit:s,disabled:o})});if(c)return n.jsx(v,{children:n.jsx(A,{payload:c,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o})});if(i==="user"){const u=Ye(e),d=u.filter(x=>x.type==="tool_result");if(d.length>0&&u.every(x=>x.type==="tool_result"))return n.jsx(v,{children:d.map((x,j)=>n.jsx(ne,{block:x,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},j))});const m=_(e);return m?n.jsx(tt,{content:m}):null}return i==="assistant"?n.jsx(rt,{event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function Ye(e){const t=e.message,r=t==null?void 0:t.content;if(Array.isArray(r))return r.filter(o=>typeof o=="object"&&o!==null);const s=e.content;return Array.isArray(s)?s.filter(o=>typeof o=="object"&&o!==null):[]}function F(e){var r;const t=e.replace(/\r\n/g,`
|
|
47
|
+
`)}function Me(e){return`data:${e.mediaType};base64,${e.data}`}function xt(e){var o,i;if(!e)return[];const t=[],r=e.items;if(r)for(const a of Array.from(r)){if((a==null?void 0:a.kind)!=="file"||!((o=a.type)!=null&&o.startsWith("image/")))continue;const c=(i=a.getAsFile)==null?void 0:i.call(a);c&&c.type.startsWith("image/")&&t.push(c)}if(t.length>0)return t;const s=e.files;return s?Array.from(s).filter(a=>a.type.startsWith("image/")):[]}function Ue(e){return new Promise((t,r)=>{const s=new FileReader;s.onload=()=>{if(typeof s.result!="string"){r(new Error(`Failed to read ${e.name}`));return}t(s.result)},s.onerror=()=>r(s.error??new Error(`Failed to read ${e.name}`)),s.readAsDataURL(e)})}async function gt(e){return Promise.all(Array.from(e).map(async t=>{if(!t.type.startsWith("image/"))throw new Error(`${t.name} is not an image`);const r=await Ue(t),s=r.indexOf(",");if(s===-1)throw new Error(`Failed to parse ${t.name}`);return{type:"image",mediaType:t.type||"image/png",data:r.slice(s+1),filename:t.name}}))}function M(e){return typeof e=="object"&&e!==null}function Pe(e){return M(e)&&typeof e.name=="string"&&e.name.toLowerCase()==="askuserquestion"}function Ee(e){return!M(e)||typeof e.label!="string"||!e.label.trim()?null:{label:e.label.trim(),description:typeof e.description=="string"?e.description.trim():""}}function Ie(e){if(!M(e)||typeof e.question!="string"||!e.question.trim())return null;const t=Array.isArray(e.options)?e.options.map(Ee).filter(r=>r!==null):[];return t.length===0?null:{header:typeof e.header=="string"&&e.header.trim()?e.header.trim():void 0,question:e.question.trim(),multiSelect:e.multiSelect===!0,options:t}}function F(e){if(!M(e)||!Array.isArray(e.questions))return null;const t=e.questions.map(Ie).filter(r=>r!==null);return t.length===0?null:{questions:t}}function S(e){return JSON.stringify({questions:e.questions})}function O(e){const t=F(e);if(t)return t;if(Pe(e)){const r=M(e.input)?e.input:void 0,s=F(r);return s?{...s,...typeof e.id=="string"&&e.id.trim()?{toolUseId:e.id.trim()}:{}}:null}return null}function Oe(e){var o;const t=e.trim();if(!t)return[];const r=[t],s=t.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi);for(const i of s){const a=(o=i[1])==null?void 0:o.trim();a&&r.push(a)}return r}function B(e){for(const t of Oe(e))try{const r=JSON.parse(t),s=F(r);if(s)return s}catch{}return null}function Be(e){return e.questions.map(t=>t.options.length>0?[0]:[])}function qe(e,t){return e.questions.every((r,s)=>(t[s]??[]).length>0)}function ze(e,t){const s=e.questions.map((o,i)=>{const a=[...new Set(t[i]??[])].sort((c,u)=>c-u).filter(c=>o.options[c]!==void 0);return{header:o.header??null,question:o.question,multiSelect:o.multiSelect,selectedOptions:a.map(c=>o.options[c]).filter(c=>c!==void 0)}}).map(o=>{const i=o.header??o.question,a=o.selectedOptions.map(c=>c.label).join(o.multiSelect?", ":"");return`${i}: ${a}`}).join(`
|
|
48
|
+
`);return e.toolUseId?[{type:"tool_result",toolUseId:e.toolUseId,content:s,isError:!1}]:[{type:"text",text:s}]}function C(e){return typeof e=="object"&&e!==null}function Fe(e){if(!e)return;const t=["file_path","path","command"].map(r=>e[r]).find(r=>typeof r=="string"&&r.trim().length>0);return t==null?void 0:t.trim()}function Je(e){const t=e.toLowerCase();return t.includes(" permission to write ")?"Write":t.includes(" permission to edit ")?"Edit":t.includes(" permission to run ")||t.includes(" permission to execute ")?"Bash":"Action"}function J(e){const t=e.trim();if(!t.startsWith("Awaiting your permission to "))return null;const r=t.match(/`([^`]+)`/);return{requests:[{toolName:Je(t),target:r==null?void 0:r[1],summary:t}]}}function Le(e){if(!Array.isArray(e.permission_denials))return null;const t=[];for(const r of e.permission_denials){if(!C(r)||typeof r.tool_name!="string")continue;const s=C(r.tool_input)?r.tool_input:void 0,o=Fe(s),i=typeof e.result=="string"&&e.result.trim().length>0?e.result.trim():`Awaiting your permission to use ${r.tool_name}${o?` on \`${o}\``:""}.`;t.push({toolName:r.tool_name,...typeof r.tool_use_id=="string"?{toolUseId:r.tool_use_id}:{},...o?{target:o}:{},summary:i})}return t.length>0?{requests:t}:null}function K(e){if(!Array.isArray(e))return null;for(const t of e){if(!C(t)||t.type!=="text"||typeof t.text!="string")continue;const r=J(t.text);if(r)return r}return null}function V(e){if(!C(e))return null;const t=Le(e);if(t)return t;if(typeof e.result=="string"){const s=J(e.result);if(s)return s}if(typeof e.message=="string"){const s=J(e.message);if(s)return s}if(C(e.message)){const s=V(e.message);if(s)return s;const o=K(e.message.content);if(o)return o}const r=K(e.content);return r||null}function Re(e){return JSON.stringify(e.requests.map(t=>({toolName:t.toolName,target:t.target??null,summary:t.summary})))}function We(e,t){return e.requests.map(r=>{const s=r.target?` for \`${r.target}\``:"",o=t==="approve"?`Approved. Proceed with the requested ${r.toolName} action${s}.`:`Denied. Do not proceed with the requested ${r.toolName} action${s}. Ask for another approach if needed.`;return r.toolUseId?{type:"tool_result",toolUseId:r.toolUseId,content:o,isError:t==="deny"}:t==="approve"?{type:"text",text:o}:{type:"text",text:o}})}function Ve(e){return _(e)!==null}function L(e){return typeof e=="object"&&e!==null}function X(e){if(e.type==="user"){const t=_(e),r=typeof e.timestamp=="string"?e.timestamp:"";if(t)return`user:${r}:${b(t)}`}return JSON.stringify(e)}function $(e){return Array.isArray(e)?e.map(t=>$(t)):L(e)?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,$(r)])):e}function Y(e){const t=_(e);if(t)return`user:${b(t)}`;if(e.type==="assistant"){if(typeof e.message=="string")return`assistant:${JSON.stringify(e.message)}`;if(L(e.message)&&"content"in e.message)return`assistant:${JSON.stringify($(e.message.content))}`;if(Array.isArray(e.content))return`assistant:${JSON.stringify($(e.content))}`;if(L(e.message))return`assistant:${JSON.stringify($(e.message))}`}return JSON.stringify(e)}function G(e){if(typeof e.timestamp!="string")return null;const t=Date.parse(e.timestamp);return Number.isNaN(t)?null:t}function R(e){const t=O(e);return t?`question:${S(t)}`:null}function De(e){const t=V(e);return t?`permission:${Re(t)}`:null}function Z(e){if(!Array.isArray(e))return null;const t=new Set;for(const r of e){const s=R(r);if(s){t.add(s);continue}if(typeof r=="object"&&r!==null&&r.type==="text"&&typeof r.text=="string"){const o=B(r.text);o&&t.add(S(o))}}return t.size===0?null:Array.from(t).sort().join("|")}function He(e){const t=R(e);if(t)return t;if(typeof e.message=="string"){const r=B(e.message);return r?S(r):null}if(typeof e.message=="object"&&e.message!==null){const r=R(e.message);return r||Z(e.message.content)}return Z(e.content)}function Ke(e){return De(e)}function ht(e,t,r){const s=typeof t.timestamp=="string"?t.timestamp:"";return`${e}-${s}-${r}`}function yt(e,t){const r=new Map;for(const o of t){const i=Y(o);r.set(i,(r.get(i)??0)+1)}const s=[];for(let o=e.length-1;o>=0;o-=1){const i=e[o];if(!i)continue;const a=Y(i),c=r.get(a)??0;if(c>0){r.set(a,c-1);continue}s.push({...i})}return[...s.reverse(),...t.map(o=>({...o}))].map((o,i)=>({event:o,order:i})).sort((o,i)=>{const a=G(o.event),c=G(i.event);return a!==null&&c!==null&&a!==c?a-c:o.order-i.order}).map(o=>o.event)}function bt(e,t){const r=X(t);return e.some(s=>X(s)===r)?e:[...e,{...t}]}function jt(e,t){const r=new Map;for(const s of t){const o=_(s);if(!o)continue;const i=b(o);r.set(i,(r.get(i)??0)+1)}return e.filter(s=>{const o=b(s.content),i=r.get(o)??0;return i<=0?!0:(r.set(o,i-1),!1)})}function Nt(e,t){const r=b(t),s=e.findIndex(o=>b(o.content)===r);return s===-1?e:e.filter((o,i)=>i!==s)}function wt(e,t){const r=b(t);return e.some(s=>{const o=_(s);return o!==null&&b(o)===r})}function kt(e){const t=[];let r=null;for(const s of e){if(Ve(s)){r=null,t.push(s);continue}const o=Ke(s)??He(s);o&&o===r||(t.push(s),o&&(r=o))}return t}function A({payload:e,disabled:t=!1,bypassEnabled:r=!1,onBypassChange:s,onSubmit:o}){const[i,a]=g.useState(()=>r?Be(e):e.questions.map(()=>[])),[c,u]=g.useState(!1),[d,m]=g.useState(!1);g.useEffect(()=>{r&&a(l=>l.map((f,y)=>{var p;return f.length>0?f:(p=e.questions[y])!=null&&p.options.length?[0]:[]}))},[r,e]);const x=qe(e,i)&&!t&&!c&&!d&&!!o,j=(l,f)=>{t||d||c||a(y=>y.map((p,N)=>{if(N!==l)return p;const w=e.questions[N];return w?w.multiSelect?p.includes(f)?p.filter(q=>q!==f):[...p,f].sort((q,se)=>q-se):[f]:p}))},H=async()=>{if(!x||!o)return;u(!0);const l=await o(ze(e,i));u(!1),l&&m(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-primary/20 bg-primary/5 p-4 shadow-[0_24px_80px_-60px_hsl(var(--primary)/0.9)]",children:[n.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:n.jsx(fe,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-primary/80",children:"Ask User Question"}),n.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:"Select the answer you want to send back to the agent."})]})]}),n.jsxs(P,{type:"button",variant:r?"secondary":"outline",size:"sm",onClick:()=>s==null?void 0:s(!r),className:"rounded-[14px]",children:[n.jsx(ke,{className:"h-4 w-4"}),r?"Bypass on":"Bypass future questions"]})]}),n.jsx("div",{className:"mt-4 space-y-4",children:e.questions.map((l,f)=>{const y=i[f]??[];return n.jsxs("div",{className:"space-y-3 rounded-[20px] border border-border/60 bg-background/75 p-4",children:[n.jsxs("div",{children:[l.header&&n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-muted-foreground",children:l.header}),n.jsx("div",{className:"mt-1 text-sm font-medium leading-6 text-foreground",children:l.question}),n.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:l.multiSelect?"Select one or more options.":"Select one option."})]}),n.jsx("div",{className:"space-y-2",children:l.options.map((p,N)=>{const w=y.includes(N);return n.jsxs("button",{type:"button",onClick:()=>j(f,N),disabled:t||c||d,"aria-pressed":w,className:E("flex w-full items-start gap-3 rounded-[18px] border px-4 py-3 text-left transition-colors",w?"border-primary/50 bg-primary/10 text-foreground":"border-border/60 bg-background/80 text-foreground hover:border-primary/30 hover:bg-primary/5"),children:[n.jsx("span",{className:E("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",w?"border-primary bg-primary text-primary-foreground":"border-border/70 bg-background text-transparent"),children:n.jsx(T,{className:"h-3.5 w-3.5"})}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-sm font-medium leading-5",children:p.label}),p.description&&n.jsx("span",{className:"mt-1 block text-xs leading-5 text-muted-foreground",children:p.description})]})]},`${p.label}-${N}`)})})]},`${l.header??"question"}-${f}`)})}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:r?"Bypass is enabled. New question cards will default to the first option.":"Enable bypass if you want future question cards to preselect the first option."}),n.jsx(P,{type:"button",onClick:()=>void H(),disabled:!x,className:"rounded-[16px] px-5",children:d?"Sent":c?"Sending...":e.questions.length>1?"Send answers":"Send answer"})]})]})}function Xe({payload:e,disabled:t=!1,onSubmit:r}){const[s,o]=g.useState(null),[i,a]=g.useState(!1),c=!t&&!i&&!!r,u=async d=>{if(!c||!r)return;o(d);const m=await r(We(e,d));o(null),m&&a(!0)};return n.jsxs("div",{className:"rounded-[24px] border border-amber-500/25 bg-amber-500/5 p-4 shadow-[0_24px_80px_-60px_rgba(245,158,11,0.8)]",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-amber-500/25 bg-amber-500/10 text-amber-600 shadow-sm dark:text-amber-400",children:n.jsx(Ne,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.22em] text-amber-700/80 dark:text-amber-300/80",children:"Permission Request"}),n.jsx("div",{className:"mt-1 space-y-3",children:e.requests.map((d,m)=>n.jsxs("div",{className:"rounded-[18px] border border-border/60 bg-background/75 px-4 py-3",children:[n.jsx("div",{className:"text-sm font-medium leading-6 text-foreground",children:d.summary}),(d.toolName||d.target)&&n.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[11px] uppercase tracking-[0.18em] text-muted-foreground",children:[n.jsx("span",{children:d.toolName}),d.target&&n.jsx("span",{className:"font-mono normal-case tracking-normal",children:d.target})]})]},`${d.toolUseId??d.toolName}-${m}`))})]})]}),n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-end gap-2",children:[n.jsxs(P,{type:"button",variant:"outline",onClick:()=>void u("deny"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(oe,{className:"h-4 w-4"}),i?"Sent":s==="deny"?"Sending...":"Deny"]}),n.jsxs(P,{type:"button",onClick:()=>void u("approve"),disabled:!c||s!==null,className:"rounded-[14px]",children:[n.jsx(T,{className:"h-4 w-4"}),i?"Sent":s==="approve"?"Sending...":"Approve"]})]})]})}function _t({event:e,questionBypassEnabled:t=!1,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o=!1}){const i=e.type,a=V(e),c=O(e);if(a)return n.jsx(v,{children:n.jsx(Xe,{payload:a,onSubmit:s,disabled:o})});if(c)return n.jsx(v,{children:n.jsx(A,{payload:c,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o})});if(i==="user"){const u=Ye(e),d=u.filter(x=>x.type==="tool_result");if(d.length>0&&u.every(x=>x.type==="tool_result"))return n.jsx(v,{children:d.map((x,j)=>n.jsx(ne,{block:x,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},j))});const m=_(e);return m?n.jsx(tt,{content:m}):null}return i==="assistant"?n.jsx(rt,{event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o}):null}function Ye(e){const t=e.message,r=t==null?void 0:t.content;if(Array.isArray(r))return r.filter(o=>typeof o=="object"&&o!==null);const s=e.content;return Array.isArray(s)?s.filter(o=>typeof o=="object"&&o!==null):[]}function z(e){var r;const t=e.replace(/\r\n/g,`
|
|
49
49
|
`).split(`
|
|
50
50
|
`);for(;t.length>0&&((r=t[0])==null?void 0:r.trim())==="";)t.shift();return t.join(`
|
|
51
|
-
`)}const Ge=/\b((?:https?:\/\/|www\.)[^\s<>()[\]{}'"`]+[^\s<>()[\]{}'"`.,;:!?])/gi;function te({text:e,className:t=""}){const r=[];let s=0;for(const o of e.matchAll(Ge)){const i=o.index??0;i>s&&r.push({kind:"text",value:e.slice(s,i)});const a=o[0],c=a.startsWith("www.")?`https://${a}`:a;r.push({kind:"link",value:a,href:c}),s=i+a.length}return s<e.length&&r.push({kind:"text",value:e.slice(s)}),r.length===0&&r.push({kind:"text",value:e}),n.jsx("div",{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${t}`,children:r.map((o,i)=>o.kind==="link"?n.jsx("a",{href:o.href,target:"_blank",rel:"noreferrer noopener",className:"underline decoration-current/40 underline-offset-2 hover:decoration-current",onClick:a=>a.stopPropagation(),children:o.value},i):n.jsx("span",{children:o.value},i))})}function re({text:e,className:t=""}){const[r,s]=g.useState(!1);if(!e)return null;const o=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)}catch{}};return n.jsx("button",{type:"button",onClick:o,"aria-label":r?"Copied":"Copy message",className:`flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/60 bg-background/86 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-all hover:-translate-y-px hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}async function Ze(e){let r=await(await fetch(e)).blob();r.type!=="image/png"&&(r=await Qe(r)),await navigator.clipboard.write([new ClipboardItem({[r.type]:r})])}async function Qe(e){const t=await createImageBitmap(e),r=document.createElement("canvas");r.width=t.width,r.height=t.height;const s=r.getContext("2d");if(!s)throw new Error("canvas 2d context unavailable");return s.drawImage(t,0,0),await new Promise((o,i)=>{r.toBlob(a=>a?o(a):i(new Error("toBlob failed")),"image/png")})}function et({dataUrl:e,className:t=""}){const[r,s]=g.useState(!1),o=async i=>{i.stopPropagation();try{await Ze(e),s(!0),setTimeout(()=>s(!1),1500)}catch(a){console.error("copy image failed",a)}};return n.jsx("button",{type:"button",onClick:o,"aria-label":r?"Copied":"Copy image",className:`flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/60 bg-background/86 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-all hover:-translate-y-px hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}function tt({content:e}){const t=Te(e),r=e.filter(s=>s.type==="image");return n.jsx("div",{className:"animate-message-rise flex justify-end",children:n.jsxs("div",{className:"group relative flex max-w-[88%] items-start gap-3",children:[n.jsx(re,{text:t,className:"absolute -left-8 top-7"}),n.jsxs("div",{className:"flex min-w-0 flex-col items-end gap-1",children:[n.jsx("div",{className:"pr-1 text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"You"}),n.jsxs("div",{className:"space-y-1 rounded-[24px] rounded-br-[9px] border border-primary/20 bg-primary px-3.5 py-2.5 text-[12px] leading-[18px] text-primary-foreground shadow-[0_22px_72px_-44px_hsl(var(--primary)/0.95)]",children:[t&&n.jsx(te,{text:t}),r.length>0&&n.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((s,o)=>{const i=Me(s);return n.jsxs("div",{className:"relative",children:[n.jsx("img",{src:i,alt:s.filename??`attachment ${o+1}`,className:"max-h-72 w-full rounded-2xl border border-primary-foreground/15 object-cover"}),n.jsx(et,{dataUrl:i,className:"absolute right-2 top-2"})]},`${s.filename??"image"}-${o}`)})})]})]}),n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:n.jsx(Se,{className:"h-4 w-4"})})]})})}function v({children:e}){return n.jsx("div",{className:"animate-message-rise flex justify-start",children:n.jsxs("div",{className:"flex max-w-[92%] items-start gap-3",children:[n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-border/70 bg-muted/70 text-muted-foreground shadow-sm",children:n.jsx(ie,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 space-y-2",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"Agent"}),e]})]})})}function rt({event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const i=e.message;if(!i)return null;const a=O(i);if(a)return n.jsx(v,{children:n.jsx(A,{payload:a,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o})});const c=i.content;if(!c||!Array.isArray(c))return null;const u=new Set,d=c.filter(l=>l.type==="text").map(l=>({...l,text:
|
|
51
|
+
`)}const Ge=/\b((?:https?:\/\/|www\.)[^\s<>()[\]{}'"`]+[^\s<>()[\]{}'"`.,;:!?])/gi;function te({text:e,className:t=""}){const r=[];let s=0;for(const o of e.matchAll(Ge)){const i=o.index??0;i>s&&r.push({kind:"text",value:e.slice(s,i)});const a=o[0],c=a.startsWith("www.")?`https://${a}`:a;r.push({kind:"link",value:a,href:c}),s=i+a.length}return s<e.length&&r.push({kind:"text",value:e.slice(s)}),r.length===0&&r.push({kind:"text",value:e}),n.jsx("div",{className:`whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${t}`,children:r.map((o,i)=>o.kind==="link"?n.jsx("a",{href:o.href,target:"_blank",rel:"noreferrer noopener",className:"underline decoration-current/40 underline-offset-2 hover:decoration-current",onClick:a=>a.stopPropagation(),children:o.value},i):n.jsx("span",{children:o.value},i))})}function re({text:e,className:t=""}){const[r,s]=g.useState(!1);if(!e)return null;const o=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)}catch{}};return n.jsx("button",{type:"button",onClick:o,"aria-label":r?"Copied":"Copy message",className:`flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/60 bg-background/86 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-all hover:-translate-y-px hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}async function Ze(e){let r=await(await fetch(e)).blob();r.type!=="image/png"&&(r=await Qe(r)),await navigator.clipboard.write([new ClipboardItem({[r.type]:r})])}async function Qe(e){const t=await createImageBitmap(e),r=document.createElement("canvas");r.width=t.width,r.height=t.height;const s=r.getContext("2d");if(!s)throw new Error("canvas 2d context unavailable");return s.drawImage(t,0,0),await new Promise((o,i)=>{r.toBlob(a=>a?o(a):i(new Error("toBlob failed")),"image/png")})}function et({dataUrl:e,className:t=""}){const[r,s]=g.useState(!1),o=async i=>{i.stopPropagation();try{await Ze(e),s(!0),setTimeout(()=>s(!1),1500)}catch(a){console.error("copy image failed",a)}};return n.jsx("button",{type:"button",onClick:o,"aria-label":r?"Copied":"Copy image",className:`flex h-6 w-6 items-center justify-center rounded-[10px] border border-border/60 bg-background/86 text-muted-foreground opacity-0 shadow-sm backdrop-blur transition-all hover:-translate-y-px hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100 ${t}`,children:r?n.jsx(T,{className:"h-3 w-3 text-emerald-500"}):n.jsx(Q,{className:"h-3 w-3"})})}function tt({content:e}){const t=Te(e),r=e.filter(s=>s.type==="image");return n.jsx("div",{className:"animate-message-rise flex justify-end",children:n.jsxs("div",{className:"group relative flex max-w-[88%] items-start gap-3",children:[n.jsx(re,{text:t,className:"absolute -left-8 top-7"}),n.jsxs("div",{className:"flex min-w-0 flex-col items-end gap-1",children:[n.jsx("div",{className:"pr-1 text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"You"}),n.jsxs("div",{className:"space-y-1 rounded-[24px] rounded-br-[9px] border border-primary/20 bg-primary px-3.5 py-2.5 text-[12px] leading-[18px] text-primary-foreground shadow-[0_22px_72px_-44px_hsl(var(--primary)/0.95)]",children:[t&&n.jsx(te,{text:t}),r.length>0&&n.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((s,o)=>{const i=Me(s);return n.jsxs("div",{className:"relative",children:[n.jsx("img",{src:i,alt:s.filename??`attachment ${o+1}`,className:"max-h-72 w-full rounded-2xl border border-primary-foreground/15 object-cover"}),n.jsx(et,{dataUrl:i,className:"absolute right-2 top-2"})]},`${s.filename??"image"}-${o}`)})})]})]}),n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-primary/20 bg-primary/10 text-primary shadow-sm",children:n.jsx(Se,{className:"h-4 w-4"})})]})})}function v({children:e}){return n.jsx("div",{className:"animate-message-rise flex justify-start",children:n.jsxs("div",{className:"flex max-w-[92%] items-start gap-3",children:[n.jsx("div",{className:"mt-6 flex h-8 w-8 shrink-0 items-center justify-center rounded-[14px] border border-border/70 bg-muted/70 text-muted-foreground shadow-sm",children:n.jsx(ie,{className:"h-4 w-4"})}),n.jsxs("div",{className:"min-w-0 space-y-2",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.28em] text-muted-foreground",children:"Agent"}),e]})]})})}function rt({event:e,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o}){const i=e.message;if(!i)return null;const a=O(i);if(a)return n.jsx(v,{children:n.jsx(A,{payload:a,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o})});const c=i.content;if(!c||!Array.isArray(c))return null;const u=new Set,d=c.filter(l=>l.type==="text").map(l=>({...l,text:z(String(l.text??"")),questionPayload:B(z(String(l.text??"")))})).filter(l=>l.text.length>0||l.questionPayload),m=c.filter(l=>l.type==="thinking").map(l=>z(String(l.thinking??""))).filter(Boolean).join(`
|
|
52
52
|
|
|
53
53
|
`),x=c.filter(l=>l.type==="tool_use"),j=c.filter(l=>l.type==="tool_result");return d.length>0||m.length>0||x.length>0||j.length>0?n.jsxs(v,{children:[m.length>0&&n.jsx(it,{text:m}),d.map((l,f)=>{if(l.questionPayload){const y=S(l.questionPayload);return u.has(y)?null:(u.add(y),n.jsx(A,{payload:l.questionPayload,bypassEnabled:t,onBypassChange:r,onSubmit:s,disabled:o},f))}return n.jsxs("div",{className:"group relative rounded-[24px] rounded-bl-[9px] border border-border/70 bg-card/86 px-3.5 py-2.5 text-[12px] leading-[18px] text-foreground shadow-[0_20px_70px_-58px_rgba(15,23,42,0.75)] backdrop-blur-sm dark:shadow-[0_20px_70px_-58px_rgba(0,0,0,0.95)]",children:[n.jsx(re,{text:l.text,className:"absolute right-2 top-2"}),n.jsx(te,{text:l.text})]},f)}),x.map((l,f)=>n.jsx(at,{block:l,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},f)),j.map((l,f)=>n.jsx(ne,{block:l,renderedQuestionSignatures:u,questionBypassEnabled:t,onQuestionBypassChange:r,onSubmitQuestionResponse:s,questionResponseDisabled:o},f))]}):null}function nt(e){return e.replace(/\s+/g," ").trim()}function k(e,t=132){const r=nt(e);return r?r.length>t?`${r.slice(0,t-3)}...`:r:""}function W(e,t=84){if(typeof e=="string")return k(e,t);if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const r=e.slice(0,3).map(s=>W(s,28)).filter(Boolean).join(", ");return k(r||JSON.stringify(e),t)}if(typeof e=="object"&&e!==null){const r=Object.entries(e).slice(0,3).map(([s,o])=>`${s}: ${W(o,32)}`).join(" · ");return k(r||JSON.stringify(e),t)}return""}function st(e){if(!e)return"No input";const t=Object.entries(e).slice(0,4).map(([r,s])=>`${r}: ${W(s,40)}`).filter(r=>r.trim().length>0).join(" · ");return k(t||JSON.stringify(e),156)||"No input"}function ot({expanded:e}){return n.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-[12px] border border-border/60 bg-background/70 px-2 py-1 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground shadow-sm",children:[e?"Less":"More",e?n.jsx(ae,{className:"h-3 w-3"}):n.jsx(ce,{className:"h-3 w-3"})]})}function D({title:e,preview:t,icon:r,children:s,accentClassName:o,previewClassName:i="font-mono text-[11px] text-muted-foreground/90"}){const[a,c]=g.useState(!1);return n.jsxs("div",{className:`overflow-hidden rounded-[20px] border border-border/60 shadow-sm ${o}`,children:[n.jsxs("button",{type:"button",onClick:()=>c(u=>!u),className:"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors hover:bg-background/30",children:[n.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-[12px] border border-border/60 bg-background/70 text-muted-foreground",children:r}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:e})}),n.jsx("div",{className:`mt-1 whitespace-pre-wrap break-words text-[12px] leading-5 ${i}`,children:t})]}),n.jsx(ot,{expanded:a})]}),a&&n.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:s})]})}function it({text:e}){const t=k(e,156);return n.jsx(D,{title:"Thinking",preview:t,icon:n.jsx(ue,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/35",previewClassName:"text-[12px] leading-5 text-muted-foreground/90",children:n.jsx("div",{className:"whitespace-pre-wrap text-[13px] leading-5 text-muted-foreground/90",children:e})})}function at({block:e,renderedQuestionSignatures:t,questionBypassEnabled:r,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:i}){const a=String(e.name??"tool"),c=e.input,u=O(e);if(u){const m=S(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),n.jsx(A,{payload:u,bypassEnabled:r,onBypassChange:s,onSubmit:o,disabled:i}))}const d=st(c);if(a==="TodoWrite"){const m=ct(c==null?void 0:c.todos);if(m.length>0)return n.jsx(lt,{todos:m})}return n.jsx(D,{title:`Tool: ${a}`,preview:d,icon:n.jsx(ee,{className:"h-3.5 w-3.5"}),accentClassName:"bg-muted/25",children:n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:JSON.stringify(c??{},null,2)})})}function ne({block:e,renderedQuestionSignatures:t,questionBypassEnabled:r,onQuestionBypassChange:s,onSubmitQuestionResponse:o,questionResponseDisabled:i}){const a=e.content,c=typeof a=="string"?a:Array.isArray(a)?a.map(m=>String(m.text??"")).join(`
|
|
54
54
|
`):"";if(!c)return null;const u=B(c);if(u){const m=S(u);return t!=null&&t.has(m)?null:(t==null||t.add(m),n.jsx(A,{payload:u,bypassEnabled:r,onBypassChange:s,onSubmit:o,disabled:i}))}const d=k(c,156);return n.jsx(D,{title:"Result",preview:d,icon:n.jsx(ee,{className:"h-3.5 w-3.5"}),accentClassName:"bg-background/65",children:n.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:c})})}function ct(e){return Array.isArray(e)?e.map(t=>{if(typeof t!="object"||t===null)return null;const r=t,s=typeof r.content=="string"?r.content:"";if(!s)return null;const o=typeof r.activeForm=="string"?r.activeForm:s,i=typeof r.status=="string"?r.status:"pending";return{content:s,activeForm:o,status:i==="completed"||i==="in_progress"?i:"pending"}}).filter(t=>t!==null):[]}function lt({todos:e}){const t=e.filter(o=>o.status==="completed").length,r=e.length,s=e.find(o=>o.status==="in_progress");return n.jsxs("div",{className:"overflow-hidden rounded-[20px] border border-border/60 bg-muted/20 shadow-sm",children:[n.jsxs("div",{className:"flex items-center gap-3 border-b border-border/50 px-4 py-3",children:[n.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[12px] border border-border/60 bg-background/70 text-muted-foreground",children:n.jsx(he,{className:"h-3.5 w-3.5"})}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-muted-foreground",children:"Todos"}),n.jsx("div",{className:"mt-0.5 truncate text-[12px] leading-5 text-muted-foreground/90",children:s?s.activeForm:r===0?"No items":t===r?"All complete":"Up next"})]}),n.jsxs("div",{className:"shrink-0 rounded-[11px] border border-border/60 bg-background/70 px-2 py-0.5 font-mono text-[10px] tracking-wide text-muted-foreground",children:[t,"/",r]})]}),n.jsx("ul",{className:"divide-y divide-border/40",children:e.map((o,i)=>n.jsxs("li",{className:"flex items-start gap-3 px-4 py-2.5",children:[n.jsx(dt,{status:o.status}),n.jsx("span",{className:o.status==="completed"?"text-[13px] leading-5 text-muted-foreground line-through decoration-muted-foreground/60":o.status==="in_progress"?"text-[13px] font-medium leading-5 text-foreground":"text-[13px] leading-5 text-foreground/85",children:o.status==="in_progress"?o.activeForm:o.content})]},`${i}-${o.content}`))})]})}function dt({status:e}){return e==="completed"?n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-emerald-500/15 text-emerald-500 dark:text-emerald-400",children:n.jsx(T,{className:"h-3 w-3"})}):e==="in_progress"?n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-primary",children:n.jsx(be,{className:"h-3.5 w-3.5 animate-spin"})}):n.jsx("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground/60",children:n.jsx(xe,{className:"h-3 w-3"})})}function St({label:e,value:t}){return n.jsxs("div",{className:"min-w-[5.5rem] flex-1 rounded-[16px] border border-border/60 bg-background/52 px-2.5 py-2 shadow-sm",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),n.jsx("div",{className:"mt-0.5 text-sm font-semibold tracking-tight text-foreground",children:t})]})}function $t({label:e}){return n.jsx("div",{className:"flex h-64 items-center justify-center text-sm text-muted-foreground",children:e})}function vt({label:e,value:t,mono:r,action:s}){return n.jsxs("div",{className:"grid grid-cols-[4.25rem,minmax(0,1fr)] items-start gap-2",children:[n.jsx("span",{className:"pt-0.5 text-[10px] font-medium uppercase tracking-[0.18em] text-muted-foreground",children:e}),n.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[n.jsx("span",{className:E("min-w-0 flex-1 break-all text-[12px] text-foreground",r&&"font-mono text-[11px] leading-5"),children:t}),s]})]})}function Ct({label:e,value:t,mono:r}){return n.jsxs("div",{className:"rounded-[15px] border border-border/60 bg-background/62 px-2.5 py-2 shadow-sm",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:e}),n.jsx("div",{className:E("mt-0.5 text-[12px] font-medium text-foreground",r&&"font-mono text-[11px]"),children:t})]})}function At({capabilities:e,action:t}){return n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3",children:[n.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[n.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.22em] text-muted-foreground",children:"Capabilities"}),n.jsx("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px]",children:e.length>0?e.map(r=>n.jsx(le,{variant:"secondary",className:"rounded-[11px]",children:r},r)):n.jsx("span",{className:"text-[12px] text-muted-foreground",children:"None declared"})})]}),t&&n.jsx("div",{className:"shrink-0 self-start",children:t})]})}export{_t as C,St as D,vt as I,be as L,Ct as M,$t as T,ht as a,mt as b,At as c,jt as d,xt as e,bt as f,_ as g,Nt as h,kt as i,ft as j,pt as k,wt as l,yt as m,U as n,gt as r,Me as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,
|
|
1
|
+
import{r as l,b8 as P,b3 as O,j as e,B as g,b as N,z as $,o as T}from"./index-Bg0PqgJi.js";import{G as R}from"./DashboardPage-DaZ-EQZ4.js";import{F as _}from"./file-BXP_hlLG.js";import{F as B}from"./folder-B3put-Ay.js";import"./DashboardShared-CKWmFD7i.js";import"./input-DH4KoLjb.js";function D(r,t){if(!(r!=null&&r.trim()))return[];const s=r.split(`
|
|
2
2
|
`),n=[];let a=[];const d=()=>{if(a.length===0)return;const c=a.join(`
|
|
3
|
-
`).trim();if(!c){a=[];return}const i=
|
|
3
|
+
`).trim();if(!c){a=[];return}const i=A(a);if(!i){a=[];return}n.push({id:`${t}:${i}`,path:i,section:t,patch:c}),a=[]};for(const c of s)c.startsWith("diff --git ")&&a.length>0&&d(),a.push(c);return d(),n}function I(r){const t=[];for(const s of[...r].sort((n,a)=>n.path.localeCompare(a.path))){const n=s.path.split("/").filter(Boolean);let a=t,d="";n.forEach((c,i)=>{d=d?`${d}/${c}`:c;const h=i===n.length-1;let u=a.find(b=>b.name===c);u||(u=h?{type:"file",name:c,path:d,item:s}:{type:"folder",name:c,path:d,children:[]},a.push(u)),h||(u.children??(u.children=[]),a=u.children)})}return t}function G(r){const t=[];let s="";for(const n of r.split("/").filter(Boolean).slice(0,-1))s=s?`${s}/${n}`:n,t.push(s);return t}function z(r){return r.filter(t=>t&&!t.endsWith("/")).map(t=>({id:`untracked:${t}`,path:t,section:"untracked"}))}function A(r){var d,c;const t=(d=r.find(i=>i.startsWith("+++ ")))==null?void 0:d.slice(4).trim();if(t&&t!=="/dev/null")return w(t);const s=(c=r.find(i=>i.startsWith("--- ")))==null?void 0:c.slice(4).trim();if(s&&s!=="/dev/null")return w(s);const n=r.find(i=>i.startsWith("diff --git "));if(!n)return null;const a=n.match(/^diff --git a\/(.+?) b\/(.+)$/);return a?w(a[2]||a[1]||""):null}function w(r){return r.replace(/^[ab]\//,"")}const y={staged:"Staged",unstaged:"Unstaged",untracked:"Untracked"};function se({taskId:r}){const[t,s]=l.useState(null),[n,a]=l.useState(!0),[d,c]=l.useState(null),[i,h]=l.useState(null),[u,b]=l.useState(null),[L,v]=l.useState(!1),[M,k]=l.useState(null),S=l.useCallback(async()=>{a(!0),c(null),s(null);try{const o=await P(r);s(o)}catch(o){c(o instanceof Error?o.message:"Failed to load diff")}finally{a(!1)}},[r]);l.useEffect(()=>{S()},[S]);const F=l.useMemo(()=>D(t==null?void 0:t.staged,"staged"),[t==null?void 0:t.staged]),E=l.useMemo(()=>D(t==null?void 0:t.unstaged,"unstaged"),[t==null?void 0:t.unstaged]),C=l.useMemo(()=>z((t==null?void 0:t.untrackedFiles)??[]),[t==null?void 0:t.untrackedFiles]),j=l.useMemo(()=>[{section:"staged",items:F},{section:"unstaged",items:E},{section:"untracked",items:C}],[F,E,C]),p=l.useMemo(()=>j.flatMap(o=>o.items),[j]),f=l.useMemo(()=>p.find(o=>o.id===i)??p[0]??null,[p,i]);return l.useEffect(()=>{var o;(!i||!p.some(m=>m.id===i))&&h(((o=p[0])==null?void 0:o.id)??null)},[p,i]),l.useEffect(()=>{if(b(null),k(null),v(!1),!f||f.section!=="untracked")return;if(f.path.endsWith("/")){k("This untracked path is a directory. Open the Files tab to inspect its contents.");return}let o=!1;return v(!0),O(r,f.path).then(m=>{o||b(m)}).catch(m=>{o||k(m instanceof Error?m.message:"Failed to load file content")}).finally(()=>{o||v(!1)}),()=>{o=!0}},[f,r]),n?e.jsx(x,{tone:"muted",children:"Loading diff..."}):d?e.jsx(x,{tone:"destructive",children:d}):t!=null&&t.available?p.length>0?e.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-border/60 bg-background/30 lg:border-b-0 lg:border-r",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Repository diff"}),e.jsx("div",{className:"mt-1.5 flex items-start justify-between gap-2",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] font-semibold text-foreground",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:t.branch??"detached HEAD"})]}),t.repoRoot&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-muted-foreground",children:t.repoRoot})]})}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:j.map(o=>e.jsxs(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:[y[o.section]," ",o.items.length]},o.section))})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:e.jsx("div",{className:"space-y-1.5",children:j.map(({section:o,items:m})=>e.jsx(J,{section:o,items:m,selectedId:(f==null?void 0:f.id)??null,onSelect:h},o))})})]}),e.jsx("section",{className:"min-h-0 flex flex-col bg-card/10",children:f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:y[f.section]}),f.section==="untracked"?e.jsx(g,{variant:"secondary",className:"rounded-full text-[10px]",children:"File content"}):e.jsx(g,{variant:"secondary",className:"rounded-full text-[10px]",children:"Diff patch"})]}),e.jsx("div",{className:"mt-1.5 break-all font-mono text-[10px] text-muted-foreground",children:f.path})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2.5",children:f.section==="untracked"?e.jsx(q,{loading:L,error:M,content:u}):e.jsx(H,{patch:f.patch??""})})]}):e.jsx(x,{tone:"muted",children:"Select a file to inspect."})})]}):e.jsx(x,{tone:"muted",children:"Working tree is clean."}):e.jsx(x,{tone:"muted",children:"Task working directory is not inside a Git repository."})}function J({section:r,items:t,selectedId:s,onSelect:n}){const a=l.useMemo(()=>I(t),[t]),d=l.useMemo(()=>t.find(u=>u.id===s)??null,[t,s]),c=l.useMemo(()=>new Set(d?G(d.path):[]),[d]),[i,h]=l.useState(!0);return e.jsxs("section",{className:"rounded-[16px] border border-border/60 bg-background/35",children:[e.jsxs("button",{type:"button",onClick:()=>h(u=>!u),"aria-expanded":i,className:N("flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-background/55",i?"border-b border-border/60":""),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[i?e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(T,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-[12px] font-medium text-foreground",children:y[r]})]}),e.jsx(g,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:t.length})]}),i&&e.jsx("div",{className:"p-1.5",children:a.length>0?e.jsx("div",{className:"space-y-0.5",children:a.map(u=>e.jsx(U,{node:u,depth:0,selectedId:s,expandedAncestorPaths:c,onSelect:n},`${r}:${u.path}`))}):e.jsx("div",{className:"rounded-[12px] border border-dashed border-border/70 bg-background/30 px-2.5 py-1.5 text-[11px] text-muted-foreground",children:"No files."})})]})}function U({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){var d;return r.type==="folder"?e.jsx(V,{node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}):e.jsxs("button",{type:"button",onClick:()=>{r.item&&a(r.item.id)},className:N("flex w-full cursor-pointer items-center gap-1.5 rounded-[10px] px-1.5 py-1 text-left transition-colors",((d=r.item)==null?void 0:d.id)===s?"bg-primary/10 text-foreground":"text-foreground/90 hover:bg-background/55"),style:{paddingLeft:`${t*12+6}px`},children:[e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"truncate text-[12px]",children:r.name})]})}function V({node:r,depth:t,selectedId:s,expandedAncestorPaths:n,onSelect:a}){const[d,c]=l.useState(!0);return l.useEffect(()=>{n.has(r.path)&&c(!0)},[n,r.path]),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>c(i=>!i),"aria-expanded":d,className:"flex w-full cursor-pointer select-none items-center gap-1.5 rounded-[10px] px-1.5 py-1 text-left text-[12px] text-muted-foreground transition-colors hover:bg-background/55 hover:text-foreground",style:{paddingLeft:`${t*12+6}px`},children:[d?e.jsx($,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(T,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(B,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:r.name})]}),d&&e.jsx("div",{className:"space-y-0.5",children:(r.children??[]).map(i=>e.jsx(U,{node:i,depth:t+1,selectedId:s,expandedAncestorPaths:n,onSelect:a},i.path))})]})}function H({patch:r}){const t=r.split(`
|
|
4
4
|
`);return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/55",children:[e.jsxs("div",{className:"border-b border-border/60 px-3 py-2",children:[e.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"File diff"}),e.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[t.length," lines"]})]}),e.jsx("div",{className:"font-mono text-[11px] leading-5",children:t.map((s,n)=>e.jsxs("div",{className:N("grid grid-cols-[44px_minmax(0,1fr)] gap-3 px-3 py-0.5",K(s)),children:[e.jsx("span",{className:"select-none text-right text-muted-foreground/55",children:n+1}),e.jsx("span",{className:"whitespace-pre-wrap break-all text-foreground",children:s||" "})]},`${n}-${s}`))})]})}function q({loading:r,error:t,content:s}){if(r)return e.jsx(x,{tone:"muted",children:"Loading file content..."});if(t)return e.jsx(x,{tone:"destructive",children:t});if(!s)return e.jsx(x,{tone:"muted",children:"Select an untracked file to preview its content."});if(s.kind==="image"){const n=s.content?`data:${s.mimeType};base64,${s.content}`:s.downloadUrl;return n?e.jsx("div",{className:"flex min-h-[20rem] items-center justify-center rounded-[28px] border border-border/60 bg-background/55 p-4",children:e.jsx("img",{src:n,alt:s.path,className:"max-h-full max-w-full rounded-[20px] object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):e.jsx(x,{tone:"muted",children:"Image preview is not available."})}if(s.kind==="pdf"&&s.downloadUrl)return e.jsx("div",{className:"h-full min-h-[24rem] overflow-hidden rounded-[28px] border border-border/60 bg-background/55",children:e.jsx("iframe",{src:s.downloadUrl,title:s.path,className:"h-full w-full border-0"})});if(s.kind==="json"){let n=s.content;try{n=JSON.stringify(JSON.parse(s.content),null,2)}catch{}return e.jsx(W,{content:n,truncated:s.truncated})}return s.kind==="markdown"||s.kind==="text"||s.kind==="html"?e.jsx(W,{content:s.content,truncated:s.truncated}):e.jsx(x,{tone:"muted",children:"This file cannot be previewed inline."})}function W({content:r,truncated:t}){return e.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background/55",children:[e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap px-3 py-3 font-mono text-[11px] leading-5 text-foreground",children:r}),t&&e.jsx("div",{className:"border-t border-border/60 px-3 py-2 text-[11px] text-muted-foreground",children:"Content truncated. Open the Files tab to inspect the full artifact."})]})}function x({children:r,tone:t}){return e.jsx("div",{className:N("flex h-full min-h-[12rem] items-center justify-center rounded-[20px] text-[12px]",t==="muted"?"text-muted-foreground":"text-destructive"),children:r})}function K(r){return r.startsWith("@@")?"bg-sky-500/10":r.startsWith("+")&&!r.startsWith("+++")?"bg-emerald-500/10":r.startsWith("-")&&!r.startsWith("---")?"bg-destructive/10":r.startsWith("diff ")||r.startsWith("index ")||r.startsWith("---")||r.startsWith("+++")?"bg-muted/45":""}export{se as DiffTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Ze,
|
|
1
|
+
import{c as Ze,b2 as Dt,j as y,r as re,b3 as Ar,b4 as Pr,b5 as zr,B as rn,i as Me,o as jr,b as Te}from"./index-Bg0PqgJi.js";import{F as Lr}from"./folder-B3put-Ay.js";import{F as Fr}from"./file-BXP_hlLG.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -31,5 +31,5 @@ import{c as Ze,b1 as Dt,j as y,r as re,b2 as Ar,b3 as Pr,b4 as zr,B as rn,i as M
|
|
|
31
31
|
`});++r<e.length;)r&&t.push({type:"text",value:`
|
|
32
32
|
`}),t.push(e[r]);return n&&e.length>0&&t.push({type:"text",value:`
|
|
33
33
|
`}),t}function It(e){let n=0,t=e.charCodeAt(n);for(;t===9||t===32;)n++,t=e.charCodeAt(n);return e.slice(n)}function vt(e,n){const t=Ta(e,n),r=t.one(e,void 0),i=ga(t),l=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&l.children.push({type:"text",value:`
|
|
34
|
-
`},i),l}function ja(e,n){return e&&"run"in e?async function(t,r){const i=vt(t,{file:r,...n});await e.run(i,r)}:function(t,r){return vt(t,{file:r,...e||n})}}function Tt(e){if(e)throw e}var cn,Nt;function La(){if(Nt)return cn;Nt=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):n.call(u)==="[object Array]"},l=function(u){if(!u||n.call(u)!=="[object Object]")return!1;var s=e.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!s&&!f)return!1;var m;for(m in u);return typeof m>"u"||e.call(u,m)},o=function(u,s){t&&s.name==="__proto__"?t(u,s.name,{enumerable:!0,configurable:!0,value:s.newValue,writable:!0}):u[s.name]=s.newValue},a=function(u,s){if(s==="__proto__")if(e.call(u,s)){if(r)return r(u,s).value}else return;return u[s]};return cn=function c(){var u,s,f,m,p,w,C=arguments[0],T=1,k=arguments.length,P=!1;for(typeof C=="boolean"&&(P=C,C=arguments[1]||{},T=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});T<k;++T)if(u=arguments[T],u!=null)for(s in u)f=a(C,s),m=a(u,s),C!==m&&(P&&m&&(l(m)||(p=i(m)))?(p?(p=!1,w=f&&i(f)?f:[]):w=f&&l(f)?f:{},o(C,{name:s,newValue:c(P,w,m)})):typeof m<"u"&&o(C,{name:s,newValue:m}));return C},cn}var Fa=La();const pn=Dt(Fa);function Tn(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Oa(){const e=[],n={run:t,use:r};return n;function t(...i){let l=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(c,...u){const s=e[++l];let f=-1;if(c){o(c);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,s?Da(s,a)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),n}}function Da(e,n){let t;return r;function r(...o){const a=e.length>o.length;let c;a&&o.push(i);try{c=e.apply(this,o)}catch(u){const s=u;if(a&&t)throw s;return i(s)}a||(c&&c.then&&typeof c.then=="function"?c.then(l,i):c instanceof Error?i(c):l(c))}function i(o,...a){t||(t=!0,n(o,...a))}function l(o){i(null,o)}}const se={basename:_a,dirname:Ra,extname:Ma,join:Ba,sep:"/"};function _a(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');$e(e);let t=0,r=-1,i=e.length,l;if(n===void 0||n.length===0||n.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(l){t=i+1;break}}else r<0&&(l=!0,r=i+1);return r<0?"":e.slice(t,r)}if(n===e)return"";let o=-1,a=n.length-1;for(;i--;)if(e.codePointAt(i)===47){if(l){t=i+1;break}}else o<0&&(l=!0,o=i+1),a>-1&&(e.codePointAt(i)===n.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return t===r?r=o:r<0&&(r=e.length),e.slice(t,r)}function Ra(e){if($e(e),e.length===0)return".";let n=-1,t=e.length,r;for(;--t;)if(e.codePointAt(t)===47){if(r){n=t;break}}else r||(r=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function Ma(e){$e(e);let n=e.length,t=-1,r=0,i=-1,l=0,o;for(;n--;){const a=e.codePointAt(n);if(a===47){if(o){r=n+1;break}continue}t<0&&(o=!0,t=n+1),a===46?i<0?i=n:l!==1&&(l=1):i>-1&&(l=-1)}return i<0||t<0||l===0||l===1&&i===t-1&&i===r+1?"":e.slice(i,t)}function Ba(...e){let n=-1,t;for(;++n<e.length;)$e(e[n]),e[n]&&(t=t===void 0?e[n]:t+"/"+e[n]);return t===void 0?".":Ua(t)}function Ua(e){$e(e);const n=e.codePointAt(0)===47;let t=Ha(e,!n);return t.length===0&&!n&&(t="."),t.length>0&&e.codePointAt(e.length-1)===47&&(t+="/"),n?"/"+t:t}function Ha(e,n){let t="",r=0,i=-1,l=0,o=-1,a,c;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||l===1))if(i!==o-1&&l===2){if(t.length<2||r!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(c=t.lastIndexOf("/"),c!==t.length-1){c<0?(t="",r=0):(t=t.slice(0,c),r=t.length-1-t.lastIndexOf("/")),i=o,l=0;continue}}else if(t.length>0){t="",r=0,i=o,l=0;continue}}n&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+e.slice(i+1,o):t=e.slice(i+1,o),r=o-i-1;i=o,l=0}else a===46&&l>-1?l++:l=-1}return t}function $e(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Va={cwd:qa};function qa(){return"/"}function Nn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function $a(e){if(typeof e=="string")e=new URL(e);else if(!Nn(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Wa(e)}function Wa(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const n=e.pathname;let t=-1;for(;++t<n.length;)if(n.codePointAt(t)===37&&n.codePointAt(t+1)===50){const r=n.codePointAt(t+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(n)}const fn=["history","path","basename","stem","extname","dirname"];class xr{constructor(n){let t;n?Nn(n)?t={path:n}:typeof n=="string"||Ya(n)?t={value:n}:t=n:t={},this.cwd="cwd"in t?"":Va.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<fn.length;){const l=fn[r];l in t&&t[l]!==void 0&&t[l]!==null&&(this[l]=l==="history"?[...t[l]]:t[l])}let i;for(i in t)fn.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?se.basename(this.path):void 0}set basename(n){dn(n,"basename"),hn(n,"basename"),this.path=se.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?se.dirname(this.path):void 0}set dirname(n){At(this.basename,"dirname"),this.path=se.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?se.extname(this.path):void 0}set extname(n){if(hn(n,"extname"),At(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=se.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){Nn(n)&&(n=$a(n)),dn(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?se.basename(this.path,this.extname):void 0}set stem(n){dn(n,"stem"),hn(n,"stem"),this.path=se.join(this.dirname||"",n+(this.extname||""))}fail(n,t,r){const i=this.message(n,t,r);throw i.fatal=!0,i}info(n,t,r){const i=this.message(n,t,r);return i.fatal=void 0,i}message(n,t,r){const i=new J(n,t,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function hn(e,n){if(e&&e.includes(se.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+se.sep+"`")}function dn(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function At(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function Ya(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Xa=(function(e){const r=this.constructor.prototype,i=r[e],l=function(){return i.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),Qa={}.hasOwnProperty;class Vn extends Xa{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Oa()}copy(){const n=new Vn;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];n.use(...r)}return n.data(pn(!0,{},this.namespace)),n}data(n,t){return typeof n=="string"?arguments.length===2?(xn("data",this.frozen),this.namespace[n]=t,this):Qa.call(this.namespace,n)&&this.namespace[n]||void 0:n?(xn("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=t.call(n,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const t=Qe(n),r=this.parser||this.Parser;return mn("parse",r),r(String(t),t)}process(n,t){const r=this;return this.freeze(),mn("process",this.parser||this.Parser),gn("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(l,o){const a=Qe(n),c=r.parse(a);r.run(c,a,function(s,f,m){if(s||!f||!m)return u(s);const p=f,w=r.stringify(p,m);Ga(w)?m.value=w:m.result=w,u(s,m)});function u(s,f){s||!f?o(s):l?l(f):t(void 0,f)}}}processSync(n){let t=!1,r;return this.freeze(),mn("processSync",this.parser||this.Parser),gn("processSync",this.compiler||this.Compiler),this.process(n,i),zt("processSync","process",t),r;function i(l,o){t=!0,Tt(l),r=o}}run(n,t,r){Pt(n),this.freeze();const i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?l(void 0,r):new Promise(l);function l(o,a){const c=Qe(t);i.run(n,c,u);function u(s,f,m){const p=f||n;s?a(s):o?o(p):r(void 0,p,m)}}}runSync(n,t){let r=!1,i;return this.run(n,t,l),zt("runSync","run",r),i;function l(o,a){Tt(o),i=a,r=!0}}stringify(n,t){this.freeze();const r=Qe(t),i=this.compiler||this.Compiler;return gn("stringify",i),Pt(n),i(n,r)}use(n,...t){const r=this.attachers,i=this.namespace;if(xn("use",this.frozen),n!=null)if(typeof n=="function")c(n,t);else if(typeof n=="object")Array.isArray(n)?a(n):o(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function l(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[s,...f]=u;c(s,f)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=pn(!0,i.settings,u.settings))}function a(u){let s=-1;if(u!=null)if(Array.isArray(u))for(;++s<u.length;){const f=u[s];l(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,s){let f=-1,m=-1;for(;++f<r.length;)if(r[f][0]===u){m=f;break}if(m===-1)r.push([u,...s]);else if(s.length>0){let[p,...w]=s;const C=r[m][1];Tn(C)&&Tn(p)&&(p=pn(!0,C,p)),r[m]=[u,p,...w]}}}}const Ja=new Vn().freeze();function mn(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function gn(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xn(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Pt(e){if(!Tn(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zt(e,n,t){if(!t)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Qe(e){return Ka(e)?e:new xr(e)}function Ka(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Ga(e){return typeof e=="string"||Za(e)}function Za(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const eu="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jt=[],Lt={allowDangerousHtml:!0},nu=/^(https?|ircs?|mailto|xmpp)$/i,tu=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function ru(e){const n=iu(e),t=lu(e);return ou(n.runSync(n.parse(t),t),e)}function iu(e){const n=e.rehypePlugins||jt,t=e.remarkPlugins||jt,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Lt}:Lt;return Ja().use(_o).use(t).use(ja,r).use(n)}function lu(e){const n=e.children||"",t=new xr;return typeof n=="string"&&(t.value=n),t}function ou(e,n){const t=n.allowedElements,r=n.allowElement,i=n.components,l=n.disallowedElements,o=n.skipHtml,a=n.unwrapDisallowed,c=n.urlTransform||au;for(const s of tu)Object.hasOwn(n,s.from)&&(""+s.from+(s.to?"use `"+s.to+"` instead":"remove it")+eu+s.id,void 0);return gr(e,u),mi(e,{Fragment:y.Fragment,components:i,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function u(s,f,m){if(s.type==="raw"&&m&&typeof f=="number")return o?m.children.splice(f,1):m.children[f]={type:"text",value:s.value},f;if(s.type==="element"){let p;for(p in an)if(Object.hasOwn(an,p)&&Object.hasOwn(s.properties,p)){const w=s.properties[p],C=an[p];(C===null||C.includes(s.tagName))&&(s.properties[p]=c(String(w||""),p,s))}}if(s.type==="element"){let p=t?!t.includes(s.tagName):l?l.includes(s.tagName):!1;if(!p&&r&&typeof f=="number"&&(p=!r(s,f,m)),p&&m&&typeof f=="number")return a&&s.children?m.children.splice(f,1,...s.children):m.children.splice(f,1),f}}}function au(e){const n=e.indexOf(":"),t=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return n===-1||i!==-1&&n>i||t!==-1&&n>t||r!==-1&&n>r||nu.test(e.slice(0,n))?e:""}const uu={getOutput:zr,getOutputTree:Pr,getOutputContent:Ar};function mu({taskId:e,api:n=uu}){var I,M,B,x,D,U,_;const[t,r]=re.useState(null),[i,l]=re.useState([]),[o,a]=re.useState("."),[c,u]=re.useState(null),[s,f]=re.useState(!0),[m,p]=re.useState(null),w=re.useCallback(async()=>{p(null),f(!0),a("."),l([]),u(null);try{const N=await n.getOutput(e);if(r(N),!N.available){f(!1);return}const v=await n.getOutputTree(e,".");l(v.entries),f(!1)}catch(N){p(N instanceof Error?N.message:"Failed to load output"),f(!1)}},[n,e]);re.useEffect(()=>{w()},[w]);const C=re.useCallback(async N=>{p(null);try{const v=await n.getOutputTree(e,N);l(v.entries),a(N),u(null)}catch(v){p(v instanceof Error?v.message:"Failed to load directory")}},[n,e]),T=re.useCallback(async N=>{p(null);try{const v=await n.getOutputContent(e,N);u(v)}catch(v){p(v instanceof Error?v.message:"Failed to load file")}},[n,e]),k=re.useCallback(()=>{if(o===".")return;const N=o.split("/");N.pop();const v=N.length===0?".":N.join("/");C(v)},[o,C]);if(s)return y.jsx(yn,{tone:"muted",children:"Loading files..."});if(m)return y.jsx(yn,{tone:"destructive",children:m});if(!(t!=null&&t.available))return y.jsx(yn,{tone:"muted",children:"Task output is not available yet. The task may not have started."});const P=(((I=t.summary)==null?void 0:I.htmlEntries.length)??0)+(((B=(M=t.summary)==null?void 0:M.markdownEntries)==null?void 0:B.length)??0);return y.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[y.jsxs("aside",{className:Te("flex min-h-0 flex-col border-b border-border/60 bg-background/30 lg:border-b-0 lg:border-r",c&&"hidden lg:flex"),children:[y.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[y.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Task output"}),y.jsxs("div",{className:"mt-1.5 flex items-start justify-between gap-2",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:((x=t.summary)==null?void 0:x.rootName)??"Artifacts"}),y.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[((D=t.summary)==null?void 0:D.fileCount)??i.length," files",P>0&&` · ${P} previews`]})]}),y.jsx(rn,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:c?"Inspecting":"Browse"})]}),y.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-full border border-border/70 bg-background/55 px-2 py-1",children:[o!=="."&&y.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-full",onClick:k,children:y.jsx(Qn,{className:"h-3 w-3"})}),y.jsx("span",{className:"truncate font-mono text-[10px] text-muted-foreground",children:o==="."?((U=t.summary)==null?void 0:U.rootPath)??((_=t.summary)==null?void 0:_.rootName)??"/":o})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:i.length>0?y.jsx("div",{className:"space-y-0.5",children:i.map(N=>y.jsxs("button",{type:"button",onClick:()=>{N.type==="directory"?C(N.path):T(N.path)},className:Te("flex w-full items-center gap-2 rounded-[10px] border px-2 py-1.5 text-left transition-colors",(c==null?void 0:c.path)===N.path?"border-primary/40 bg-primary/10":"border-transparent bg-transparent hover:border-border/60 hover:bg-background/55"),children:[N.type==="directory"?y.jsx(jr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):y.jsx(Fr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:N.name}),y.jsx("div",{className:"mt-0 flex items-center gap-1.5 text-[10px] text-muted-foreground",children:N.type==="directory"?y.jsx("span",{children:"Directory"}):y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"capitalize",children:N.kind??"file"}),N.size!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),y.jsx("span",{children:pu(N.size)})]})]})})]}),N.type==="directory"&&y.jsx(Lr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]},N.path))}):y.jsx("div",{className:"flex h-full items-center justify-center rounded-[14px] border border-dashed border-border/70 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"Empty directory"})})]}),y.jsx("section",{className:Te("min-h-0 flex flex-col bg-card/10",!c&&"hidden lg:flex"),children:c?y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:y.jsxs("div",{className:"flex items-start justify-between gap-2",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 rounded-full",onClick:()=>u(null),children:y.jsx(Qn,{className:"h-3 w-3"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[y.jsx(rn,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] capitalize",children:c.kind}),c.truncated&&y.jsx(rn,{variant:"secondary",className:"rounded-full text-[10px]",children:"Truncated"})]}),y.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground",children:c.path})]})]}),c.downloadUrl&&y.jsx(Me,{asChild:!0,variant:"outline",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",children:y.jsxs("a",{href:c.downloadUrl,download:!0,children:[y.jsx(An,{className:"h-3.5 w-3.5"}),"Download"]})})]})}),y.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2.5",children:y.jsx(su,{content:c})})]}):y.jsx("div",{className:"flex h-full items-center justify-center p-4",children:y.jsxs("div",{className:"max-w-md rounded-[20px] border border-border/60 bg-background/55 px-4 py-4 text-center",children:[y.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"Select a file to inspect"}),y.jsx("p",{className:"mt-1 text-[11px] leading-5 text-muted-foreground",children:"Preview source files, generated assets, or exported documents from this task."})]})})})]})}function su({content:e}){const n=e.downloadUrl;if(e.truncated&&!e.content)return y.jsx(kr,{title:"File is too large to preview inline",description:e.path,action:n?y.jsx(Me,{asChild:!0,variant:"outline",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",children:y.jsxs("a",{href:n,download:!0,children:[y.jsx(An,{className:"h-3.5 w-3.5"}),"Download"]})}):void 0});if(e.kind==="image"){const t=e.content?`data:${e.mimeType};base64,${e.content}`:n;return t?y.jsx("div",{className:"flex h-full min-h-[16rem] items-center justify-center rounded-[20px] border border-border/60 bg-background/55 p-3",children:y.jsx("img",{src:t,alt:e.path,className:"max-h-full max-w-full rounded-[14px] object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):y.jsx(Ot,{content:e})}if(e.kind==="pdf"&&n)return y.jsx("div",{className:"h-full min-h-[20rem] overflow-hidden rounded-[20px] border border-border/60 bg-background/55",children:y.jsx("iframe",{src:n,title:e.path,className:"h-full w-full border-0"})});if(e.kind==="json"){let t=e.content;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch{}return y.jsx(Ft,{content:t,truncated:e.truncated})}return e.kind==="markdown"?y.jsx(cu,{content:e.content,truncated:e.truncated}):e.kind==="text"||e.kind==="html"?y.jsx(Ft,{content:e.content,truncated:e.truncated}):y.jsx(Ot,{content:e})}function cu({content:e,truncated:n}){const[t,r]=re.useState(!1);return y.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background",children:[y.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-end rounded-t-[20px] border-b border-border/60 bg-background/95 px-3 py-1.5 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:y.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-muted/50 p-0.5",children:[y.jsxs("button",{type:"button",onClick:()=>r(!1),className:Te("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] transition-colors",t?"text-muted-foreground hover:text-foreground":"bg-background font-medium text-foreground shadow-sm"),children:[y.jsx(Br,{className:"h-3 w-3"}),"Preview"]}),y.jsxs("button",{type:"button",onClick:()=>r(!0),className:Te("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] transition-colors",t?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[y.jsx(_r,{className:"h-3 w-3"}),"Raw"]})]})}),t?y.jsx(yr,{content:e}):y.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none px-4 py-3 text-foreground",children:y.jsx(ru,{children:e})}),n&&y.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[10px] text-muted-foreground",children:"Content truncated. Download the file to inspect the full artifact."})]})}function Ft({content:e,truncated:n}){return y.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background",children:[y.jsx(yr,{content:e}),n&&y.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[10px] text-muted-foreground",children:"Content truncated. Download the file to inspect the full artifact."})]})}function yr({content:e}){const n=e.length===0?[""]:e.split(`
|
|
34
|
+
`},i),l}function ja(e,n){return e&&"run"in e?async function(t,r){const i=vt(t,{file:r,...n});await e.run(i,r)}:function(t,r){return vt(t,{file:r,...e||n})}}function Tt(e){if(e)throw e}var cn,Nt;function La(){if(Nt)return cn;Nt=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):n.call(u)==="[object Array]"},l=function(u){if(!u||n.call(u)!=="[object Object]")return!1;var s=e.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!s&&!f)return!1;var m;for(m in u);return typeof m>"u"||e.call(u,m)},o=function(u,s){t&&s.name==="__proto__"?t(u,s.name,{enumerable:!0,configurable:!0,value:s.newValue,writable:!0}):u[s.name]=s.newValue},a=function(u,s){if(s==="__proto__")if(e.call(u,s)){if(r)return r(u,s).value}else return;return u[s]};return cn=function c(){var u,s,f,m,p,w,C=arguments[0],T=1,k=arguments.length,P=!1;for(typeof C=="boolean"&&(P=C,C=arguments[1]||{},T=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});T<k;++T)if(u=arguments[T],u!=null)for(s in u)f=a(C,s),m=a(u,s),C!==m&&(P&&m&&(l(m)||(p=i(m)))?(p?(p=!1,w=f&&i(f)?f:[]):w=f&&l(f)?f:{},o(C,{name:s,newValue:c(P,w,m)})):typeof m<"u"&&o(C,{name:s,newValue:m}));return C},cn}var Fa=La();const pn=Dt(Fa);function Tn(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Oa(){const e=[],n={run:t,use:r};return n;function t(...i){let l=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(c,...u){const s=e[++l];let f=-1;if(c){o(c);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,s?Da(s,a)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),n}}function Da(e,n){let t;return r;function r(...o){const a=e.length>o.length;let c;a&&o.push(i);try{c=e.apply(this,o)}catch(u){const s=u;if(a&&t)throw s;return i(s)}a||(c&&c.then&&typeof c.then=="function"?c.then(l,i):c instanceof Error?i(c):l(c))}function i(o,...a){t||(t=!0,n(o,...a))}function l(o){i(null,o)}}const se={basename:_a,dirname:Ra,extname:Ma,join:Ba,sep:"/"};function _a(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');$e(e);let t=0,r=-1,i=e.length,l;if(n===void 0||n.length===0||n.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(l){t=i+1;break}}else r<0&&(l=!0,r=i+1);return r<0?"":e.slice(t,r)}if(n===e)return"";let o=-1,a=n.length-1;for(;i--;)if(e.codePointAt(i)===47){if(l){t=i+1;break}}else o<0&&(l=!0,o=i+1),a>-1&&(e.codePointAt(i)===n.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return t===r?r=o:r<0&&(r=e.length),e.slice(t,r)}function Ra(e){if($e(e),e.length===0)return".";let n=-1,t=e.length,r;for(;--t;)if(e.codePointAt(t)===47){if(r){n=t;break}}else r||(r=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function Ma(e){$e(e);let n=e.length,t=-1,r=0,i=-1,l=0,o;for(;n--;){const a=e.codePointAt(n);if(a===47){if(o){r=n+1;break}continue}t<0&&(o=!0,t=n+1),a===46?i<0?i=n:l!==1&&(l=1):i>-1&&(l=-1)}return i<0||t<0||l===0||l===1&&i===t-1&&i===r+1?"":e.slice(i,t)}function Ba(...e){let n=-1,t;for(;++n<e.length;)$e(e[n]),e[n]&&(t=t===void 0?e[n]:t+"/"+e[n]);return t===void 0?".":Ua(t)}function Ua(e){$e(e);const n=e.codePointAt(0)===47;let t=Ha(e,!n);return t.length===0&&!n&&(t="."),t.length>0&&e.codePointAt(e.length-1)===47&&(t+="/"),n?"/"+t:t}function Ha(e,n){let t="",r=0,i=-1,l=0,o=-1,a,c;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||l===1))if(i!==o-1&&l===2){if(t.length<2||r!==2||t.codePointAt(t.length-1)!==46||t.codePointAt(t.length-2)!==46){if(t.length>2){if(c=t.lastIndexOf("/"),c!==t.length-1){c<0?(t="",r=0):(t=t.slice(0,c),r=t.length-1-t.lastIndexOf("/")),i=o,l=0;continue}}else if(t.length>0){t="",r=0,i=o,l=0;continue}}n&&(t=t.length>0?t+"/..":"..",r=2)}else t.length>0?t+="/"+e.slice(i+1,o):t=e.slice(i+1,o),r=o-i-1;i=o,l=0}else a===46&&l>-1?l++:l=-1}return t}function $e(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Va={cwd:qa};function qa(){return"/"}function Nn(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function $a(e){if(typeof e=="string")e=new URL(e);else if(!Nn(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Wa(e)}function Wa(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const n=e.pathname;let t=-1;for(;++t<n.length;)if(n.codePointAt(t)===37&&n.codePointAt(t+1)===50){const r=n.codePointAt(t+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(n)}const fn=["history","path","basename","stem","extname","dirname"];class xr{constructor(n){let t;n?Nn(n)?t={path:n}:typeof n=="string"||Ya(n)?t={value:n}:t=n:t={},this.cwd="cwd"in t?"":Va.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<fn.length;){const l=fn[r];l in t&&t[l]!==void 0&&t[l]!==null&&(this[l]=l==="history"?[...t[l]]:t[l])}let i;for(i in t)fn.includes(i)||(this[i]=t[i])}get basename(){return typeof this.path=="string"?se.basename(this.path):void 0}set basename(n){dn(n,"basename"),hn(n,"basename"),this.path=se.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?se.dirname(this.path):void 0}set dirname(n){At(this.basename,"dirname"),this.path=se.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?se.extname(this.path):void 0}set extname(n){if(hn(n,"extname"),At(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=se.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){Nn(n)&&(n=$a(n)),dn(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?se.basename(this.path,this.extname):void 0}set stem(n){dn(n,"stem"),hn(n,"stem"),this.path=se.join(this.dirname||"",n+(this.extname||""))}fail(n,t,r){const i=this.message(n,t,r);throw i.fatal=!0,i}info(n,t,r){const i=this.message(n,t,r);return i.fatal=void 0,i}message(n,t,r){const i=new J(n,t,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function hn(e,n){if(e&&e.includes(se.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+se.sep+"`")}function dn(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function At(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function Ya(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Xa=(function(e){const r=this.constructor.prototype,i=r[e],l=function(){return i.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),Qa={}.hasOwnProperty;class Vn extends Xa{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Oa()}copy(){const n=new Vn;let t=-1;for(;++t<this.attachers.length;){const r=this.attachers[t];n.use(...r)}return n.data(pn(!0,{},this.namespace)),n}data(n,t){return typeof n=="string"?arguments.length===2?(xn("data",this.frozen),this.namespace[n]=t,this):Qa.call(this.namespace,n)&&this.namespace[n]||void 0:n?(xn("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=t.call(n,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const t=Qe(n),r=this.parser||this.Parser;return mn("parse",r),r(String(t),t)}process(n,t){const r=this;return this.freeze(),mn("process",this.parser||this.Parser),gn("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(l,o){const a=Qe(n),c=r.parse(a);r.run(c,a,function(s,f,m){if(s||!f||!m)return u(s);const p=f,w=r.stringify(p,m);Ga(w)?m.value=w:m.result=w,u(s,m)});function u(s,f){s||!f?o(s):l?l(f):t(void 0,f)}}}processSync(n){let t=!1,r;return this.freeze(),mn("processSync",this.parser||this.Parser),gn("processSync",this.compiler||this.Compiler),this.process(n,i),zt("processSync","process",t),r;function i(l,o){t=!0,Tt(l),r=o}}run(n,t,r){Pt(n),this.freeze();const i=this.transformers;return!r&&typeof t=="function"&&(r=t,t=void 0),r?l(void 0,r):new Promise(l);function l(o,a){const c=Qe(t);i.run(n,c,u);function u(s,f,m){const p=f||n;s?a(s):o?o(p):r(void 0,p,m)}}}runSync(n,t){let r=!1,i;return this.run(n,t,l),zt("runSync","run",r),i;function l(o,a){Tt(o),i=a,r=!0}}stringify(n,t){this.freeze();const r=Qe(t),i=this.compiler||this.Compiler;return gn("stringify",i),Pt(n),i(n,r)}use(n,...t){const r=this.attachers,i=this.namespace;if(xn("use",this.frozen),n!=null)if(typeof n=="function")c(n,t);else if(typeof n=="object")Array.isArray(n)?a(n):o(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function l(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[s,...f]=u;c(s,f)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=pn(!0,i.settings,u.settings))}function a(u){let s=-1;if(u!=null)if(Array.isArray(u))for(;++s<u.length;){const f=u[s];l(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,s){let f=-1,m=-1;for(;++f<r.length;)if(r[f][0]===u){m=f;break}if(m===-1)r.push([u,...s]);else if(s.length>0){let[p,...w]=s;const C=r[m][1];Tn(C)&&Tn(p)&&(p=pn(!0,C,p)),r[m]=[u,p,...w]}}}}const Ja=new Vn().freeze();function mn(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function gn(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function xn(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Pt(e){if(!Tn(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zt(e,n,t){if(!t)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Qe(e){return Ka(e)?e:new xr(e)}function Ka(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Ga(e){return typeof e=="string"||Za(e)}function Za(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const eu="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jt=[],Lt={allowDangerousHtml:!0},nu=/^(https?|ircs?|mailto|xmpp)$/i,tu=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function ru(e){const n=iu(e),t=lu(e);return ou(n.runSync(n.parse(t),t),e)}function iu(e){const n=e.rehypePlugins||jt,t=e.remarkPlugins||jt,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Lt}:Lt;return Ja().use(_o).use(t).use(ja,r).use(n)}function lu(e){const n=e.children||"",t=new xr;return typeof n=="string"&&(t.value=n),t}function ou(e,n){const t=n.allowedElements,r=n.allowElement,i=n.components,l=n.disallowedElements,o=n.skipHtml,a=n.unwrapDisallowed,c=n.urlTransform||au;for(const s of tu)Object.hasOwn(n,s.from)&&(""+s.from+(s.to?"use `"+s.to+"` instead":"remove it")+eu+s.id,void 0);return gr(e,u),mi(e,{Fragment:y.Fragment,components:i,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function u(s,f,m){if(s.type==="raw"&&m&&typeof f=="number")return o?m.children.splice(f,1):m.children[f]={type:"text",value:s.value},f;if(s.type==="element"){let p;for(p in an)if(Object.hasOwn(an,p)&&Object.hasOwn(s.properties,p)){const w=s.properties[p],C=an[p];(C===null||C.includes(s.tagName))&&(s.properties[p]=c(String(w||""),p,s))}}if(s.type==="element"){let p=t?!t.includes(s.tagName):l?l.includes(s.tagName):!1;if(!p&&r&&typeof f=="number"&&(p=!r(s,f,m)),p&&m&&typeof f=="number")return a&&s.children?m.children.splice(f,1,...s.children):m.children.splice(f,1),f}}}function au(e){const n=e.indexOf(":"),t=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return n===-1||i!==-1&&n>i||t!==-1&&n>t||r!==-1&&n>r||nu.test(e.slice(0,n))?e:""}const uu={getOutput:zr,getOutputTree:Pr,getOutputContent:Ar};function mu({taskId:e,api:n=uu}){var I,M,B,x,D,U,_;const[t,r]=re.useState(null),[i,l]=re.useState([]),[o,a]=re.useState("."),[c,u]=re.useState(null),[s,f]=re.useState(!0),[m,p]=re.useState(null),w=re.useCallback(async()=>{p(null),f(!0),a("."),l([]),u(null);try{const N=await n.getOutput(e);if(r(N),!N.available){f(!1);return}const v=await n.getOutputTree(e,".");l(v.entries),f(!1)}catch(N){p(N instanceof Error?N.message:"Failed to load output"),f(!1)}},[n,e]);re.useEffect(()=>{w()},[w]);const C=re.useCallback(async N=>{p(null);try{const v=await n.getOutputTree(e,N);l(v.entries),a(N),u(null)}catch(v){p(v instanceof Error?v.message:"Failed to load directory")}},[n,e]),T=re.useCallback(async N=>{p(null);try{const v=await n.getOutputContent(e,N);u(v)}catch(v){p(v instanceof Error?v.message:"Failed to load file")}},[n,e]),k=re.useCallback(()=>{if(o===".")return;const N=o.split("/");N.pop();const v=N.length===0?".":N.join("/");C(v)},[o,C]);if(s)return y.jsx(yn,{tone:"muted",children:"Loading files..."});if(m)return y.jsx(yn,{tone:"destructive",children:m});if(!(t!=null&&t.available))return y.jsx(yn,{tone:"muted",children:"Task output is not available yet. The task may not have started."});const P=(((I=t.summary)==null?void 0:I.htmlEntries.length)??0)+(((B=(M=t.summary)==null?void 0:M.markdownEntries)==null?void 0:B.length)??0);return y.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[y.jsxs("aside",{className:Te("flex min-h-0 flex-col border-b border-border/60 bg-background/30 lg:border-b-0 lg:border-r",c&&"hidden lg:flex"),children:[y.jsxs("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:[y.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Task output"}),y.jsxs("div",{className:"mt-1.5 flex items-start justify-between gap-2",children:[y.jsxs("div",{className:"min-w-0",children:[y.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:((x=t.summary)==null?void 0:x.rootName)??"Artifacts"}),y.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:[((D=t.summary)==null?void 0:D.fileCount)??i.length," files",P>0&&` · ${P} previews`]})]}),y.jsx(rn,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px]",children:c?"Inspecting":"Browse"})]}),y.jsxs("div",{className:"mt-2 flex items-center gap-1.5 rounded-full border border-border/70 bg-background/55 px-2 py-1",children:[o!=="."&&y.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-full",onClick:k,children:y.jsx(Qn,{className:"h-3 w-3"})}),y.jsx("span",{className:"truncate font-mono text-[10px] text-muted-foreground",children:o==="."?((U=t.summary)==null?void 0:U.rootPath)??((_=t.summary)==null?void 0:_.rootName)??"/":o})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:i.length>0?y.jsx("div",{className:"space-y-0.5",children:i.map(N=>y.jsxs("button",{type:"button",onClick:()=>{N.type==="directory"?C(N.path):T(N.path)},className:Te("flex w-full items-center gap-2 rounded-[10px] border px-2 py-1.5 text-left transition-colors",(c==null?void 0:c.path)===N.path?"border-primary/40 bg-primary/10":"border-transparent bg-transparent hover:border-border/60 hover:bg-background/55"),children:[N.type==="directory"?y.jsx(Lr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}):y.jsx(Fr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:N.name}),y.jsx("div",{className:"mt-0 flex items-center gap-1.5 text-[10px] text-muted-foreground",children:N.type==="directory"?y.jsx("span",{children:"Directory"}):y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"capitalize",children:N.kind??"file"}),N.size!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"h-1 w-1 rounded-full bg-border"}),y.jsx("span",{children:pu(N.size)})]})]})})]}),N.type==="directory"&&y.jsx(jr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]},N.path))}):y.jsx("div",{className:"flex h-full items-center justify-center rounded-[14px] border border-dashed border-border/70 bg-background/35 px-3 text-center text-[11px] text-muted-foreground",children:"Empty directory"})})]}),y.jsx("section",{className:Te("min-h-0 flex flex-col bg-card/10",!c&&"hidden lg:flex"),children:c?y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-2.5",children:y.jsxs("div",{className:"flex items-start justify-between gap-2",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx(Me,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 rounded-full",onClick:()=>u(null),children:y.jsx(Qn,{className:"h-3 w-3"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[y.jsx(rn,{variant:"outline",className:"rounded-full border-border/70 bg-background/60 text-[10px] capitalize",children:c.kind}),c.truncated&&y.jsx(rn,{variant:"secondary",className:"rounded-full text-[10px]",children:"Truncated"})]}),y.jsx("div",{className:"mt-1 truncate font-mono text-[10px] text-muted-foreground",children:c.path})]})]}),c.downloadUrl&&y.jsx(Me,{asChild:!0,variant:"outline",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",children:y.jsxs("a",{href:c.downloadUrl,download:!0,children:[y.jsx(An,{className:"h-3.5 w-3.5"}),"Download"]})})]})}),y.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2.5",children:y.jsx(su,{content:c})})]}):y.jsx("div",{className:"flex h-full items-center justify-center p-4",children:y.jsxs("div",{className:"max-w-md rounded-[20px] border border-border/60 bg-background/55 px-4 py-4 text-center",children:[y.jsx("div",{className:"text-[12px] font-medium text-foreground",children:"Select a file to inspect"}),y.jsx("p",{className:"mt-1 text-[11px] leading-5 text-muted-foreground",children:"Preview source files, generated assets, or exported documents from this task."})]})})})]})}function su({content:e}){const n=e.downloadUrl;if(e.truncated&&!e.content)return y.jsx(kr,{title:"File is too large to preview inline",description:e.path,action:n?y.jsx(Me,{asChild:!0,variant:"outline",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",children:y.jsxs("a",{href:n,download:!0,children:[y.jsx(An,{className:"h-3.5 w-3.5"}),"Download"]})}):void 0});if(e.kind==="image"){const t=e.content?`data:${e.mimeType};base64,${e.content}`:n;return t?y.jsx("div",{className:"flex h-full min-h-[16rem] items-center justify-center rounded-[20px] border border-border/60 bg-background/55 p-3",children:y.jsx("img",{src:t,alt:e.path,className:"max-h-full max-w-full rounded-[14px] object-contain shadow-[0_24px_90px_-52px_rgba(0,0,0,0.65)]"})}):y.jsx(Ot,{content:e})}if(e.kind==="pdf"&&n)return y.jsx("div",{className:"h-full min-h-[20rem] overflow-hidden rounded-[20px] border border-border/60 bg-background/55",children:y.jsx("iframe",{src:n,title:e.path,className:"h-full w-full border-0"})});if(e.kind==="json"){let t=e.content;try{t=JSON.stringify(JSON.parse(e.content),null,2)}catch{}return y.jsx(Ft,{content:t,truncated:e.truncated})}return e.kind==="markdown"?y.jsx(cu,{content:e.content,truncated:e.truncated}):e.kind==="text"||e.kind==="html"?y.jsx(Ft,{content:e.content,truncated:e.truncated}):y.jsx(Ot,{content:e})}function cu({content:e,truncated:n}){const[t,r]=re.useState(!1);return y.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background",children:[y.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-end rounded-t-[20px] border-b border-border/60 bg-background/95 px-3 py-1.5 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:y.jsxs("div",{className:"flex items-center gap-1 rounded-full border border-border/70 bg-muted/50 p-0.5",children:[y.jsxs("button",{type:"button",onClick:()=>r(!1),className:Te("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] transition-colors",t?"text-muted-foreground hover:text-foreground":"bg-background font-medium text-foreground shadow-sm"),children:[y.jsx(Br,{className:"h-3 w-3"}),"Preview"]}),y.jsxs("button",{type:"button",onClick:()=>r(!0),className:Te("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] transition-colors",t?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[y.jsx(_r,{className:"h-3 w-3"}),"Raw"]})]})}),t?y.jsx(yr,{content:e}):y.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none px-4 py-3 text-foreground",children:y.jsx(ru,{children:e})}),n&&y.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[10px] text-muted-foreground",children:"Content truncated. Download the file to inspect the full artifact."})]})}function Ft({content:e,truncated:n}){return y.jsxs("div",{className:"rounded-[20px] border border-border/60 bg-background",children:[y.jsx(yr,{content:e}),n&&y.jsx("div",{className:"border-t border-border/60 px-3 py-1.5 text-[10px] text-muted-foreground",children:"Content truncated. Download the file to inspect the full artifact."})]})}function yr({content:e}){const n=e.length===0?[""]:e.split(`
|
|
35
35
|
`),t=`${Math.max(2,String(n.length).length)+1}ch`;return y.jsx("div",{className:"overflow-x-auto font-mono text-[11px] leading-5 text-foreground",children:y.jsx("div",{className:"min-w-full",children:n.map((r,i)=>y.jsxs("div",{className:"flex",children:[y.jsx("span",{className:"sticky left-0 shrink-0 select-none border-r border-border/40 bg-background/95 px-2 py-0 text-right tabular-nums text-muted-foreground/55",style:{width:t},children:i+1}),y.jsx("span",{className:"whitespace-pre-wrap break-all px-3 py-0",children:r||" "})]},i))})})}function Ot({content:e}){return y.jsx(kr,{title:`${e.kind} file`,description:e.path,action:e.downloadUrl?y.jsx(Me,{asChild:!0,variant:"outline",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",children:y.jsxs("a",{href:e.downloadUrl,download:!0,children:[y.jsx(An,{className:"h-3.5 w-3.5"}),"Download"]})}):void 0})}function kr({title:e,description:n,action:t}){return y.jsx("div",{className:"flex h-full min-h-[14rem] items-center justify-center rounded-[20px] border border-dashed border-border/70 bg-background/35 p-4 text-center",children:y.jsxs("div",{className:"max-w-sm",children:[y.jsx("div",{className:"text-[12px] font-medium text-foreground",children:e}),y.jsx("div",{className:"mt-1 break-all font-mono text-[10px] text-muted-foreground",children:n}),t&&y.jsx("div",{className:"mt-2.5 flex justify-center",children:t})]})})}function yn({children:e,tone:n}){return y.jsx("div",{className:Te("flex h-48 items-center justify-center text-[12px]",n==="muted"?"text-muted-foreground":"text-destructive"),children:e})}function pu(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}export{mu as FilesTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as M,j as e,i as u,
|
|
1
|
+
import{c as M,j as e,i as u,ad as B,r as a,b6 as W,b5 as X,H as Y,D as Z,g as ee,b7 as se,B as D}from"./index-Bg0PqgJi.js";import{I as re,P as te}from"./input-DH4KoLjb.js";/**
|
|
2
2
|
* @license lucide-react v1.7.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -18,4 +18,4 @@ import{c as M,j as e,i as u,ac as B,r as a,b5 as W,b4 as X,G as Y,D as Z,g as ee
|
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const oe=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],de=M("settings-2",oe),ue={getOutput:X,createPreviewSession:W};function fe({taskId:s,api:n=ue,allowPortPreview:l=!0}){const[i,c]=a.useState(null),[r,v]=a.useState(null),[d,p]=a.useState(null),[b,h]=a.useState(""),[P,k]=a.useState(!1),[
|
|
21
|
+
*/const oe=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],de=M("settings-2",oe),ue={getOutput:X,createPreviewSession:W};function fe({taskId:s,api:n=ue,allowPortPreview:l=!0}){const[i,c]=a.useState(null),[r,v]=a.useState(null),[d,p]=a.useState(null),[b,h]=a.useState(""),[P,k]=a.useState(!1),[V,C]=a.useState(!0),[j,m]=a.useState(null),[G,E]=a.useState(!1),$=a.useCallback(async()=>{C(!0),m(null),c(null),v(null),p(null);try{const t=await n.getOutput(s);c(t),C(!1)}catch(t){m(t instanceof Error?t.message:"Failed to load output"),C(!1)}},[n,s]);a.useEffect(()=>{$()},[$]);const w=a.useCallback(async t=>{m(null);try{const o=await n.createPreviewSession(s,t!=null&&t.path?{path:t.path}:void 0);v(o),k(!1),t&&p(t)}catch(o){m(o instanceof Error?o.message:"Failed to create preview session")}},[n,s]),y=a.useCallback(async t=>{const o=t??Number.parseInt(b,10);if(!Number.isInteger(o)||o<1||o>65535){m("Enter a port between 1 and 65535");return}m(null);try{const S=await n.createPreviewSession(s,{port:o});v(S),p(null),h(String(o)),k(!0)}catch(S){m(S instanceof Error?S.message:"Failed to create preview session")}},[n,b,s]),g=a.useMemo(()=>R(i),[i]);a.useEffect(()=>{if(P||!(i!=null&&i.available)||g.length===0||r&&r.kind!=="service")return;const t=d??g[0];t&&w(t)},[d,i,g,P,r,w]);const f=a.useCallback(()=>{if((r==null?void 0:r.kind)==="service"&&typeof r.port=="number"){y(r.port);return}v(null);const t=d??R(i)[0];t&&w(t)},[d,i,r,y,w]);if(a.useEffect(()=>{if(!r)return;const t=r.expiresAt-Date.now()-5e3;if(t<=0){f();return}const o=window.setTimeout(f,t);return()=>window.clearTimeout(o)},[f,r]),V)return e.jsx(N,{children:"Loading preview..."});const x=l&&P;if(j&&r&&!x)return e.jsx(N,{children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"text-sm text-destructive",children:j}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(u,{variant:"outline",size:"sm",onClick:f,className:"rounded-full",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),"Retry"]})})]})});const F=!!(i!=null&&i.available);if(!F&&!l)return e.jsx(N,{children:"Task output is not available yet."});if(!r)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5",children:[e.jsx(H,{session:null,serviceModeOpen:x,allowPortPreview:l,servicePort:b,onRefresh:f,onFullscreen:()=>E(!0),onServiceModeToggle:()=>k(t=>!t),onServicePortChange:h,onServiceStart:()=>void y()}),!x&&e.jsx(U,{entries:g,activeEntry:d,onEntrySelect:t=>void w(t)})]}),x?e.jsx(I,{serviceSession:null,error:j}):e.jsx(N,{children:j?e.jsx("span",{className:"text-sm text-destructive",children:j}):F?g.length>0?"Starting preview session...":"No HTML or Markdown files were found in this task output.":"Task output is not available yet."})]});const _=K(r),J=q(r),L=xe(r),T=r.kind==="service"?r:null,Q=x?T:r,A=e.jsx("iframe",{src:r.previewUrl,className:"h-full w-full border-0",sandbox:L,title:"Task Preview"});return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-border/60 px-4 py-2.5",children:[e.jsx(H,{session:Q,serviceModeOpen:x,allowPortPreview:l,servicePort:b,onRefresh:f,onFullscreen:()=>E(!0),onServiceModeToggle:()=>k(t=>!t),onServicePortChange:h,onServiceStart:()=>void y()}),!x&&e.jsx(U,{entries:g,activeEntry:d,previewKind:r.kind,onEntrySelect:t=>void w(t)})]}),x?e.jsx(I,{serviceSession:T,error:j,children:T?A:null}):e.jsx("div",{className:"min-h-0 flex-1 p-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:A})}),e.jsx(Y,{open:G,onOpenChange:E,children:e.jsxs(Z,{className:"flex h-[95vh] max-w-[95vw] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs(ee,{className:"sr-only",children:["Preview: ",_]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-4 py-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:_}),e.jsx("span",{className:"text-xs text-muted-foreground",children:z(r.expiresAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",onClick:f,title:"Refresh",children:e.jsx(O,{className:"h-3.5 w-3.5"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:J,target:"_blank",rel:"noopener noreferrer",children:e.jsx(B,{className:"h-3.5 w-3.5"})})}),e.jsx(se,{asChild:!0,children:e.jsxs(u,{variant:"outline",size:"sm",className:"rounded-full",title:"Exit fullscreen",children:[e.jsx(le,{className:"h-3.5 w-3.5"}),"Exit fullscreen"]})})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx("iframe",{src:r.previewUrl,className:"h-full w-full border-0",sandbox:L,title:"Task Preview Fullscreen"})})]})})]})}function R(s){var i,c;const n=((i=s==null?void 0:s.summary)==null?void 0:i.htmlEntries)??[],l=((c=s==null?void 0:s.summary)==null?void 0:c.markdownEntries)??[];return[...n.map(r=>({...r,kind:"html"})),...l.map(r=>({...r,kind:"markdown"}))]}function U({entries:s,activeEntry:n,previewKind:l,onEntrySelect:i}){return e.jsx("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.map(c=>{const r=(n==null?void 0:n.path)===c.path;return e.jsx("button",{type:"button",onClick:()=>i(c),className:r?"rounded-full border border-primary/40 bg-primary/10 px-3 py-1 text-xs font-medium text-primary":"rounded-full border border-border/70 bg-background/55 px-3 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:c.label},`${c.kind}:${c.path}`)}),e.jsxs(D,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:[s.length," ",s.length===1?"file":"files"]}),e.jsx(D,{variant:"outline",className:"rounded-full border-border/70 bg-background/60",children:l==="service"?"Service proxy":"Sandboxed iframe"})]})})}function H({session:s,serviceModeOpen:n,allowPortPreview:l,servicePort:i,onRefresh:c,onFullscreen:r,onServiceModeToggle:v,onServicePortChange:d,onServiceStart:p}){const b=s?q(s):null;return e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-3",children:n&&d&&p?e.jsxs("form",{className:"flex min-w-0 items-center gap-2",onSubmit:h=>{h.preventDefault(),p()},children:[e.jsx("span",{className:"shrink-0 text-sm font-semibold text-foreground",children:"Preview service"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:["Port",e.jsx(re,{type:"number",min:1,max:65535,inputMode:"numeric",value:i??"",onChange:h=>d(h.target.value),placeholder:"12345","aria-label":"Service preview port",className:"h-7 w-24 rounded-full px-3 text-xs"})]}),e.jsxs(u,{type:"submit",variant:"outline",size:"sm",className:"h-7 rounded-full px-2.5 text-xs",children:[e.jsx(te,{className:"h-3.5 w-3.5"}),"Run"]}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:z(s.expiresAt)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"truncate text-sm font-semibold text-foreground",children:s?K(s):"Preview"}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:z(s.expiresAt)})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",onClick:c,title:"Refresh",children:e.jsx(O,{className:"h-3.5 w-3.5"})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:b??s.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(B,{className:"h-3.5 w-3.5"})})}),e.jsx(u,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-full",onClick:r,title:"Fullscreen",children:e.jsx(ie,{className:"h-3.5 w-3.5"})})]}),l&&e.jsxs(u,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:v,className:"h-7 shrink-0 rounded-full px-2.5 text-xs",children:[e.jsx(de,{className:"h-3.5 w-3.5"}),"Advanced"]})]})]})}function I({serviceSession:s,error:n,children:l}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[n&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-xs text-destructive",children:n}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:s&&l?e.jsx("div",{className:"h-full overflow-hidden rounded-2xl border border-border/60 bg-white shadow-sm",children:l}):e.jsx(N,{children:"No service preview running."})})]})}function q(s){return s.openUrl??s.previewUrl}function xe(s){return s.kind==="service"?void 0:"allow-scripts allow-same-origin"}function K(s){if(s.kind==="service"&&typeof s.port=="number"){const n=s.entryPath?`/${s.entryPath.replace(/^\/+/,"")}`:"";return`127.0.0.1:${s.port}${n}`}return s.entryPath}function N({children:s}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:s})}function z(s){const n=Math.max(0,Math.round((s-Date.now())/1e3));if(n<60)return`${n}s`;const l=Math.floor(n/60),i=n%60;return`${l}m ${i}s`}export{H as PreviewHeader,I as PreviewServicePanel,fe as PreviewTab,U as PreviewToolbar,xe as getPreviewIframeSandbox,q as getPreviewOpenUrl};
|
package/dashboard/assets/{SharedConversationPage-e35GHbGI.js → SharedConversationPage-B4sLTwC9.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-
|
|
2
|
-
import{c as N,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesTab-vVa4GgR5.js","assets/index-Bg0PqgJi.js","assets/index-BzzXPy7Y.css","assets/folder-B3put-Ay.js","assets/file-BXP_hlLG.js","assets/PreviewTab-DRyl2BmE.js","assets/input-DH4KoLjb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as N,aB as k,r as s,j as e,M as S,P as T,Q as C,a3 as P,aX as M,aY as _,aZ as j,a_ as E,a$ as L,a1 as w,b0 as A}from"./index-Bg0PqgJi.js";import{n as I,j as O,i as F,L as R,C as z,T as v,m as B}from"./DashboardShared-CKWmFD7i.js";/**
|
|
3
3
|
* @license lucide-react v1.7.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const
|
|
7
|
+
*/const D=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],V=N("message-square-text",D),q=s.lazy(async()=>({default:(await w(()=>import("./FilesTab-vVa4GgR5.js"),__vite__mapDeps([0,1,2,3,4]))).FilesTab})),G=s.lazy(async()=>({default:(await w(()=>import("./PreviewTab-DRyl2BmE.js"),__vite__mapDeps([5,1,2,6]))).PreviewTab})),H={getOutput:j,getOutputTree:_,getOutputContent:M},U={getOutput:j,createPreviewSession:(t,r)=>A(t,typeof r=="string"?r:r==null?void 0:r.path)};function X(){const{shareId:t}=k(),[r,n]=s.useState(null),[c,a]=s.useState([]),[x,u]=s.useState(!0),[p,d]=s.useState(null),l=s.useRef(null);return s.useEffect(()=>{if(!t){n(null),a([]),d("Shared conversation not found"),u(!1);return}let o=!1;l.current=t,u(!0),d(null);const m=async h=>{try{const[f,b]=await Promise.all([E(t),L(t)]);if(o||l.current!==t)return;n(f),a(y=>h?b.logs:B(y,b.logs)),d(null)}catch(f){if(o||l.current!==t)return;h&&(n(null),a([]),d(f instanceof Error?f.message:"Failed to load shared conversation"))}finally{!o&&l.current===t&&h&&u(!1)}};m(!0);const i=window.setInterval(()=>{m(!1)},2500);return()=>{o=!0,window.clearInterval(i)}},[t]),e.jsx(W,{conversation:r,logs:c,loading:x,error:p})}function W({conversation:t,logs:r,loading:n,error:c}){const[a,x]=s.useState("transcript"),[u,p]=s.useState(!1),d=s.useMemo(()=>{if(!t)return null;const i=I(t.payload.initialMessage);return i.length>0?O(i,new Date(t.createdAt).toISOString()):null},[t]),l=s.useMemo(()=>F([...d?[d]:[],...r]),[d,r]),o=(t==null?void 0:t.scope)==="filesPreview",m=e.jsx("section",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain scroll-pb-16 px-4 py-5 sm:px-6",children:e.jsxs("div",{className:"mx-auto flex max-w-[72rem] flex-col gap-5 pb-16",children:[n&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border/60 bg-background/60 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"}),"Loading shared conversation..."]}),!n&&c&&e.jsxs("div",{className:"rounded-lg border border-destructive/20 bg-destructive/10 px-5 py-8 text-center text-destructive",children:[e.jsx("div",{className:"text-base font-semibold",children:"Shared conversation unavailable"}),e.jsx("div",{className:"mt-2 text-sm",children:c})]}),!n&&!c&&l.length===0&&e.jsxs("div",{className:"rounded-lg border border-dashed border-border/70 bg-background/35 px-5 py-8 text-center",children:[e.jsx(V,{className:"mx-auto h-6 w-6 text-muted-foreground"}),e.jsx("div",{className:"mt-3 text-sm font-medium text-foreground",children:"No transcript output yet"})]}),!n&&!c&&l.map((i,h)=>e.jsx(z,{event:i,questionResponseDisabled:!0},`shared-${h}`))]})});return e.jsxs("div",{className:"relative flex h-full min-h-0 overflow-hidden bg-background text-foreground",children:[e.jsxs("aside",{className:"hidden w-64 shrink-0 flex-col border-r border-border/60 bg-muted/20 px-4 py-5 lg:flex xl:w-72",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background shadow-sm",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:"Meshy Workspace"}),e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.24em] text-muted-foreground",children:"Shared view"})]})]}),e.jsx("div",{className:"mt-7 text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Shared conversation"}),t&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("h1",{className:"max-h-28 overflow-hidden break-words text-base font-semibold leading-5 text-foreground [overflow-wrap:anywhere]",title:t.title,children:t.title}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{status:t.status}),e.jsx(T,{priority:t.priority})]}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[e.jsxs("div",{children:["updated ",C(t.updatedAt)]}),e.jsx("div",{className:"font-mono",children:t.id.slice(0,8)})]})]}),e.jsxs("div",{className:"mt-auto space-y-2 pt-6",children:[u&&e.jsx("div",{className:"rounded-xl border border-border/70 bg-background/80 p-3 font-mono text-[11px] text-foreground shadow-sm",children:"npx -y meshy-node@latest start"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("a",{href:"https://github.com/ai-microsoft/meshy",target:"_blank",rel:"noreferrer","aria-label":"Open Meshy on GitHub",className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",onClick:()=>p(i=>!i),"aria-expanded":u,className:"inline-flex h-9 items-center gap-2 rounded-full border border-border/70 bg-background/70 px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(P,{className:"h-4 w-4"}),"Try it"]})]})]})]}),e.jsxs("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"shrink-0 border-b border-border/60 bg-background/85 px-4 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-border/70 bg-foreground text-xs font-semibold tracking-[0.24em] text-background lg:hidden",children:"M"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-[0.28em] text-muted-foreground",children:"Meshy Workspace"}),e.jsx("div",{className:"truncate text-base font-semibold text-foreground",children:(t==null?void 0:t.title)??"Shared conversation"})]})]}),o&&e.jsxs("div",{className:"mt-3 inline-flex h-auto rounded-full bg-muted/70 p-1 text-muted-foreground",children:[e.jsx("button",{type:"button",onClick:()=>x("transcript"),className:g(a==="transcript"),children:"Transcript"}),e.jsx("button",{type:"button",onClick:()=>x("files"),className:g(a==="files"),children:"Files"}),e.jsx("button",{type:"button",onClick:()=>x("preview"),className:g(a==="preview"),children:"Preview"})]})]}),o&&t?e.jsxs(e.Fragment,{children:[a==="transcript"&&m,a==="files"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(v,{label:"Loading files..."}),children:e.jsx(q,{taskId:t.shareId,api:H})})}),a==="preview"&&e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(v,{label:"Loading preview..."}),children:e.jsx(G,{taskId:t.shareId,api:U,allowPortPreview:!1})})})]}):m]})]})}function g(t){return t?"inline-flex items-center justify-center whitespace-nowrap rounded-full bg-background px-3 py-1.5 text-sm font-medium text-foreground shadow-sm":"inline-flex items-center justify-center whitespace-nowrap rounded-full px-3 py-1.5 text-sm font-medium transition-colors hover:text-foreground"}function Z({className:t}){return e.jsx("svg",{className:t,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.58 2 12.23c0 4.51 2.87 8.34 6.84 9.7.5.1.68-.22.68-.49 0-.24-.01-.88-.01-1.73-2.78.62-3.37-1.37-3.37-1.37-.45-1.18-1.11-1.49-1.11-1.49-.91-.64.07-.63.07-.63 1 .07 1.53 1.06 1.53 1.06.89 1.56 2.34 1.11 2.91.85.09-.66.35-1.11.63-1.37-2.22-.26-4.55-1.14-4.55-5.05 0-1.12.39-2.03 1.03-2.75-.1-.26-.45-1.31.1-2.71 0 0 .84-.27 2.75 1.05A9.3 9.3 0 0 1 12 6.96c.85 0 1.71.12 2.51.34 1.91-1.32 2.75-1.05 2.75-1.05.55 1.4.2 2.45.1 2.71.64.72 1.03 1.63 1.03 2.75 0 3.92-2.34 4.79-4.57 5.05.36.32.68.94.68 1.9 0 1.37-.01 2.47-.01 2.81 0 .27.18.59.69.49A10.05 10.05 0 0 0 22 12.23C22 6.58 17.52 2 12 2Z"})})}export{X as SharedConversationPage,W as SharedConversationView};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as o}from"./index-Bg0PqgJi.js";/**
|
|
2
|
+
* @license lucide-react v1.7.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const a=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],c=o("folder",a);export{c as F};
|