dsh-artifact-studio 0.2.0 → 0.3.1

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 CHANGED
@@ -11,7 +11,7 @@ The agent creates pages and documents as versioned files, and you open them besi
11
11
  - A save is refused when someone else saved first, so neither the agent nor you can silently overwrite the other.
12
12
  - Pages export as HTML. Docs export as Markdown, Word, or HTML. You can print either type or save it as a PDF from the print dialog.
13
13
  - A design system reaches pages as `--artifact-*` CSS variables. It has a library default and an optional project override.
14
- - The left sidebar opens the Artifacts page with a project selector. Artifacts open as tabs beside the chat. Back preserves gallery search, filters, paging, and scroll.
14
+ - The left sidebar opens the Artifacts page with one scope selector for all projects, one project, or the library. Artifacts open as tabs beside the chat. Back preserves gallery search, the scope and type filters, paging, and scroll.
15
15
  - A bundled `artifact-design` skill gives the agent design rules, and page writes return warnings for network URLs, browser storage, fixed widths over 960 pixels, and pages that ignore the design tokens.
16
16
  - The interface uses the Harness's own components and follows its light and dark theme. A page follows dark mode when it declares `<meta name="color-scheme" content="light dark">`.
17
17
  - Reload and Back ask whether to save, discard, or cancel when edits are pending. Multiple views share a draft and serialize saves. Draft recovery stays in window memory until saved or discarded. It does not survive a browser restart.
package/client.js CHANGED
@@ -4,31 +4,31 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
  globalThis.__dshArtifactsRequireAsync = require.async;
7
- "use strict";var va=Object.create;var ot=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var ka=Object.getPrototypeOf,Ta=Object.prototype.hasOwnProperty;var Sa=(e,t)=>{for(var r in t)ot(e,r,{get:t[r],enumerable:!0})},sr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of wa(t))!Ta.call(e,a)&&a!==r&&ot(e,a,{get:()=>t[a],enumerable:!(n=xa(t,a))||n.enumerable});return e};var Na=(e,t,r)=>(r=e!=null?va(ka(e)):{},sr(t||!e||!e.__esModule?ot(r,"default",{value:e,enumerable:!0}):r,e)),Ca=e=>sr(ot({},"__esModule",{value:!0}),e);var Rn={};Sa(Rn,{ARTIFACT_ID:()=>Ye,ARTIFACT_KIND:()=>_t,ArtifactCard:()=>Wt,ArtifactTab:()=>$t,CARD_TOOLS:()=>na,DocView:()=>mt,PANEL_ID:()=>$e,apply:()=>An,inject:()=>Tn});module.exports=Ca(Rn);var aa=require("@deepseek-ai/dsh-client-ui-primitives");var Aa=["page","doc"];function Ra(e){return Aa.some(t=>t===e)}var lr={page:["html"],doc:["md","docx","html"]};var it=/^art_(ws|lib)_[a-z0-9]{10,32}$/;var _e=["primary","accent","surface","text","muted"];function Lt(e){if(e===null||typeof e!="object")return!1;let t="origin"in e?e.origin:void 0,r="action"in e?e.action:void 0;return(t==="agent"||t==="user")&&(r==="create"||r==="update"||r==="restore")}function ct(e){if(e===null||typeof e!="object")return!1;let t={...e};return t.schemaVersion===1&&typeof t.id=="string"&&it.test(t.id)&&(t.scope==="workspace"||t.scope==="library")&&typeof t.type=="string"&&Ra(t.type)&&typeof t.title=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"&&typeof t.version=="number"&&Number.isInteger(t.version)&&t.version>=1&&typeof t.contentFile=="string"&&typeof t.contentBytes=="number"&&typeof t.contentHash=="string"&&Lt(t.source)}var st="dsh-resource://artifact/",lt="data-artifact-theme";function z(e){return e.scope==="workspace"?`${st}workspace/${encodeURIComponent(e.workspaceId)}/${e.id}`:`${st}library/${e.id}`}function ke(e){if(typeof e!="string"||!e.startsWith(st))return;let t=e.slice(st.length).split("/");if(t[0]==="library"&&t.length===2){let r=t[1]??"";return it.test(r)&&r.startsWith("art_lib_")?{scope:"library",id:r}:void 0}if(t[0]==="workspace"&&t.length===3){let r=t[2]??"",n;try{n=decodeURIComponent(t[1]??"")}catch{return}return n===""||!it.test(r)||!r.startsWith("art_ws_")?void 0:{scope:"workspace",workspaceId:n,id:r}}}function cr(e){if(it.test(e))return e.startsWith("art_ws_")?"workspace":"library"}function dr(e){let t=[];for(let n of _e)t.push(`--artifact-color-${n}: ${e.colors[n]};`);t.push(`--artifact-font-family: ${e.typography.fontFamily};`),t.push(`--artifact-font-display: ${e.typography.displayFamily};`),t.push(`--artifact-font-mono: ${e.typography.monoFamily};`),e.typography.scale.forEach((n,a)=>t.push(`--artifact-font-size-${a}: ${n}px;`)),t.push(`--artifact-space-unit: ${e.spacing.unit}px;`),e.spacing.scale.forEach((n,a)=>t.push(`--artifact-space-${a}: ${n}px;`));for(let[n,a]of Object.entries(e.radius))t.push(`--artifact-radius-${n}: ${a}px;`);let r=_e.map(n=>`--artifact-color-${n}: ${e.colorsDark[n]};`).join(`
7
+ "use strict";var Ta=Object.create;var rt=Object.defineProperty;var Sa=Object.getOwnPropertyDescriptor;var Ca=Object.getOwnPropertyNames;var Na=Object.getPrototypeOf,Aa=Object.prototype.hasOwnProperty;var Ra=(e,t)=>{for(var r in t)rt(e,r,{get:t[r],enumerable:!0})},sr=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ca(t))!Aa.call(e,n)&&n!==r&&rt(e,n,{get:()=>t[n],enumerable:!(a=Sa(t,n))||a.enumerable});return e};var Ea=(e,t,r)=>(r=e!=null?Ta(Na(e)):{},sr(t||!e||!e.__esModule?rt(r,"default",{value:e,enumerable:!0}):r,e)),Pa=e=>sr(rt({},"__esModule",{value:!0}),e);var Mn={};Ra(Mn,{ARTIFACT_ID:()=>Ge,ARTIFACT_KIND:()=>_t,ArtifactCard:()=>$t,ArtifactTab:()=>Vt,CARD_TOOLS:()=>sa,DocView:()=>pt,PANEL_ID:()=>je,apply:()=>Dn,inject:()=>En});module.exports=Pa(Mn);var ia=require("@deepseek-ai/dsh-client-ui-primitives");var Ia=["page","doc"];function La(e){return Ia.some(t=>t===e)}var lr={page:["html"],doc:["md","docx","html"]};var at=/^art_(ws|lib)_[a-z0-9]{10,32}$/;var $e=["primary","accent","surface","text","muted"];function Lt(e){if(e===null||typeof e!="object")return!1;let t="origin"in e?e.origin:void 0,r="action"in e?e.action:void 0;return(t==="agent"||t==="user")&&(r==="create"||r==="update"||r==="restore")}function it(e){if(e===null||typeof e!="object")return!1;let t={...e};return t.schemaVersion===1&&typeof t.id=="string"&&at.test(t.id)&&(t.scope==="workspace"||t.scope==="library")&&typeof t.type=="string"&&La(t.type)&&typeof t.title=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"&&typeof t.version=="number"&&Number.isInteger(t.version)&&t.version>=1&&typeof t.contentFile=="string"&&typeof t.contentBytes=="number"&&typeof t.contentHash=="string"&&Lt(t.source)}var nt="dsh-resource://artifact/",ot="data-artifact-theme";function H(e){return e.scope==="workspace"?`${nt}workspace/${encodeURIComponent(e.workspaceId)}/${e.id}`:`${nt}library/${e.id}`}function he(e){if(typeof e!="string"||!e.startsWith(nt))return;let t=e.slice(nt.length).split("/");if(t[0]==="library"&&t.length===2){let r=t[1]??"";return at.test(r)&&r.startsWith("art_lib_")?{scope:"library",id:r}:void 0}if(t[0]==="workspace"&&t.length===3){let r=t[2]??"",a;try{a=decodeURIComponent(t[1]??"")}catch{return}return a===""||!at.test(r)||!r.startsWith("art_ws_")?void 0:{scope:"workspace",workspaceId:a,id:r}}}function cr(e){if(at.test(e))return e.startsWith("art_ws_")?"workspace":"library"}function dr(e){let t=[];for(let a of $e)t.push(`--artifact-color-${a}: ${e.colors[a]};`);t.push(`--artifact-font-family: ${e.typography.fontFamily};`),t.push(`--artifact-font-display: ${e.typography.displayFamily};`),t.push(`--artifact-font-mono: ${e.typography.monoFamily};`),e.typography.scale.forEach((a,n)=>t.push(`--artifact-font-size-${n}: ${a}px;`)),t.push(`--artifact-space-unit: ${e.spacing.unit}px;`),e.spacing.scale.forEach((a,n)=>t.push(`--artifact-space-${n}: ${a}px;`));for(let[a,n]of Object.entries(e.radius))t.push(`--artifact-radius-${a}: ${n}px;`);let r=$e.map(a=>`--artifact-color-${a}: ${e.colorsDark[a]};`).join(`
8
8
  `);return[`:root {
9
9
  ${t.join(`
10
10
  `)}
11
- }`,`:root[${lt}="dark"] {
11
+ }`,`:root[${ot}="dark"] {
12
12
  color-scheme: dark;
13
13
  ${r}
14
14
  }`,`@media (prefers-color-scheme: dark) {
15
- :root[${lt}="auto"] {
15
+ :root[${ot}="auto"] {
16
16
  color-scheme: dark;
17
17
  ${r.replace(/\n /g,`
18
18
  `)}
19
19
  }
20
20
  }`].join(`
21
- `)}function pr(e,t){let r=t?e.colorsDark:e.colors,n={"--artifact-font-family":e.typography.fontFamily,"--artifact-font-display":e.typography.displayFamily,"--artifact-font-mono":e.typography.monoFamily};for(let a of _e)n[`--artifact-color-${a}`]=r[a];e.typography.scale.forEach((a,i)=>{n[`--artifact-font-size-${i}`]=`${a}px`}),e.spacing.scale.forEach((a,i)=>{n[`--artifact-space-${i}`]=`${a}px`});for(let[a,i]of Object.entries(e.radius))n[`--artifact-radius-${a}`]=`${i}px`;return n}var Ea="/artifacts-rpc",Ie=class extends Error{code;details;constructor(t,r,n){super(r),this.name="ArtifactCallError",this.code=t,this.details=n}},zt=null;function ur(e){zt=e}async function G(e,t,r,n){if(zt===null)throw new Ie("artifact/not-ready","The artifact channel is not ready.",{});let a=await zt.rpc.call(Ea,e,t,n);if(!a.ok)throw new Ie(a.error.code,a.error.message,a.error.details);if(!r(a.value))throw new Ie("artifact/bad-response",`The ${e} response has an unexpected shape.`,{});return a.value}function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Pa(e){return _(e)&&Array.isArray(e.items)&&e.items.every(ct)&&typeof e.total=="number"&&typeof e.hasMore=="boolean"}function Da(e){return _(e)&&ct(e.manifest)&&typeof e.content=="string"&&typeof e.version=="number"&&typeof e.designCss=="string"&&fr(e.design)}function dt(e){return _(e)&&ct(e.manifest)}function La(e){return _(e)&&typeof e.version=="number"&&typeof e.createdAt=="string"&&typeof e.contentHash=="string"&&typeof e.contentBytes=="number"&&Lt(e.source)}function Ma(e){return _(e)&&Array.isArray(e.versions)&&e.versions.every(La)}function za(e){return _(e)&&e.trashed===!0&&typeof e.trashPath=="string"}function Ia(e){return _(e)&&typeof e.path=="string"&&typeof e.bytes=="number"&&typeof e.fileName=="string"&&typeof e.mediaType=="string"&&typeof e.data=="string"}function Oa(e){return _(e)&&typeof e.html=="string"}function fr(e){return _(e)&&e.schemaVersion===1&&typeof e.name=="string"&&_(e.colors)&&_(e.colorsDark)&&_(e.typography)&&_(e.spacing)&&_(e.radius)}function Mt(e){return _(e)&&fr(e.tokens)&&(e.source==="workspace"||e.source==="library"||e.source==="default")&&typeof e.css=="string"}function J(e){return{scope:e.scope,...e.workspaceId===null?{}:{workspaceId:e.workspaceId}}}var L={list:(e,t,r)=>G("list",{...J(e),...t},Pa,r),get:(e,t,r,n)=>G("get",{...J(e),id:t,...r===void 0?{}:{version:r}},Da,n),create:(e,t,r,n)=>G("create",{...J(e),type:t,title:r,content:n},dt),update:(e,t,r,n,a)=>G("update",{...J(e),id:t,baseVersion:r,content:n,...a===void 0?{}:{title:a}},dt),rename:(e,t,r,n)=>G("update",{...J(e),id:t,baseVersion:r,title:n},dt),remove:(e,t)=>G("delete",{...J(e),id:t},za),history:(e,t,r)=>G("history",{...J(e),id:t},Ma,r),restore:(e,t,r,n)=>G("restore",{...J(e),id:t,version:r,baseVersion:n},dt),exportFile:(e,t,r,n)=>G("export",{...J(e),id:t,format:r,version:n},Ia),printable:(e,t,r)=>G("printable",{...J(e),id:t,version:r},Oa),designSystem:(e,t)=>G("designSystem",e===null?{}:{workspaceId:e},Mt,t),saveDesignSystem:(e,t)=>G("saveDesignSystem",{...J(e),tokens:t},Mt),clearDesignSystem:e=>G("clearDesignSystem",{workspaceId:e,scope:"workspace"},Mt)};function U(e){return e instanceof Ie?e.code:void 0}function V(e){switch(e){case"artifact/not-found":return"error.notFound";case"artifact/stale-version":return"error.stale";case"artifact/too-large":return"error.tooLarge";case"artifact/no-workspace":return"error.noWorkspace";case"artifact/forbidden-path":return"error.forbidden";case"artifact/corrupt":return"error.corrupt";case"artifact/invalid-tokens":return"error.tokens";case"artifact/library-unavailable":return"error.library";default:return"error.generic"}}function mr(e){let t=atob(e.data),r=new Uint8Array(t.length);for(let i=0;i<t.length;i+=1)r[i]=t.charCodeAt(i);let n=URL.createObjectURL(new Blob([r],{type:e.mediaType})),a=document.createElement("a");a.href=n,a.download=e.fileName,a.rel="noopener",document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(n),3e4)}var Fe=require("react");var qe=require("react");function ut(e){let t=e,r=new Set;return{get:()=>t,set(n){t=n;for(let a of r)a()},subscribe(n){return r.add(n),()=>r.delete(n)}}}var Oe=ut(new Map);function fe(e,t){if(Oe.get().get(e)===t)return;let r=new Map(Oe.get());r.set(e,t),Oe.set(r)}function gr(e){return Oe.get().get(e)}function br(e){return(0,qe.useSyncExternalStore)(Oe.subscribe,()=>e===void 0?void 0:Oe.get().get(e))}var Ue=ut(new Map);function Ae(e,t){if((Ue.get().get(e)??0)>=t)return;let r=new Map(Ue.get());r.set(e,t),Ue.set(r)}function yr(e){return(0,qe.useSyncExternalStore)(Ue.subscribe,()=>e===void 0?0:Ue.get().get(e)??0)}var pt=ut(0);function me(){pt.set(pt.get()+1)}function ft(){return(0,qe.useSyncExternalStore)(pt.subscribe,pt.get)}var Be=ut(null);function $(e){Be.set({seq:(Be.get()?.seq??0)+1,message:e})}function hr(){return(0,qe.useSyncExternalStore)(Be.subscribe,Be.get)}function It(e){let t=Be.get();t===null||e!==void 0&&t.seq!==e||Be.set(null)}var ge=new Map,Ot;function vr(){Ot?.();let e=t=>{[...ge.values()].some(r=>r.getSnapshot().draft!==null||r.getSnapshot().saving)&&(t.preventDefault(),t.returnValue="")};return window.addEventListener("beforeunload",e),Ot=()=>window.removeEventListener("beforeunload",e),Ot}var Bt=class{state={payload:null,draft:null,loading:!0,saving:!1,conflict:!1,revision:0};listeners=new Set;pending=null;readSequence=0;mounts=0;renameTo;where;key;address;constructor(t){this.address=t,this.key=z(t),this.where={scope:t.scope,workspaceId:t.scope==="workspace"?t.workspaceId:null}}getSnapshot=()=>this.state;subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t));publish(t){this.state={...this.state,...t},this.state.draft!==null||this.state.saving?ge.set(this.key,this):this.mounts===0&&ge.get(this.key)===this&&ge.delete(this.key);for(let r of this.listeners)r()}attach(){return this.mounts+=1,ge.set(this.key,this),this.mounts===1&&(this.state.payload===null||this.state.draft===null)&&this.load(),()=>{this.mounts-=1,this.mounts===0&&this.state.draft===null&&!this.state.saving&&ge.get(this.key)===this&&ge.delete(this.key)}}async load(){let t=++this.readSequence;this.publish({loading:!0,failure:void 0});try{let r=await L.get(this.where,this.address.id);if(t!==this.readSequence)return;if(this.state.draft!==null&&this.state.payload!==null){this.publish({loading:!1,conflict:r.version!==this.state.payload.version});return}this.publish({payload:r,loading:!1,conflict:!1,failure:void 0,revision:this.state.revision+1}),fe(this.address.id,r.manifest.title),Ae(this.address.id,r.version)}catch(r){t===this.readSequence&&this.publish({loading:!1,failure:U(r)??"artifact/storage-failure"})}}edit(t){this.publish({draft:t,failure:void 0})}async discardAndReload(){this.pending!==null&&await this.pending,this.publish({draft:null,conflict:!1,failure:void 0}),await this.load()}externalVersion(t){this.state.payload===null||t<=this.state.payload.version||this.state.saving||(this.state.draft!==null?this.publish({conflict:!0}):this.load())}save(t){return t!==void 0&&(this.renameTo=t),this.pending!==null?this.pending:this.state.conflict||this.state.payload===null?Promise.resolve(!1):(this.pending=Promise.resolve().then(()=>this.drain()),this.pending)}async drain(){this.publish({saving:!0,failure:void 0});try{for(;this.state.draft!==null||this.renameTo!==void 0;){let t=this.state.payload;if(t===null||this.state.conflict)return!1;let r=this.state.draft,n=r??t.content,a=this.renameTo,{manifest:i}=await L.update(this.where,this.address.id,t.version,n,a);this.renameTo===a&&(this.renameTo=void 0),this.accept(i,n,this.state.draft===r?null:this.state.draft)}return!0}catch(t){let r=U(t)??"artifact/storage-failure";return this.renameTo=void 0,this.publish({failure:r,conflict:r==="artifact/stale-version"}),!1}finally{this.pending=null,this.publish({saving:!1})}}accept(t,r,n){let a=this.state.payload;a!==null&&(++this.readSequence,this.publish({payload:{...a,manifest:t,content:r,version:t.version},draft:n,conflict:!1,loading:!1}),fe(t.id,t.title),Ae(t.id,t.version),me())}};function xr(e){let t=z(e),r=(0,Fe.useMemo)(()=>{let a=ge.get(t);if(a!==void 0)return a;let i=new Bt(e);return ge.set(t,i),i},[t]),n=(0,Fe.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot);return(0,Fe.useEffect)(()=>r.attach(),[r]),{model:r,state:n}}var v=require("react"),m=require("@deepseek-ai/dsh-client-ui-primitives");var D=require("react"),wr=require("@deepseek-ai/dsh-client-ui-primitives");var ne=require("react/jsx-runtime"),Ke=null;function Ba(){if(Ke===null){let e=globalThis.__dshArtifactsRequireAsync;if(typeof e!="function")return Promise.reject(new Error("The document editor loader is unavailable."));Ke=e("./client.doc.js"),Ke.catch(()=>{Ke=null})}return Ke}var Fa=["heading","bold","italic","bulletList","orderedList","codeBlock"];function ja(e){let t=window.getSelection(),r=e.getBoundingClientRect(),a=(t!==null&&t.rangeCount>0?t.getRangeAt(0):null)?.getBoundingClientRect();if(a===void 0||a.width===0&&a.height===0)return{top:e.scrollTop+8,left:16};let i=Math.min(Math.max(a.left-r.left+a.width/2,120),Math.max(r.width-120,120));return{top:Math.max(a.top-r.top+e.scrollTop-46,e.scrollTop+4),left:i}}function mt({markdown:e,revision:t,editable:r,label:n,loadingLabel:a,failedLabel:i,onChange:s,onSave:d,onSelectionText:u,t:f,design:b,dark:y=!1,selectionAction:h}){let k=(0,D.useRef)(null),c=(0,D.useRef)(null),g=(0,D.useRef)(null),M=(0,D.useRef)(s);M.current=s;let E=(0,D.useRef)(u);E.current=u;let P=(0,D.useRef)({markdown:e,editable:r,label:n});P.current={markdown:e,editable:r,label:n};let[F,se]=(0,D.useState)([]),[B,te]=(0,D.useState)("loading"),[X,xe]=(0,D.useState)(null),le=(0,D.useRef)(null);(0,D.useLayoutEffect)(()=>{let x=le.current,C=k.current;if(x===null||C===null||X===null)return;let I=x.offsetWidth/2,O=C.clientWidth,H=I*2+16>=O?O/2:Math.min(Math.max(X.left,I+8),O-I-8);x.style.left=H+"px"});let ce=(0,D.useMemo)(()=>b===void 0?{}:{...pr(b,y),colorScheme:y?"dark":"light"},[b,y]),re=x=>{E.current?.(x);let C=k.current;xe(x===""||C===null?null:ja(C))},Q=(0,D.useRef)(re);Q.current=re,(0,D.useEffect)(()=>{let x=!1;return Ba().then(C=>{x||c.current===null||(g.current=C.mountDocEditor({element:c.current,...P.current,onChange:I=>M.current(I),onSelectionChange:se,onSelectionText:I=>Q.current(I)}),te("ready"))}).catch(()=>{x||te("failed")}),()=>{x=!0,g.current?.destroy(),g.current=null}},[]),(0,D.useEffect)(()=>{let x=g.current;x!==null&&x.getMarkdown()!==e&&x.setMarkdown(e)},[t,e]),(0,D.useEffect)(()=>{g.current?.setEditable(r)},[r]),(0,D.useEffect)(()=>{let x=()=>{let C=g.current,I=k.current,O=window.getSelection();C===null||I===null||O!==null&&O.anchorNode!==null&&!I.contains(O.anchorNode)||Q.current(C.getSelectionText())};return document.addEventListener("selectionchange",x),()=>document.removeEventListener("selectionchange",x)},[]);let j=X!==null&&f!==void 0&&(r||h!=null);return(0,ne.jsxs)("div",{className:"art-doc",ref:k,"data-doc-revision":t,onKeyDown:x=>{(x.ctrlKey||x.metaKey)&&x.key.toLowerCase()==="s"&&(x.preventDefault(),d()),x.key==="Escape"&&X!==null&&xe(null)},children:[j?(0,ne.jsxs)("div",{ref:le,className:"art-doc-toolbar",role:"toolbar","aria-label":f("format.toolbar"),style:{top:X.top,left:X.left},children:[r?Fa.map(x=>(0,ne.jsx)(wr.Button,{size:"sm",variant:"ghost","aria-pressed":F.includes(x),disabled:B!=="ready",onMouseDown:C=>C.preventDefault(),onClick:()=>g.current?.format(x),children:f(`format.${x}`)},x)):null,r&&h!=null?(0,ne.jsx)("span",{className:"art-doc-toolbar-gap","aria-hidden":"true"}):null,h]}):null,B==="loading"?(0,ne.jsx)("p",{className:"art-note",children:a}):null,B==="failed"?(0,ne.jsx)("p",{className:"art-note",children:i}):null,(0,ne.jsx)("div",{className:"art-docpage",style:ce,children:(0,ne.jsx)("div",{className:"art-doc-mount",ref:c})})]})}function Ha(e){return/<meta\b[^>]*name\s*=\s*["']?color-scheme["']?[^>]*content\s*=\s*["'][^"']*\bdark\b/i.test(e)||/<meta\b[^>]*content\s*=\s*["'][^"']*\bdark\b[^"']*["'][^>]*name\s*=\s*["']?color-scheme/i.test(e)}var Tr="default-src 'none'; img-src data: blob:; media-src data: blob:; style-src 'unsafe-inline'; script-src 'unsafe-inline' 'unsafe-eval'; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'",Sr=["body, .art-docpage { color: var(--artifact-color-text); font-family: var(--artifact-font-family); font-size: 16px; line-height: 1.65; }","h1, h2, h3, h4 { font-family: var(--artifact-font-display); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; margin: 1.8em 0 0.5em; color: var(--artifact-color-text); text-wrap: balance; }","h1 { font-size: 2.1em; margin-top: 0; }","h2 { font-size: 1.45em; }","h3 { font-size: 1.15em; }","p, ul, ol, blockquote, table, pre { margin: 0 0 1em; }","a { color: var(--artifact-color-primary); text-underline-offset: 2px; }","strong { font-weight: 650; }","code { font-family: var(--artifact-font-mono); font-size: 0.88em; padding: 0.1em 0.35em; border-radius: var(--artifact-radius-sm); background: color-mix(in srgb, var(--artifact-color-text) 7%, transparent); }","pre { font-family: var(--artifact-font-mono); font-size: 0.86em; line-height: 1.55; padding: 14px 16px; border-radius: var(--artifact-radius-md); background: color-mix(in srgb, var(--artifact-color-text) 6%, transparent); overflow: auto; }","pre code { padding: 0; background: none; font-size: 1em; }","blockquote { padding: 0 0 0 16px; border-left: 3px solid var(--artifact-color-accent); color: var(--artifact-color-muted); }","ul, ol { padding-left: 1.4em; }","li + li { margin-top: 0.25em; }","table { border-collapse: collapse; width: 100%; font-size: 0.94em; font-variant-numeric: tabular-nums; }","th, td { padding: 8px 10px; border-bottom: 1px solid color-mix(in srgb, var(--artifact-color-text) 14%, transparent); text-align: left; vertical-align: top; }","th { font-weight: 600; color: var(--artifact-color-muted); border-bottom-color: color-mix(in srgb, var(--artifact-color-text) 28%, transparent); }","hr { border: none; border-top: 1px solid color-mix(in srgb, var(--artifact-color-text) 14%, transparent); margin: 2em 0; }"].join(`
22
- `);var Ft="<script>addEventListener('message',function(e){if(e.source!==parent||e.data!=='dsh-artifact-print')return;addEventListener('afterprint',function(){parent.postMessage('dsh-artifact-printed','*')},{once:true});print()})<\/script>";function kr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function $a(e){return e.replace(/<meta\b[^>]*http-equiv\s*=\s*["']?refresh["']?[^>]*>/gi,"").replace(/<meta\b[^>]*content\s*=\s*["'][^"']*url\s*=[^>]*>/gi,"")}function Nr(e,t,r,n,a="",i="auto"){let s='<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">'+(r===null?"":`<meta http-equiv="Content-Security-Policy" content="${kr(r)}">`)+`<title>${kr(n)}</title><style data-artifact-tokens>${t}</style>`+a;return`<!doctype html><html${Ha(e)?` ${lt}="${i}"`:""}><head>${s}</head><body>${$a(e)}</body></html>`}var Cr="allow-scripts",Va="allow-scripts allow-modals",Wa=3e4,_a="<script>(function(){var t;document.addEventListener('selectionchange',function(){clearTimeout(t);t=setTimeout(function(){var s=String(getSelection()||'');parent.postMessage({dshArtifactSelection:s.slice(0,4000)},'*')},150)})})()<\/script>",Ua=4e3;function gt(e,t,r,n="auto",a=!1){return Nr(e,t,Tr,r,a?_a:"",n)}function Ar(e){if(e===null||typeof e!="object")return;let t={...e};return typeof t.dshArtifactSelection=="string"?t.dshArtifactSelection.slice(0,Ua):void 0}function Rr(e){let t=/<\/head>/i.test(e)?e.replace(/<\/head>/i,`${Ft}</head>`):`${Ft}${e}`,r=URL.createObjectURL(new Blob([t],{type:"text/html"})),n=document.createElement("iframe");n.setAttribute("sandbox",Va),n.setAttribute("aria-hidden","true"),n.tabIndex=-1,n.style.cssText="position:fixed;left:-10000px;top:0;width:800px;height:1000px;border:0;";let a=!1,i=()=>{a||(a=!0,clearTimeout(d),window.removeEventListener("message",s),n.remove(),URL.revokeObjectURL(r))},s=u=>{u.source===n.contentWindow&&u.data==="dsh-artifact-printed"&&i()};window.addEventListener("message",s);let d=setTimeout(i,Wa);n.addEventListener("load",()=>{n.contentWindow?.postMessage("dsh-artifact-print","*")},{once:!0}),n.src=r,document.body.appendChild(n)}var Er={"agent.ask":"Edit with agent","agent.reference":'In artifact "{title}" ({id}, v{version}):',"agent.referenceOld":'In artifact "{title}" ({id}, v{version}, the current version is v{current}):',"agent.added":"Added to your message. Describe the change, then send.","agent.addedTruncated":"Added to your message. The selection was shortened to 2,000 characters.","agent.insertFailed":"The message box is busy, so the request was copied instead.","agent.copied":"Copied. Paste it into a conversation, then send.","agent.copyTitle":"Copy the request","card.creating":"Creating {title}","card.updating":"Updating {title}","card.updatingUntitled":"Updating the artifact","card.openNamed":"Open {title}","tab.codeHint":"Read-only code. Select text to ask the agent about it.","tab.editSource":"Edit code","tab.deleteTitle":"Move to trash?","code.copy":"Copy code","dialog.close":"Close","dialog.done":"Done","design.colorsDark":"Dark colors","design.display":"Heading font stack","composer.recent":"This project","composer.empty":"No artifacts yet","composer.start":"Start with","composer.all":"All artifacts","gallery.copyPrompt":"Copy prompt","gallery.copyPromptNamed":"Copy the {name} prompt","gallery.promptCopied":"Prompt copied. Paste it into a conversation.","prompt.dashboard":"Dashboard","prompt.dashboardText":"Make a dashboard page that shows ","prompt.explainer":"Explainer","prompt.explainerText":"Make a one-page visual explainer of ","prompt.report":"Report","prompt.reportText":"Write a report document about ","prompt.brief":"Project brief","prompt.briefText":"Write a project brief with context, goal, scope, and open questions for ","filter.scope":"Filter by storage","filter.type":"Filter by type","tab.mode":"Page view","tab.manualSave":"Page source saves with Save or Ctrl/Cmd+S.","tab.versionPicker":"Choose version","tab.currentVersion":"current","tab.allVersions":"All versions","tab.agentUpdate":"Updated to v{version}","tab.viewHistory":"View history","tab.dismiss":"Dismiss","tab.leaveTitle":"Keep your changes?","tab.leaveHint":"Save your changes before continuing, or discard them. Cancel keeps you here.","tab.discardContinue":"Discard and continue","tab.saveContinue":"Save and continue","tab.copyDraft":"Copy my draft","tab.discardReload":"Discard mine and reload","history.close":"Close history","action.copied":"Copied","action.copyFailed":"Copy was blocked. Select the text and copy it manually.","format.toolbar":"Document formatting","format.heading":"Heading","format.bold":"Bold","format.italic":"Italic","format.bulletList":"Bullet list","format.orderedList":"Numbered list","format.codeBlock":"Code block",panel:"Artifacts","panel.workspace":"Project","action.back":"Back","scope.workspace":"This project","scope.library":"Library","scope.workspaceHint":"Stored in the Harness home for this workspace.","scope.libraryHint":"Stored in your profile and shared by every project.","type.page":"Page","type.doc":"Document","type.all":"All types","filter.all":"All","gallery.search":"Search artifacts","gallery.searchLabel":"Search by title","gallery.create":"New artifact","gallery.newPage":"New page","gallery.newDoc":"New document","gallery.design":"Design system","gallery.refresh":"Refresh","gallery.more":"Show more","gallery.truncated":"Only the first 500 artifacts are scanned.","gallery.version":"v{version}","gallery.updated":"Updated {time}","gallery.count":"{count} artifacts","gallery.pinned":"Pinned","gallery.recent":"Recently updated","gallery.coverTitle":"Preview of {title}","gallery.coverFailed":"Preview unavailable","gallery.pin":"Pin {title}","gallery.unpin":"Unpin {title}","gallery.allPinned":"Everything here is pinned.","empty.workspaceTitle":"No artifacts in this project yet","empty.workspaceHint":"Ask the agent for a dashboard, report, or one-pager, or start one here.","empty.libraryTitle":"Your library is empty","empty.libraryHint":"Library artifacts follow you to every project. Ask the agent to save one to the library.","empty.noMatch":"Nothing matches that search.","empty.typeMatch":"No {type} artifacts match the filter.","empty.noWorkspace":"Open a session in a workspace to see its artifacts.","empty.loading":"Loading...","create.title":"New {type}","create.name":"Title","create.scope":"Save to","create.submit":"Create","create.cancel":"Cancel","create.untitledPage":"Untitled page","create.untitledDoc":"Untitled document","tab.preview":"Preview","tab.source":"Code","tab.history":"History","tab.export":"Export","tab.reload":"Reload","tab.rename":"Rename","tab.delete":"Move to trash","tab.deleteConfirm":'"{title}" moves to the trash. Its files stay there for 7 days.',"tab.save":"Save","tab.saving":"Saving...","tab.saved":"Saved","tab.readOnly":"Read-only","tab.saveFailed":"Save failed","tab.unsaved":"Unsaved changes","tab.frameTitle":"Artifact preview: {title}","tab.versionOf":"Version {version}","tab.viewingOld":"Viewing version {version}. The current version is {current}.","tab.backToCurrent":"Back to current","tab.restoreThis":"Restore this version","tab.conflictTitle":"This artifact changed","tab.conflictHint":"A newer version was saved while you were editing. Your draft is kept here. Copy it before discarding, then reload the latest version.","tab.deleted":"This artifact is no longer here","tab.deletedHint":"It was moved to the trash or deleted.","tab.close":"Close tab","history.title":"Versions","history.current":"Current","history.byAgent":"Agent","history.byUser":"You","history.restored":"Restored from v{version}","history.created":"Created","history.updated":"Edited","history.empty":"No earlier versions.","export.html":"HTML file","export.md":"Markdown file","export.docx":"Word document","export.print":"Print or save as PDF","export.done":"Saved {name} to {path}","design.title":"Design system","design.hint":"Pages and documents use these values through CSS variables.","design.source.workspace":"This project overrides the library.","design.source.library":"Inherited from your library.","design.source.default":"Built-in defaults. Save to start your own.","design.name":"Name","design.colors":"Colors","design.color.primary":"Primary","design.color.accent":"Accent","design.color.surface":"Surface","design.color.text":"Text","design.color.muted":"Muted","design.type":"Typography","design.font":"Body font stack","design.mono":"Code font stack","design.radius":"Corner radius","design.radius.sm":"Small","design.radius.md":"Medium","design.radius.lg":"Large","design.notes":"Notes for the agent","design.notesHint":"Tone, layout rules, or brand guidance the agent reads before it designs.","design.saveWorkspace":"Save for this project","design.saveLibrary":"Save to library","design.clear":"Remove project override","design.saved":"Design system saved","design.preview":"Preview","design.previewHeading":"Quarterly review","design.previewBody":"Revenue grew in every region this quarter.","design.previewButton":"Primary action","card.created":"Created","card.updated":"Updated","card.working":"Writing the artifact...","card.failed":"The artifact was not saved","card.missing":"This result has no artifact details.","composer.label":"Artifacts","error.generic":"Something went wrong. Try again.","error.notFound":"This artifact no longer exists.","error.stale":"The artifact changed. Reload to continue.","error.tooLarge":"The content is over the 2 MiB limit.","error.noWorkspace":"This session has no workspace.","error.forbidden":"That path is not allowed.","error.corrupt":"The artifact files are damaged.","error.tokens":"A design value is not valid CSS.","error.library":"The library folder cannot be created.","error.surface":"The artifact panel failed to draw.","error.surfaceHint":"Reload the window. Your artifacts are safe on disk.","action.retry":"Retry","action.reloadWindow":"Reload window","time.justNow":"just now","time.minutes":"{count} min ago","time.hours":"{count} h ago","time.days":"{count} d ago"},Pr={"agent.ask":"\u8BA9\u667A\u80FD\u4F53\u4FEE\u6539","agent.reference":"\u5728\u4EA7\u7269\u201C{title}\u201D\uFF08{id}\uFF0Cv{version}\uFF09\u4E2D\uFF1A","agent.referenceOld":"\u5728\u4EA7\u7269\u201C{title}\u201D\uFF08{id}\uFF0Cv{version}\uFF0C\u5F53\u524D\u7248\u672C\u4E3A v{current}\uFF09\u4E2D\uFF1A","agent.added":"\u5DF2\u52A0\u5165\u6D88\u606F\u6846\u3002\u63CF\u8FF0\u8981\u4FEE\u6539\u7684\u5185\u5BB9\u540E\u53D1\u9001\u3002","agent.addedTruncated":"\u5DF2\u52A0\u5165\u6D88\u606F\u6846\u3002\u9009\u4E2D\u7684\u6587\u672C\u5DF2\u7F29\u77ED\u4E3A 2,000 \u4E2A\u5B57\u7B26\u3002","agent.insertFailed":"\u6D88\u606F\u6846\u6B63\u5FD9\uFF0C\u5DF2\u6539\u4E3A\u590D\u5236\u8BF7\u6C42\u3002","agent.copied":"\u5DF2\u590D\u5236\u3002\u7C98\u8D34\u5230\u5BF9\u8BDD\u4E2D\u540E\u53D1\u9001\u3002","agent.copyTitle":"\u590D\u5236\u8BF7\u6C42","card.creating":"\u6B63\u5728\u521B\u5EFA {title}","card.updating":"\u6B63\u5728\u66F4\u65B0 {title}","card.updatingUntitled":"\u6B63\u5728\u66F4\u65B0\u4EA7\u7269","card.openNamed":"\u6253\u5F00 {title}","tab.codeHint":"\u53EA\u8BFB\u4EE3\u7801\u3002\u9009\u4E2D\u6587\u672C\u5373\u53EF\u8BA9\u667A\u80FD\u4F53\u5904\u7406\u3002","tab.editSource":"\u7F16\u8F91\u4EE3\u7801","tab.deleteTitle":"\u79FB\u5230\u56DE\u6536\u7AD9\uFF1F","code.copy":"\u590D\u5236\u4EE3\u7801","dialog.close":"\u5173\u95ED","dialog.done":"\u5B8C\u6210","design.colorsDark":"\u6DF1\u8272\u914D\u8272","design.display":"\u6807\u9898\u5B57\u4F53\u6808","composer.recent":"\u5F53\u524D\u9879\u76EE","composer.empty":"\u8FD8\u6CA1\u6709\u4EA7\u7269","composer.start":"\u4ECE\u8FD9\u91CC\u5F00\u59CB","composer.all":"\u5168\u90E8\u4EA7\u7269","gallery.copyPrompt":"\u590D\u5236\u63D0\u793A\u8BCD","gallery.copyPromptNamed":"\u590D\u5236\u201C{name}\u201D\u63D0\u793A\u8BCD","gallery.promptCopied":"\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\u3002\u7C98\u8D34\u5230\u5BF9\u8BDD\u4E2D\u5373\u53EF\u3002","prompt.dashboard":"\u4EEA\u8868\u76D8","prompt.dashboardText":"\u5236\u4F5C\u4E00\u4E2A\u4EEA\u8868\u76D8\u9875\u9762\uFF0C\u5C55\u793A","prompt.explainer":"\u56FE\u89E3\u8BF4\u660E","prompt.explainerText":"\u5236\u4F5C\u4E00\u9875\u53EF\u89C6\u5316\u8BF4\u660E\uFF0C\u4E3B\u9898\u662F","prompt.report":"\u62A5\u544A","prompt.reportText":"\u5199\u4E00\u4EFD\u62A5\u544A\u6587\u6863\uFF0C\u4E3B\u9898\u662F","prompt.brief":"\u9879\u76EE\u7B80\u4ECB","prompt.briefText":"\u5199\u4E00\u4EFD\u9879\u76EE\u7B80\u4ECB\uFF0C\u5305\u542B\u80CC\u666F\u3001\u76EE\u6807\u3001\u8303\u56F4\u548C\u5F85\u5B9A\u95EE\u9898\uFF0C\u9879\u76EE\u662F","filter.scope":"\u6309\u5B58\u50A8\u4F4D\u7F6E\u7B5B\u9009","filter.type":"\u6309\u7C7B\u578B\u7B5B\u9009","tab.mode":"\u9875\u9762\u89C6\u56FE","tab.manualSave":"\u9875\u9762\u6E90\u7801\u9700\u70B9\u51FB\u4FDD\u5B58\u6216\u6309 Ctrl/Cmd+S\u3002","tab.versionPicker":"\u9009\u62E9\u7248\u672C","tab.currentVersion":"\u5F53\u524D","tab.allVersions":"\u5168\u90E8\u7248\u672C","tab.agentUpdate":"\u5DF2\u66F4\u65B0\u5230 v{version}","tab.viewHistory":"\u67E5\u770B\u5386\u53F2","tab.dismiss":"\u5173\u95ED","tab.leaveTitle":"\u4FDD\u7559\u66F4\u6539\uFF1F","tab.leaveHint":"\u7EE7\u7EED\u524D\u4FDD\u5B58\u66F4\u6539\uFF0C\u6216\u653E\u5F03\u66F4\u6539\u3002\u53D6\u6D88\u5C06\u4FDD\u7559\u5F53\u524D\u7F16\u8F91\u3002","tab.discardContinue":"\u653E\u5F03\u5E76\u7EE7\u7EED","tab.saveContinue":"\u4FDD\u5B58\u5E76\u7EE7\u7EED","tab.copyDraft":"\u590D\u5236\u6211\u7684\u8349\u7A3F","tab.discardReload":"\u653E\u5F03\u6211\u7684\u66F4\u6539\u5E76\u91CD\u65B0\u52A0\u8F7D","history.close":"\u5173\u95ED\u5386\u53F2","action.copied":"\u5DF2\u590D\u5236","action.copyFailed":"\u590D\u5236\u88AB\u963B\u6B62\u3002\u8BF7\u9009\u4E2D\u6587\u672C\u540E\u624B\u52A8\u590D\u5236\u3002","format.toolbar":"\u6587\u6863\u683C\u5F0F","format.heading":"\u6807\u9898","format.bold":"\u7C97\u4F53","format.italic":"\u659C\u4F53","format.bulletList":"\u9879\u76EE\u7B26\u53F7\u5217\u8868","format.orderedList":"\u7F16\u53F7\u5217\u8868","format.codeBlock":"\u4EE3\u7801\u5757",panel:"\u4EA7\u7269","panel.workspace":"\u9879\u76EE","action.back":"\u8FD4\u56DE","scope.workspace":"\u5F53\u524D\u9879\u76EE","scope.library":"\u8D44\u6599\u5E93","scope.workspaceHint":"\u4FDD\u5B58\u5728 Harness \u4E3B\u76EE\u5F55\u4E2D\uFF0C\u4EC5\u5C5E\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u3002","scope.libraryHint":"\u4FDD\u5B58\u5728\u4E2A\u4EBA\u914D\u7F6E\u4E2D\uFF0C\u6240\u6709\u9879\u76EE\u5171\u4EAB\u3002","type.page":"\u9875\u9762","type.doc":"\u6587\u6863","type.all":"\u5168\u90E8\u7C7B\u578B","filter.all":"\u5168\u90E8","gallery.search":"\u641C\u7D22\u4EA7\u7269","gallery.searchLabel":"\u6309\u6807\u9898\u641C\u7D22","gallery.create":"\u65B0\u5EFA\u4EA7\u7269","gallery.newPage":"\u65B0\u5EFA\u9875\u9762","gallery.newDoc":"\u65B0\u5EFA\u6587\u6863","gallery.design":"\u8BBE\u8BA1\u7CFB\u7EDF","gallery.refresh":"\u5237\u65B0","gallery.more":"\u663E\u793A\u66F4\u591A","gallery.truncated":"\u4EC5\u626B\u63CF\u524D 500 \u4E2A\u4EA7\u7269\u3002","gallery.version":"v{version}","gallery.updated":"\u66F4\u65B0\u4E8E {time}","gallery.count":"{count} \u4E2A\u4EA7\u7269","gallery.pinned":"\u5DF2\u7F6E\u9876","gallery.recent":"\u6700\u8FD1\u66F4\u65B0","gallery.coverTitle":"{title} \u7684\u9884\u89C8","gallery.coverFailed":"\u9884\u89C8\u4E0D\u53EF\u7528","gallery.pin":"\u7F6E\u9876 {title}","gallery.unpin":"\u53D6\u6D88\u7F6E\u9876 {title}","gallery.allPinned":"\u8FD9\u91CC\u7684\u4EA7\u7269\u90FD\u5DF2\u7F6E\u9876\u3002","empty.workspaceTitle":"\u672C\u9879\u76EE\u8FD8\u6CA1\u6709\u4EA7\u7269","empty.workspaceHint":"\u8BA9\u667A\u80FD\u4F53\u751F\u6210\u4EEA\u8868\u76D8\u3001\u62A5\u544A\u6216\u5355\u9875\uFF0C\u6216\u5728\u8FD9\u91CC\u65B0\u5EFA\u3002","empty.libraryTitle":"\u8D44\u6599\u5E93\u4E3A\u7A7A","empty.libraryHint":"\u8D44\u6599\u5E93\u4E2D\u7684\u4EA7\u7269\u5728\u6240\u6709\u9879\u76EE\u53EF\u7528\u3002\u8BA9\u667A\u80FD\u4F53\u628A\u4EA7\u7269\u4FDD\u5B58\u5230\u8D44\u6599\u5E93\u3002","empty.noMatch":"\u6CA1\u6709\u5339\u914D\u7684\u4EA7\u7269\u3002","empty.typeMatch":"\u6CA1\u6709\u7B26\u5408\u7C7B\u578B\u7B5B\u9009\u7684{type}\u4EA7\u7269\u3002","empty.noWorkspace":"\u5728\u5DE5\u4F5C\u533A\u4E2D\u6253\u5F00\u4F1A\u8BDD\u4EE5\u67E5\u770B\u5176\u4EA7\u7269\u3002","empty.loading":"\u52A0\u8F7D\u4E2D...","create.title":"\u65B0\u5EFA{type}","create.name":"\u6807\u9898","create.scope":"\u4FDD\u5B58\u5230","create.submit":"\u521B\u5EFA","create.cancel":"\u53D6\u6D88","create.untitledPage":"\u672A\u547D\u540D\u9875\u9762","create.untitledDoc":"\u672A\u547D\u540D\u6587\u6863","tab.preview":"\u9884\u89C8","tab.source":"\u4EE3\u7801","tab.history":"\u5386\u53F2","tab.export":"\u5BFC\u51FA","tab.reload":"\u91CD\u65B0\u52A0\u8F7D","tab.rename":"\u91CD\u547D\u540D","tab.delete":"\u79FB\u5230\u56DE\u6536\u7AD9","tab.deleteConfirm":"\u201C{title}\u201D\u5C06\u79FB\u5230\u56DE\u6536\u7AD9\uFF0C\u6587\u4EF6\u4F1A\u4FDD\u7559 7 \u5929\u3002","tab.save":"\u4FDD\u5B58","tab.saving":"\u6B63\u5728\u4FDD\u5B58...","tab.saved":"\u5DF2\u4FDD\u5B58","tab.readOnly":"\u53EA\u8BFB","tab.saveFailed":"\u4FDD\u5B58\u5931\u8D25","tab.unsaved":"\u6709\u672A\u4FDD\u5B58\u7684\u66F4\u6539","tab.frameTitle":"\u4EA7\u7269\u9884\u89C8\uFF1A{title}","tab.versionOf":"\u7248\u672C {version}","tab.viewingOld":"\u6B63\u5728\u67E5\u770B\u7248\u672C {version}\uFF0C\u5F53\u524D\u7248\u672C\u4E3A {current}\u3002","tab.backToCurrent":"\u56DE\u5230\u5F53\u524D\u7248\u672C","tab.restoreThis":"\u6062\u590D\u6B64\u7248\u672C","tab.conflictTitle":"\u6B64\u4EA7\u7269\u5DF2\u66F4\u6539","tab.conflictHint":"\u7F16\u8F91\u671F\u95F4\u4FDD\u5B58\u4E86\u66F4\u65B0\u7248\u672C\u3002\u8349\u7A3F\u4ECD\u4FDD\u7559\u5728\u8FD9\u91CC\u3002\u653E\u5F03\u524D\u53EF\u5148\u590D\u5236\u8349\u7A3F\uFF0C\u518D\u91CD\u65B0\u52A0\u8F7D\u6700\u65B0\u7248\u672C\u3002","tab.deleted":"\u6B64\u4EA7\u7269\u5DF2\u4E0D\u5B58\u5728","tab.deletedHint":"\u5B83\u5DF2\u88AB\u79FB\u5230\u56DE\u6536\u7AD9\u6216\u5220\u9664\u3002","tab.close":"\u5173\u95ED\u6807\u7B7E\u9875","history.title":"\u7248\u672C","history.current":"\u5F53\u524D","history.byAgent":"\u667A\u80FD\u4F53","history.byUser":"\u4F60","history.restored":"\u4ECE v{version} \u6062\u590D","history.created":"\u521B\u5EFA","history.updated":"\u7F16\u8F91","history.empty":"\u6CA1\u6709\u66F4\u65E9\u7684\u7248\u672C\u3002","export.html":"HTML \u6587\u4EF6","export.md":"Markdown \u6587\u4EF6","export.docx":"Word \u6587\u6863","export.print":"\u6253\u5370\u6216\u53E6\u5B58\u4E3A PDF","export.done":"\u5DF2\u5C06 {name} \u4FDD\u5B58\u5230 {path}","design.title":"\u8BBE\u8BA1\u7CFB\u7EDF","design.hint":"\u9875\u9762\u548C\u6587\u6863\u901A\u8FC7 CSS \u53D8\u91CF\u4F7F\u7528\u8FD9\u4E9B\u503C\u3002","design.source.workspace":"\u672C\u9879\u76EE\u8986\u76D6\u4E86\u8D44\u6599\u5E93\u8BBE\u7F6E\u3002","design.source.library":"\u7EE7\u627F\u81EA\u8D44\u6599\u5E93\u3002","design.source.default":"\u5185\u7F6E\u9ED8\u8BA4\u503C\u3002\u4FDD\u5B58\u540E\u5373\u53EF\u81EA\u5B9A\u4E49\u3002","design.name":"\u540D\u79F0","design.colors":"\u989C\u8272","design.color.primary":"\u4E3B\u8272","design.color.accent":"\u5F3A\u8C03\u8272","design.color.surface":"\u5E95\u8272","design.color.text":"\u6587\u5B57","design.color.muted":"\u6B21\u8981","design.type":"\u5B57\u4F53","design.font":"\u6B63\u6587\u5B57\u4F53","design.mono":"\u4EE3\u7801\u5B57\u4F53","design.radius":"\u5706\u89D2","design.radius.sm":"\u5C0F","design.radius.md":"\u4E2D","design.radius.lg":"\u5927","design.notes":"\u7ED9\u667A\u80FD\u4F53\u7684\u8BF4\u660E","design.notesHint":"\u667A\u80FD\u4F53\u8BBE\u8BA1\u524D\u4F1A\u8BFB\u53D6\u7684\u8BED\u6C14\u3001\u6392\u7248\u89C4\u5219\u6216\u54C1\u724C\u89C4\u8303\u3002","design.saveWorkspace":"\u4FDD\u5B58\u5230\u672C\u9879\u76EE","design.saveLibrary":"\u4FDD\u5B58\u5230\u8D44\u6599\u5E93","design.clear":"\u79FB\u9664\u9879\u76EE\u8986\u76D6","design.saved":"\u8BBE\u8BA1\u7CFB\u7EDF\u5DF2\u4FDD\u5B58","design.preview":"\u9884\u89C8","design.previewHeading":"\u5B63\u5EA6\u56DE\u987E","design.previewBody":"\u672C\u5B63\u5EA6\u5404\u533A\u57DF\u6536\u5165\u5747\u6709\u589E\u957F\u3002","design.previewButton":"\u4E3B\u8981\u64CD\u4F5C","card.created":"\u5DF2\u521B\u5EFA","card.updated":"\u5DF2\u66F4\u65B0","card.working":"\u6B63\u5728\u5199\u5165\u4EA7\u7269...","card.failed":"\u4EA7\u7269\u672A\u4FDD\u5B58","card.missing":"\u6B64\u7ED3\u679C\u6CA1\u6709\u4EA7\u7269\u4FE1\u606F\u3002","composer.label":"\u4EA7\u7269","error.generic":"\u51FA\u9519\u4E86\uFF0C\u8BF7\u91CD\u8BD5\u3002","error.notFound":"\u6B64\u4EA7\u7269\u5DF2\u4E0D\u5B58\u5728\u3002","error.stale":"\u4EA7\u7269\u5DF2\u66F4\u6539\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u3002","error.tooLarge":"\u5185\u5BB9\u8D85\u8FC7 2 MiB \u4E0A\u9650\u3002","error.noWorkspace":"\u6B64\u4F1A\u8BDD\u6CA1\u6709\u5DE5\u4F5C\u533A\u3002","error.forbidden":"\u4E0D\u5141\u8BB8\u8BBF\u95EE\u8BE5\u8DEF\u5F84\u3002","error.corrupt":"\u4EA7\u7269\u6587\u4EF6\u5DF2\u635F\u574F\u3002","error.tokens":"\u67D0\u4E2A\u8BBE\u8BA1\u503C\u4E0D\u662F\u6709\u6548\u7684 CSS\u3002","error.library":"\u65E0\u6CD5\u521B\u5EFA\u8D44\u6599\u5E93\u6587\u4EF6\u5939\u3002","error.surface":"\u4EA7\u7269\u9762\u677F\u7ED8\u5236\u5931\u8D25\u3002","error.surfaceHint":"\u8BF7\u91CD\u65B0\u52A0\u8F7D\u7A97\u53E3\u3002\u4F60\u7684\u4EA7\u7269\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728\u78C1\u76D8\u4E0A\u3002","action.retry":"\u91CD\u8BD5","action.reloadWindow":"\u91CD\u65B0\u52A0\u8F7D\u7A97\u53E3","time.justNow":"\u521A\u521A","time.minutes":"{count} \u5206\u949F\u524D","time.hours":"{count} \u5C0F\u65F6\u524D","time.days":"{count} \u5929\u524D"};function bt(e,t,r=Date.now()){let n=Math.max(0,r-Date.parse(t)),a=Math.floor(n/6e4);if(a<1)return e("time.justNow");if(a<60)return e("time.minutes",{count:a});let i=Math.floor(a/60);if(i<24)return e("time.hours",{count:i});let s=Math.floor(i/24);return s<7?e("time.days",{count:s}):new Date(t).toLocaleDateString()}var Z=require("react/jsx-runtime");function qa(e,t){let r=t.source.origin==="agent"?e("history.byAgent"):e("history.byUser"),n=t.source.action==="restore"&&t.source.restoredFrom!==void 0?e("history.restored",{version:t.source.restoredFrom}):t.source.action==="create"?e("history.created"):e("history.updated");return`${r} \xB7 ${n} \xB7 ${bt(e,t.createdAt)}`}function Dr({t:e,versions:t,failed:r,current:n,selected:a,onSelect:i}){return(0,Z.jsxs)("div",{className:"art-history-body",children:[t===null?(0,Z.jsx)("p",{className:"art-note",children:e("empty.loading")}):null,r?(0,Z.jsx)("p",{className:"art-note",children:e("error.generic")}):null,!r&&t!==null&&t.length<=1?(0,Z.jsx)("p",{className:"art-note",children:e("history.empty")}):null,t?.map(s=>(0,Z.jsxs)("button",{type:"button",className:"art-version","aria-current":s.version===a?"true":void 0,onClick:()=>i(s.version),children:[(0,Z.jsxs)("span",{className:"art-version-top",children:[(0,Z.jsx)("span",{children:e("tab.versionOf",{version:s.version})}),s.version===n?(0,Z.jsx)("span",{className:"art-badge",children:e("history.current")}):null]}),(0,Z.jsx)("span",{className:"art-version-sub",children:qa(e,s)})]},s.version))]})}var oe=require("react");var Te=require("react/jsx-runtime");function yt({content:e,designCss:t,title:r,frameTitle:n,dark:a=!1,onSelectionText:i}){let[s,d]=(0,oe.useState)(null),[u,f]=(0,oe.useState)(!1),b=(0,oe.useRef)(0),y=(0,oe.useRef)(null),h=(0,oe.useRef)(i);h.current=i;let k=i!==void 0;return(0,oe.useEffect)(()=>{b.current=0,f(!1);let c=URL.createObjectURL(new Blob([gt(e,t,r,a?"dark":"light",k)],{type:"text/html"}));return d(c),()=>URL.revokeObjectURL(c)},[e,t,r,a,k]),(0,oe.useEffect)(()=>{if(!k)return;let c=g=>{if(y.current===null||b.current>1||g.source!==y.current.contentWindow)return;let M=Ar(g.data);M!==void 0&&h.current?.(M)};return window.addEventListener("message",c),()=>window.removeEventListener("message",c)},[k]),u?(0,Te.jsx)("div",{className:"art-center",role:"alert",children:r}):s===null?null:(0,Te.jsx)("iframe",{ref:y,className:"art-frame",title:n,sandbox:Cr,referrerPolicy:"no-referrer",src:s,onLoad:()=>{b.current+=1,b.current>1&&f(!0)}},s)}function Lr({value:e,readOnly:t,label:r,hint:n,onChange:a,onSave:i,onSelectionText:s}){let d=u=>{t||s?.(u.value.slice(u.selectionStart,u.selectionEnd))};return(0,Te.jsxs)("div",{className:"art-source-wrap",children:[n===void 0?null:(0,Te.jsx)("div",{className:"art-code-bar",children:(0,Te.jsx)("span",{children:n})}),(0,Te.jsx)("textarea",{className:"art-source","aria-label":r,spellCheck:!1,readOnly:t,value:e,autoFocus:!t,onChange:u=>{a(u.target.value),s?.("")},onSelect:u=>d(u.currentTarget),onMouseUp:u=>d(u.currentTarget),onKeyUp:u=>d(u.currentTarget),onKeyDown:u=>{if((u.ctrlKey||u.metaKey)&&u.key.toLowerCase()==="s"){u.preventDefault(),i();return}if(u.key==="Tab"&&!u.shiftKey&&!t){u.preventDefault();let f=u.currentTarget,b=f.selectionStart,y=f.selectionEnd,h=e.slice(0,b)+" "+e.slice(y);a(h),requestAnimationFrame(()=>f.setSelectionRange(b+2,b+2))}}})]})}function jt(e,t=2e3){let r=e.replace(/\r\n/g,`
21
+ `)}function pr(e,t){let r=t?e.colorsDark:e.colors,a={"--artifact-font-family":e.typography.fontFamily,"--artifact-font-display":e.typography.displayFamily,"--artifact-font-mono":e.typography.monoFamily};for(let n of $e)a[`--artifact-color-${n}`]=r[n];e.typography.scale.forEach((n,o)=>{a[`--artifact-font-size-${o}`]=`${n}px`}),e.spacing.scale.forEach((n,o)=>{a[`--artifact-space-${o}`]=`${n}px`});for(let[n,o]of Object.entries(e.radius))a[`--artifact-radius-${n}`]=`${o}px`;return a}var Da="/artifacts-rpc",Ie=class extends Error{code;details;constructor(t,r,a){super(r),this.name="ArtifactCallError",this.code=t,this.details=a}},Mt=null;function ur(e){Mt=e}async function Q(e,t,r,a){if(Mt===null)throw new Ie("artifact/not-ready","The artifact channel is not ready.",{});let n=await Mt.rpc.call(Da,e,t,a);if(!n.ok)throw new Ie(n.error.code,n.error.message,n.error.details);if(!r(n.value))throw new Ie("artifact/bad-response",`The ${e} response has an unexpected shape.`,{});return n.value}function K(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ma(e){return K(e)&&Array.isArray(e.items)&&e.items.every(it)&&typeof e.total=="number"&&typeof e.hasMore=="boolean"}function za(e){return K(e)&&it(e.manifest)&&typeof e.content=="string"&&typeof e.version=="number"&&typeof e.designCss=="string"&&fr(e.design)}function st(e){return K(e)&&it(e.manifest)}function Oa(e){return K(e)&&typeof e.version=="number"&&typeof e.createdAt=="string"&&typeof e.contentHash=="string"&&typeof e.contentBytes=="number"&&Lt(e.source)}function ja(e){return K(e)&&Array.isArray(e.versions)&&e.versions.every(Oa)}function Ba(e){return K(e)&&e.trashed===!0&&typeof e.trashPath=="string"}function Fa(e){return K(e)&&typeof e.path=="string"&&typeof e.bytes=="number"&&typeof e.fileName=="string"&&typeof e.mediaType=="string"&&typeof e.data=="string"}function Ha(e){return K(e)&&typeof e.html=="string"}function fr(e){return K(e)&&e.schemaVersion===1&&typeof e.name=="string"&&K(e.colors)&&K(e.colorsDark)&&K(e.typography)&&K(e.spacing)&&K(e.radius)}function Dt(e){return K(e)&&fr(e.tokens)&&(e.source==="workspace"||e.source==="library"||e.source==="default")&&typeof e.css=="string"}function te(e){return{scope:e.scope,...e.workspaceId===null?{}:{workspaceId:e.workspaceId}}}var z={list:(e,t,r)=>Q("list",{...te(e),...t},Ma,r),get:(e,t,r,a)=>Q("get",{...te(e),id:t,...r===void 0?{}:{version:r}},za,a),create:(e,t,r,a)=>Q("create",{...te(e),type:t,title:r,content:a},st),update:(e,t,r,a,n)=>Q("update",{...te(e),id:t,baseVersion:r,content:a,...n===void 0?{}:{title:n}},st),rename:(e,t,r,a)=>Q("update",{...te(e),id:t,baseVersion:r,title:a},st),remove:(e,t)=>Q("delete",{...te(e),id:t},Ba),history:(e,t,r)=>Q("history",{...te(e),id:t},ja,r),restore:(e,t,r,a)=>Q("restore",{...te(e),id:t,version:r,baseVersion:a},st),exportFile:(e,t,r,a)=>Q("export",{...te(e),id:t,format:r,version:a},Fa),printable:(e,t,r)=>Q("printable",{...te(e),id:t,version:r},Ha),designSystem:(e,t)=>Q("designSystem",e===null?{}:{workspaceId:e},Dt,t),saveDesignSystem:(e,t)=>Q("saveDesignSystem",{...te(e),tokens:t},Dt),clearDesignSystem:e=>Q("clearDesignSystem",{workspaceId:e,scope:"workspace"},Dt)};function Y(e){return e instanceof Ie?e.code:void 0}function X(e){switch(e){case"artifact/not-found":return"error.notFound";case"artifact/stale-version":return"error.stale";case"artifact/too-large":return"error.tooLarge";case"artifact/no-workspace":return"error.noWorkspace";case"artifact/forbidden-path":return"error.forbidden";case"artifact/corrupt":return"error.corrupt";case"artifact/invalid-tokens":return"error.tokens";case"artifact/library-unavailable":return"error.library";default:return"error.generic"}}function mr(e){let t=atob(e.data),r=new Uint8Array(t.length);for(let o=0;o<t.length;o+=1)r[o]=t.charCodeAt(o);let a=URL.createObjectURL(new Blob([r],{type:e.mediaType})),n=document.createElement("a");n.href=a,n.download=e.fileName,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(a),3e4)}var Me=require("react");var We=require("react");function ct(e){let t=e,r=new Set;return{get:()=>t,set(a){t=a;for(let n of r)n()},subscribe(a){return r.add(a),()=>r.delete(a)}}}var Le=ct(new Map);function de(e,t){if(Le.get().get(e)===t)return;let r=new Map(Le.get());r.set(e,t),Le.set(r)}function gr(e){return Le.get().get(e)}function br(e){return(0,We.useSyncExternalStore)(Le.subscribe,()=>e===void 0?void 0:Le.get().get(e))}var _e=ct(new Map);function Se(e,t){if((_e.get().get(e)??0)>=t)return;let r=new Map(_e.get());r.set(e,t),_e.set(r)}function yr(e){return(0,We.useSyncExternalStore)(_e.subscribe,()=>e===void 0?0:_e.get().get(e)??0)}var lt=ct(0);function pe(){lt.set(lt.get()+1)}function dt(){return(0,We.useSyncExternalStore)(lt.subscribe,lt.get)}var De=ct(null);function W(e){De.set({seq:(De.get()?.seq??0)+1,message:e})}function hr(){return(0,We.useSyncExternalStore)(De.subscribe,De.get)}function zt(e){let t=De.get();t===null||e!==void 0&&t.seq!==e||De.set(null)}var ue=new Map,Ot;function vr(){Ot?.();let e=t=>{[...ue.values()].some(r=>r.getSnapshot().draft!==null||r.getSnapshot().saving)&&(t.preventDefault(),t.returnValue="")};return window.addEventListener("beforeunload",e),Ot=()=>window.removeEventListener("beforeunload",e),Ot}var jt=class{state={payload:null,draft:null,loading:!0,saving:!1,conflict:!1,revision:0};listeners=new Set;pending=null;readSequence=0;mounts=0;renameTo;where;key;address;constructor(t){this.address=t,this.key=H(t),this.where={scope:t.scope,workspaceId:t.scope==="workspace"?t.workspaceId:null}}getSnapshot=()=>this.state;subscribe=t=>(this.listeners.add(t),()=>this.listeners.delete(t));publish(t){this.state={...this.state,...t},this.state.draft!==null||this.state.saving?ue.set(this.key,this):this.mounts===0&&ue.get(this.key)===this&&ue.delete(this.key);for(let r of this.listeners)r()}attach(){return this.mounts+=1,ue.set(this.key,this),this.mounts===1&&(this.state.payload===null||this.state.draft===null)&&this.load(),()=>{this.mounts-=1,this.mounts===0&&this.state.draft===null&&!this.state.saving&&ue.get(this.key)===this&&ue.delete(this.key)}}async load(){let t=++this.readSequence;this.publish({loading:!0,failure:void 0});try{let r=await z.get(this.where,this.address.id);if(t!==this.readSequence)return;if(this.state.draft!==null&&this.state.payload!==null){this.publish({loading:!1,conflict:r.version!==this.state.payload.version});return}this.publish({payload:r,loading:!1,conflict:!1,failure:void 0,revision:this.state.revision+1}),de(this.address.id,r.manifest.title),Se(this.address.id,r.version)}catch(r){t===this.readSequence&&this.publish({loading:!1,failure:Y(r)??"artifact/storage-failure"})}}edit(t){this.publish({draft:t,failure:void 0})}async discardAndReload(){this.pending!==null&&await this.pending,this.publish({draft:null,conflict:!1,failure:void 0}),await this.load()}externalVersion(t){this.state.payload===null||t<=this.state.payload.version||this.state.saving||(this.state.draft!==null?this.publish({conflict:!0}):this.load())}save(t){return t!==void 0&&(this.renameTo=t),this.pending!==null?this.pending:this.state.conflict||this.state.payload===null?Promise.resolve(!1):(this.pending=Promise.resolve().then(()=>this.drain()),this.pending)}async drain(){this.publish({saving:!0,failure:void 0});try{for(;this.state.draft!==null||this.renameTo!==void 0;){let t=this.state.payload;if(t===null||this.state.conflict)return!1;let r=this.state.draft,a=r??t.content,n=this.renameTo,{manifest:o}=await z.update(this.where,this.address.id,t.version,a,n);this.renameTo===n&&(this.renameTo=void 0),this.accept(o,a,this.state.draft===r?null:this.state.draft)}return!0}catch(t){let r=Y(t)??"artifact/storage-failure";return this.renameTo=void 0,this.publish({failure:r,conflict:r==="artifact/stale-version"}),!1}finally{this.pending=null,this.publish({saving:!1})}}accept(t,r,a){let n=this.state.payload;n!==null&&(++this.readSequence,this.publish({payload:{...n,manifest:t,content:r,version:t.version},draft:a,conflict:!1,loading:!1}),de(t.id,t.title),Se(t.id,t.version),pe())}};function xr(e){let t=H(e),r=(0,Me.useMemo)(()=>{let n=ue.get(t);if(n!==void 0)return n;let o=new jt(e);return ue.set(t,o),o},[t]),a=(0,Me.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot);return(0,Me.useEffect)(()=>r.attach(),[r]),{model:r,state:a}}var v=require("react"),b=require("@deepseek-ai/dsh-client-ui-primitives");var D=require("react"),wr=require("@deepseek-ai/dsh-client-ui-primitives");var oe=require("react/jsx-runtime"),Ue=null;function Va(){if(Ue===null){let e=globalThis.__dshArtifactsRequireAsync;if(typeof e!="function")return Promise.reject(new Error("The document editor loader is unavailable."));Ue=e("./client.doc.js"),Ue.catch(()=>{Ue=null})}return Ue}var $a=["heading","bold","italic","bulletList","orderedList","codeBlock"];function _a(e){let t=window.getSelection(),r=e.getBoundingClientRect(),n=(t!==null&&t.rangeCount>0?t.getRangeAt(0):null)?.getBoundingClientRect();if(n===void 0||n.width===0&&n.height===0)return{top:e.scrollTop+8,left:16};let o=Math.min(Math.max(n.left-r.left+n.width/2,120),Math.max(r.width-120,120));return{top:Math.max(n.top-r.top+e.scrollTop-46,e.scrollTop+4),left:o}}function pt({markdown:e,revision:t,editable:r,label:a,loadingLabel:n,failedLabel:o,onChange:s,onSave:l,onSelectionText:f,t:u,design:h,dark:w=!1,selectionAction:k}){let S=(0,D.useRef)(null),m=(0,D.useRef)(null),d=(0,D.useRef)(null),y=(0,D.useRef)(s);y.current=s;let E=(0,D.useRef)(f);E.current=f;let I=(0,D.useRef)({markdown:e,editable:r,label:a});I.current={markdown:e,editable:r,label:a};let[O,Z]=(0,D.useState)([]),[M,J]=(0,D.useState)("loading"),[$,_]=(0,D.useState)(null),A=(0,D.useRef)(null);(0,D.useLayoutEffect)(()=>{let x=A.current,g=S.current;if(x===null||g===null||$===null)return;let L=x.offsetWidth/2,j=g.clientWidth,F=L*2+16>=j?j/2:Math.min(Math.max($.left,L+8),j-L-8);x.style.left=F+"px"});let q=(0,D.useMemo)(()=>h===void 0?{}:{...pr(h,w),colorScheme:w?"dark":"light"},[h,w]),V=x=>{E.current?.(x);let g=S.current;_(x===""||g===null?null:_a(g))},ae=(0,D.useRef)(V);ae.current=V,(0,D.useEffect)(()=>{let x=!1;return Va().then(g=>{x||m.current===null||(d.current=g.mountDocEditor({element:m.current,...I.current,onChange:L=>y.current(L),onSelectionChange:Z,onSelectionText:L=>ae.current(L)}),J("ready"))}).catch(()=>{x||J("failed")}),()=>{x=!0,d.current?.destroy(),d.current=null}},[]),(0,D.useEffect)(()=>{let x=d.current;x!==null&&x.getMarkdown()!==e&&x.setMarkdown(e)},[t,e]),(0,D.useEffect)(()=>{d.current?.setEditable(r)},[r]),(0,D.useEffect)(()=>{let x=()=>{let g=d.current,L=S.current,j=window.getSelection();g===null||L===null||j!==null&&j.anchorNode!==null&&!L.contains(j.anchorNode)||ae.current(g.getSelectionText())};return document.addEventListener("selectionchange",x),()=>document.removeEventListener("selectionchange",x)},[]);let ee=$!==null&&u!==void 0&&(r||k!=null);return(0,oe.jsxs)("div",{className:"art-doc",ref:S,"data-doc-revision":t,onKeyDown:x=>{(x.ctrlKey||x.metaKey)&&x.key.toLowerCase()==="s"&&(x.preventDefault(),l()),x.key==="Escape"&&$!==null&&_(null)},children:[ee?(0,oe.jsxs)("div",{ref:A,className:"art-doc-toolbar",role:"toolbar","aria-label":u("format.toolbar"),style:{top:$.top,left:$.left},children:[r?$a.map(x=>(0,oe.jsx)(wr.Button,{size:"sm",variant:"ghost","aria-pressed":O.includes(x),disabled:M!=="ready",onMouseDown:g=>g.preventDefault(),onClick:()=>d.current?.format(x),children:u(`format.${x}`)},x)):null,r&&k!=null?(0,oe.jsx)("span",{className:"art-doc-toolbar-gap","aria-hidden":"true"}):null,k]}):null,M==="loading"?(0,oe.jsx)("p",{className:"art-note",children:n}):null,M==="failed"?(0,oe.jsx)("p",{className:"art-note",children:o}):null,(0,oe.jsx)("div",{className:"art-docpage",style:q,children:(0,oe.jsx)("div",{className:"art-doc-mount",ref:m})})]})}function Wa(e){return/<meta\b[^>]*name\s*=\s*["']?color-scheme["']?[^>]*content\s*=\s*["'][^"']*\bdark\b/i.test(e)||/<meta\b[^>]*content\s*=\s*["'][^"']*\bdark\b[^"']*["'][^>]*name\s*=\s*["']?color-scheme/i.test(e)}var Tr="default-src 'none'; img-src data: blob:; media-src data: blob:; style-src 'unsafe-inline'; script-src 'unsafe-inline' 'unsafe-eval'; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'",Sr=["body, .art-docpage { color: var(--artifact-color-text); font-family: var(--artifact-font-family); font-size: 16px; line-height: 1.65; }","h1, h2, h3, h4 { font-family: var(--artifact-font-display); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; margin: 1.8em 0 0.5em; color: var(--artifact-color-text); text-wrap: balance; }","h1 { font-size: 2.1em; margin-top: 0; }","h2 { font-size: 1.45em; }","h3 { font-size: 1.15em; }","p, ul, ol, blockquote, table, pre { margin: 0 0 1em; }","a { color: var(--artifact-color-primary); text-underline-offset: 2px; }","strong { font-weight: 650; }","code { font-family: var(--artifact-font-mono); font-size: 0.88em; padding: 0.1em 0.35em; border-radius: var(--artifact-radius-sm); background: color-mix(in srgb, var(--artifact-color-text) 7%, transparent); }","pre { font-family: var(--artifact-font-mono); font-size: 0.86em; line-height: 1.55; padding: 14px 16px; border-radius: var(--artifact-radius-md); background: color-mix(in srgb, var(--artifact-color-text) 6%, transparent); overflow: auto; }","pre code { padding: 0; background: none; font-size: 1em; }","blockquote { padding: 0 0 0 16px; border-left: 3px solid var(--artifact-color-accent); color: var(--artifact-color-muted); }","ul, ol { padding-left: 1.4em; }","li + li { margin-top: 0.25em; }","table { border-collapse: collapse; width: 100%; font-size: 0.94em; font-variant-numeric: tabular-nums; }","th, td { padding: 8px 10px; border-bottom: 1px solid color-mix(in srgb, var(--artifact-color-text) 14%, transparent); text-align: left; vertical-align: top; }","th { font-weight: 600; color: var(--artifact-color-muted); border-bottom-color: color-mix(in srgb, var(--artifact-color-text) 28%, transparent); }","hr { border: none; border-top: 1px solid color-mix(in srgb, var(--artifact-color-text) 14%, transparent); margin: 2em 0; }"].join(`
22
+ `);var Bt="<script>addEventListener('message',function(e){if(e.source!==parent||e.data!=='dsh-artifact-print')return;addEventListener('afterprint',function(){parent.postMessage('dsh-artifact-printed','*')},{once:true});print()})<\/script>";function kr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ua(e){return e.replace(/<meta\b[^>]*http-equiv\s*=\s*["']?refresh["']?[^>]*>/gi,"").replace(/<meta\b[^>]*content\s*=\s*["'][^"']*url\s*=[^>]*>/gi,"")}function Cr(e,t,r,a,n="",o="auto"){let s='<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">'+(r===null?"":`<meta http-equiv="Content-Security-Policy" content="${kr(r)}">`)+`<title>${kr(a)}</title><style data-artifact-tokens>${t}</style>`+n;return`<!doctype html><html${Wa(e)?` ${ot}="${o}"`:""}><head>${s}</head><body>${Ua(e)}</body></html>`}var Nr="allow-scripts",qa="allow-scripts allow-modals",Ga=3e4,Ka="<script>(function(){var t;document.addEventListener('selectionchange',function(){clearTimeout(t);t=setTimeout(function(){var s=String(getSelection()||'');parent.postMessage({dshArtifactSelection:s.slice(0,4000)},'*')},150)})})()<\/script>",Ya=4e3;function ut(e,t,r,a="auto",n=!1){return Cr(e,t,Tr,r,n?Ka:"",a)}function Ar(e){if(e===null||typeof e!="object")return;let t={...e};return typeof t.dshArtifactSelection=="string"?t.dshArtifactSelection.slice(0,Ya):void 0}function Rr(e){let t=/<\/head>/i.test(e)?e.replace(/<\/head>/i,`${Bt}</head>`):`${Bt}${e}`,r=URL.createObjectURL(new Blob([t],{type:"text/html"})),a=document.createElement("iframe");a.setAttribute("sandbox",qa),a.setAttribute("aria-hidden","true"),a.tabIndex=-1,a.style.cssText="position:fixed;left:-10000px;top:0;width:800px;height:1000px;border:0;";let n=!1,o=()=>{n||(n=!0,clearTimeout(l),window.removeEventListener("message",s),a.remove(),URL.revokeObjectURL(r))},s=f=>{f.source===a.contentWindow&&f.data==="dsh-artifact-printed"&&o()};window.addEventListener("message",s);let l=setTimeout(o,Ga);a.addEventListener("load",()=>{a.contentWindow?.postMessage("dsh-artifact-print","*")},{once:!0}),a.src=r,document.body.appendChild(a)}var Er={"agent.ask":"Edit with agent","agent.reference":'In artifact "{title}" ({id}, v{version}):',"agent.referenceOld":'In artifact "{title}" ({id}, v{version}, the current version is v{current}):',"agent.added":"Added to your message. Describe the change, then send.","agent.addedTruncated":"Added to your message. The selection was shortened to 2,000 characters.","agent.insertFailed":"The message box is busy, so the request was copied instead.","agent.copied":"Copied. Paste it into a conversation, then send.","agent.copyTitle":"Copy the request","card.creating":"Creating {title}","card.updating":"Updating {title}","card.updatingUntitled":"Updating the artifact","card.openNamed":"Open {title}","tab.codeHint":"Read-only code. Select text to ask the agent about it.","tab.editSource":"Edit code","tab.deleteTitle":"Move to trash?","code.copy":"Copy code","dialog.close":"Close","dialog.done":"Done","design.colorsDark":"Dark colors","design.display":"Heading font stack","composer.recent":"This project","composer.empty":"No artifacts yet","composer.start":"Start with","composer.all":"All artifacts","gallery.copyPrompt":"Copy prompt","gallery.copyPromptNamed":"Copy the {name} prompt","gallery.promptCopied":"Prompt copied. Paste it into a conversation.","prompt.dashboard":"Dashboard","prompt.dashboardText":"Create an artifact page: a dashboard that shows ","prompt.explainer":"Explainer","prompt.explainerText":"Create an artifact page: a one-page visual explainer of ","prompt.report":"Report","prompt.reportText":"Create an artifact doc: a report about ","prompt.brief":"Project brief","prompt.briefText":"Create an artifact doc: a project brief with context, goal, scope, and open questions for ","filter.type":"Filter by type","tab.mode":"Page view","tab.manualSave":"Page source saves with Save or Ctrl/Cmd+S.","tab.versionPicker":"Choose version","tab.currentVersion":"current","tab.allVersions":"All versions","tab.agentUpdate":"Updated to v{version}","tab.viewHistory":"View history","tab.dismiss":"Dismiss","tab.leaveTitle":"Keep your changes?","tab.leaveHint":"Save your changes before continuing, or discard them. Cancel keeps you here.","tab.discardContinue":"Discard and continue","tab.saveContinue":"Save and continue","tab.copyDraft":"Copy my draft","tab.discardReload":"Discard mine and reload","history.close":"Close history","action.copied":"Copied","action.copyFailed":"Copy was blocked. Select the text and copy it manually.","format.toolbar":"Document formatting","format.heading":"Heading","format.bold":"Bold","format.italic":"Italic","format.bulletList":"Bullet list","format.orderedList":"Numbered list","format.codeBlock":"Code block",panel:"Artifacts","action.back":"Back","scope.label":"Scope","scope.all":"All projects","scope.workspace":"This project","scope.library":"Library","type.page":"Page","type.doc":"Document","type.all":"All types","gallery.search":"Search artifacts","gallery.searchLabel":"Search by title","gallery.create":"New artifact","gallery.newPage":"New page","gallery.newDoc":"New document","gallery.design":"Design system","gallery.refresh":"Refresh","gallery.more":"Show more","gallery.truncated":"Only the first 500 artifacts are scanned.","gallery.failedProjects":"Some sources could not be loaded.","gallery.version":"v{version}","gallery.updated":"Updated {time}","gallery.count":"{count} artifacts","gallery.pinned":"Pinned","gallery.recent":"Recently updated","gallery.coverTitle":"Preview of {title}","gallery.coverFailed":"Preview unavailable","gallery.pin":"Pin {title}","gallery.unpin":"Unpin {title}","gallery.allPinned":"Everything here is pinned.","empty.workspaceTitle":"No artifacts in this project yet","empty.workspaceHint":"Ask the agent for a dashboard, report, or one-pager, or start one here.","empty.allTitle":"No artifacts yet","empty.allHint":"Artifacts from every project and your library appear here.","empty.libraryTitle":"Your library is empty","empty.libraryHint":"Library artifacts follow you to every project. Ask the agent to save one to the library.","empty.noMatch":"Nothing matches that search.","empty.typeMatch":"No {type} artifacts match the filter.","empty.noWorkspace":"Open a session in a workspace to see its artifacts.","empty.loading":"Loading...","create.title":"New {type}","create.name":"Title","create.scope":"Save to","create.submit":"Create","create.cancel":"Cancel","create.untitledPage":"Untitled page","create.untitledDoc":"Untitled document","tab.preview":"Preview","tab.source":"Code","tab.history":"History","tab.export":"Export","tab.reload":"Reload","tab.rename":"Rename","tab.delete":"Move to trash","tab.deleteConfirm":'"{title}" moves to the trash. Its files stay there for 7 days.',"tab.save":"Save","tab.saving":"Saving...","tab.saved":"Saved","tab.readOnly":"Read-only","tab.saveFailed":"Save failed","tab.unsaved":"Unsaved changes","tab.frameTitle":"Artifact preview: {title}","tab.versionOf":"Version {version}","tab.viewingOld":"Viewing version {version}. The current version is {current}.","tab.backToCurrent":"Back to current","tab.restoreThis":"Restore this version","tab.conflictTitle":"This artifact changed","tab.conflictHint":"A newer version was saved while you were editing. Your draft is kept here. Copy it before discarding, then reload the latest version.","tab.deleted":"This artifact is no longer here","tab.deletedHint":"It was moved to the trash or deleted.","tab.close":"Close tab","history.title":"Versions","history.current":"Current","history.byAgent":"Agent","history.byUser":"You","history.restored":"Restored from v{version}","history.created":"Created","history.updated":"Edited","history.empty":"No earlier versions.","export.html":"HTML file","export.md":"Markdown file","export.docx":"Word document","export.print":"Print or save as PDF","export.done":"Saved {name} to {path}","design.title":"Design system","design.hint":"Pages and documents use these values through CSS variables.","design.source.workspace":"This project overrides the library.","design.source.library":"Inherited from your library.","design.source.default":"Built-in defaults. Save to start your own.","design.name":"Name","design.colors":"Colors","design.color.primary":"Primary","design.color.accent":"Accent","design.color.surface":"Surface","design.color.text":"Text","design.color.muted":"Muted","design.type":"Typography","design.font":"Body font stack","design.mono":"Code font stack","design.radius":"Corner radius","design.radius.sm":"Small","design.radius.md":"Medium","design.radius.lg":"Large","design.notes":"Notes for the agent","design.notesHint":"Tone, layout rules, or brand guidance the agent reads before it designs.","design.saveWorkspace":"Save for this project","design.saveWorkspaceNamed":"Save for {name}","design.saveLibrary":"Save to library","design.clear":"Remove project override","design.saved":"Design system saved","design.preview":"Preview","design.previewHeading":"Quarterly review","design.previewBody":"Revenue grew in every region this quarter.","design.previewButton":"Primary action","card.created":"Created","card.updated":"Updated","card.working":"Writing the artifact...","card.failed":"The artifact was not saved","card.missing":"This result has no artifact details.","composer.label":"Artifacts","error.generic":"Something went wrong. Try again.","error.notFound":"This artifact no longer exists.","error.stale":"The artifact changed. Reload to continue.","error.tooLarge":"The content is over the 2 MiB limit.","error.noWorkspace":"This session has no workspace.","error.forbidden":"That path is not allowed.","error.corrupt":"The artifact files are damaged.","error.tokens":"A design value is not valid CSS.","error.library":"The library folder cannot be created.","error.surface":"The artifact panel failed to draw.","error.surfaceHint":"Reload the window. Your artifacts are safe on disk.","action.retry":"Retry","action.reloadWindow":"Reload window","time.justNow":"just now","time.minutes":"{count} min ago","time.hours":"{count} h ago","time.days":"{count} d ago"},Pr={"agent.ask":"\u8BA9\u667A\u80FD\u4F53\u4FEE\u6539","agent.reference":"\u5728\u4EA7\u7269\u201C{title}\u201D\uFF08{id}\uFF0Cv{version}\uFF09\u4E2D\uFF1A","agent.referenceOld":"\u5728\u4EA7\u7269\u201C{title}\u201D\uFF08{id}\uFF0Cv{version}\uFF0C\u5F53\u524D\u7248\u672C\u4E3A v{current}\uFF09\u4E2D\uFF1A","agent.added":"\u5DF2\u52A0\u5165\u6D88\u606F\u6846\u3002\u63CF\u8FF0\u8981\u4FEE\u6539\u7684\u5185\u5BB9\u540E\u53D1\u9001\u3002","agent.addedTruncated":"\u5DF2\u52A0\u5165\u6D88\u606F\u6846\u3002\u9009\u4E2D\u7684\u6587\u672C\u5DF2\u7F29\u77ED\u4E3A 2,000 \u4E2A\u5B57\u7B26\u3002","agent.insertFailed":"\u6D88\u606F\u6846\u6B63\u5FD9\uFF0C\u5DF2\u6539\u4E3A\u590D\u5236\u8BF7\u6C42\u3002","agent.copied":"\u5DF2\u590D\u5236\u3002\u7C98\u8D34\u5230\u5BF9\u8BDD\u4E2D\u540E\u53D1\u9001\u3002","agent.copyTitle":"\u590D\u5236\u8BF7\u6C42","card.creating":"\u6B63\u5728\u521B\u5EFA {title}","card.updating":"\u6B63\u5728\u66F4\u65B0 {title}","card.updatingUntitled":"\u6B63\u5728\u66F4\u65B0\u4EA7\u7269","card.openNamed":"\u6253\u5F00 {title}","tab.codeHint":"\u53EA\u8BFB\u4EE3\u7801\u3002\u9009\u4E2D\u6587\u672C\u5373\u53EF\u8BA9\u667A\u80FD\u4F53\u5904\u7406\u3002","tab.editSource":"\u7F16\u8F91\u4EE3\u7801","tab.deleteTitle":"\u79FB\u5230\u56DE\u6536\u7AD9\uFF1F","code.copy":"\u590D\u5236\u4EE3\u7801","dialog.close":"\u5173\u95ED","dialog.done":"\u5B8C\u6210","design.colorsDark":"\u6DF1\u8272\u914D\u8272","design.display":"\u6807\u9898\u5B57\u4F53\u6808","composer.recent":"\u5F53\u524D\u9879\u76EE","composer.empty":"\u8FD8\u6CA1\u6709\u4EA7\u7269","composer.start":"\u4ECE\u8FD9\u91CC\u5F00\u59CB","composer.all":"\u5168\u90E8\u4EA7\u7269","gallery.copyPrompt":"\u590D\u5236\u63D0\u793A\u8BCD","gallery.copyPromptNamed":"\u590D\u5236\u201C{name}\u201D\u63D0\u793A\u8BCD","gallery.promptCopied":"\u63D0\u793A\u8BCD\u5DF2\u590D\u5236\u3002\u7C98\u8D34\u5230\u5BF9\u8BDD\u4E2D\u5373\u53EF\u3002","prompt.dashboard":"\u4EEA\u8868\u76D8","prompt.dashboardText":"\u521B\u5EFA\u4E00\u4E2A artifact \u9875\u9762\uFF1A\u4E00\u4E2A\u4EEA\u8868\u76D8\uFF0C\u5C55\u793A","prompt.explainer":"\u56FE\u89E3\u8BF4\u660E","prompt.explainerText":"\u521B\u5EFA\u4E00\u4E2A artifact \u9875\u9762\uFF1A\u4E00\u9875\u53EF\u89C6\u5316\u8BF4\u660E\uFF0C\u4E3B\u9898\u662F","prompt.report":"\u62A5\u544A","prompt.reportText":"\u521B\u5EFA\u4E00\u4E2A artifact \u6587\u6863\uFF1A\u4E00\u4EFD\u62A5\u544A\uFF0C\u4E3B\u9898\u662F","prompt.brief":"\u9879\u76EE\u7B80\u4ECB","prompt.briefText":"\u521B\u5EFA\u4E00\u4E2A artifact \u6587\u6863\uFF1A\u4E00\u4EFD\u9879\u76EE\u7B80\u4ECB\uFF0C\u5305\u542B\u80CC\u666F\u3001\u76EE\u6807\u3001\u8303\u56F4\u548C\u5F85\u5B9A\u95EE\u9898\uFF0C\u9879\u76EE\u662F","filter.type":"\u6309\u7C7B\u578B\u7B5B\u9009","tab.mode":"\u9875\u9762\u89C6\u56FE","tab.manualSave":"\u9875\u9762\u6E90\u7801\u9700\u70B9\u51FB\u4FDD\u5B58\u6216\u6309 Ctrl/Cmd+S\u3002","tab.versionPicker":"\u9009\u62E9\u7248\u672C","tab.currentVersion":"\u5F53\u524D","tab.allVersions":"\u5168\u90E8\u7248\u672C","tab.agentUpdate":"\u5DF2\u66F4\u65B0\u5230 v{version}","tab.viewHistory":"\u67E5\u770B\u5386\u53F2","tab.dismiss":"\u5173\u95ED","tab.leaveTitle":"\u4FDD\u7559\u66F4\u6539\uFF1F","tab.leaveHint":"\u7EE7\u7EED\u524D\u4FDD\u5B58\u66F4\u6539\uFF0C\u6216\u653E\u5F03\u66F4\u6539\u3002\u53D6\u6D88\u5C06\u4FDD\u7559\u5F53\u524D\u7F16\u8F91\u3002","tab.discardContinue":"\u653E\u5F03\u5E76\u7EE7\u7EED","tab.saveContinue":"\u4FDD\u5B58\u5E76\u7EE7\u7EED","tab.copyDraft":"\u590D\u5236\u6211\u7684\u8349\u7A3F","tab.discardReload":"\u653E\u5F03\u6211\u7684\u66F4\u6539\u5E76\u91CD\u65B0\u52A0\u8F7D","history.close":"\u5173\u95ED\u5386\u53F2","action.copied":"\u5DF2\u590D\u5236","action.copyFailed":"\u590D\u5236\u88AB\u963B\u6B62\u3002\u8BF7\u9009\u4E2D\u6587\u672C\u540E\u624B\u52A8\u590D\u5236\u3002","format.toolbar":"\u6587\u6863\u683C\u5F0F","format.heading":"\u6807\u9898","format.bold":"\u7C97\u4F53","format.italic":"\u659C\u4F53","format.bulletList":"\u9879\u76EE\u7B26\u53F7\u5217\u8868","format.orderedList":"\u7F16\u53F7\u5217\u8868","format.codeBlock":"\u4EE3\u7801\u5757",panel:"\u4EA7\u7269","action.back":"\u8FD4\u56DE","scope.label":"\u8303\u56F4","scope.all":"\u5168\u90E8\u9879\u76EE","scope.workspace":"\u5F53\u524D\u9879\u76EE","scope.library":"\u8D44\u6599\u5E93","type.page":"\u9875\u9762","type.doc":"\u6587\u6863","type.all":"\u5168\u90E8\u7C7B\u578B","gallery.search":"\u641C\u7D22\u4EA7\u7269","gallery.searchLabel":"\u6309\u6807\u9898\u641C\u7D22","gallery.create":"\u65B0\u5EFA\u4EA7\u7269","gallery.newPage":"\u65B0\u5EFA\u9875\u9762","gallery.newDoc":"\u65B0\u5EFA\u6587\u6863","gallery.design":"\u8BBE\u8BA1\u7CFB\u7EDF","gallery.refresh":"\u5237\u65B0","gallery.more":"\u663E\u793A\u66F4\u591A","gallery.truncated":"\u4EC5\u626B\u63CF\u524D 500 \u4E2A\u4EA7\u7269\u3002","gallery.failedProjects":"\u90E8\u5206\u6765\u6E90\u52A0\u8F7D\u5931\u8D25\u3002","gallery.version":"v{version}","gallery.updated":"\u66F4\u65B0\u4E8E {time}","gallery.count":"{count} \u4E2A\u4EA7\u7269","gallery.pinned":"\u5DF2\u7F6E\u9876","gallery.recent":"\u6700\u8FD1\u66F4\u65B0","gallery.coverTitle":"{title} \u7684\u9884\u89C8","gallery.coverFailed":"\u9884\u89C8\u4E0D\u53EF\u7528","gallery.pin":"\u7F6E\u9876 {title}","gallery.unpin":"\u53D6\u6D88\u7F6E\u9876 {title}","gallery.allPinned":"\u8FD9\u91CC\u7684\u4EA7\u7269\u90FD\u5DF2\u7F6E\u9876\u3002","empty.workspaceTitle":"\u672C\u9879\u76EE\u8FD8\u6CA1\u6709\u4EA7\u7269","empty.workspaceHint":"\u8BA9\u667A\u80FD\u4F53\u751F\u6210\u4EEA\u8868\u76D8\u3001\u62A5\u544A\u6216\u5355\u9875\uFF0C\u6216\u5728\u8FD9\u91CC\u65B0\u5EFA\u3002","empty.allTitle":"\u8FD8\u6CA1\u6709\u4EA7\u7269","empty.allHint":"\u8FD9\u91CC\u663E\u793A\u6240\u6709\u9879\u76EE\u548C\u8D44\u6599\u5E93\u4E2D\u7684\u4EA7\u7269\u3002","empty.libraryTitle":"\u8D44\u6599\u5E93\u4E3A\u7A7A","empty.libraryHint":"\u8D44\u6599\u5E93\u4E2D\u7684\u4EA7\u7269\u5728\u6240\u6709\u9879\u76EE\u53EF\u7528\u3002\u8BA9\u667A\u80FD\u4F53\u628A\u4EA7\u7269\u4FDD\u5B58\u5230\u8D44\u6599\u5E93\u3002","empty.noMatch":"\u6CA1\u6709\u5339\u914D\u7684\u4EA7\u7269\u3002","empty.typeMatch":"\u6CA1\u6709\u7B26\u5408\u7C7B\u578B\u7B5B\u9009\u7684{type}\u4EA7\u7269\u3002","empty.noWorkspace":"\u5728\u5DE5\u4F5C\u533A\u4E2D\u6253\u5F00\u4F1A\u8BDD\u4EE5\u67E5\u770B\u5176\u4EA7\u7269\u3002","empty.loading":"\u52A0\u8F7D\u4E2D...","create.title":"\u65B0\u5EFA{type}","create.name":"\u6807\u9898","create.scope":"\u4FDD\u5B58\u5230","create.submit":"\u521B\u5EFA","create.cancel":"\u53D6\u6D88","create.untitledPage":"\u672A\u547D\u540D\u9875\u9762","create.untitledDoc":"\u672A\u547D\u540D\u6587\u6863","tab.preview":"\u9884\u89C8","tab.source":"\u4EE3\u7801","tab.history":"\u5386\u53F2","tab.export":"\u5BFC\u51FA","tab.reload":"\u91CD\u65B0\u52A0\u8F7D","tab.rename":"\u91CD\u547D\u540D","tab.delete":"\u79FB\u5230\u56DE\u6536\u7AD9","tab.deleteConfirm":"\u201C{title}\u201D\u5C06\u79FB\u5230\u56DE\u6536\u7AD9\uFF0C\u6587\u4EF6\u4F1A\u4FDD\u7559 7 \u5929\u3002","tab.save":"\u4FDD\u5B58","tab.saving":"\u6B63\u5728\u4FDD\u5B58...","tab.saved":"\u5DF2\u4FDD\u5B58","tab.readOnly":"\u53EA\u8BFB","tab.saveFailed":"\u4FDD\u5B58\u5931\u8D25","tab.unsaved":"\u6709\u672A\u4FDD\u5B58\u7684\u66F4\u6539","tab.frameTitle":"\u4EA7\u7269\u9884\u89C8\uFF1A{title}","tab.versionOf":"\u7248\u672C {version}","tab.viewingOld":"\u6B63\u5728\u67E5\u770B\u7248\u672C {version}\uFF0C\u5F53\u524D\u7248\u672C\u4E3A {current}\u3002","tab.backToCurrent":"\u56DE\u5230\u5F53\u524D\u7248\u672C","tab.restoreThis":"\u6062\u590D\u6B64\u7248\u672C","tab.conflictTitle":"\u6B64\u4EA7\u7269\u5DF2\u66F4\u6539","tab.conflictHint":"\u7F16\u8F91\u671F\u95F4\u4FDD\u5B58\u4E86\u66F4\u65B0\u7248\u672C\u3002\u8349\u7A3F\u4ECD\u4FDD\u7559\u5728\u8FD9\u91CC\u3002\u653E\u5F03\u524D\u53EF\u5148\u590D\u5236\u8349\u7A3F\uFF0C\u518D\u91CD\u65B0\u52A0\u8F7D\u6700\u65B0\u7248\u672C\u3002","tab.deleted":"\u6B64\u4EA7\u7269\u5DF2\u4E0D\u5B58\u5728","tab.deletedHint":"\u5B83\u5DF2\u88AB\u79FB\u5230\u56DE\u6536\u7AD9\u6216\u5220\u9664\u3002","tab.close":"\u5173\u95ED\u6807\u7B7E\u9875","history.title":"\u7248\u672C","history.current":"\u5F53\u524D","history.byAgent":"\u667A\u80FD\u4F53","history.byUser":"\u4F60","history.restored":"\u4ECE v{version} \u6062\u590D","history.created":"\u521B\u5EFA","history.updated":"\u7F16\u8F91","history.empty":"\u6CA1\u6709\u66F4\u65E9\u7684\u7248\u672C\u3002","export.html":"HTML \u6587\u4EF6","export.md":"Markdown \u6587\u4EF6","export.docx":"Word \u6587\u6863","export.print":"\u6253\u5370\u6216\u53E6\u5B58\u4E3A PDF","export.done":"\u5DF2\u5C06 {name} \u4FDD\u5B58\u5230 {path}","design.title":"\u8BBE\u8BA1\u7CFB\u7EDF","design.hint":"\u9875\u9762\u548C\u6587\u6863\u901A\u8FC7 CSS \u53D8\u91CF\u4F7F\u7528\u8FD9\u4E9B\u503C\u3002","design.source.workspace":"\u672C\u9879\u76EE\u8986\u76D6\u4E86\u8D44\u6599\u5E93\u8BBE\u7F6E\u3002","design.source.library":"\u7EE7\u627F\u81EA\u8D44\u6599\u5E93\u3002","design.source.default":"\u5185\u7F6E\u9ED8\u8BA4\u503C\u3002\u4FDD\u5B58\u540E\u5373\u53EF\u81EA\u5B9A\u4E49\u3002","design.name":"\u540D\u79F0","design.colors":"\u989C\u8272","design.color.primary":"\u4E3B\u8272","design.color.accent":"\u5F3A\u8C03\u8272","design.color.surface":"\u5E95\u8272","design.color.text":"\u6587\u5B57","design.color.muted":"\u6B21\u8981","design.type":"\u5B57\u4F53","design.font":"\u6B63\u6587\u5B57\u4F53","design.mono":"\u4EE3\u7801\u5B57\u4F53","design.radius":"\u5706\u89D2","design.radius.sm":"\u5C0F","design.radius.md":"\u4E2D","design.radius.lg":"\u5927","design.notes":"\u7ED9\u667A\u80FD\u4F53\u7684\u8BF4\u660E","design.notesHint":"\u667A\u80FD\u4F53\u8BBE\u8BA1\u524D\u4F1A\u8BFB\u53D6\u7684\u8BED\u6C14\u3001\u6392\u7248\u89C4\u5219\u6216\u54C1\u724C\u89C4\u8303\u3002","design.saveWorkspace":"\u4FDD\u5B58\u5230\u672C\u9879\u76EE","design.saveWorkspaceNamed":"\u4FDD\u5B58\u5230 {name}","design.saveLibrary":"\u4FDD\u5B58\u5230\u8D44\u6599\u5E93","design.clear":"\u79FB\u9664\u9879\u76EE\u8986\u76D6","design.saved":"\u8BBE\u8BA1\u7CFB\u7EDF\u5DF2\u4FDD\u5B58","design.preview":"\u9884\u89C8","design.previewHeading":"\u5B63\u5EA6\u56DE\u987E","design.previewBody":"\u672C\u5B63\u5EA6\u5404\u533A\u57DF\u6536\u5165\u5747\u6709\u589E\u957F\u3002","design.previewButton":"\u4E3B\u8981\u64CD\u4F5C","card.created":"\u5DF2\u521B\u5EFA","card.updated":"\u5DF2\u66F4\u65B0","card.working":"\u6B63\u5728\u5199\u5165\u4EA7\u7269...","card.failed":"\u4EA7\u7269\u672A\u4FDD\u5B58","card.missing":"\u6B64\u7ED3\u679C\u6CA1\u6709\u4EA7\u7269\u4FE1\u606F\u3002","composer.label":"\u4EA7\u7269","error.generic":"\u51FA\u9519\u4E86\uFF0C\u8BF7\u91CD\u8BD5\u3002","error.notFound":"\u6B64\u4EA7\u7269\u5DF2\u4E0D\u5B58\u5728\u3002","error.stale":"\u4EA7\u7269\u5DF2\u66F4\u6539\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u3002","error.tooLarge":"\u5185\u5BB9\u8D85\u8FC7 2 MiB \u4E0A\u9650\u3002","error.noWorkspace":"\u6B64\u4F1A\u8BDD\u6CA1\u6709\u5DE5\u4F5C\u533A\u3002","error.forbidden":"\u4E0D\u5141\u8BB8\u8BBF\u95EE\u8BE5\u8DEF\u5F84\u3002","error.corrupt":"\u4EA7\u7269\u6587\u4EF6\u5DF2\u635F\u574F\u3002","error.tokens":"\u67D0\u4E2A\u8BBE\u8BA1\u503C\u4E0D\u662F\u6709\u6548\u7684 CSS\u3002","error.library":"\u65E0\u6CD5\u521B\u5EFA\u8D44\u6599\u5E93\u6587\u4EF6\u5939\u3002","error.surface":"\u4EA7\u7269\u9762\u677F\u7ED8\u5236\u5931\u8D25\u3002","error.surfaceHint":"\u8BF7\u91CD\u65B0\u52A0\u8F7D\u7A97\u53E3\u3002\u4F60\u7684\u4EA7\u7269\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728\u78C1\u76D8\u4E0A\u3002","action.retry":"\u91CD\u8BD5","action.reloadWindow":"\u91CD\u65B0\u52A0\u8F7D\u7A97\u53E3","time.justNow":"\u521A\u521A","time.minutes":"{count} \u5206\u949F\u524D","time.hours":"{count} \u5C0F\u65F6\u524D","time.days":"{count} \u5929\u524D"};function ft(e,t,r=Date.now()){let a=Math.max(0,r-Date.parse(t)),n=Math.floor(a/6e4);if(n<1)return e("time.justNow");if(n<60)return e("time.minutes",{count:n});let o=Math.floor(n/60);if(o<24)return e("time.hours",{count:o});let s=Math.floor(o/24);return s<7?e("time.days",{count:s}):new Date(t).toLocaleDateString()}var re=require("react/jsx-runtime");function Xa(e,t){let r=t.source.origin==="agent"?e("history.byAgent"):e("history.byUser"),a=t.source.action==="restore"&&t.source.restoredFrom!==void 0?e("history.restored",{version:t.source.restoredFrom}):t.source.action==="create"?e("history.created"):e("history.updated");return`${r} \xB7 ${a} \xB7 ${ft(e,t.createdAt)}`}function Ir({t:e,versions:t,failed:r,current:a,selected:n,onSelect:o}){return(0,re.jsxs)("div",{className:"art-history-body",children:[t===null?(0,re.jsx)("p",{className:"art-note",children:e("empty.loading")}):null,r?(0,re.jsx)("p",{className:"art-note",children:e("error.generic")}):null,!r&&t!==null&&t.length<=1?(0,re.jsx)("p",{className:"art-note",children:e("history.empty")}):null,t?.map(s=>(0,re.jsxs)("button",{type:"button",className:"art-version","aria-current":s.version===n?"true":void 0,onClick:()=>o(s.version),children:[(0,re.jsxs)("span",{className:"art-version-top",children:[(0,re.jsx)("span",{children:e("tab.versionOf",{version:s.version})}),s.version===a?(0,re.jsx)("span",{className:"art-badge",children:e("history.current")}):null]}),(0,re.jsx)("span",{className:"art-version-sub",children:Xa(e,s)})]},s.version))]})}var ie=require("react");var ve=require("react/jsx-runtime");function mt({content:e,designCss:t,title:r,frameTitle:a,dark:n=!1,onSelectionText:o}){let[s,l]=(0,ie.useState)(null),[f,u]=(0,ie.useState)(!1),h=(0,ie.useRef)(0),w=(0,ie.useRef)(null),k=(0,ie.useRef)(o);k.current=o;let S=o!==void 0;return(0,ie.useEffect)(()=>{h.current=0,u(!1);let m=URL.createObjectURL(new Blob([ut(e,t,r,n?"dark":"light",S)],{type:"text/html"}));return l(m),()=>URL.revokeObjectURL(m)},[e,t,r,n,S]),(0,ie.useEffect)(()=>{if(!S)return;let m=d=>{if(w.current===null||h.current>1||d.source!==w.current.contentWindow)return;let y=Ar(d.data);y!==void 0&&k.current?.(y)};return window.addEventListener("message",m),()=>window.removeEventListener("message",m)},[S]),f?(0,ve.jsx)("div",{className:"art-center",role:"alert",children:r}):s===null?null:(0,ve.jsx)("iframe",{ref:w,className:"art-frame",title:a,sandbox:Nr,referrerPolicy:"no-referrer",src:s,onLoad:()=>{h.current+=1,h.current>1&&u(!0)}},s)}function Lr({value:e,readOnly:t,label:r,hint:a,onChange:n,onSave:o,onSelectionText:s}){let l=f=>{t||s?.(f.value.slice(f.selectionStart,f.selectionEnd))};return(0,ve.jsxs)("div",{className:"art-source-wrap",children:[a===void 0?null:(0,ve.jsx)("div",{className:"art-code-bar",children:(0,ve.jsx)("span",{children:a})}),(0,ve.jsx)("textarea",{className:"art-source","aria-label":r,spellCheck:!1,readOnly:t,value:e,autoFocus:!t,onChange:f=>{n(f.target.value),s?.("")},onSelect:f=>l(f.currentTarget),onMouseUp:f=>l(f.currentTarget),onKeyUp:f=>l(f.currentTarget),onKeyDown:f=>{if((f.ctrlKey||f.metaKey)&&f.key.toLowerCase()==="s"){f.preventDefault(),o();return}if(f.key==="Tab"&&!f.shiftKey&&!t){f.preventDefault();let u=f.currentTarget,h=u.selectionStart,w=u.selectionEnd,k=e.slice(0,h)+" "+e.slice(w);n(k),requestAnimationFrame(()=>u.setSelectionRange(h+2,h+2))}}})]})}function Ft(e,t=2e3){let r=e.replace(/\r\n/g,`
23
23
  `).replace(/[ \t]+\n/g,`
24
24
  `).replace(/\n{3,}/g,`
25
25
 
26
- `).trim();return r.length<=t?{text:r,truncated:!1}:{text:r.slice(0,t).trimEnd(),truncated:!0}}function Mr(e,t){let r=t.version===t.current?"agent.reference":"agent.referenceOld";return`${e(r,{title:t.title,id:t.id,version:t.version,current:t.current})} `}function Ht(e,t){return e===""?t:`${e.split(`
26
+ `).trim();return r.length<=t?{text:r,truncated:!1}:{text:r.slice(0,t).trimEnd(),truncated:!0}}function Dr(e,t){let r=t.version===t.current?"agent.reference":"agent.referenceOld";return`${e(r,{title:t.title,id:t.id,version:t.version,current:t.current})} `}function Ht(e,t){return e===""?t:`${e.split(`
27
27
  `).map(r=>`> ${r}`).join(`
28
28
  `)}
29
29
 
30
- ${t}`}var zr=require("react"),Ir="data-ds-dark-theme";function Ka(){return typeof document<"u"&&document.body?.hasAttribute(Ir)===!0}function Ga(e){if(typeof document>"u"||document.body===null)return()=>{};let t=new MutationObserver(e);return t.observe(document.body,{attributes:!0,attributeFilter:[Ir]}),()=>t.disconnect()}function je(){return(0,zr.useSyncExternalStore)(Ga,Ka,()=>!1)}var o=require("react/jsx-runtime");function Ge({label:e,icon:t,onClick:r,pressed:n,disabled:a,buttonRef:i}){return(0,o.jsx)(m.Tooltip,{label:e,side:"bottom",portal:!0,children:(0,o.jsx)(m.Button,{ref:i,size:"sm",className:"art-icon-button","aria-label":e,"aria-pressed":n,disabled:a,onClick:r,children:t})})}function Ya({quote:e,askLabel:t,dismissLabel:r,onAsk:n,onDismiss:a}){return(0,o.jsxs)("div",{className:"art-selection-bar",role:"toolbar","aria-label":t,children:[(0,o.jsx)("span",{className:"art-selection-quote",title:e,children:e}),(0,o.jsx)(m.Button,{size:"sm",variant:"primary",icon:(0,o.jsx)(m.IconSparkleRegular,{size:14}),onClick:n,children:t}),(0,o.jsx)(Ge,{label:r,icon:(0,o.jsx)(m.IconCloseOutlineRegular,{size:14}),onClick:a})]})}function Xa({label:e,closeLabel:t,overlay:r,onClose:n,children:a}){let i=(0,v.useRef)(null);return(0,v.useEffect)(()=>{i.current?.querySelector("[data-drawer-initial]")?.focus()??i.current?.querySelector(".art-version, button")?.focus()},[e]),(0,v.useEffect)(()=>{if(!r)return;let s=d=>{let u=i.current;u===null||d.target instanceof Node&&u.contains(d.target)||u.querySelector("button")?.focus()};return document.addEventListener("focusin",s),()=>document.removeEventListener("focusin",s)},[r]),(0,o.jsxs)("div",{className:"art-drawer-layer","data-overlay":r?"true":void 0,children:[r?(0,o.jsx)("div",{className:"art-drawer-scrim","aria-hidden":"true",onPointerDown:n}):null,(0,o.jsxs)("aside",{ref:i,className:"art-drawer",role:"dialog","aria-modal":r?"true":void 0,"aria-label":e,onKeyDown:s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),n();return}if(s.key!=="Tab"||!r)return;let d=[...i.current?.querySelectorAll("button:not(:disabled)")??[]],u=d[0],f=d[d.length-1];u===void 0||f===void 0||(s.shiftKey&&document.activeElement===u?(s.preventDefault(),f.focus()):!s.shiftKey&&document.activeElement===f&&(s.preventDefault(),u.focus()))},children:[(0,o.jsxs)("div",{className:"art-drawer-head",children:[(0,o.jsx)("h2",{children:e}),(0,o.jsx)(Ge,{label:t,icon:(0,o.jsx)(m.IconCloseOutlineRegular,{size:14}),onClick:n})]}),(0,o.jsx)("div",{className:"art-drawer-body",children:a})]})]})}function $t(e){let t=e.useTabInfo(),r=ke(t.tab.contentId??t.tab.navigation?.address),n=e.useWorkspaces(a=>a.items.find(i=>r?.scope==="workspace"&&i.workspaceId===r.workspaceId)?.title);return r===void 0?(0,o.jsx)("section",{className:"art-root",children:(0,o.jsx)("p",{className:"art-note",children:e.t("error.notFound")})}):(0,o.jsx)(Br,{t:e.t,address:r,useTabInfo:e.useTabInfo,onBack:t.tab.actions?.close,workspaceName:n,inputActions:e.inputActions},z(r))}function Or({t:e,address:t,onBack:r,workspaceName:n}){return(0,o.jsx)(Br,{t:e,address:t,onBack:r,workspaceName:n,back:!0},z(t))}var Qa=()=>{};function Br({t:e,address:t,useTabInfo:r,onBack:n,workspaceName:a,back:i,inputActions:s}){let{model:d,state:u}=xr(t),{payload:f,draft:b,saving:y,conflict:h,failure:k}=u,c=d.where,g=t.id,M=je(),[E,P]=(0,v.useState)("preview"),[F,se]=(0,v.useState)(!1),[B,te]=(0,v.useState)(!1),[X,xe]=(0,v.useState)(!1),[le,ce]=(0,v.useState)(null),[re,Q]=(0,v.useState)(!1),[j,x]=(0,v.useState)(!1),[C,I]=(0,v.useState)(null),[O,H]=(0,v.useState)(null),[St,Pe]=(0,v.useState)(!1),[S,K]=(0,v.useState)(""),[De,de]=(0,v.useState)(null),[Je,Ze]=(0,v.useState)(!1),[ae,we]=(0,v.useState)(!1),[Le,pe]=(0,v.useState)(null),[Xt,Nt]=(0,v.useState)(null),[Qt,Ve]=(0,v.useState)(null),ue=(0,v.useRef)(0),et=(0,v.useRef)(null),Jt=(0,v.useRef)(null),Zt=(0,v.useRef)(null),Ct=(0,v.useRef)(!1),tt=yr(g),er=(r??Qa)();(0,v.useEffect)(()=>{f!==null&&tt>f.version&&b===null&&!y&&!h&&Ve(tt),d.externalVersion(tt)},[tt,d,y,f?.version,b,h]),(0,v.useEffect)(()=>{h&&Ve(null)},[h]),(0,v.useEffect)(()=>{pe(null)},[f?.version,C?.version,u.revision]);let oa=f!==null,Me=(0,v.useCallback)(()=>{let p=et.current,T=p===null?0:p.clientWidth;xe(T>0?T<=600:window.innerWidth<=600)},[]);(0,v.useEffect)(()=>{let p=et.current;if(p===null)return;Me();let T=new ResizeObserver(Me);return T.observe(p),window.addEventListener("resize",Me),()=>{T.disconnect(),window.removeEventListener("resize",Me)}},[oa,Me]);let Ne=(0,v.useCallback)(p=>{d.getSnapshot().draft!==null||d.getSnapshot().saving?de({run:p}):p()},[d]),At=(0,v.useCallback)(()=>{++ue.current,x(!1),I(null),pe(null),H(null),Ve(null)},[]),rt=(0,v.useCallback)(async()=>{At(),await d.discardAndReload()},[d,At]);(0,v.useEffect)(()=>er?.tab.actions?.bindCommands({refresh:()=>Ne(rt)}),[er?.tab.actions,Ne,rt]),(0,v.useEffect)(()=>{if(f?.manifest.type!=="doc"||b===null||h||y)return;let p=setTimeout(()=>void d.save(),1200);return()=>clearTimeout(p)},[b,h,y,d,f?.manifest.type]),(0,v.useEffect)(()=>{if(!B||f===null)return;let p=new AbortController;return ce(null),Q(!1),L.history(c,g,p.signal).then(T=>{p.signal.aborted||ce(T.versions)}).catch(()=>{p.signal.aborted||Q(!0)}),()=>p.abort()},[B,f?.version,d]),(0,v.useEffect)(()=>()=>{++ue.current},[]),(0,v.useEffect)(()=>{if(B){Ct.current=!0;return}Ct.current&&(Ct.current=!1,Zt.current?.focus())},[B]),(0,v.useEffect)(()=>{if(E!=="source"||f?.manifest.type!=="page")return;let p=()=>{let T=Jt.current,W=window.getSelection();if(T===null||W===null||W.anchorNode===null||!T.contains(W.anchorNode))return;let ze=jt(W.toString());pe(ze.text===""?null:ze)};return document.addEventListener("selectionchange",p),()=>document.removeEventListener("selectionchange",p)},[E,f?.manifest.type]);let tr=()=>{++ue.current,x(!1),I(null),te(!1)},Rt=()=>{Me(),++ue.current,x(!1),I(null),H(null),te(!0)},rr=async p=>{let T=++ue.current;if(H(null),pe(null),p===f?.version){x(!1),I(null);return}x(!0);try{let W=await L.get(c,g,p);T===ue.current&&I(W)}catch(W){T===ue.current&&$(e(V(U(W))))}finally{T===ue.current&&x(!1)}},ar=async()=>j?null:C!==null?C.version:await d.save()?d.getSnapshot().payload?.version??null:null,nr=async p=>{if(!ae){we(!0);try{let T=await ar();if(T===null)return;if(p==="print")Rr((await L.printable(c,g,T)).html);else{let W=await L.exportFile(c,g,p,T);mr(W),$(e("export.done",{name:W.fileName,path:W.path}))}}catch(T){$(e(V(U(T))))}finally{we(!1)}}},ia=async()=>{S.trim()===""||y||await d.save(S.trim())&&Pe(!1)},sa=async()=>{if(C===null||ae)return;let p=C.version;Ne(async()=>{we(!0);try{let T=await L.restore(c,g,p,d.getSnapshot().payload?.version??0);Ae(g,T.manifest.version),me(),At(),await d.load()}catch(T){$(e(V(U(T))))}finally{we(!1)}})},Et=async(p,T)=>{try{await navigator.clipboard.writeText(p),$(e(T))}catch{Nt(p)}},Pt=async p=>{if(!(ae||h||j||f===null)){we(!0);try{let T=await ar();if(T===null)return;let W=d.getSnapshot().payload??f,ze=Mr(e,{title:W.manifest.title,id:g,version:T,current:W.version}),nt=p?.text??"";if(pe(null),s===void 0){await Et(Ht(nt,ze),"agent.copied");return}if((nt===""||s.insertQuote(nt))&&s.insertText(ze,s.captureInsertion())){$(e(p?.truncated===!0?"agent.addedTruncated":"agent.added"));return}await Et(Ht(nt,ze),"agent.insertFailed")}finally{we(!1)}}},Dt=(0,v.useCallback)(p=>{let T=jt(p);pe(T.text===""?null:T)},[]),la=async()=>{if(O==="version"){H(null);return}if(f!==null){try{let p=await L.history(c,g);ce(p.versions)}catch(p){$(e(V(U(p))));return}H("version")}};if(f===null)return(0,o.jsx)("section",{className:"art-root","data-dsh-artifact-studio":"",ref:et,children:(0,o.jsxs)("div",{className:"art-center",role:k===void 0?"status":"alert",children:[(0,o.jsx)("p",{className:"art-center-hint",children:e(k===void 0?"empty.loading":V(k))}),(0,o.jsxs)("div",{className:"art-center-actions",children:[k===void 0?null:(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:()=>void d.load(),children:e("action.retry")}),n===void 0?null:(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:n,children:e("tab.close")})]})]})});let Ce=f.manifest.type,at=C?.content??b??f.content,We=C!==null,ca=C?.version??f.version,da=e(y?"tab.saving":h?"tab.conflictTitle":j?"empty.loading":C!==null?"tab.readOnly":k!==void 0?"tab.saveFailed":b!==null?"tab.unsaved":"tab.saved"),pa=h||k!==void 0&&!y?"error":y?"warn":void 0,ua=t.scope==="workspace"?a??t.workspaceId:e("scope.library"),fa=E==="source"&&!We&&(F||b!==null),or=[...lr[Ce].map(p=>({id:p,label:e(`export.${p}`)})),{type:"separator",id:"export-gap"},{id:"print",label:e("export.print")}],ir=p=>{H(null),p==="print"?nr("print"):(p==="html"||p==="md"||p==="docx")&&nr(p)},ma=[...X?[...or,{type:"separator",id:"more-gap"}]:[],{id:"rename",label:e("tab.rename")},{id:"reload",label:e("tab.reload")},{type:"separator",id:"danger-gap"},{id:"delete",label:e("tab.delete"),danger:!0}],ga=p=>{H(null),p==="rename"?(K(f.manifest.title),Pe(!0)):p==="reload"?Ne(rt):p==="delete"?Ze(!0):ir(p)},ba=[...(le??[]).map(p=>({id:"v"+p.version,label:e("tab.versionOf",{version:p.version})+(p.version===f.version?" \xB7 "+e("tab.currentVersion"):"")})),{type:"separator",id:"versions-gap"},{id:"all",label:e("tab.allVersions")}],ya=p=>{H(null),p==="all"?Rt():rr(Number(p.slice(1)))},ha=(0,o.jsx)(m.Button,{size:"sm",variant:"primary",className:"art-ask",icon:(0,o.jsx)(m.IconSparkleRegular,{size:14}),disabled:ae||h||j,onClick:()=>void Pt(Le),children:e("agent.ask")});return(0,o.jsxs)("section",{className:"art-root","data-dsh-artifact-studio":"","data-artifact-id":g,"aria-busy":ae,ref:et,children:[(0,o.jsxs)("header",{className:"art-header art-editor-header",children:[(0,o.jsxs)("div",{className:"art-heading",children:[!i||n===void 0?null:(0,o.jsx)(Ge,{label:e("action.back"),icon:(0,o.jsx)(m.IconChevronLeftOutlineRegular,{size:16}),onClick:()=>Ne(n)}),(0,o.jsxs)("div",{className:"art-identity",children:[(0,o.jsx)("h1",{className:"art-title",title:f.manifest.title,children:f.manifest.title}),(0,o.jsxs)("div",{className:"art-meta",children:[(0,o.jsxs)("span",{className:"art-meta-text",children:[ua,t.scope==="workspace"?" \xB7 "+e("scope.workspace"):null]}),(0,o.jsx)("span",{className:"art-meta-dot","aria-hidden":"true",children:"\xB7"}),(0,o.jsx)(m.Menu,{open:O==="version",onClose:()=>H(null),items:ba,onSelect:ya,portal:!0,autoFocus:!0,anchor:(0,o.jsxs)("button",{type:"button",className:"art-version-button","aria-label":e("tab.versionPicker"),"aria-haspopup":"menu","aria-expanded":O==="version",onClick:()=>void la(),children:[e("gallery.version",{version:ca}),(0,o.jsx)(m.IconChevronDownOutlineRegular,{size:12})]})}),(0,o.jsx)("span",{className:"art-meta-dot","aria-hidden":"true",children:"\xB7"}),(0,o.jsx)("span",{className:"art-save-status","data-tone":pa,"aria-live":"polite",children:da})]})]})]}),(0,o.jsxs)("div",{className:"art-actions art-editor-actions",children:[Ce!=="page"?null:(0,o.jsx)(m.SegmentedControl,{id:"art-mode-"+g,className:"art-segment",label:e("tab.mode"),value:E,options:[{value:"preview",label:e("tab.preview")},{value:"source",label:e("tab.source")}],onChange:p=>{P(p),pe(null)}}),b===null||We?null:(0,o.jsx)(Ge,{label:e("tab.save"),icon:(0,o.jsx)(m.IconSaveOutlineRegular,{size:16}),disabled:h,onClick:()=>void d.save()}),(0,o.jsx)(Ge,{buttonRef:Zt,label:e("tab.history"),icon:(0,o.jsx)(m.IconClockOutlineRegular,{size:16}),pressed:B,onClick:()=>{B?tr():Rt()}}),X?null:(0,o.jsx)(m.Menu,{open:O==="export",onClose:()=>H(null),items:or,onSelect:ir,align:"end",portal:!0,autoFocus:!0,anchor:(0,o.jsx)(m.Button,{size:"sm",icon:(0,o.jsx)(m.IconDownloadOutlineRegular,{size:14}),"aria-label":e("tab.export"),"aria-haspopup":"menu","aria-expanded":O==="export",disabled:ae||j,onClick:()=>H(O==="export"?null:"export"),children:e("tab.export")})}),ha,(0,o.jsx)(m.Menu,{open:O==="more",onClose:()=>H(null),items:ma,onSelect:ga,align:"end",portal:!0,autoFocus:!0,anchor:(0,o.jsx)(m.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.more"),"aria-haspopup":"menu","aria-expanded":O==="more",onClick:()=>H(O==="more"?null:"more"),children:(0,o.jsx)(m.IconEllipsisOutlineRegular,{size:14})})})]})]}),St?(0,o.jsxs)("form",{className:"art-inline-form",onSubmit:p=>{p.preventDefault(),ia()},children:[(0,o.jsx)("input",{"aria-label":e("tab.rename"),value:S,maxLength:120,autoFocus:!0,onChange:p=>K(p.target.value),onKeyDown:p=>{p.key==="Escape"&&Pe(!1)}}),(0,o.jsx)(m.Button,{type:"submit",size:"sm",variant:"primary",disabled:y||h,children:e("tab.save")}),(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:()=>Pe(!1),children:e("create.cancel")})]}):null,Qt===null?null:(0,o.jsxs)("div",{className:"art-bar",role:"status",children:[(0,o.jsx)("span",{children:e("tab.agentUpdate",{version:Qt})}),(0,o.jsxs)("span",{className:"art-bar-actions",children:[(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:()=>{Ve(null),Rt()},children:e("tab.viewHistory")}),(0,o.jsx)(m.Button,{size:"sm",onClick:()=>Ve(null),children:e("tab.dismiss")})]})]}),h?(0,o.jsxs)("div",{className:"art-bar","data-tone":"warn",role:"alert",children:[(0,o.jsxs)("span",{className:"art-bar-text",children:[(0,o.jsx)("strong",{children:e("tab.conflictTitle")}),(0,o.jsx)("span",{children:e("tab.conflictHint")})]}),(0,o.jsxs)("span",{className:"art-bar-actions",children:[(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:()=>void Et(b??"","action.copied"),children:e("tab.copyDraft")}),(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:()=>Ne(rt),children:e("tab.discardReload")})]})]}):null,!h&&k!==void 0?(0,o.jsxs)("div",{className:"art-bar","data-tone":"error",role:"alert",children:[(0,o.jsx)("span",{children:e(V(k))}),(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:()=>void d.save(),children:e("action.retry")})]}):null,C===null?null:(0,o.jsxs)("div",{className:"art-bar",role:"status",children:[(0,o.jsx)("span",{children:e("tab.viewingOld",{version:C.version,current:f.version})}),(0,o.jsxs)("span",{className:"art-bar-actions",children:[(0,o.jsx)(m.Button,{size:"sm",variant:"outline",onClick:()=>{++ue.current,x(!1),I(null),pe(null)},children:e("tab.backToCurrent")}),(0,o.jsx)(m.Button,{size:"sm",variant:"outline",disabled:ae,onClick:()=>void sa(),children:e("tab.restoreThis")})]})]}),(0,o.jsxs)("div",{className:"art-body",children:[(0,o.jsxs)("div",{className:"art-stage",role:Ce==="page"?"tabpanel":void 0,id:Ce==="page"?"art-mode-"+g+"-"+E+"-panel":void 0,"aria-labelledby":Ce==="page"?"art-mode-"+g+"-"+E:void 0,children:[Ce!=="page"||Le===null||B?null:(0,o.jsx)(Ya,{quote:Le.text,askLabel:e("agent.ask"),dismissLabel:e("tab.dismiss"),onAsk:()=>void Pt(Le),onDismiss:()=>pe(null)}),Ce==="doc"?(0,o.jsx)(mt,{markdown:at,revision:(C?.version??0)+":"+u.revision,editable:!We&&!h,label:f.manifest.title,loadingLabel:e("empty.loading"),failedLabel:e("error.generic"),design:f.design,dark:M,t:e,onChange:p=>d.edit(p),onSave:()=>void d.save(),onSelectionText:Dt,selectionAction:Le===null?null:(0,o.jsx)(m.Button,{size:"sm",variant:"primary",icon:(0,o.jsx)(m.IconSparkleRegular,{size:14}),onMouseDown:p=>p.preventDefault(),onClick:()=>void Pt(Le),children:e("agent.ask")})}):E==="preview"?(0,o.jsx)(yt,{content:at,designCss:f.designCss,title:f.manifest.title,frameTitle:e("tab.frameTitle",{title:f.manifest.title}),dark:M,onSelectionText:Dt}):fa?(0,o.jsx)(Lr,{value:at,readOnly:!1,label:e("tab.source"),hint:e("tab.manualSave"),onChange:p=>d.edit(p),onSave:()=>void d.save(),onSelectionText:Dt}):(0,o.jsxs)("div",{className:"art-code",ref:Jt,children:[(0,o.jsxs)("div",{className:"art-code-bar",children:[(0,o.jsx)("span",{children:e(We?"tab.readOnly":"tab.codeHint")}),We?null:(0,o.jsx)(m.Button,{size:"sm",variant:"outline",icon:(0,o.jsx)(m.IconEditOutlineRegular,{size:14}),onClick:()=>se(!0),children:e("tab.editSource")})]}),(0,o.jsx)(m.CodeBlock,{code:at,lang:"html",lineNumbers:!0,showHeader:!1,wrap:!0,className:"art-code-block",copyLabel:e("code.copy"),copiedLabel:e("action.copied")})]})]}),B?(0,o.jsx)(Xa,{label:e("history.title"),closeLabel:e("history.close"),overlay:X,onClose:tr,children:(0,o.jsx)(Dr,{t:e,versions:le,failed:re,current:f.version,selected:C?.version??f.version,onSelect:p=>void rr(p)})}):null]}),(0,o.jsx)(m.Modal,{open:De!==null,onClose:()=>de(null),title:e("tab.leaveTitle"),closeLabel:e("dialog.close"),description:e(h?"tab.conflictHint":"tab.leaveHint"),footer:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(m.Button,{variant:"outline",disabled:ae,onClick:()=>de(null),children:e("create.cancel")}),(0,o.jsx)(m.Button,{variant:"outline",disabled:y||ae,onClick:()=>{let p=De?.run;de(null),p!==void 0&&d.discardAndReload().then(p)},children:e("tab.discardContinue")}),(0,o.jsx)(m.Button,{variant:"primary",disabled:h||ae,onClick:async()=>{we(!0);let p=await d.save();we(!1);let T=De?.run;p&&T!==void 0&&(de(null),await T())},children:e("tab.saveContinue")})]}),children:k===void 0?null:(0,o.jsx)("p",{className:"art-modal-error",role:"alert",children:e(V(k))})}),(0,o.jsx)(m.Modal,{open:Je,onClose:()=>Ze(!1),title:e("tab.deleteTitle"),closeLabel:e("dialog.close"),description:e("tab.deleteConfirm",{title:f.manifest.title}),footer:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(m.Button,{variant:"outline",onClick:()=>Ze(!1),children:e("create.cancel")}),(0,o.jsx)(m.Button,{variant:"primary",onClick:()=>{Ze(!1),Ne(async()=>{try{await L.remove(c,g),me(),n?.()}catch(p){$(e(V(U(p))))}})},children:e("tab.delete")})]})}),(0,o.jsx)(m.Modal,{open:Xt!==null,onClose:()=>Nt(null),title:e("agent.copyTitle"),closeLabel:e("dialog.close"),description:e("action.copyFailed"),footer:(0,o.jsx)(m.Button,{variant:"primary",onClick:()=>Nt(null),children:e("dialog.done")}),children:(0,o.jsx)("textarea",{className:"art-fallback",readOnly:!0,value:Xt??"","aria-label":e("agent.copyTitle"),onFocus:p=>p.currentTarget.select()})})]})}var Fr=Na(require("react"),1),jr=require("@deepseek-ai/dsh-client-ui-primitives"),Re=require("react/jsx-runtime"),ht=class extends Fr.default.Component{constructor(t){super(t),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,Re.jsx)("section",{className:"art-root","data-dsh-artifact-studio":"",children:(0,Re.jsxs)("div",{className:"art-center",role:"alert",children:[(0,Re.jsx)("p",{className:"art-center-title",children:this.props.title}),(0,Re.jsx)("p",{className:"art-center-hint",children:this.props.hint}),(0,Re.jsx)(jr.Button,{size:"sm",variant:"outline",onClick:()=>window.location.reload(),children:this.props.reloadLabel})]})}):this.props.children}};var xt=require("react"),He=require("@deepseek-ai/dsh-client-ui-primitives");var po=require("react"),q=require("react/jsx-runtime");function Vt({children:e,size:t=16}){return(0,q.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}var vt=({size:e})=>(0,q.jsxs)(Vt,{size:e,children:[(0,q.jsx)("rect",{x:"3.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),(0,q.jsx)("rect",{x:"13.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),(0,q.jsx)("rect",{x:"3.5",y:"13.5",width:"7",height:"7",rx:"1.5"}),(0,q.jsx)("path",{d:"M17 13.5v7M13.5 17h7"})]}),ie=({size:e})=>(0,q.jsxs)(Vt,{size:e,children:[(0,q.jsx)("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2"}),(0,q.jsx)("path",{d:"M3.5 8.5h17M9 13l-2 1.8L9 16.5M15 13l2 1.8-2 1.7"})]}),be=({size:e})=>(0,q.jsxs)(Vt,{size:e,children:[(0,q.jsx)("path",{d:"M6.5 3.5h7l4 4v13h-11z"}),(0,q.jsx)("path",{d:"M13.5 3.5v4h4M9 12h6M9 15.5h6"})]});var ye={sidebarRight:null,layout:null};var A=require("react/jsx-runtime");function Ja(e){if(e===null||typeof e!="object")return null;let t={...e},{id:r,type:n,title:a,version:i,workspaceId:s}=t;if(t.kind!=="artifact"||typeof r!="string"||typeof a!="string"||typeof i!="number"||n!=="page"&&n!=="doc")return null;let d=cr(r);return d===void 0?null:d==="workspace"?typeof s!="string"||s===""?null:{id:r,type:n,title:a,version:i,address:{scope:d,workspaceId:s,id:r}}:{id:r,type:n,title:a,version:i,address:{scope:d,id:r}}}function Za(e){return Array.isArray(e)?e.map(t=>{if(t===null||typeof t!="object")return"";let r={...t};return r.type==="text"&&typeof r.text=="string"?r.text:""}).filter(t=>t!=="").join(`
31
- `).trim():""}function en(e){if(e===null||typeof e!="object")return;let t={...e};return typeof t.title=="string"&&t.title.trim()!==""?t.title.trim():void 0}var Hr=new Set;function Wt({t:e,phase:t,toolName:r,block:n}){let a=t==="result"&&n?.isError!==!0?Ja(n?.meta):null,i=(0,xt.useRef)(t!=="result");t!=="result"&&(i.current=!0);let s=r==="artifact_update";if((0,xt.useEffect)(()=>{if(a===null)return;fe(a.id,a.title),Ae(a.id,a.version),me();let u=a.id+":"+a.version;!i.current||Hr.has(u)||(Hr.add(u),ye.sidebarRight?.openResource(z(a.address)))},[a?.id,a?.version,a?.title]),t!=="result"){let u=en(n?.args),f=u===void 0?e(s?"card.updatingUntitled":"card.working"):e(s?"card.updating":"card.creating",{title:u});return(0,A.jsxs)("div",{className:"art-card","data-artifact-card":"working",children:[(0,A.jsx)("span",{className:"art-card-icon",children:(0,A.jsx)(ie,{})}),(0,A.jsx)("span",{className:"art-card-text",children:(0,A.jsx)(He.TextShimmer,{active:!0,className:"art-card-title",children:(0,A.jsx)("span",{role:"status",children:f})})}),(0,A.jsx)(He.StateDot,{state:"ongoing"})]})}if(n?.isError===!0)return(0,A.jsxs)("div",{className:"art-card","data-artifact-card":"error",children:[(0,A.jsx)("span",{className:"art-card-icon","data-tone":"error",children:(0,A.jsx)(ie,{})}),(0,A.jsxs)("span",{className:"art-card-text",children:[(0,A.jsx)("span",{className:"art-card-title",children:e("card.failed")}),(0,A.jsx)("span",{className:"art-card-sub","data-tone":"error",children:Za(n.content)})]})]});if(a===null)return(0,A.jsxs)("div",{className:"art-card","data-artifact-card":"missing",children:[(0,A.jsx)("span",{className:"art-card-icon",children:(0,A.jsx)(ie,{})}),(0,A.jsx)("span",{className:"art-card-sub",children:e("card.missing")})]});let d=z(a.address);return(0,A.jsxs)("button",{type:"button",className:"art-card art-card-open","data-artifact-card":"ready","data-artifact-id":a.id,"aria-label":e("card.openNamed",{title:a.title}),onClick:()=>ye.sidebarRight?.openResource(d),children:[(0,A.jsx)("span",{className:"art-card-icon",children:a.type==="page"?(0,A.jsx)(ie,{}):(0,A.jsx)(be,{})}),(0,A.jsxs)("span",{className:"art-card-text",children:[(0,A.jsx)("span",{className:"art-card-title",title:a.title,children:a.title}),(0,A.jsxs)("span",{className:"art-card-sub",children:[e(s?"card.updated":"card.created")," \xB7 ",e(`type.${a.type}`)," \xB7 ",e("gallery.version",{version:a.version}),a.address.scope==="library"?" \xB7 "+e("scope.library"):""]})]}),(0,A.jsx)("span",{className:"art-card-go","aria-hidden":"true",children:(0,A.jsx)(He.IconChevronRightOutlineRegular,{size:14})})]})}var Xe=require("react"),wt=require("@deepseek-ai/dsh-client-ui-primitives");var $r=require("react");function Vr({sessionId:e,useSessions:t,useWorkspaces:r}){let n=r(i=>i.items),a=t(i=>i.byId[e]);return(0,$r.useMemo)(()=>{let i=typeof a?.cwd=="string"?a.cwd:null,s=n.find(d=>d.sessionIds?.includes(e))??n.find(d=>i!==null&&(i===d.path||i.startsWith(`${d.path}/`)))??null;return{root:i??s?.path??null,workspaceId:s?.workspaceId??null}},[n,a,e])}var Ye="dsh-artifact-studio/artifact",_t="artifact",$e="dsh-artifact-studio-panel";var Ee=require("react/jsx-runtime"),tn=6,Ut=["dashboard","explainer","report","brief"];function rn(e,t){let r=e.filter(a=>a.source.sessionId===t),n=e.filter(a=>a.source.sessionId!==t);return[...r,...n].slice(0,tn)}function Wr(e){let{t,sessionId:r,inputActions:n}=e,i=Vr(e).workspaceId,s=ft(),[d,u]=(0,Xe.useState)(!1),[f,b]=(0,Xe.useState)(null);(0,Xe.useEffect)(()=>{if(!d||i===null)return;let c=new AbortController;return L.list({scope:"workspace",workspaceId:i},{},c.signal).then(g=>{c.signal.aborted||b(rn(g.items,r))}).catch(()=>{c.signal.aborted||b([])}),()=>c.abort()},[d,i,r,s]);let y=i===null?[{type:"label",id:"no-workspace",text:t("empty.noWorkspace")}]:f===null?[{type:"label",id:"loading",text:t("empty.loading")}]:f.length===0?[{type:"label",id:"empty",text:t("composer.empty")}]:f.map(c=>({id:"open:"+c.id,label:c.title,icon:c.type==="page"?(0,Ee.jsx)(ie,{size:14}):(0,Ee.jsx)(be,{size:14})})),h=[{type:"label",id:"recent",text:t("composer.recent")},...y,...n===void 0?[]:[{type:"separator",id:"start-gap"},{type:"label",id:"start",text:t("composer.start")},...Ut.map(c=>({id:"prompt:"+c,label:t(`prompt.${c}`)}))],{type:"separator",id:"all-gap"},{id:"all",label:t("composer.all")}];return(0,Ee.jsx)(wt.Menu,{open:d,onClose:()=>u(!1),items:h,onSelect:c=>{if(u(!1),c==="all"){ye.layout?.selectPanel($e);return}if(c.startsWith("prompt:")&&n!==void 0){n.insertText(t(`prompt.${c.slice(7)}Text`),n.captureInsertion());return}let g=f?.find(M=>"open:"+M.id===c);g===void 0||i===null||(fe(g.id,g.title),ye.sidebarRight?.openResource(z({scope:"workspace",workspaceId:i,id:g.id})))},side:"top",portal:!0,autoFocus:!0,anchor:(0,Ee.jsx)(wt.Tooltip,{label:t("composer.label"),side:"top",portal:!0,children:(0,Ee.jsx)("button",{type:"button",className:"art-composer","aria-label":t("composer.label"),"aria-haspopup":"menu","aria-expanded":d,onClick:()=>u(c=>!c),children:(0,Ee.jsx)(vt,{})})})})}var Y=require("react");var R=require("react"),N=require("@deepseek-ai/dsh-client-ui-primitives");var he=require("react"),kt=require("@deepseek-ai/dsh-client-ui-primitives");var w=require("react/jsx-runtime"),an=["sm","md","lg"],nn=e=>`<!doctype html><html><head><meta name="color-scheme" content="light dark"><style>
30
+ ${t}`}var Mr=require("react"),zr="data-ds-dark-theme";function Qa(){return typeof document<"u"&&document.body?.hasAttribute(zr)===!0}function Za(e){if(typeof document>"u"||document.body===null)return()=>{};let t=new MutationObserver(e);return t.observe(document.body,{attributes:!0,attributeFilter:[zr]}),()=>t.disconnect()}function ze(){return(0,Mr.useSyncExternalStore)(Za,Qa,()=>!1)}var i=require("react/jsx-runtime");function qe({label:e,icon:t,onClick:r,pressed:a,disabled:n,buttonRef:o}){return(0,i.jsx)(b.Tooltip,{label:e,side:"bottom",portal:!0,children:(0,i.jsx)(b.Button,{ref:o,size:"sm",className:"art-icon-button","aria-label":e,"aria-pressed":a,disabled:n,onClick:r,children:t})})}function Ja({quote:e,askLabel:t,dismissLabel:r,onAsk:a,onDismiss:n}){return(0,i.jsxs)("div",{className:"art-selection-bar",role:"toolbar","aria-label":t,children:[(0,i.jsx)("span",{className:"art-selection-quote",title:e,children:e}),(0,i.jsx)(b.Button,{size:"sm",variant:"primary",icon:(0,i.jsx)(b.IconSparkleRegular,{size:14}),onClick:a,children:t}),(0,i.jsx)(qe,{label:r,icon:(0,i.jsx)(b.IconCloseOutlineRegular,{size:14}),onClick:n})]})}function en({label:e,closeLabel:t,overlay:r,onClose:a,children:n}){let o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{o.current?.querySelector("[data-drawer-initial]")?.focus()??o.current?.querySelector(".art-version, button")?.focus()},[e]),(0,v.useEffect)(()=>{if(!r)return;let s=l=>{let f=o.current;f===null||l.target instanceof Node&&f.contains(l.target)||f.querySelector("button")?.focus()};return document.addEventListener("focusin",s),()=>document.removeEventListener("focusin",s)},[r]),(0,i.jsxs)("div",{className:"art-drawer-layer","data-overlay":r?"true":void 0,children:[r?(0,i.jsx)("div",{className:"art-drawer-scrim","aria-hidden":"true",onPointerDown:a}):null,(0,i.jsxs)("aside",{ref:o,className:"art-drawer",role:"dialog","aria-modal":r?"true":void 0,"aria-label":e,onKeyDown:s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),a();return}if(s.key!=="Tab"||!r)return;let l=[...o.current?.querySelectorAll("button:not(:disabled)")??[]],f=l[0],u=l[l.length-1];f===void 0||u===void 0||(s.shiftKey&&document.activeElement===f?(s.preventDefault(),u.focus()):!s.shiftKey&&document.activeElement===u&&(s.preventDefault(),f.focus()))},children:[(0,i.jsxs)("div",{className:"art-drawer-head",children:[(0,i.jsx)("h2",{children:e}),(0,i.jsx)(qe,{label:t,icon:(0,i.jsx)(b.IconCloseOutlineRegular,{size:14}),onClick:a})]}),(0,i.jsx)("div",{className:"art-drawer-body",children:n})]})]})}function Vt(e){let t=e.useTabInfo(),r=he(t.tab.contentId??t.tab.navigation?.address),a=e.useWorkspaces(n=>n.items.find(o=>r?.scope==="workspace"&&o.workspaceId===r.workspaceId)?.title);return r===void 0?(0,i.jsx)("section",{className:"art-root",children:(0,i.jsx)("p",{className:"art-note",children:e.t("error.notFound")})}):(0,i.jsx)(jr,{t:e.t,address:r,useTabInfo:e.useTabInfo,onBack:t.tab.actions?.close,workspaceName:a,inputActions:e.inputActions},H(r))}function Or({t:e,address:t,onBack:r,workspaceName:a}){return(0,i.jsx)(jr,{t:e,address:t,onBack:r,workspaceName:a,back:!0},H(t))}var tn=()=>{};function jr({t:e,address:t,useTabInfo:r,onBack:a,workspaceName:n,back:o,inputActions:s}){let{model:l,state:f}=xr(t),{payload:u,draft:h,saving:w,conflict:k,failure:S}=f,m=l.where,d=t.id,y=ze(),[E,I]=(0,v.useState)("preview"),[O,Z]=(0,v.useState)(!1),[M,J]=(0,v.useState)(!1),[$,_]=(0,v.useState)(!1),[A,q]=(0,v.useState)(null),[V,ae]=(0,v.useState)(!1),[ee,x]=(0,v.useState)(!1),[g,L]=(0,v.useState)(null),[j,F]=(0,v.useState)(null),[Tt,we]=(0,v.useState)(!1),[Be,Yt]=(0,v.useState)(""),[St,Fe]=(0,v.useState)(null),[la,Xe]=(0,v.useState)(!1),[ne,ye]=(0,v.useState)(!1),[Re,le]=(0,v.useState)(null),[Xt,Ct]=(0,v.useState)(null),[Qt,He]=(0,v.useState)(null),ce=(0,v.useRef)(0),Qe=(0,v.useRef)(null),Zt=(0,v.useRef)(null),Jt=(0,v.useRef)(null),Nt=(0,v.useRef)(!1),Ze=yr(d),er=(r??tn)();(0,v.useEffect)(()=>{u!==null&&Ze>u.version&&h===null&&!w&&!k&&He(Ze),l.externalVersion(Ze)},[Ze,l,w,u?.version,h,k]),(0,v.useEffect)(()=>{k&&He(null)},[k]),(0,v.useEffect)(()=>{le(null)},[u?.version,g?.version,f.revision]);let ca=u!==null,Ee=(0,v.useCallback)(()=>{let p=Qe.current,C=p===null?0:p.clientWidth;_(C>0?C<=600:window.innerWidth<=600)},[]);(0,v.useEffect)(()=>{let p=Qe.current;if(p===null)return;Ee();let C=new ResizeObserver(Ee);return C.observe(p),window.addEventListener("resize",Ee),()=>{C.disconnect(),window.removeEventListener("resize",Ee)}},[ca,Ee]);let ke=(0,v.useCallback)(p=>{l.getSnapshot().draft!==null||l.getSnapshot().saving?Fe({run:p}):p()},[l]),At=(0,v.useCallback)(()=>{++ce.current,x(!1),L(null),le(null),F(null),He(null)},[]),Je=(0,v.useCallback)(async()=>{At(),await l.discardAndReload()},[l,At]);(0,v.useEffect)(()=>er?.tab.actions?.bindCommands({refresh:()=>ke(Je)}),[er?.tab.actions,ke,Je]),(0,v.useEffect)(()=>{if(u?.manifest.type!=="doc"||h===null||k||w)return;let p=setTimeout(()=>void l.save(),1200);return()=>clearTimeout(p)},[h,k,w,l,u?.manifest.type]),(0,v.useEffect)(()=>{if(!M||u===null)return;let p=new AbortController;return q(null),ae(!1),z.history(m,d,p.signal).then(C=>{p.signal.aborted||q(C.versions)}).catch(()=>{p.signal.aborted||ae(!0)}),()=>p.abort()},[M,u?.version,l]),(0,v.useEffect)(()=>()=>{++ce.current},[]),(0,v.useEffect)(()=>{if(M){Nt.current=!0;return}Nt.current&&(Nt.current=!1,Jt.current?.focus())},[M]),(0,v.useEffect)(()=>{if(E!=="source"||u?.manifest.type!=="page")return;let p=()=>{let C=Zt.current,G=window.getSelection();if(C===null||G===null||G.anchorNode===null||!C.contains(G.anchorNode))return;let Pe=Ft(G.toString());le(Pe.text===""?null:Pe)};return document.addEventListener("selectionchange",p),()=>document.removeEventListener("selectionchange",p)},[E,u?.manifest.type]);let tr=()=>{++ce.current,x(!1),L(null),J(!1)},Rt=()=>{Ee(),++ce.current,x(!1),L(null),F(null),J(!0)},rr=async p=>{let C=++ce.current;if(F(null),le(null),p===u?.version){x(!1),L(null);return}x(!0);try{let G=await z.get(m,d,p);C===ce.current&&L(G)}catch(G){C===ce.current&&W(e(X(Y(G))))}finally{C===ce.current&&x(!1)}},ar=async()=>ee?null:g!==null?g.version:await l.save()?l.getSnapshot().payload?.version??null:null,nr=async p=>{if(!ne){ye(!0);try{let C=await ar();if(C===null)return;if(p==="print")Rr((await z.printable(m,d,C)).html);else{let G=await z.exportFile(m,d,p,C);mr(G),W(e("export.done",{name:G.fileName,path:G.path}))}}catch(C){W(e(X(Y(C))))}finally{ye(!1)}}},da=async()=>{Be.trim()===""||w||await l.save(Be.trim())&&we(!1)},pa=async()=>{if(g===null||ne)return;let p=g.version;ke(async()=>{ye(!0);try{let C=await z.restore(m,d,p,l.getSnapshot().payload?.version??0);Se(d,C.manifest.version),pe(),At(),await l.load()}catch(C){W(e(X(Y(C))))}finally{ye(!1)}})},Et=async(p,C)=>{try{await navigator.clipboard.writeText(p),W(e(C))}catch{Ct(p)}},Pt=async p=>{if(!(ne||k||ee||u===null)){ye(!0);try{let C=await ar();if(C===null)return;let G=l.getSnapshot().payload??u,Pe=Dr(e,{title:G.manifest.title,id:d,version:C,current:G.version}),tt=p?.text??"";if(le(null),s===void 0){await Et(Ht(tt,Pe),"agent.copied");return}if((tt===""||s.insertQuote(tt))&&s.insertText(Pe,s.captureInsertion())){W(e(p?.truncated===!0?"agent.addedTruncated":"agent.added"));return}await Et(Ht(tt,Pe),"agent.insertFailed")}finally{ye(!1)}}},It=(0,v.useCallback)(p=>{let C=Ft(p);le(C.text===""?null:C)},[]),ua=async()=>{if(j==="version"){F(null);return}if(u!==null){try{let p=await z.history(m,d);q(p.versions)}catch(p){W(e(X(Y(p))));return}F("version")}};if(u===null)return(0,i.jsx)("section",{className:"art-root","data-dsh-artifact-studio":"",ref:Qe,children:(0,i.jsxs)("div",{className:"art-center",role:S===void 0?"status":"alert",children:[(0,i.jsx)("p",{className:"art-center-hint",children:e(S===void 0?"empty.loading":X(S))}),(0,i.jsxs)("div",{className:"art-center-actions",children:[S===void 0?null:(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:()=>void l.load(),children:e("action.retry")}),a===void 0?null:(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:a,children:e("tab.close")})]})]})});let Te=u.manifest.type,et=g?.content??h??u.content,Ve=g!==null,fa=g?.version??u.version,ma=e(w?"tab.saving":k?"tab.conflictTitle":ee?"empty.loading":g!==null?"tab.readOnly":S!==void 0?"tab.saveFailed":h!==null?"tab.unsaved":"tab.saved"),ga=k||S!==void 0&&!w?"error":w?"warn":void 0,ba=t.scope==="workspace"?n??t.workspaceId:e("scope.library"),ya=E==="source"&&!Ve&&(O||h!==null),or=[...lr[Te].map(p=>({id:p,label:e(`export.${p}`)})),{type:"separator",id:"export-gap"},{id:"print",label:e("export.print")}],ir=p=>{F(null),p==="print"?nr("print"):(p==="html"||p==="md"||p==="docx")&&nr(p)},ha=[...$?[...or,{type:"separator",id:"more-gap"}]:[],{id:"rename",label:e("tab.rename")},{id:"reload",label:e("tab.reload")},{type:"separator",id:"danger-gap"},{id:"delete",label:e("tab.delete"),danger:!0}],va=p=>{F(null),p==="rename"?(Yt(u.manifest.title),we(!0)):p==="reload"?ke(Je):p==="delete"?Xe(!0):ir(p)},xa=[...(A??[]).map(p=>({id:"v"+p.version,label:e("tab.versionOf",{version:p.version})+(p.version===u.version?" \xB7 "+e("tab.currentVersion"):"")})),{type:"separator",id:"versions-gap"},{id:"all",label:e("tab.allVersions")}],wa=p=>{F(null),p==="all"?Rt():rr(Number(p.slice(1)))},ka=(0,i.jsx)(b.Button,{size:"sm",variant:"primary",className:"art-ask",icon:(0,i.jsx)(b.IconSparkleRegular,{size:14}),disabled:ne||k||ee,onClick:()=>void Pt(Re),children:e("agent.ask")});return(0,i.jsxs)("section",{className:"art-root","data-dsh-artifact-studio":"","data-artifact-id":d,"aria-busy":ne,ref:Qe,children:[(0,i.jsxs)("header",{className:"art-header art-editor-header",children:[(0,i.jsxs)("div",{className:"art-heading",children:[!o||a===void 0?null:(0,i.jsx)(qe,{label:e("action.back"),icon:(0,i.jsx)(b.IconChevronLeftOutlineRegular,{size:16}),onClick:()=>ke(a)}),(0,i.jsxs)("div",{className:"art-identity",children:[(0,i.jsx)("h1",{className:"art-title",title:u.manifest.title,children:u.manifest.title}),(0,i.jsxs)("div",{className:"art-meta",children:[(0,i.jsxs)("span",{className:"art-meta-text",children:[ba,t.scope==="workspace"?" \xB7 "+e("scope.workspace"):null]}),(0,i.jsx)("span",{className:"art-meta-dot","aria-hidden":"true",children:"\xB7"}),(0,i.jsx)(b.Menu,{open:j==="version",onClose:()=>F(null),items:xa,onSelect:wa,portal:!0,autoFocus:!0,anchor:(0,i.jsxs)("button",{type:"button",className:"art-version-button","aria-label":e("tab.versionPicker"),"aria-haspopup":"menu","aria-expanded":j==="version",onClick:()=>void ua(),children:[e("gallery.version",{version:fa}),(0,i.jsx)(b.IconChevronDownOutlineRegular,{size:12})]})}),(0,i.jsx)("span",{className:"art-meta-dot","aria-hidden":"true",children:"\xB7"}),(0,i.jsx)("span",{className:"art-save-status","data-tone":ga,"aria-live":"polite",children:ma})]})]})]}),(0,i.jsxs)("div",{className:"art-actions art-editor-actions",children:[Te!=="page"?null:(0,i.jsx)(b.SegmentedControl,{id:"art-mode-"+d,className:"art-segment",label:e("tab.mode"),value:E,options:[{value:"preview",label:e("tab.preview")},{value:"source",label:e("tab.source")}],onChange:p=>{I(p),le(null)}}),h===null||Ve?null:(0,i.jsx)(qe,{label:e("tab.save"),icon:(0,i.jsx)(b.IconSaveOutlineRegular,{size:16}),disabled:k,onClick:()=>void l.save()}),(0,i.jsx)(qe,{buttonRef:Jt,label:e("tab.history"),icon:(0,i.jsx)(b.IconClockOutlineRegular,{size:16}),pressed:M,onClick:()=>{M?tr():Rt()}}),$?null:(0,i.jsx)(b.Menu,{open:j==="export",onClose:()=>F(null),items:or,onSelect:ir,align:"end",portal:!0,autoFocus:!0,anchor:(0,i.jsx)(b.Button,{size:"sm",icon:(0,i.jsx)(b.IconDownloadOutlineRegular,{size:14}),"aria-label":e("tab.export"),"aria-haspopup":"menu","aria-expanded":j==="export",disabled:ne||ee,onClick:()=>F(j==="export"?null:"export"),children:e("tab.export")})}),ka,(0,i.jsx)(b.Menu,{open:j==="more",onClose:()=>F(null),items:ha,onSelect:va,align:"end",portal:!0,autoFocus:!0,anchor:(0,i.jsx)(b.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.more"),"aria-haspopup":"menu","aria-expanded":j==="more",onClick:()=>F(j==="more"?null:"more"),children:(0,i.jsx)(b.IconEllipsisOutlineRegular,{size:14})})})]})]}),Tt?(0,i.jsxs)("form",{className:"art-inline-form",onSubmit:p=>{p.preventDefault(),da()},children:[(0,i.jsx)("input",{"aria-label":e("tab.rename"),value:Be,maxLength:120,autoFocus:!0,onChange:p=>Yt(p.target.value),onKeyDown:p=>{p.key==="Escape"&&we(!1)}}),(0,i.jsx)(b.Button,{type:"submit",size:"sm",variant:"primary",disabled:w||k,children:e("tab.save")}),(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:()=>we(!1),children:e("create.cancel")})]}):null,Qt===null?null:(0,i.jsxs)("div",{className:"art-bar",role:"status",children:[(0,i.jsx)("span",{children:e("tab.agentUpdate",{version:Qt})}),(0,i.jsxs)("span",{className:"art-bar-actions",children:[(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:()=>{He(null),Rt()},children:e("tab.viewHistory")}),(0,i.jsx)(b.Button,{size:"sm",onClick:()=>He(null),children:e("tab.dismiss")})]})]}),k?(0,i.jsxs)("div",{className:"art-bar","data-tone":"warn",role:"alert",children:[(0,i.jsxs)("span",{className:"art-bar-text",children:[(0,i.jsx)("strong",{children:e("tab.conflictTitle")}),(0,i.jsx)("span",{children:e("tab.conflictHint")})]}),(0,i.jsxs)("span",{className:"art-bar-actions",children:[(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:()=>void Et(h??"","action.copied"),children:e("tab.copyDraft")}),(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:()=>ke(Je),children:e("tab.discardReload")})]})]}):null,!k&&S!==void 0?(0,i.jsxs)("div",{className:"art-bar","data-tone":"error",role:"alert",children:[(0,i.jsx)("span",{children:e(X(S))}),(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:()=>void l.save(),children:e("action.retry")})]}):null,g===null?null:(0,i.jsxs)("div",{className:"art-bar",role:"status",children:[(0,i.jsx)("span",{children:e("tab.viewingOld",{version:g.version,current:u.version})}),(0,i.jsxs)("span",{className:"art-bar-actions",children:[(0,i.jsx)(b.Button,{size:"sm",variant:"outline",onClick:()=>{++ce.current,x(!1),L(null),le(null)},children:e("tab.backToCurrent")}),(0,i.jsx)(b.Button,{size:"sm",variant:"outline",disabled:ne,onClick:()=>void pa(),children:e("tab.restoreThis")})]})]}),(0,i.jsxs)("div",{className:"art-body",children:[(0,i.jsxs)("div",{className:"art-stage",role:Te==="page"?"tabpanel":void 0,id:Te==="page"?"art-mode-"+d+"-"+E+"-panel":void 0,"aria-labelledby":Te==="page"?"art-mode-"+d+"-"+E:void 0,children:[Te!=="page"||Re===null||M?null:(0,i.jsx)(Ja,{quote:Re.text,askLabel:e("agent.ask"),dismissLabel:e("tab.dismiss"),onAsk:()=>void Pt(Re),onDismiss:()=>le(null)}),Te==="doc"?(0,i.jsx)(pt,{markdown:et,revision:(g?.version??0)+":"+f.revision,editable:!Ve&&!k,label:u.manifest.title,loadingLabel:e("empty.loading"),failedLabel:e("error.generic"),design:u.design,dark:y,t:e,onChange:p=>l.edit(p),onSave:()=>void l.save(),onSelectionText:It,selectionAction:Re===null?null:(0,i.jsx)(b.Button,{size:"sm",variant:"primary",icon:(0,i.jsx)(b.IconSparkleRegular,{size:14}),onMouseDown:p=>p.preventDefault(),onClick:()=>void Pt(Re),children:e("agent.ask")})}):E==="preview"?(0,i.jsx)(mt,{content:et,designCss:u.designCss,title:u.manifest.title,frameTitle:e("tab.frameTitle",{title:u.manifest.title}),dark:y,onSelectionText:It}):ya?(0,i.jsx)(Lr,{value:et,readOnly:!1,label:e("tab.source"),hint:e("tab.manualSave"),onChange:p=>l.edit(p),onSave:()=>void l.save(),onSelectionText:It}):(0,i.jsxs)("div",{className:"art-code",ref:Zt,children:[(0,i.jsxs)("div",{className:"art-code-bar",children:[(0,i.jsx)("span",{children:e(Ve?"tab.readOnly":"tab.codeHint")}),Ve?null:(0,i.jsx)(b.Button,{size:"sm",variant:"outline",icon:(0,i.jsx)(b.IconEditOutlineRegular,{size:14}),onClick:()=>Z(!0),children:e("tab.editSource")})]}),(0,i.jsx)(b.CodeBlock,{code:et,lang:"html",lineNumbers:!0,showHeader:!1,wrap:!0,className:"art-code-block",copyLabel:e("code.copy"),copiedLabel:e("action.copied")})]})]}),M?(0,i.jsx)(en,{label:e("history.title"),closeLabel:e("history.close"),overlay:$,onClose:tr,children:(0,i.jsx)(Ir,{t:e,versions:A,failed:V,current:u.version,selected:g?.version??u.version,onSelect:p=>void rr(p)})}):null]}),(0,i.jsx)(b.Modal,{open:St!==null,onClose:()=>Fe(null),title:e("tab.leaveTitle"),closeLabel:e("dialog.close"),description:e(k?"tab.conflictHint":"tab.leaveHint"),footer:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b.Button,{variant:"outline",disabled:ne,onClick:()=>Fe(null),children:e("create.cancel")}),(0,i.jsx)(b.Button,{variant:"outline",disabled:w||ne,onClick:()=>{let p=St?.run;Fe(null),p!==void 0&&l.discardAndReload().then(p)},children:e("tab.discardContinue")}),(0,i.jsx)(b.Button,{variant:"primary",disabled:k||ne,onClick:async()=>{ye(!0);let p=await l.save();ye(!1);let C=St?.run;p&&C!==void 0&&(Fe(null),await C())},children:e("tab.saveContinue")})]}),children:S===void 0?null:(0,i.jsx)("p",{className:"art-modal-error",role:"alert",children:e(X(S))})}),(0,i.jsx)(b.Modal,{open:la,onClose:()=>Xe(!1),title:e("tab.deleteTitle"),closeLabel:e("dialog.close"),description:e("tab.deleteConfirm",{title:u.manifest.title}),footer:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b.Button,{variant:"outline",onClick:()=>Xe(!1),children:e("create.cancel")}),(0,i.jsx)(b.Button,{variant:"primary",onClick:()=>{Xe(!1),ke(async()=>{try{await z.remove(m,d),pe(),a?.()}catch(p){W(e(X(Y(p))))}})},children:e("tab.delete")})]})}),(0,i.jsx)(b.Modal,{open:Xt!==null,onClose:()=>Ct(null),title:e("agent.copyTitle"),closeLabel:e("dialog.close"),description:e("action.copyFailed"),footer:(0,i.jsx)(b.Button,{variant:"primary",onClick:()=>Ct(null),children:e("dialog.done")}),children:(0,i.jsx)("textarea",{className:"art-fallback",readOnly:!0,value:Xt??"","aria-label":e("agent.copyTitle"),onFocus:p=>p.currentTarget.select()})})]})}var Br=Ea(require("react"),1),Fr=require("@deepseek-ai/dsh-client-ui-primitives"),Ce=require("react/jsx-runtime"),gt=class extends Br.default.Component{constructor(t){super(t),this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,Ce.jsx)("section",{className:"art-root","data-dsh-artifact-studio":"",children:(0,Ce.jsxs)("div",{className:"art-center",role:"alert",children:[(0,Ce.jsx)("p",{className:"art-center-title",children:this.props.title}),(0,Ce.jsx)("p",{className:"art-center-hint",children:this.props.hint}),(0,Ce.jsx)(Fr.Button,{size:"sm",variant:"outline",onClick:()=>window.location.reload(),children:this.props.reloadLabel})]})}):this.props.children}};var ht=require("react"),Oe=require("@deepseek-ai/dsh-client-ui-primitives");var yo=require("react"),B=require("react/jsx-runtime");function bt({children:e,size:t=16}){return(0,B.jsx)("svg",{viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}var yt=({size:e})=>(0,B.jsxs)(bt,{size:e,children:[(0,B.jsx)("rect",{x:"3.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),(0,B.jsx)("rect",{x:"13.5",y:"3.5",width:"7",height:"7",rx:"1.5"}),(0,B.jsx)("rect",{x:"3.5",y:"13.5",width:"7",height:"7",rx:"1.5"}),(0,B.jsx)("path",{d:"M17 13.5v7M13.5 17h7"})]}),se=({size:e})=>(0,B.jsxs)(bt,{size:e,children:[(0,B.jsx)("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2"}),(0,B.jsx)("path",{d:"M3.5 8.5h17M9 13l-2 1.8L9 16.5M15 13l2 1.8-2 1.7"})]}),fe=({size:e})=>(0,B.jsxs)(bt,{size:e,children:[(0,B.jsx)("path",{d:"M6.5 3.5h7l4 4v13h-11z"}),(0,B.jsx)("path",{d:"M13.5 3.5v4h4M9 12h6M9 15.5h6"})]}),Hr=({size:e})=>(0,B.jsxs)(bt,{size:e,children:[(0,B.jsx)("path",{d:"M20.5 12a8.5 8.5 0 1 1-8.5-8.5c4.7 0 8.5 3.4 8.5 7.6 0 2.1-1.7 3.8-3.8 3.8h-1.4c-1 0-1.9.8-1.9 1.8 0 .8.5 1.3.5 2.1 0 1-.7 1.7-1.9 1.7Z"}),(0,B.jsx)("circle",{cx:"7.6",cy:"10",r:"1.1",fill:"currentColor",stroke:"none"}),(0,B.jsx)("circle",{cx:"10",cy:"6.8",r:"1.1",fill:"currentColor",stroke:"none"}),(0,B.jsx)("circle",{cx:"14",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),(0,B.jsx)("circle",{cx:"17",cy:"10.2",r:"1.1",fill:"currentColor",stroke:"none"})]});var me={sidebarRight:null,layout:null};var R=require("react/jsx-runtime");function rn(e){if(e===null||typeof e!="object")return null;let t={...e},{id:r,type:a,title:n,version:o,workspaceId:s}=t;if(t.kind!=="artifact"||typeof r!="string"||typeof n!="string"||typeof o!="number"||a!=="page"&&a!=="doc")return null;let l=cr(r);return l===void 0?null:l==="workspace"?typeof s!="string"||s===""?null:{id:r,type:a,title:n,version:o,address:{scope:l,workspaceId:s,id:r}}:{id:r,type:a,title:n,version:o,address:{scope:l,id:r}}}function an(e){return Array.isArray(e)?e.map(t=>{if(t===null||typeof t!="object")return"";let r={...t};return r.type==="text"&&typeof r.text=="string"?r.text:""}).filter(t=>t!=="").join(`
31
+ `).trim():""}function nn(e){if(e===null||typeof e!="object")return;let t={...e};return typeof t.title=="string"&&t.title.trim()!==""?t.title.trim():void 0}var Vr=new Set;function $t({t:e,phase:t,toolName:r,block:a}){let n=t==="result"&&a?.isError!==!0?rn(a?.meta):null,o=(0,ht.useRef)(t!=="result");t!=="result"&&(o.current=!0);let s=r==="artifact_update";if((0,ht.useEffect)(()=>{if(n===null)return;de(n.id,n.title),Se(n.id,n.version),pe();let f=n.id+":"+n.version;!o.current||Vr.has(f)||(Vr.add(f),me.sidebarRight?.openResource(H(n.address)))},[n?.id,n?.version,n?.title]),t!=="result"){let f=nn(a?.args),u=f===void 0?e(s?"card.updatingUntitled":"card.working"):e(s?"card.updating":"card.creating",{title:f});return(0,R.jsxs)("div",{className:"art-card","data-artifact-card":"working",children:[(0,R.jsx)("span",{className:"art-card-icon",children:(0,R.jsx)(se,{})}),(0,R.jsx)("span",{className:"art-card-text",children:(0,R.jsx)(Oe.TextShimmer,{active:!0,className:"art-card-title",children:(0,R.jsx)("span",{role:"status",children:u})})}),(0,R.jsx)(Oe.StateDot,{state:"ongoing"})]})}if(a?.isError===!0)return(0,R.jsxs)("div",{className:"art-card","data-artifact-card":"error",children:[(0,R.jsx)("span",{className:"art-card-icon","data-tone":"error",children:(0,R.jsx)(se,{})}),(0,R.jsxs)("span",{className:"art-card-text",children:[(0,R.jsx)("span",{className:"art-card-title",children:e("card.failed")}),(0,R.jsx)("span",{className:"art-card-sub","data-tone":"error",children:an(a.content)})]})]});if(n===null)return(0,R.jsxs)("div",{className:"art-card","data-artifact-card":"missing",children:[(0,R.jsx)("span",{className:"art-card-icon",children:(0,R.jsx)(se,{})}),(0,R.jsx)("span",{className:"art-card-sub",children:e("card.missing")})]});let l=H(n.address);return(0,R.jsxs)("button",{type:"button",className:"art-card art-card-open","data-artifact-card":"ready","data-artifact-id":n.id,"aria-label":e("card.openNamed",{title:n.title}),onClick:()=>me.sidebarRight?.openResource(l),children:[(0,R.jsx)("span",{className:"art-card-icon",children:n.type==="page"?(0,R.jsx)(se,{}):(0,R.jsx)(fe,{})}),(0,R.jsxs)("span",{className:"art-card-text",children:[(0,R.jsx)("span",{className:"art-card-title",title:n.title,children:n.title}),(0,R.jsxs)("span",{className:"art-card-sub",children:[e(s?"card.updated":"card.created")," \xB7 ",e(`type.${n.type}`)," \xB7 ",e("gallery.version",{version:n.version}),n.address.scope==="library"?" \xB7 "+e("scope.library"):""]})]}),(0,R.jsx)("span",{className:"art-card-go","aria-hidden":"true",children:(0,R.jsx)(Oe.IconChevronRightOutlineRegular,{size:14})})]})}var Ke=require("react"),vt=require("@deepseek-ai/dsh-client-ui-primitives");var $r=require("react");function _r({sessionId:e,useSessions:t,useWorkspaces:r}){let a=r(o=>o.items),n=t(o=>o.byId[e]);return(0,$r.useMemo)(()=>{let o=typeof n?.cwd=="string"?n.cwd:null,s=a.find(l=>l.sessionIds?.includes(e))??a.find(l=>o!==null&&(o===l.path||o.startsWith(`${l.path}/`)))??null;return{root:o??s?.path??null,workspaceId:s?.workspaceId??null}},[a,n,e])}var Ge="dsh-artifact-studio/artifact",_t="artifact",je="dsh-artifact-studio-panel";var Ne=require("react/jsx-runtime"),on=6,Wt=["dashboard","explainer","report","brief"];function sn(e,t){let r=e.filter(n=>n.source.sessionId===t),a=e.filter(n=>n.source.sessionId!==t);return[...r,...a].slice(0,on)}function Wr(e){let{t,sessionId:r,inputActions:a}=e,o=_r(e).workspaceId,s=dt(),[l,f]=(0,Ke.useState)(!1),[u,h]=(0,Ke.useState)(null);(0,Ke.useEffect)(()=>{if(!l||o===null)return;let m=new AbortController;return z.list({scope:"workspace",workspaceId:o},{},m.signal).then(d=>{m.signal.aborted||h(sn(d.items,r))}).catch(()=>{m.signal.aborted||h([])}),()=>m.abort()},[l,o,r,s]);let w=o===null?[{type:"label",id:"no-workspace",text:t("empty.noWorkspace")}]:u===null?[{type:"label",id:"loading",text:t("empty.loading")}]:u.length===0?[{type:"label",id:"empty",text:t("composer.empty")}]:u.map(m=>({id:"open:"+m.id,label:m.title,icon:m.type==="page"?(0,Ne.jsx)(se,{size:14}):(0,Ne.jsx)(fe,{size:14})})),k=[{type:"label",id:"recent",text:t("composer.recent")},...w,...a===void 0?[]:[{type:"separator",id:"start-gap"},{type:"label",id:"start",text:t("composer.start")},...Wt.map(m=>({id:"prompt:"+m,label:t(`prompt.${m}`)}))],{type:"separator",id:"all-gap"},{id:"all",label:t("composer.all")}];return(0,Ne.jsx)(vt.Menu,{open:l,onClose:()=>f(!1),items:k,onSelect:m=>{if(f(!1),m==="all"){me.layout?.selectPanel(je);return}if(m.startsWith("prompt:")&&a!==void 0){a.insertText(t(`prompt.${m.slice(7)}Text`),a.captureInsertion());return}let d=u?.find(y=>"open:"+y.id===m);d===void 0||o===null||(de(d.id,d.title),me.sidebarRight?.openResource(H({scope:"workspace",workspaceId:o,id:d.id})))},side:"top",portal:!0,autoFocus:!0,anchor:(0,Ne.jsx)(vt.Tooltip,{label:t("composer.label"),side:"top",portal:!0,children:(0,Ne.jsx)("button",{type:"button",className:"art-composer","aria-label":t("composer.label"),"aria-haspopup":"menu","aria-expanded":l,onClick:()=>f(m=>!m),children:(0,Ne.jsx)(yt,{})})})})}var U=require("react");var P=require("react"),N=require("@deepseek-ai/dsh-client-ui-primitives");var ge=require("react"),xt=require("@deepseek-ai/dsh-client-ui-primitives");var T=require("react/jsx-runtime"),ln=["sm","md","lg"],cn=e=>`<!doctype html><html><head><meta name="color-scheme" content="light dark"><style>
32
32
  body { margin: 0; padding: 20px; font-family: var(--artifact-font-family); background: var(--artifact-color-surface); color: var(--artifact-color-text); }
33
33
  h2 { margin: 0 0 6px; font-family: var(--artifact-font-display); font-size: var(--artifact-font-size-4); letter-spacing: -0.02em; }
34
34
  p { margin: 0 0 14px; color: var(--artifact-color-muted); }
@@ -37,7 +37,7 @@ button { padding: 8px 14px; border: 0; border-radius: var(--artifact-radius-md);
37
37
  .tag { padding: 3px 8px; border-radius: var(--artifact-radius-sm); background: color-mix(in srgb, var(--artifact-color-accent) 18%, transparent); color: var(--artifact-color-accent); font-size: 12px; }
38
38
  code { font-family: var(--artifact-font-mono); font-size: 12px; }
39
39
  </style></head><body><h2>${e("design.previewHeading")}</h2><p>${e("design.previewBody")}</p>
40
- <div class="row"><button>${e("design.previewButton")}</button><span class="tag">+12%</span><code>var(--artifact-color-primary)</code></div></body></html>`;function on(e){return/^#[0-9a-f]{6}$/i.test(e)}function _r({t:e,workspaceId:t}){let[r,n]=(0,he.useState)(null),[a,i]=(0,he.useState)(null),[s,d]=(0,he.useState)(!1),[u,f]=(0,he.useState)(!1),b=je();(0,he.useEffect)(()=>{let c=new AbortController;return L.designSystem(t,c.signal).then(g=>{n(g),i(g.tokens)}).catch(()=>{c.signal.aborted||d(!0)}),()=>c.abort()},[t]);let y=(0,he.useMemo)(()=>a===null?"":dr(a),[a]);if(s)return(0,w.jsx)("p",{className:"art-note",children:e("error.generic")});if(r===null||a===null)return(0,w.jsx)("p",{className:"art-note",children:e("empty.loading")});let h=async c=>{f(!0);try{let g=await L.saveDesignSystem({scope:c,workspaceId:t},a);n(g),i(g.tokens),$(e("design.saved"))}catch(g){$(e(V(U(g))))}finally{f(!1)}},k=async()=>{if(t!==null){f(!0);try{let c=await L.clearDesignSystem(t);n(c),i(c.tokens)}catch(c){$(e(V(U(c))))}finally{f(!1)}}};return(0,w.jsxs)("div",{className:"art-design",children:[(0,w.jsxs)("p",{className:"art-design-source",children:[e("design.hint")," ",e(`design.source.${r.source}`)]}),(0,w.jsxs)("div",{className:"art-design-group",children:[(0,w.jsx)("h3",{children:e("design.preview")}),(0,w.jsx)("div",{className:"art-design-preview",style:{height:150,display:"flex"},children:(0,w.jsx)(yt,{content:nn(e),designCss:y,title:a.name,frameTitle:e("design.preview"),dark:b})})]}),(0,w.jsxs)("label",{className:"art-field",children:[e("design.name"),(0,w.jsx)("input",{type:"text",value:a.name,maxLength:80,onChange:c=>i({...a,name:c.target.value})})]}),["colors","colorsDark"].map(c=>(0,w.jsxs)("div",{className:"art-design-group",children:[(0,w.jsx)("h3",{children:e(c==="colors"?"design.colors":"design.colorsDark")}),(0,w.jsx)("div",{className:"art-swatches",children:_e.map(g=>{let M=E=>{let P={...a[c],[g]:E};i({...a,[c]:P})};return(0,w.jsxs)("div",{className:"art-swatch",children:[(0,w.jsx)("input",{type:"color","aria-label":e(`design.color.${g}`)+" "+e(c==="colors"?"design.colors":"design.colorsDark"),value:on(a[c][g])?a[c][g]:"#000000",onChange:E=>M(E.target.value)}),(0,w.jsxs)("span",{className:"art-swatch-text",children:[e(`design.color.${g}`),(0,w.jsx)("input",{type:"text","aria-label":e(`design.color.${g}`)+" "+e(c==="colors"?"design.colors":"design.colorsDark")+" CSS",value:a[c][g],onChange:E=>M(E.target.value)})]})]},g)})})]},c)),(0,w.jsxs)("div",{className:"art-design-group",children:[(0,w.jsx)("h3",{children:e("design.type")}),(0,w.jsxs)("label",{className:"art-field",children:[e("design.font"),(0,w.jsx)("input",{type:"text",value:a.typography.fontFamily,onChange:c=>i({...a,typography:{...a.typography,fontFamily:c.target.value}})})]}),(0,w.jsxs)("label",{className:"art-field",children:[e("design.display"),(0,w.jsx)("input",{type:"text",value:a.typography.displayFamily,onChange:c=>i({...a,typography:{...a.typography,displayFamily:c.target.value}})})]}),(0,w.jsxs)("label",{className:"art-field",children:[e("design.mono"),(0,w.jsx)("input",{type:"text",value:a.typography.monoFamily,onChange:c=>i({...a,typography:{...a.typography,monoFamily:c.target.value}})})]})]}),(0,w.jsxs)("div",{className:"art-design-group",children:[(0,w.jsx)("h3",{children:e("design.radius")}),(0,w.jsx)("div",{className:"art-radius-row",children:an.map(c=>(0,w.jsxs)("label",{children:[e(`design.radius.${c}`),(0,w.jsx)("input",{type:"number",min:0,max:64,value:a.radius[c],onChange:g=>i({...a,radius:{...a.radius,[c]:Number(g.target.value)||0}})})]},c))})]}),(0,w.jsxs)("label",{className:"art-field",children:[e("design.notes"),(0,w.jsx)("textarea",{value:a.notes,maxLength:4e3,onChange:c=>i({...a,notes:c.target.value})}),(0,w.jsx)("span",{className:"art-field-hint",children:e("design.notesHint")})]}),(0,w.jsxs)("div",{className:"art-design-actions",children:[t===null?null:(0,w.jsx)(kt.Button,{size:"sm",variant:"primary",disabled:u,onClick:()=>void h("workspace"),children:e("design.saveWorkspace")}),(0,w.jsx)(kt.Button,{size:"sm",variant:t===null?"primary":"outline",disabled:u,onClick:()=>void h("library"),children:e("design.saveLibrary")}),r.source==="workspace"&&t!==null?(0,w.jsx)(kt.Button,{size:"sm",variant:"outline",disabled:u,onClick:()=>void k(),children:e("design.clear")}):null]})]})}var Ur=require("react"),qr="dsh-artifact-studio.pins";function sn(){if(typeof window>"u")return new Set;try{let e=window.localStorage.getItem(qr);if(e===null)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(r=>typeof r=="string")):new Set}catch{return new Set}}var Tt=sn(),qt=new Set;function ln(e){return qt.add(e),()=>qt.delete(e)}function Kr(){return(0,Ur.useSyncExternalStore)(ln,()=>Tt,()=>Tt)}function Gr(e){let t=new Set(Tt);t.has(e)?t.delete(e):t.add(e),Tt=t;try{window.localStorage.setItem(qr,JSON.stringify([...t]))}catch{}for(let r of qt)r()}var cn=`<!doctype html>
40
+ <div class="row"><button>${e("design.previewButton")}</button><span class="tag">+12%</span><code>var(--artifact-color-primary)</code></div></body></html>`;function dn(e){return/^#[0-9a-f]{6}$/i.test(e)}function Ur({t:e,workspaceId:t,workspaceTitle:r}){let[a,n]=(0,ge.useState)(null),[o,s]=(0,ge.useState)(null),[l,f]=(0,ge.useState)(!1),[u,h]=(0,ge.useState)(!1),w=ze();(0,ge.useEffect)(()=>{let d=new AbortController;return z.designSystem(t,d.signal).then(y=>{n(y),s(y.tokens)}).catch(()=>{d.signal.aborted||f(!0)}),()=>d.abort()},[t]);let k=(0,ge.useMemo)(()=>o===null?"":dr(o),[o]);if(l)return(0,T.jsx)("p",{className:"art-note",children:e("error.generic")});if(a===null||o===null)return(0,T.jsx)("p",{className:"art-note",children:e("empty.loading")});let S=async d=>{h(!0);try{let y=await z.saveDesignSystem({scope:d,workspaceId:t},o);n(y),s(y.tokens),W(e("design.saved"))}catch(y){W(e(X(Y(y))))}finally{h(!1)}},m=async()=>{if(t!==null){h(!0);try{let d=await z.clearDesignSystem(t);n(d),s(d.tokens)}catch(d){W(e(X(Y(d))))}finally{h(!1)}}};return(0,T.jsxs)("div",{className:"art-design",children:[(0,T.jsxs)("p",{className:"art-design-source",children:[e("design.hint")," ",e(`design.source.${a.source}`)]}),(0,T.jsxs)("div",{className:"art-design-group",children:[(0,T.jsx)("h3",{children:e("design.preview")}),(0,T.jsx)("div",{className:"art-design-preview",style:{height:150,display:"flex"},children:(0,T.jsx)(mt,{content:cn(e),designCss:k,title:o.name,frameTitle:e("design.preview"),dark:w})})]}),(0,T.jsxs)("label",{className:"art-field",children:[e("design.name"),(0,T.jsx)("input",{type:"text",value:o.name,maxLength:80,onChange:d=>s({...o,name:d.target.value})})]}),["colors","colorsDark"].map(d=>(0,T.jsxs)("div",{className:"art-design-group",children:[(0,T.jsx)("h3",{children:e(d==="colors"?"design.colors":"design.colorsDark")}),(0,T.jsx)("div",{className:"art-swatches",children:$e.map(y=>{let E=I=>{let O={...o[d],[y]:I};s({...o,[d]:O})};return(0,T.jsxs)("div",{className:"art-swatch",children:[(0,T.jsx)("input",{type:"color","aria-label":e(`design.color.${y}`)+" "+e(d==="colors"?"design.colors":"design.colorsDark"),value:dn(o[d][y])?o[d][y]:"#000000",onChange:I=>E(I.target.value)}),(0,T.jsxs)("span",{className:"art-swatch-text",children:[e(`design.color.${y}`),(0,T.jsx)("input",{type:"text","aria-label":e(`design.color.${y}`)+" "+e(d==="colors"?"design.colors":"design.colorsDark")+" CSS",value:o[d][y],onChange:I=>E(I.target.value)})]})]},y)})})]},d)),(0,T.jsxs)("div",{className:"art-design-group",children:[(0,T.jsx)("h3",{children:e("design.type")}),(0,T.jsxs)("label",{className:"art-field",children:[e("design.font"),(0,T.jsx)("input",{type:"text",value:o.typography.fontFamily,onChange:d=>s({...o,typography:{...o.typography,fontFamily:d.target.value}})})]}),(0,T.jsxs)("label",{className:"art-field",children:[e("design.display"),(0,T.jsx)("input",{type:"text",value:o.typography.displayFamily,onChange:d=>s({...o,typography:{...o.typography,displayFamily:d.target.value}})})]}),(0,T.jsxs)("label",{className:"art-field",children:[e("design.mono"),(0,T.jsx)("input",{type:"text",value:o.typography.monoFamily,onChange:d=>s({...o,typography:{...o.typography,monoFamily:d.target.value}})})]})]}),(0,T.jsxs)("div",{className:"art-design-group",children:[(0,T.jsx)("h3",{children:e("design.radius")}),(0,T.jsx)("div",{className:"art-radius-row",children:ln.map(d=>(0,T.jsxs)("label",{children:[e(`design.radius.${d}`),(0,T.jsx)("input",{type:"number",min:0,max:64,value:o.radius[d],onChange:y=>s({...o,radius:{...o.radius,[d]:Number(y.target.value)||0}})})]},d))})]}),(0,T.jsxs)("label",{className:"art-field",children:[e("design.notes"),(0,T.jsx)("textarea",{value:o.notes,maxLength:4e3,onChange:d=>s({...o,notes:d.target.value})}),(0,T.jsx)("span",{className:"art-field-hint",children:e("design.notesHint")})]}),(0,T.jsxs)("div",{className:"art-design-actions",children:[t===null?null:(0,T.jsx)(xt.Button,{size:"sm",variant:"primary",disabled:u,onClick:()=>void S("workspace"),children:r===void 0?e("design.saveWorkspace"):e("design.saveWorkspaceNamed",{name:r})}),(0,T.jsx)(xt.Button,{size:"sm",variant:t===null?"primary":"outline",disabled:u,onClick:()=>void S("library"),children:e("design.saveLibrary")}),a.source==="workspace"&&t!==null?(0,T.jsx)(xt.Button,{size:"sm",variant:"outline",disabled:u,onClick:()=>void m(),children:e("design.clear")}):null]})]})}var qr=require("react"),Gr="dsh-artifact-studio.pins";function pn(){if(typeof window>"u")return new Set;try{let e=window.localStorage.getItem(Gr);if(e===null)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(r=>typeof r=="string")):new Set}catch{return new Set}}var wt=pn(),Ut=new Set;function un(e){return Ut.add(e),()=>Ut.delete(e)}function Kr(){return(0,qr.useSyncExternalStore)(un,()=>wt,()=>wt)}function Yr(e){let t=new Set(wt);t.has(e)?t.delete(e):t.add(e),wt=t;try{window.localStorage.setItem(Gr,JSON.stringify([...t]))}catch{}for(let r of Ut)r()}var fn=`<!doctype html>
41
41
  <html lang="en">
42
42
  <head>
43
43
  <meta charset="utf-8">
@@ -63,12 +63,12 @@ code { font-family: var(--artifact-font-mono); font-size: 12px; }
63
63
  </main>
64
64
  </body>
65
65
  </html>
66
- `,dn=`# {{title}}
66
+ `,mn=`# {{title}}
67
67
 
68
68
  Start writing, or select text and choose Edit with agent.
69
- `;function pn(e){return e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`)}function un(e){return e.replace(/[\\`*_\[\]#]/g,t=>`\\${t}`)}function Yr(e,t){return e==="doc"?dn.replace("{{title}}",un(t)):cn.replace("{{title}}",pn(t))}var l=require("react/jsx-runtime"),fn={items:[],total:0,hasMore:!1,truncated:!1};function Kt(e,t){return e.scope==="library"?{manifest:e,address:{scope:"library",id:e.id},where:{scope:"library",workspaceId:t}}:t===null?null:{manifest:e,address:{scope:"workspace",workspaceId:t,id:e.id},where:{scope:"workspace",workspaceId:t}}}function mn(e,t){e!==void 0&&(fe(t.manifest.id,t.manifest.title),e(z(t.address)))}var Qe=new Map,Gt=new Map;function gn(e){let t=z(e.address),r=Qe.get(t);if(r!==void 0&&r.version>=e.manifest.version)return Promise.resolve(r);let n=`${t}:${e.manifest.version}`,a=Gt.get(n);if(a!==void 0)return a;let i=L.get(e.where,e.manifest.id).then(s=>{let d={version:s.version,content:s.content,designCss:s.designCss},u=Qe.get(t);return(u===void 0||u.version<=d.version)&&(Qe.size>=60&&Qe.clear(),Qe.set(t,d)),d}).finally(()=>{Gt.delete(n)});return Gt.set(n,i),i}function bn(e){if(typeof DOMParser>"u")return e.replace(/<script\b[^>]*>[\s\S]*?<\/script\s*>/gi,"").replace(/<script\b[^>]*\/?>/gi,"").replace(/\son[a-z]+\s*=\s*"[^"]*"/gi,"");let t=new DOMParser().parseFromString(e,"text/html");for(let r of t.querySelectorAll("script, iframe, object, embed, base"))r.remove();for(let r of t.querySelectorAll("*"))for(let n of[...r.attributes]){let a=n.name.toLowerCase();(a.startsWith("on")||a==="srcdoc")&&r.removeAttribute(n.name)}return t.documentElement.outerHTML}function yn(e){let t=e.replace(/```[\s\S]*?```/g," ").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/<[^>]+>/g," ").replace(/[#>*_`~]/g," ").replace(/\s+/g," ").trim();return t.length>220?`${t.slice(0,220).trimEnd()}...`:t}function hn({t:e,view:t}){let[r,n]=(0,R.useState)(null),[a,i]=(0,R.useState)(!1),[s,d]=(0,R.useState)(typeof IntersectionObserver>"u"),[u,f]=(0,R.useState)(null),b=(0,R.useRef)(null),y=je(),h=z(t.address),k=t.manifest.title,c=t.manifest.type,g=t.manifest.version;(0,R.useEffect)(()=>{if(s)return;let P=b.current;if(P===null)return;let F=new IntersectionObserver(se=>{se.some(B=>B.isIntersecting)&&(d(!0),F.disconnect())},{rootMargin:"140px"});return F.observe(P),()=>F.disconnect()},[s]),(0,R.useEffect)(()=>{if(!s)return;let P=!1;return gn(t).then(F=>{!P&&F.version===g&&(n(F),i(!1))}).catch(()=>{P||i(!0)}),()=>{P=!0}},[s,h,g]),(0,R.useEffect)(()=>{if(c!=="page"||r===null){f(null);return}let P=URL.createObjectURL(new Blob([gt(bn(r.content),r.designCss,k,y?"dark":"light")],{type:"text/html"}));return f(P),()=>URL.revokeObjectURL(P)},[r,c,k,y]);let M=c==="page"?(0,l.jsx)(ie,{}):(0,l.jsx)(be,{});if(a)return(0,l.jsx)("span",{className:"art-cover",ref:b,"aria-hidden":"true",children:(0,l.jsx)("span",{className:"art-cover-fallback",children:M})});if(c==="page")return(0,l.jsx)("span",{className:"art-cover",ref:b,"aria-hidden":"true",children:u===null?(0,l.jsx)("span",{className:"art-cover-fallback",children:M}):(0,l.jsx)("span",{className:"art-cover-frame-wrap",children:(0,l.jsx)("iframe",{className:"art-cover-frame",src:u,sandbox:"",title:e("gallery.coverTitle",{title:k}),tabIndex:-1,loading:"lazy",referrerPolicy:"no-referrer"})})});let E=r===null?"":yn(r.content);return(0,l.jsx)("span",{className:"art-cover",ref:b,"aria-hidden":"true",children:E===""?(0,l.jsx)("span",{className:"art-cover-fallback",children:M}):(0,l.jsxs)("span",{className:"art-cover-doc",children:[(0,l.jsx)("span",{className:"art-cover-doc-title",children:k}),(0,l.jsx)("span",{className:"art-cover-doc-text",children:E})]})})}function vn({t:e,view:t,pinned:r,onOpen:n}){let a=z(t.address),i=e(r?"gallery.unpin":"gallery.pin",{title:t.manifest.title});return(0,l.jsxs)("li",{className:"art-tile",children:[(0,l.jsxs)("button",{type:"button",className:"art-tile-open",onClick:()=>n(t),children:[(0,l.jsx)(hn,{t:e,view:t}),(0,l.jsxs)("span",{className:"art-tile-body",children:[(0,l.jsx)("span",{className:"art-tile-title",title:t.manifest.title,children:t.manifest.title}),(0,l.jsxs)("span",{className:"art-tile-sub",children:[e(`type.${t.manifest.type}`)," \xB7 ",e("gallery.updated",{time:bt(e,t.manifest.updatedAt)})," \xB7 ",e("gallery.version",{version:t.manifest.version}),t.manifest.scope==="library"?" \xB7 "+e("scope.library"):""]})]})]}),(0,l.jsx)(N.Tooltip,{label:i,side:"left",portal:!0,children:(0,l.jsx)("button",{type:"button",className:"art-tile-pin","aria-label":i,"aria-pressed":r,onClick:()=>Gr(a),children:r?(0,l.jsx)(N.IconPinFillRegular,{size:14}):(0,l.jsx)(N.IconPinOutlineRegular,{size:14})})})]})}function Xr({t:e,heading:t,views:r,pinned:n,onOpen:a}){let i=(0,R.useId)();return r.length===0?null:(0,l.jsxs)("section",{className:"art-section","aria-labelledby":i,children:[(0,l.jsxs)("div",{className:"art-section-head",children:[(0,l.jsx)("h2",{className:"art-section-title",id:i,children:t}),(0,l.jsx)("span",{className:"art-section-hint",children:e("gallery.count",{count:r.length})})]}),(0,l.jsx)("ul",{className:"art-grid",children:r.map(s=>(0,l.jsx)(vn,{t:e,view:s,pinned:n.has(z(s.address)),onOpen:a},z(s.address)))})]})}function Qr(e,t,r,n){let[a,i]=(0,R.useState)({key:"",state:{status:"loading"}}),[s,d]=(0,R.useState)(1),u=(e===null?"none":e.scope+":"+(e.workspaceId??""))+":"+t+":"+(r??""),f=e===null?{status:"ready",page:fn}:a.key===u?a.state:{status:"loading"};return(0,R.useEffect)(()=>d(1),[u,t]),(0,R.useEffect)(()=>{if(e===null)return;let b=new AbortController,y=setTimeout(async()=>{try{let h=[];for(let c=0;c<s&&(h.push(await L.list(e,{query:t,type:r,offset:c*50},b.signal)),!!h[h.length-1]?.hasMore);c+=1);let k=h[h.length-1];if(k===void 0||b.signal.aborted)return;i({key:u,state:{status:"ready",page:{...k,items:h.flatMap(c=>c.items)}}})}catch(h){b.signal.aborted||i({key:u,state:{status:"failed",code:U(h)}})}},t===""?0:180);return()=>{b.abort(),clearTimeout(y)}},[u,t,n,s]),{state:f,more:()=>d(b=>b+1)}}function xn({t:e,scope:t}){let r=async n=>{try{await navigator.clipboard.writeText(n),$(e("gallery.promptCopied"))}catch{$(e("action.copyFailed"))}};return(0,l.jsxs)("div",{className:"art-empty",children:[(0,l.jsx)("p",{className:"art-empty-title",children:e(t==="library"?"empty.libraryTitle":"empty.workspaceTitle")}),(0,l.jsx)("p",{className:"art-empty-hint",children:e(t==="library"?"empty.libraryHint":"empty.workspaceHint")}),(0,l.jsx)("ul",{className:"art-starters",children:Ut.map(n=>(0,l.jsxs)("li",{className:"art-starter",children:[(0,l.jsxs)("span",{className:"art-starter-text",children:[(0,l.jsx)("span",{className:"art-starter-name",children:e(`prompt.${n}`)}),(0,l.jsx)("span",{className:"art-starter-hint",children:e(`prompt.${n}Text`)})]}),(0,l.jsx)(N.Tooltip,{label:e("gallery.copyPrompt"),side:"left",portal:!0,children:(0,l.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.copyPromptNamed",{name:e(`prompt.${n}`)}),onClick:()=>void r(e(`prompt.${n}Text`)),children:(0,l.jsx)(N.IconCopyOutlineRegular,{size:14})})})]},n))})]})}function Jr({t:e,workspaceId:t,open:r,toolbar:n}){let[a,i]=(0,R.useState)(""),[s,d]=(0,R.useState)("all"),[u,f]=(0,R.useState)(void 0),[b,y]=(0,R.useState)("list"),[h,k]=(0,R.useState)(!1),[c,g]=(0,R.useState)(0),M=ft()+c,E=Kr(),P=Qr(t===null?null:{scope:"workspace",workspaceId:t},a,u,M),F=Qr({scope:"library",workspaceId:t},a,u,M),se=(0,R.useId)(),B=(0,R.useId)(),te=(0,R.useCallback)(S=>mn(r,S),[r]),X=(0,R.useCallback)(async(S,K)=>{if(K==="workspace"&&t===null)return;let De=e(S==="page"?"create.untitledPage":"create.untitledDoc");try{let{manifest:de}=await L.create({scope:K,workspaceId:t},S,De,Yr(S,De));me();let Je=Kt(de,t);Je!==null&&te(Je)}catch(de){$(e(V(U(de))))}},[t,e,te]),xe=s==="library"||t===null?"library":"workspace",le=s!=="library"&&P.state.status==="ready"?P.state.page:null,ce=s!=="workspace"&&F.state.status==="ready"?F.state.page:null,re=s!=="library"&&t!==null&&P.state.status==="loading"||s!=="workspace"&&F.state.status==="loading",Q=s!=="library"&&t!==null&&P.state.status==="failed"?P.state.code:s!=="workspace"&&F.state.status==="failed"?F.state.code:void 0,j=[];for(let S of le?.items??[]){let K=Kt(S,t);K!==null&&j.push(K)}for(let S of ce?.items??[]){let K=Kt(S,t);K!==null&&j.push(K)}j.sort((S,K)=>Date.parse(K.manifest.updatedAt)-Date.parse(S.manifest.updatedAt));let x=j.filter(S=>E.has(z(S.address))),C=j.filter(S=>!E.has(z(S.address))),I=le?.hasMore===!0||ce?.hasMore===!0,O=le?.truncated===!0||ce?.truncated===!0,H=t===null&&s==="workspace",St=s==="library"||t===null?"library":"workspace",Pe=()=>{s!=="library"&&P.more(),s!=="workspace"&&F.more()};return(0,l.jsxs)("section",{className:"art-root","data-dsh-artifact-studio":"",children:[(0,l.jsxs)("header",{className:"art-header",children:[(0,l.jsxs)("div",{className:"art-heading",children:[b==="design"?(0,l.jsx)(N.Tooltip,{label:e("panel"),side:"bottom",portal:!0,children:(0,l.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("panel"),onClick:()=>y("list"),children:(0,l.jsx)(N.IconChevronLeftOutlineRegular,{size:16})})}):null,(0,l.jsx)("span",{className:"art-title",children:e(b==="design"?"design.title":"panel")})]}),b==="list"?n:null,b==="list"?(0,l.jsxs)("div",{className:"art-actions",children:[(0,l.jsx)(N.Tooltip,{label:e("gallery.design"),side:"bottom",portal:!0,children:(0,l.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.design"),onClick:()=>y("design"),children:(0,l.jsx)(N.IconSlidersTwoOutlineRegular,{size:16})})}),(0,l.jsx)(N.Tooltip,{label:e("gallery.refresh"),side:"bottom",portal:!0,children:(0,l.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.refresh"),onClick:()=>g(S=>S+1),children:(0,l.jsx)(N.IconRefreshOutlineRegular,{size:16})})}),(0,l.jsx)(N.Menu,{open:h,onClose:()=>k(!1),align:"end",portal:!0,autoFocus:!0,items:[{id:"page",label:e("gallery.newPage")+" \xB7 "+e(`scope.${xe}`),icon:(0,l.jsx)(ie,{size:14})},{id:"doc",label:e("gallery.newDoc")+" \xB7 "+e(`scope.${xe}`),icon:(0,l.jsx)(be,{size:14})}],onSelect:S=>{k(!1),X(S==="doc"?"doc":"page",xe)},anchor:(0,l.jsx)(N.Button,{size:"sm",variant:"outline",icon:(0,l.jsx)(N.IconPlusOutlineRegular,{size:14}),"aria-haspopup":"menu","aria-expanded":h,onClick:()=>k(S=>!S),children:e("gallery.create")})})]}):null]}),b==="design"?(0,l.jsx)("div",{className:"art-scroll",children:(0,l.jsx)(_r,{t:e,workspaceId:t})}):(0,l.jsx)("div",{className:"art-scroll",children:(0,l.jsxs)("div",{className:"art-gallery",children:[(0,l.jsxs)("div",{className:"art-toolbar",children:[(0,l.jsx)("input",{className:"art-search",type:"search","aria-label":e("gallery.searchLabel"),placeholder:e("gallery.search"),value:a,onChange:S=>i(S.target.value)}),(0,l.jsx)(N.SegmentedControl,{id:B,className:"art-segment",label:e("filter.type"),value:u??"all",options:[{value:"all",label:e("type.all")},{value:"page",label:e("type.page")},{value:"doc",label:e("type.doc")}],onChange:S=>f(S==="all"?void 0:S)}),(0,l.jsx)(N.SegmentedControl,{id:se,className:"art-segment",label:e("filter.scope"),value:s,options:[{value:"all",label:e("filter.all")},{value:"workspace",label:e("scope.workspace")},{value:"library",label:e("scope.library")}],onChange:d})]}),(0,l.jsx)("div",{role:"tabpanel",id:B+"-"+(u??"all")+"-panel","aria-labelledby":B+"-"+(u??"all"),children:(0,l.jsxs)("div",{role:"tabpanel",id:se+"-"+s+"-panel","aria-labelledby":se+"-"+s,children:[re?(0,l.jsx)("p",{className:"art-note",children:e("empty.loading")}):null,!re&&Q!==void 0&&j.length===0?(0,l.jsxs)("div",{className:"art-empty",role:"alert",children:[(0,l.jsx)("p",{className:"art-empty-title",children:e(V(Q))}),(0,l.jsx)(N.Button,{size:"sm",variant:"outline",onClick:()=>g(S=>S+1),children:e("action.retry")})]}):null,!re&&Q!==void 0&&j.length>0?(0,l.jsxs)("div",{className:"art-bar",role:"status",children:[(0,l.jsx)("span",{children:e(V(Q))}),(0,l.jsx)(N.Button,{size:"sm",variant:"outline",onClick:()=>g(S=>S+1),children:e("action.retry")})]}):null,!re&&Q===void 0&&j.length===0?a!==""?(0,l.jsx)("p",{className:"art-note",children:e("empty.noMatch")}):u!==void 0?(0,l.jsx)("p",{className:"art-note",children:e("empty.typeMatch",{type:e(`type.${u}`)})}):H?(0,l.jsx)("p",{className:"art-note",children:e("empty.noWorkspace")}):(0,l.jsx)(xn,{t:e,scope:St}):null,!re&&j.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(Xr,{t:e,heading:e("gallery.pinned"),views:x,pinned:E,onOpen:te}),C.length===0?(0,l.jsx)("p",{className:"art-note",children:e("gallery.allPinned")}):(0,l.jsx)(Xr,{t:e,heading:e("gallery.recent"),views:C,pinned:E,onOpen:te}),I?(0,l.jsx)("div",{className:"art-gallery-more",children:(0,l.jsx)(N.Button,{size:"sm",variant:"outline",onClick:Pe,children:e("gallery.more")})}):null,O?(0,l.jsx)("p",{className:"art-note",children:e("gallery.truncated")}):null]}):null]})})]})})]})}var ee=require("react/jsx-runtime"),Zr="dsh-artifact-studio.panel.workspace";function ea({t:e,workspaces:t}){let r=(0,Y.useCallback)(y=>t.subscribe(y),[t]),n=(0,Y.useCallback)(()=>t.getSnapshot(),[t]),i=(0,Y.useSyncExternalStore)(r,n,n).items,[s,d]=(0,Y.useState)(()=>{let y=window.localStorage.getItem(Zr);return y===null||y===""?i[0]?.workspaceId??null:y}),[u,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(i.length===0){s!==null&&d(null);return}(s===null||!i.some(y=>y.workspaceId===s))&&d(i[0]?.workspaceId??null)},[i,s]),(0,Y.useEffect)(()=>{s!==null&&window.localStorage.setItem(Zr,s)},[s]);let b=(0,Y.useMemo)(()=>u===null?void 0:ke(u),[u]);return(0,ee.jsxs)("div",{className:"art-panel-stack",children:[(0,ee.jsx)("div",{className:"art-panel-region",hidden:b!==void 0,children:(0,ee.jsx)(Jr,{t:e,workspaceId:s,open:y=>f(y),toolbar:i.length===0?null:(0,ee.jsxs)("label",{className:"art-workspace",children:[(0,ee.jsx)("span",{className:"art-workspace-label",children:e("panel.workspace")}),(0,ee.jsx)("select",{className:"art-workspace-select","aria-label":e("panel.workspace"),value:s??"",onChange:y=>d(y.target.value===""?null:y.target.value),children:i.map(y=>(0,ee.jsx)("option",{value:y.workspaceId,children:y.title},y.workspaceId))})]})})}),b===void 0?null:(0,ee.jsx)("div",{className:"art-panel-region",children:(0,ee.jsx)(Or,{t:e,address:b,workspaceName:i.find(y=>b.scope==="workspace"&&y.workspaceId===b.workspaceId)?.title,onBack:()=>f(null)})})]})}var ta="dsh-artifact-studio/styles",wn=Sr.split(`
70
- `).map(e=>{let t=e.indexOf("{"),r=e.slice(0,t).split(",").map(a=>a.trim()).filter(a=>a!=="body"&&a!==".art-docpage");return(r.length===0?".art-docpage":r.map(a=>".art-docpage .art-prose "+a).join(", "))+" "+e.slice(t)}).join(`
71
- `),kn=`
69
+ `;function gn(e){return e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`)}function bn(e){return e.replace(/[\\`*_\[\]#]/g,t=>`\\${t}`)}function Xr(e,t){return e==="doc"?mn.replace("{{title}}",bn(t)):fn.replace("{{title}}",gn(t))}var c=require("react/jsx-runtime");function kt(e){return e.kind==="workspace"?"ws:"+e.workspaceId:e.kind}function Gt(e){if(e==="all")return{kind:"all"};if(e==="library")return{kind:"library"};if(e==null||!e.startsWith("ws:"))return;let t=e.slice(3);return t===""?void 0:{kind:"workspace",workspaceId:t}}function Zr(e,t,r){return e.scope==="library"?{manifest:e,address:{scope:"library",id:e.id},where:{scope:"library",workspaceId:t},project:null}:r===null?null:{manifest:e,address:{scope:"workspace",workspaceId:r.workspaceId,id:e.id},where:{scope:"workspace",workspaceId:r.workspaceId},project:r.title}}function yn(e,t){e!==void 0&&(de(t.manifest.id,t.manifest.title),e(H(t.address)))}function Jr(e){let t=H(e.address);return e.manifest.scope==="library"?t+"@"+(e.where.workspaceId??""):t}var Ye=new Map,qt=new Map;function hn(e){let t=Jr(e),r=Ye.get(t);if(r!==void 0&&r.version>=e.manifest.version)return Promise.resolve(r);let a=t+":"+e.manifest.version,n=qt.get(a);if(n!==void 0)return n;let o=z.get(e.where,e.manifest.id).then(s=>{let l={version:s.version,content:s.content,designCss:s.designCss},f=Ye.get(t);return(f===void 0||f.version<=l.version)&&(Ye.size>=60&&Ye.clear(),Ye.set(t,l)),l}).finally(()=>{qt.delete(a)});return qt.set(a,o),o}function vn(e){if(typeof DOMParser>"u")return e.replace(/<script\b[^>]*>[\s\S]*?<\/script\s*>/gi,"").replace(/<script\b[^>]*\/?>/gi,"").replace(/\son[a-z]+\s*=\s*"[^"]*"/gi,"");let t=new DOMParser().parseFromString(e,"text/html");for(let r of t.querySelectorAll("script, iframe, object, embed, base"))r.remove();for(let r of t.querySelectorAll("*"))for(let a of[...r.attributes]){let n=a.name.toLowerCase();(n.startsWith("on")||n==="srcdoc")&&r.removeAttribute(a.name)}return t.documentElement.outerHTML}function xn(e){let t=e.replace(/\x60{3}[\s\S]*?\x60{3}/g," ").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/<[^>]+>/g," ").replace(/[#>*_\x60~]/g," ").replace(/\s+/g," ").trim();return t.length>220?t.slice(0,220).trimEnd()+"...":t}function wn({t:e,view:t}){let[r,a]=(0,P.useState)(null),[n,o]=(0,P.useState)(!1),[s,l]=(0,P.useState)(typeof IntersectionObserver>"u"),[f,u]=(0,P.useState)(null),h=(0,P.useRef)(null),w=ze(),k=Jr(t),S=t.manifest.title,m=t.manifest.type,d=t.manifest.version;(0,P.useEffect)(()=>{if(s)return;let I=h.current;if(I===null)return;let O=new IntersectionObserver(Z=>{Z.some(M=>M.isIntersecting)&&(l(!0),O.disconnect())},{rootMargin:"140px"});return O.observe(I),()=>O.disconnect()},[s]),(0,P.useEffect)(()=>{if(!s)return;let I=!1;return hn(t).then(O=>{!I&&O.version===d&&(a(O),o(!1))}).catch(()=>{I||o(!0)}),()=>{I=!0}},[s,k,d]),(0,P.useEffect)(()=>{if(m!=="page"||r===null){u(null);return}let I=URL.createObjectURL(new Blob([ut(vn(r.content),r.designCss,S,w?"dark":"light")],{type:"text/html"}));return u(I),()=>URL.revokeObjectURL(I)},[r,m,S,w]);let y=m==="page"?(0,c.jsx)(se,{}):(0,c.jsx)(fe,{});if(n)return(0,c.jsx)("span",{className:"art-cover",ref:h,"aria-hidden":"true",children:(0,c.jsx)("span",{className:"art-cover-fallback",children:y})});if(m==="page")return(0,c.jsx)("span",{className:"art-cover",ref:h,"aria-hidden":"true",children:f===null?(0,c.jsx)("span",{className:"art-cover-fallback",children:y}):(0,c.jsx)("span",{className:"art-cover-frame-wrap",children:(0,c.jsx)("iframe",{className:"art-cover-frame",src:f,sandbox:"",title:e("gallery.coverTitle",{title:S}),tabIndex:-1,loading:"lazy",referrerPolicy:"no-referrer"})})});let E=r===null?"":xn(r.content);return(0,c.jsx)("span",{className:"art-cover",ref:h,"aria-hidden":"true",children:E===""?(0,c.jsx)("span",{className:"art-cover-fallback",children:y}):(0,c.jsxs)("span",{className:"art-cover-doc",children:[(0,c.jsx)("span",{className:"art-cover-doc-title",children:S}),(0,c.jsx)("span",{className:"art-cover-doc-text",children:E})]})})}function kn({t:e,view:t,pinned:r,onOpen:a,showProject:n}){let o=H(t.address),s=e(r?"gallery.unpin":"gallery.pin",{title:t.manifest.title}),l=t.manifest.scope==="library"?" \xB7 "+e("scope.library"):n&&t.project!==null?" \xB7 "+t.project:"";return(0,c.jsxs)("li",{className:"art-tile",children:[(0,c.jsxs)("button",{type:"button",className:"art-tile-open",onClick:()=>a(t),children:[(0,c.jsx)(wn,{t:e,view:t}),(0,c.jsxs)("span",{className:"art-tile-body",children:[(0,c.jsx)("span",{className:"art-tile-title",title:t.manifest.title,children:t.manifest.title}),(0,c.jsxs)("span",{className:"art-tile-sub",children:[e(`type.${t.manifest.type}`)," \xB7 ",e("gallery.updated",{time:ft(e,t.manifest.updatedAt)})," \xB7 ",e("gallery.version",{version:t.manifest.version}),l]})]})]}),(0,c.jsx)(N.Tooltip,{label:s,side:"left",portal:!0,children:(0,c.jsx)("button",{type:"button",className:"art-tile-pin","aria-label":s,"aria-pressed":r,onClick:()=>Yr(o),children:r?(0,c.jsx)(N.IconPinFillRegular,{size:14}):(0,c.jsx)(N.IconPinOutlineRegular,{size:14})})})]})}function Qr({t:e,heading:t,views:r,pinned:a,onOpen:n,showProject:o}){let s=(0,P.useId)();return r.length===0?null:(0,c.jsxs)("section",{className:"art-section","aria-labelledby":s,children:[(0,c.jsxs)("div",{className:"art-section-head",children:[(0,c.jsx)("h2",{className:"art-section-title",id:s,children:t}),(0,c.jsx)("span",{className:"art-section-hint",children:e("gallery.count",{count:r.length})})]}),(0,c.jsx)("ul",{className:"art-grid",children:r.map(l=>(0,c.jsx)(kn,{t:e,view:l,pinned:a.has(H(l.address)),onOpen:n,showProject:o},H(l.address)))})]})}function Tn(e,t,r){let a={where:{scope:"library",workspaceId:r},project:null};if(e.kind==="library")return[a];if(e.kind==="workspace"){let n=t.find(o=>o.workspaceId===e.workspaceId);return n===void 0?[]:[{where:{scope:"workspace",workspaceId:n.workspaceId},project:n}]}return[...t.map(n=>({where:{scope:"workspace",workspaceId:n.workspaceId},project:n})),a]}var Sn=12;function Cn(e,t,r,a,n,o){let[s,l]=(0,P.useState)(1),[f,u]=(0,P.useState)({key:"",state:{status:"loading"}}),h=t.map(m=>m.workspaceId+":"+m.title).join(","),w=kt(e)+":"+h+":"+(r??"")+":"+a+":"+(n??""),k=e.kind==="all",S=f.key===w?f.state:{status:"loading"};return(0,P.useEffect)(()=>l(1),[w,a]),(0,P.useEffect)(()=>{let m=Tn(e,t,r);if(m.length===0){u({key:w,state:{status:"ready",items:[],hasMore:!1,truncated:!1,failed:0}});return}let d=new AbortController,y=setTimeout(async()=>{let E=k?Sn:void 0,I=await Promise.all(m.map(async _=>{let A=[];for(let q=0;q<s;q+=1)try{let V=await z.list(_.where,{query:a,type:n,offset:q*(E??50),...E===void 0?{}:{limit:E}},d.signal);if(A.push(V),!V.hasMore)break}catch(V){return{loaded:A,failed:!0,code:Y(V)}}return{loaded:A,failed:!1}}));if(d.signal.aborted)return;let O=[],Z=!1,M=!1,J=0,$;if(I.forEach((_,A)=>{let q=m[A];if(q===void 0)return;_.failed&&(J+=1,$===void 0&&($=_.code));let V=_.loaded[_.loaded.length-1];if(V!==void 0){V.hasMore&&(Z=!0),V.truncated&&(M=!0);for(let ae of _.loaded)for(let ee of ae.items){let x=Zr(ee,r,q.project);x!==null&&O.push(x)}}}),J===m.length){u({key:w,state:{status:"failed",code:$}});return}O.sort((_,A)=>Date.parse(A.manifest.updatedAt)-Date.parse(_.manifest.updatedAt)),u({key:w,state:{status:"ready",items:O,hasMore:Z,truncated:M,failed:J}})},a===""?0:180);return()=>{d.abort(),clearTimeout(y)}},[w,o,s]),{state:S,more:()=>l(m=>m+1)}}function Nn({t:e,variant:t}){let r=t==="all"?"empty.allTitle":t==="library"?"empty.libraryTitle":"empty.workspaceTitle",a=t==="all"?"empty.allHint":t==="library"?"empty.libraryHint":"empty.workspaceHint",n=async o=>{try{await navigator.clipboard.writeText(o),W(e("gallery.promptCopied"))}catch{W(e("action.copyFailed"))}};return(0,c.jsxs)("div",{className:"art-empty",children:[(0,c.jsx)("p",{className:"art-empty-title",children:e(r)}),(0,c.jsx)("p",{className:"art-empty-hint",children:e(a)}),(0,c.jsx)("ul",{className:"art-starters",children:Wt.map(o=>(0,c.jsxs)("li",{className:"art-starter",children:[(0,c.jsxs)("span",{className:"art-starter-text",children:[(0,c.jsx)("span",{className:"art-starter-name",children:e(`prompt.${o}`)}),(0,c.jsx)("span",{className:"art-starter-hint",children:e(`prompt.${o}Text`)})]}),(0,c.jsx)(N.Tooltip,{label:e("gallery.copyPrompt"),side:"left",portal:!0,children:(0,c.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.copyPromptNamed",{name:e(`prompt.${o}`)}),onClick:()=>void n(e(`prompt.${o}Text`)),children:(0,c.jsx)(N.IconCopyOutlineRegular,{size:14})})})]},o))})]})}function ea({t:e,projects:t,scope:r,contextWorkspaceId:a,onScopeChange:n,open:o}){let[s,l]=(0,P.useState)(""),[f,u]=(0,P.useState)(void 0),[h,w]=(0,P.useState)("list"),[k,S]=(0,P.useState)(!1),[m,d]=(0,P.useState)(0),y=dt()+m,E=Kr(),I=Cn(r,t,a,s,f,y),O=(0,P.useId)(),Z=t.find(g=>g.workspaceId===a)??null,M=r.kind==="library"?null:a,J=M===null?null:t.find(g=>g.workspaceId===M)??null,$=r.kind==="library"||Z===null?"library":"workspace",_=$==="library"?e("scope.library"):Z?.title??e("scope.library"),A=I.state,q=A.status==="ready"?A.items:[],V=(0,P.useCallback)(g=>yn(o,g),[o]),ae=(0,P.useCallback)(async(g,L)=>{if(L==="workspace"&&a===null)return;let j=e(g==="page"?"create.untitledPage":"create.untitledDoc");try{let{manifest:F}=await z.create({scope:L,workspaceId:a},g,j,Xr(g,j));pe();let Tt=L==="workspace"?t.find(Be=>Be.workspaceId===a)??null:null,we=Zr(F,a,Tt);we!==null&&V(we)}catch(F){W(e(X(Y(F))))}},[a,t,e,V]),ee=q.filter(g=>E.has(H(g.address))),x=q.filter(g=>!E.has(H(g.address)));return(0,c.jsxs)("section",{className:"art-root","data-dsh-artifact-studio":"",children:[(0,c.jsxs)("header",{className:"art-header",children:[(0,c.jsxs)("div",{className:"art-heading",children:[h==="design"?(0,c.jsx)(N.Tooltip,{label:e("panel"),side:"bottom",portal:!0,children:(0,c.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("panel"),onClick:()=>w("list"),children:(0,c.jsx)(N.IconChevronLeftOutlineRegular,{size:16})})}):null,(0,c.jsx)("span",{className:"art-title",children:e(h==="design"?"design.title":"panel")})]}),h==="list"?(0,c.jsxs)("label",{className:"art-workspace",children:[(0,c.jsx)("span",{className:"art-workspace-label",children:e("scope.label")}),(0,c.jsxs)("select",{className:"art-workspace-select","aria-label":e("scope.label"),value:kt(r),onChange:g=>{let L=Gt(g.target.value);L!==void 0&&n(L)},children:[(0,c.jsx)("option",{value:"all",children:e("scope.all")}),t.map(g=>(0,c.jsx)("option",{value:"ws:"+g.workspaceId,children:g.title},g.workspaceId)),(0,c.jsx)("option",{value:"library",children:e("scope.library")})]})]}):null,h==="list"?(0,c.jsxs)("div",{className:"art-actions",children:[(0,c.jsx)(N.Tooltip,{label:e("gallery.design"),side:"bottom",portal:!0,children:(0,c.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.design"),onClick:()=>w("design"),children:(0,c.jsx)(Hr,{size:16})})}),(0,c.jsx)(N.Tooltip,{label:e("gallery.refresh"),side:"bottom",portal:!0,children:(0,c.jsx)(N.Button,{size:"sm",className:"art-icon-button","aria-label":e("gallery.refresh"),onClick:()=>d(g=>g+1),children:(0,c.jsx)(N.IconRefreshOutlineRegular,{size:16})})}),(0,c.jsx)(N.Menu,{open:k,onClose:()=>S(!1),align:"end",portal:!0,autoFocus:!0,items:[{id:"page",label:e("gallery.newPage")+" \xB7 "+_,icon:(0,c.jsx)(se,{size:14})},{id:"doc",label:e("gallery.newDoc")+" \xB7 "+_,icon:(0,c.jsx)(fe,{size:14})}],onSelect:g=>{S(!1),ae(g==="doc"?"doc":"page",$)},anchor:(0,c.jsx)(N.Button,{size:"sm",variant:"outline",icon:(0,c.jsx)(N.IconPlusOutlineRegular,{size:14}),"aria-haspopup":"menu","aria-expanded":k,onClick:()=>S(g=>!g),children:e("gallery.create")})})]}):null]}),h==="design"?(0,c.jsx)("div",{className:"art-scroll",children:(0,c.jsx)(Ur,{t:e,workspaceId:M,workspaceTitle:J?.title})}):(0,c.jsx)("div",{className:"art-scroll",children:(0,c.jsxs)("div",{className:"art-gallery",children:[(0,c.jsxs)("div",{className:"art-toolbar",children:[(0,c.jsx)("input",{className:"art-search",type:"search","aria-label":e("gallery.searchLabel"),placeholder:e("gallery.search"),value:s,onChange:g=>l(g.target.value)}),(0,c.jsx)(N.SegmentedControl,{id:O,className:"art-segment",label:e("filter.type"),value:f??"all",options:[{value:"all",label:e("type.all")},{value:"page",label:e("type.page")},{value:"doc",label:e("type.doc")}],onChange:g=>u(g==="all"?void 0:g)})]}),(0,c.jsxs)("div",{role:"tabpanel",id:O+"-"+(f??"all")+"-panel","aria-labelledby":O+"-"+(f??"all"),children:[A.status==="loading"?(0,c.jsx)("p",{className:"art-note",children:e("empty.loading")}):null,A.status==="failed"?(0,c.jsxs)("div",{className:"art-empty",role:"alert",children:[(0,c.jsx)("p",{className:"art-empty-title",children:e(X(A.code))}),(0,c.jsx)(N.Button,{size:"sm",variant:"outline",onClick:()=>d(g=>g+1),children:e("action.retry")})]}):null,A.status==="ready"&&A.failed>0?(0,c.jsxs)("div",{className:"art-bar","data-tone":"warn",role:"status",children:[(0,c.jsx)("span",{children:e("gallery.failedProjects")}),(0,c.jsx)(N.Button,{size:"sm",variant:"outline",onClick:()=>d(g=>g+1),children:e("action.retry")})]}):null,A.status==="ready"&&A.items.length===0&&A.failed===0?s!==""?(0,c.jsx)("p",{className:"art-note",children:e("empty.noMatch")}):f!==void 0?(0,c.jsx)("p",{className:"art-note",children:e("empty.typeMatch",{type:e(`type.${f}`)})}):(0,c.jsx)(Nn,{t:e,variant:r.kind}):null,A.status==="ready"&&A.items.length>0?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(Qr,{t:e,heading:e("gallery.pinned"),views:ee,pinned:E,onOpen:V,showProject:r.kind==="all"}),x.length===0?(0,c.jsx)("p",{className:"art-note",children:e("gallery.allPinned")}):(0,c.jsx)(Qr,{t:e,heading:e("gallery.recent"),views:x,pinned:E,onOpen:V,showProject:r.kind==="all"}),A.hasMore?(0,c.jsx)("div",{className:"art-gallery-more",children:(0,c.jsx)(N.Button,{size:"sm",variant:"outline",onClick:I.more,children:e("gallery.more")})}):null,A.truncated?(0,c.jsx)("p",{className:"art-note",children:e("gallery.truncated")}):null]}):null]})]})})]})}var Ae=require("react/jsx-runtime"),ta="dsh-artifact-studio.panel.scope",ra="dsh-artifact-studio.panel.workspace";function aa({t:e,workspaces:t}){let r=(0,U.useCallback)(y=>t.subscribe(y),[t]),a=(0,U.useCallback)(()=>t.getSnapshot(),[t]),o=(0,U.useSyncExternalStore)(r,a,a).items,s=(0,U.useMemo)(()=>o.map(({workspaceId:y,title:E})=>({workspaceId:y,title:E})),[o]),[l,f]=(0,U.useState)(()=>Gt(window.localStorage.getItem(ta))??{kind:"all"}),[u,h]=(0,U.useState)(()=>{let y=window.localStorage.getItem(ra);return y===null||y===""?null:y}),[w,k]=(0,U.useState)(null),S=l.kind==="workspace"?o.find(y=>y.workspaceId===l.workspaceId):void 0,m=S!==void 0?S.workspaceId:u!==null&&o.some(y=>y.workspaceId===u)?u:o[0]?.workspaceId??null;(0,U.useEffect)(()=>{if(o.length!==0){if(l.kind==="workspace"&&!o.some(y=>y.workspaceId===l.workspaceId)){f({kind:"all"});return}m!==null&&m!==u&&h(m)}},[o,l,m,u]),(0,U.useEffect)(()=>{window.localStorage.setItem(ta,kt(l))},[l]),(0,U.useEffect)(()=>{u!==null&&window.localStorage.setItem(ra,u)},[u]);let d=(0,U.useMemo)(()=>w===null?void 0:he(w),[w]);return(0,Ae.jsxs)("div",{className:"art-panel-stack",children:[(0,Ae.jsx)("div",{className:"art-panel-region",hidden:d!==void 0,children:(0,Ae.jsx)(ea,{t:e,projects:s,scope:l,contextWorkspaceId:m,onScopeChange:f,open:y=>k(y)})}),d===void 0?null:(0,Ae.jsx)("div",{className:"art-panel-region",children:(0,Ae.jsx)(Or,{t:e,address:d,workspaceName:o.find(y=>d.scope==="workspace"&&y.workspaceId===d.workspaceId)?.title,onBack:()=>k(null)})})]})}var na="dsh-artifact-studio/styles",An=Sr.split(`
70
+ `).map(e=>{let t=e.indexOf("{"),r=e.slice(0,t).split(",").map(n=>n.trim()).filter(n=>n!=="body"&&n!==".art-docpage");return(r.length===0?".art-docpage":r.map(n=>".art-docpage .art-prose "+n).join(", "))+" "+e.slice(t)}).join(`
71
+ `),Rn=`
72
72
  .art-root {
73
73
  box-sizing: border-box;
74
74
  display: flex;
@@ -557,7 +557,7 @@ Start writing, or select text and choose Edit with agent.
557
557
  .art-starter-name { font-size: 13px; font-weight: 600; color: var(--dsw-alias-label-primary); }
558
558
  .art-starter-hint { font-size: 12px; line-height: 1.5; color: var(--dsw-alias-label-secondary); }
559
559
  .art-tile-pin svg { width: 14px; height: 14px; }
560
- `;function ra(){if(typeof document>"u"||document.querySelector(`style[data-plugin-css="${ta}"]`)!==null)return;let e=document.createElement("style");e.dataset.plugin="dsh-artifact-studio",e.dataset.pluginCss=ta,e.textContent=kn+wn,document.head.appendChild(e)}var ve=require("react/jsx-runtime");var Se="artifacts",na=["artifact_create","artifact_update"],Tn=["connection","slots","locale","sidebarRightTabs","sidebarRight","workspaces"];function Sn(e){if(e===null||typeof e!="object"||!("selectPanel"in e))return null;let{selectPanel:t}=e;return typeof t!="function"?null:{selectPanel:r=>{t.call(e,r)}}}function Yt(e){return function(r){return(0,ve.jsx)(ht,{title:r.t("error.surface"),hint:r.t("error.surfaceHint"),reloadLabel:r.t("action.reloadWindow"),children:(0,ve.jsx)(e,{...r})})}}function Nn(){let e=hr();return e===null?null:(0,ve.jsx)(aa.Toast,{text:e.message,onDone:()=>It(e.seq)},e.seq)}function Cn({useTabInfo:e}){let{tab:t}=e(),r=ke(t.contentId??t.navigation?.address),n=br(r?.id);return(0,ve.jsxs)("span",{className:"art-chip",children:[(0,ve.jsx)(be,{}),(0,ve.jsx)("span",{children:n??r?.id??""})]})}function An(e){ra(),e.effect(vr,"dsh-artifact-studio: unsaved draft guard"),ur(e.connection),ye.sidebarRight=e.sidebarRight,ye.layout=Sn(e.get("layout")),e.locale.register(Se,"en",Er),e.locale.register(Se,"zh",Pr);let t=e.locale.bind(Se),r=(s,d)=>t(s,d);e.effect(()=>e.sidebarRightTabs.register({id:Ye,kind:_t,priority:"extension",patterns:["dsh-resource://artifact/**"],canOpen:s=>ke(s)!==void 0,title:s=>{let d=ke(s);return d===void 0?"":gr(d.id)??d.id}}),"dsh-artifact-studio: artifact tab type");let n=()=>({t:r});e.effect(()=>()=>It(),"dsh-artifact-studio: notification cleanup"),e.slots.inject("shell.overlay",()=>e.slots.register({name:"shell.overlay",id:"dsh-artifact-studio.notice"},Nn)),e.slots.inject("sidebar.right.pane.tab",()=>e.slots.register({name:"sidebar.right.pane.tab",key:Ye,locale:Se,inject:n},Yt($t))),e.slots.inject("sidebar.right.pane.tab.title",()=>e.slots.register({name:"sidebar.right.pane.tab.title",key:Ye,locale:Se,inject:n},Cn));for(let s of na)e.slots.inject("tool.call.toolview",()=>e.slots.register({name:"tool.call.toolview",key:s,locale:Se,inject:n},Yt(Wt)));e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"dsh-artifact-studio",order:40,locale:Se,inject:n},Wr));function a({size:s}){return(0,ve.jsx)(vt,{size:s})}let i=()=>({t:r,workspaces:e.workspaces.list});e.slots.inject("main",()=>e.slots.register({name:"main",key:$e,locale:Se,inject:i},Yt(ea))),e.slots.inject("sidebar.panellist",()=>e.slots.register({name:"sidebar.panellist",id:$e,order:10,label:()=>r("panel")},a))}
560
+ `;function oa(){if(typeof document>"u"||document.querySelector(`style[data-plugin-css="${na}"]`)!==null)return;let e=document.createElement("style");e.dataset.plugin="dsh-artifact-studio",e.dataset.pluginCss=na,e.textContent=Rn+An,document.head.appendChild(e)}var be=require("react/jsx-runtime");var xe="artifacts",sa=["artifact_create","artifact_update"],En=["connection","slots","locale","sidebarRightTabs","sidebarRight","workspaces"];function Pn(e){if(e===null||typeof e!="object"||!("selectPanel"in e))return null;let{selectPanel:t}=e;return typeof t!="function"?null:{selectPanel:r=>{t.call(e,r)}}}function Kt(e){return function(r){return(0,be.jsx)(gt,{title:r.t("error.surface"),hint:r.t("error.surfaceHint"),reloadLabel:r.t("action.reloadWindow"),children:(0,be.jsx)(e,{...r})})}}function In(){let e=hr();return e===null?null:(0,be.jsx)(ia.Toast,{text:e.message,onDone:()=>zt(e.seq)},e.seq)}function Ln({useTabInfo:e}){let{tab:t}=e(),r=he(t.contentId??t.navigation?.address),a=br(r?.id);return(0,be.jsxs)("span",{className:"art-chip",children:[(0,be.jsx)(fe,{}),(0,be.jsx)("span",{children:a??r?.id??""})]})}function Dn(e){oa(),e.effect(vr,"dsh-artifact-studio: unsaved draft guard"),ur(e.connection),me.sidebarRight=e.sidebarRight,me.layout=Pn(e.get("layout")),e.locale.register(xe,"en",Er),e.locale.register(xe,"zh",Pr);let t=e.locale.bind(xe),r=(s,l)=>t(s,l);e.effect(()=>e.sidebarRightTabs.register({id:Ge,kind:_t,priority:"extension",patterns:["dsh-resource://artifact/**"],canOpen:s=>he(s)!==void 0,title:s=>{let l=he(s);return l===void 0?"":gr(l.id)??l.id}}),"dsh-artifact-studio: artifact tab type");let a=()=>({t:r});e.effect(()=>()=>zt(),"dsh-artifact-studio: notification cleanup"),e.slots.inject("shell.overlay",()=>e.slots.register({name:"shell.overlay",id:"dsh-artifact-studio.notice"},In)),e.slots.inject("sidebar.right.pane.tab",()=>e.slots.register({name:"sidebar.right.pane.tab",key:Ge,locale:xe,inject:a},Kt(Vt))),e.slots.inject("sidebar.right.pane.tab.title",()=>e.slots.register({name:"sidebar.right.pane.tab.title",key:Ge,locale:xe,inject:a},Ln));for(let s of sa)e.slots.inject("tool.call.toolview",()=>e.slots.register({name:"tool.call.toolview",key:s,locale:xe,inject:a},Kt($t)));e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"dsh-artifact-studio",order:40,locale:xe,inject:a},Wr));function n({size:s}){return(0,be.jsx)(yt,{size:s})}let o=()=>({t:r,workspaces:e.workspaces.list});e.slots.inject("main",()=>e.slots.register({name:"main",key:je,locale:xe,inject:o},Kt(aa))),e.slots.inject("sidebar.panellist",()=>e.slots.register({name:"sidebar.panellist",id:je,order:10,label:()=>r("panel")},n))}
561
561
 
562
562
  return module.exports;
563
563
  },
@@ -3,6 +3,10 @@ const CONTENT = String.raw `# Artifact design
3
3
 
4
4
  Use this before you call \`artifact_create\`, and before an \`artifact_update\` that changes layout or styling. An artifact is a deliverable the user will look at and keep, so it should read as finished work, not a demo.
5
5
 
6
+ ## When to use an artifact
7
+
8
+ Use \`artifact_create\` when the user asks for an artifact, an artifact page, or an artifact doc. Pick \`page\` for an artifact page and \`doc\` for an artifact doc. Never write a file in the project instead. Write a project file only when the user asks for a file in the repo.
9
+
6
10
  ## Precedence
7
11
 
8
12
  1. The user's request wins. If they name a palette, font, layout, or tone, follow it.
@@ -67,8 +71,8 @@ Tell the user in one or two sentences what you made or changed. Do not repeat th
67
71
  /** The artifact design skill, registered by the \`dsh-artifact-studio/skill\` host plugin. */
68
72
  export const ARTIFACT_DESIGN_SKILL = {
69
73
  name: 'artifact-design',
70
- description: 'Design rules for artifact pages and documents: precedence, the page sandbox, design tokens, dark mode, layout, typography, and the update rule.',
71
- whenToUse: 'Load before artifact_create, and before an artifact_update that changes layout or styling.',
74
+ description: 'Design rules for artifact pages and documents: when to use an artifact, precedence, the page sandbox, design tokens, dark mode, layout, typography, and the update rule.',
75
+ whenToUse: 'Load before artifact_create, when the user asks for an artifact, and before an artifact_update that changes layout or styling.',
72
76
  source: 'bundled',
73
77
  content: CONTENT,
74
78
  };
@@ -157,6 +157,7 @@ export function createTools(host) {
157
157
  name: 'artifact_create',
158
158
  description: [
159
159
  'Create a versioned artifact the user opens, edits, and exports in a panel beside the chat. Use it for a substantial deliverable the user will look at or reuse: a dashboard, report, one-pager, landing page, interactive tool, or long document. Do not use it for short answers or for project source files.',
160
+ 'If the user asks for an artifact, an artifact page, or an artifact doc, create it here with the matching type and never write a project file instead.',
160
161
  '',
161
162
  PAGE_GUIDE,
162
163
  ].join('\n'),
package/locale/en.json CHANGED
@@ -1,4 +1,6 @@
1
1
  {
2
- "title": "Artifacts",
3
- "description": "Pages and documents the agent creates as versioned files, opened beside the chat with history, export, and a shared design system."
2
+ "meta": {
3
+ "title": "Artifacts",
4
+ "description": "Pages and documents the agent creates as versioned files, opened beside the chat with history, export, and a shared design system."
5
+ }
4
6
  }
package/locale/zh.json CHANGED
@@ -1,4 +1,6 @@
1
1
  {
2
- "title": "产物",
3
- "description": "智能体以带版本的文件生成页面和文档,在对话旁打开,支持历史、导出和共享设计系统。"
2
+ "meta": {
3
+ "title": "产物",
4
+ "description": "智能体以带版本的文件生成页面和文档,在对话旁打开,支持历史、导出和共享设计系统。"
5
+ }
4
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-artifact-studio",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Local-first artifacts for DeepSeek Harness: the agent creates pages and documents as versioned files, and you open, edit, restore, and export them beside the chat.",
6
6
  "keywords": [