zdashboard 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/web/assets/{DiagramViewer-CQYfB79k.js → DiagramViewer-CVyfeqsA.js} +3 -3
  4. package/dist/web/assets/{FileIcon-KX0Rfn5x.js → FileIcon-K_Wp_ZvI.js} +1 -1
  5. package/dist/web/assets/{FilterPills-D2zZaent.js → FilterPills-CPr9zkF3.js} +1 -1
  6. package/dist/web/assets/{Sidebar-B6Pvc7pb.js → Sidebar-CWuvJ9HX.js} +1 -1
  7. package/dist/web/assets/{Sidebar-Cg5Nabqa.js → Sidebar-CwIZTcVD.js} +1 -1
  8. package/dist/web/assets/{Workspace-DbRd77b0.js → Workspace-59BGdqNJ.js} +1 -1
  9. package/dist/web/assets/{Workspace-5hZEbEDw.js → Workspace-D1qyEg7a.js} +1 -1
  10. package/dist/web/assets/{Workspace-CpV2wf10.js → Workspace-D7f67nft.js} +1 -1
  11. package/dist/web/assets/{Workspace-BzLI5G5q.js → Workspace-DmvYpSbr.js} +1 -1
  12. package/dist/web/assets/{cynefin-OW5HDTMX-BLthHq8j.js → cynefin-OW5HDTMX-C7JFr8c7.js} +2 -2
  13. package/dist/web/assets/{excalidraw-Duf4g83v.js → excalidraw-DhBXlAqA.js} +6 -6
  14. package/dist/web/assets/index-B4vX5DS-.css +1 -0
  15. package/dist/web/assets/{index-BxPRo4R9.js → index-DJ6COP3-.js} +9 -9
  16. package/dist/web/assets/{usePluginData-BaCM6nnK.js → usePluginData-BVQYKC-X.js} +1 -1
  17. package/dist/web/assets/{web-CBXj6xFf.js → web-BJGOy2bk.js} +2 -2
  18. package/dist/web/assets/{web-oi27dtPg.js → web-CXsIp7nc.js} +2 -2
  19. package/dist/web/assets/{web-CmZk5ox_.js → web-CzoLB8PU.js} +2 -2
  20. package/dist/web/assets/{web-C7ddFKgL.js → web-DBVl3bA2.js} +2 -2
  21. package/dist/web/index.html +2 -2
  22. package/package.json +1 -1
  23. package/dist/web/assets/index-DJ7iFi2B.css +0 -1
@@ -1 +1 @@
1
- import{j as o}from"./vendor-react-OhDMXABq.js";import{u as r}from"./index-BxPRo4R9.js";function a({className:s=""}){return o.jsx("span",{"data-testid":"refresh-spinner",role:"status","aria-label":"刷新中",className:`inline-block h-3 w-3 flex-none shrink-0 animate-spin rounded-[var(--radius-full)] border border-muted-foreground/25 border-t-muted-foreground ${s}`})}const i={".md":"md",".markdown":"md",".mdx":"md",".ts":"ts",".tsx":"tsx",".js":"js",".jsx":"jsx",".mjs":"mjs",".cjs":"mjs",".mts":"mjs",".cts":"mjs",".css":"css",".scss":"css",".less":"css",".html":"html",".htm":"html",".json":"json",".yaml":"json",".yml":"json",".toml":"json",".csv":"csv",".tsv":"csv",".sh":"sh",".bash":"sh",".zsh":"sh",".sql":"sh",".py":"py",".go":"py",".rs":"py",".java":"py",".svg":"svg",".png":"svg",".jpg":"svg",".jpeg":"svg",".gif":"svg",".webp":"svg",".ico":"svg"};function c(s){const e=s.toLowerCase();if(e==="justfile"||e==="makefile")return e;const n=s.lastIndexOf("."),t=n>=0?s.slice(n).toLowerCase():"";return i[t]??"unknown"}function u({name:s,active:e}){const{icon:n}=r(),t=n(c(s));return t?o.jsx("span",{className:`h-3.5 w-3.5 shrink-0 inline-flex items-center justify-center ${e?"text-primary":"text-muted-foreground"}`,children:t}):null}export{u as F,a as R};
1
+ import{j as o}from"./vendor-react-OhDMXABq.js";import{u as r}from"./index-DJ6COP3-.js";function a({className:s=""}){return o.jsx("span",{"data-testid":"refresh-spinner",role:"status","aria-label":"刷新中",className:`inline-block h-3 w-3 flex-none shrink-0 animate-spin rounded-[var(--radius-full)] border border-muted-foreground/25 border-t-muted-foreground ${s}`})}const i={".md":"md",".markdown":"md",".mdx":"md",".ts":"ts",".tsx":"tsx",".js":"js",".jsx":"jsx",".mjs":"mjs",".cjs":"mjs",".mts":"mjs",".cts":"mjs",".css":"css",".scss":"css",".less":"css",".html":"html",".htm":"html",".json":"json",".yaml":"json",".yml":"json",".toml":"json",".csv":"csv",".tsv":"csv",".sh":"sh",".bash":"sh",".zsh":"sh",".sql":"sh",".py":"py",".go":"py",".rs":"py",".java":"py",".svg":"svg",".png":"svg",".jpg":"svg",".jpeg":"svg",".gif":"svg",".webp":"svg",".ico":"svg"};function c(s){const e=s.toLowerCase();if(e==="justfile"||e==="makefile")return e;const n=s.lastIndexOf("."),t=n>=0?s.slice(n).toLowerCase():"";return i[t]??"unknown"}function u({name:s,active:e}){const{icon:n}=r(),t=n(c(s));return t?o.jsx("span",{className:`h-3.5 w-3.5 shrink-0 inline-flex items-center justify-center ${e?"text-primary":"text-muted-foreground"}`,children:t}):null}export{u as F,a as R};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-react-OhDMXABq.js";import{d as n}from"./index-BxPRo4R9.js";function b({items:l,value:d,onChange:p,ariaLabel:c,renderExtra:o,renderLabel:a,className:t,...u}){return e.jsx("div",{role:"group","aria-label":c,className:n("inline-flex items-center gap-1.5 flex-wrap",t),...u,children:l.map(r=>{const s=r.key===d;return e.jsxs("button",{type:"button","aria-pressed":s,onClick:()=>p(r.key),className:n("inline-flex items-center gap-1.5 h-7 px-2.5 rounded-[var(--radius-full)] border text-xs transition-colors",s?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground/40",r.className),children:[r.renderLabel?r.renderLabel(r):a?a(r):e.jsx("span",{children:r.label}),r.badge&&e.jsx("span",{className:"opacity-80",children:r.badge}),r.renderExtra?r.renderExtra(r):o==null?void 0:o(r)]},r.key)})})}export{b as F};
1
+ import{j as e}from"./vendor-react-OhDMXABq.js";import{d as n}from"./index-DJ6COP3-.js";function b({items:l,value:d,onChange:p,ariaLabel:c,renderExtra:o,renderLabel:a,className:t,...u}){return e.jsx("div",{role:"group","aria-label":c,className:n("inline-flex items-center gap-1.5 flex-wrap",t),...u,children:l.map(r=>{const s=r.key===d;return e.jsxs("button",{type:"button","aria-pressed":s,onClick:()=>p(r.key),className:n("inline-flex items-center gap-1.5 h-7 px-2.5 rounded-[var(--radius-full)] border text-xs transition-colors",s?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground/40",r.className),children:[r.renderLabel?r.renderLabel(r):a?a(r):e.jsx("span",{children:r.label}),r.badge&&e.jsx("span",{className:"opacity-80",children:r.badge}),r.renderExtra?r.renderExtra(r):o==null?void 0:o(r)]},r.key)})})}export{b as F};
@@ -1 +1 @@
1
- import{r as L,j as e}from"./vendor-react-OhDMXABq.js";import{b as O,u as I,S as P,E as M,c as _,r as K,s as U}from"./index-BxPRo4R9.js";import{R as V,F as Y}from"./FileIcon-KX0Rfn5x.js";import{u as B}from"./usePluginData-BaCM6nnK.js";import{a as b}from"./fetchJson-D-dWeu1j.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";function h(r,n){return!n||r.name.toLowerCase().includes(n)?!0:(r.children??[]).some(l=>h(l,n))}const $="zd-view-collapse";function G(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return Array.isArray(n.wt)&&n.wt.every(l=>typeof l=="string")&&typeof n.root=="boolean"}const H=()=>K($,{wt:[],root:!1},G);function F(r){U($,JSON.stringify(r))}async function Q(){const r=await b("/__worktrees",{cache:"no-store"}),n={};await Promise.all(r.map(async i=>{const a=await b(`/__files?wt=${encodeURIComponent(i.path)}`,{cache:"no-store"});n[i.path]=a.tree??[]}));const l=await b("/__files",{cache:"no-store"});return{worktrees:r,wtTrees:n,rootTree:l.tree??[]}}function v({node:r,depth:n,filter:l,current:i,onSelectFile:a}){const{icon:f}=I(),d=r.children??[],p=!!l&&r.name.toLowerCase().includes(l)?d:d.filter(s=>h(s,l)),[x,g]=L.useState(!r.defaultCollapsed),o=l?!0:x;return!p.length&&l?null:e.jsxs("div",{children:[(()=>{const s=r.name.match(/^([a-z]+)(?: \((\d+)\))?$/),j=s?f(s[1]):void 0;return e.jsxs("button",{onClick:()=>g(u=>!u),"aria-expanded":o,className:"w-full flex items-center gap-1.5 px-2 py-1 text-sm text-foreground hover:bg-muted rounded-md mx-1",style:{paddingLeft:8+n*14,width:"calc(100% - 8px)"},children:[e.jsx("span",{className:`h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-transform ${o?"rotate-90":""}`,children:f("chevron-right")}),j?e.jsx("span",{className:"h-3.5 w-3.5 shrink-0 inline-flex items-center justify-center text-muted-foreground",children:j}):e.jsx("span",{className:"h-3.5 w-3.5 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-colors",children:f(o?"folder-open":"folder")}),e.jsx("span",{className:"font-medium truncate",children:s?s[1]:r.name}),(s==null?void 0:s[2])&&e.jsx("span",{className:"ml-auto mr-1 shrink-0 rounded-full bg-muted px-1.5 text-xs font-mono text-muted-foreground",children:s[2]})]})})(),o&&p.map(s=>s.kind==="dir"?e.jsx(v,{node:s,depth:n+1,filter:l,current:i,onSelectFile:a},s.name+n):e.jsxs("button",{onClick:()=>s.path&&a(s.path),className:`w-full flex items-center gap-1.5 pr-2 py-1 text-sm hover:bg-muted rounded-md mx-1 ${i===s.path?"bg-primary/10 text-foreground font-medium":"text-muted-foreground"}`,style:{paddingLeft:20+n*14,width:"calc(100% - 8px)"},children:[e.jsx(Y,{name:s.name,active:i===s.path}),e.jsx("span",{className:"truncate",children:s.name})]},s.path))]})}function ne(){var C,E,R;const r=O(),n=r.params,l=n.get("file"),i=n.get("wt"),a=(n.get("filter")??"").toLowerCase(),f=n.get("card")==="dirty",{icon:d}=I(),[m,p]=L.useState(H),x=new Set(m.wt),g=m.root,o=B("view:sidebar-trees",Q,{subscribe:"files"}),s=((C=o.data)==null?void 0:C.worktrees)??[],j=((E=o.data)==null?void 0:E.wtTrees)??{},u=((R=o.data)==null?void 0:R.rootTree)??[],A=t=>{const c=new Set(m.wt);c.has(t)?c.delete(t):c.add(t);const w={...m,wt:[...c]};p(w),F(w)},W=()=>{const t={...m,root:!m.root};p(t),F(t)},D=t=>{r.navigate({filter:t.trim()?t:null},{replace:!0})},N=s.length>0,z=!!a&&(s.some(t=>(j[t.path]??[]).some(c=>h(c,a)))||u.some(t=>h(t,a))),k=!a&&!!o.data&&!N&&u.length===0,S=!!a&&!!o.data&&!z;return e.jsx("div",{className:"p-2 flex flex-col h-full",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"w-full flex items-center gap-2",children:[e.jsx("input",{value:a,onChange:t=>D(t.target.value),placeholder:"过滤…","data-testid":"view-filter-input",className:"w-full h-7 px-2 text-xs rounded border border-border bg-background focus:border-primary"}),o.refreshing&&e.jsx(V,{})]}),e.jsxs("div",{className:"py-1 flex-1 min-h-0 overflow-auto flex flex-col","data-testid":"view-tree-scroller",children:[o.loading&&!o.data&&e.jsx(P,{rows:6,className:"mx-1 mt-1"}),o.error&&e.jsx(M,{message:o.error,onRetry:o.reload}),k&&e.jsx(_,{title:"暂无可展示的规格文件",hint:"约定扫描目录:openspec / docs / .zdev/apply"}),S&&e.jsx(_,{title:"无匹配结果",hint:"调整或清空过滤词后重试"}),!!o.data&&!o.error&&!k&&!S&&e.jsxs(e.Fragment,{children:[N&&s.map(t=>{const w=(j[t.path]??[]).filter(y=>h(y,a));if(!w.length&&a)return null;const T=f&&t.dirty;return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>A(t.path),"aria-expanded":!x.has(t.path),"data-drill-dirty":T?"true":void 0,className:`w-full flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md ${T?"bg-warning/10 ring-1 ring-warning":""}`,children:[e.jsx("span",{className:"h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-transform",children:d("chevron-right",x.has(t.path)?"":"rotate-90")}),e.jsx("span",{className:"h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground",children:d("git-branch")}),e.jsx("span",{className:"truncate",children:t.branch}),t.dirty&&e.jsx("span",{className:"ml-auto flex-none h-2 w-2 rounded-full bg-destructive shrink-0",title:"有未提交变更"})]}),!x.has(t.path)&&e.jsx("div",{className:"ml-2",children:w.map(y=>e.jsx(v,{node:y,depth:1,filter:a,current:i===t.path?l:null,onSelectFile:J=>r.navigate({wt:t.path,file:J})},y.name))})]},t.path)}),u.length>0&&(!a||u.some(t=>h(t,a)))&&e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:W,"aria-expanded":!g,className:"w-full flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-transform ${g?"":"rotate-90"}`,children:d("chevron-right")}),e.jsx("span",{className:"h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground",children:d("git-branch")}),e.jsx("span",{children:"当前分支"})]}),!g&&e.jsx("div",{className:"ml-2",children:u.filter(t=>h(t,a)).map(t=>e.jsx(v,{node:t,depth:1,filter:a,current:i?null:l,onSelectFile:c=>r.navigate({wt:null,file:c})},t.name))})]})]})]})]})})}export{ne as default};
1
+ import{r as L,j as e}from"./vendor-react-OhDMXABq.js";import{b as O,u as I,S as P,E as M,c as _,r as K,s as U}from"./index-DJ6COP3-.js";import{R as V,F as Y}from"./FileIcon-K_Wp_ZvI.js";import{u as B}from"./usePluginData-BVQYKC-X.js";import{a as b}from"./fetchJson-D-dWeu1j.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";function h(r,n){return!n||r.name.toLowerCase().includes(n)?!0:(r.children??[]).some(l=>h(l,n))}const $="zd-view-collapse";function G(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return Array.isArray(n.wt)&&n.wt.every(l=>typeof l=="string")&&typeof n.root=="boolean"}const H=()=>K($,{wt:[],root:!1},G);function F(r){U($,JSON.stringify(r))}async function Q(){const r=await b("/__worktrees",{cache:"no-store"}),n={};await Promise.all(r.map(async i=>{const a=await b(`/__files?wt=${encodeURIComponent(i.path)}`,{cache:"no-store"});n[i.path]=a.tree??[]}));const l=await b("/__files",{cache:"no-store"});return{worktrees:r,wtTrees:n,rootTree:l.tree??[]}}function v({node:r,depth:n,filter:l,current:i,onSelectFile:a}){const{icon:f}=I(),d=r.children??[],p=!!l&&r.name.toLowerCase().includes(l)?d:d.filter(s=>h(s,l)),[x,g]=L.useState(!r.defaultCollapsed),o=l?!0:x;return!p.length&&l?null:e.jsxs("div",{children:[(()=>{const s=r.name.match(/^([a-z]+)(?: \((\d+)\))?$/),j=s?f(s[1]):void 0;return e.jsxs("button",{onClick:()=>g(u=>!u),"aria-expanded":o,className:"w-full flex items-center gap-1.5 px-2 py-1 text-sm text-foreground hover:bg-muted rounded-md mx-1",style:{paddingLeft:8+n*14,width:"calc(100% - 8px)"},children:[e.jsx("span",{className:`h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-transform ${o?"rotate-90":""}`,children:f("chevron-right")}),j?e.jsx("span",{className:"h-3.5 w-3.5 shrink-0 inline-flex items-center justify-center text-muted-foreground",children:j}):e.jsx("span",{className:"h-3.5 w-3.5 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-colors",children:f(o?"folder-open":"folder")}),e.jsx("span",{className:"font-medium truncate",children:s?s[1]:r.name}),(s==null?void 0:s[2])&&e.jsx("span",{className:"ml-auto mr-1 shrink-0 rounded-full bg-muted px-1.5 text-xs font-mono text-muted-foreground",children:s[2]})]})})(),o&&p.map(s=>s.kind==="dir"?e.jsx(v,{node:s,depth:n+1,filter:l,current:i,onSelectFile:a},s.name+n):e.jsxs("button",{onClick:()=>s.path&&a(s.path),className:`w-full flex items-center gap-1.5 pr-2 py-1 text-sm hover:bg-muted rounded-md mx-1 ${i===s.path?"bg-primary/10 text-foreground font-medium":"text-muted-foreground"}`,style:{paddingLeft:20+n*14,width:"calc(100% - 8px)"},children:[e.jsx(Y,{name:s.name,active:i===s.path}),e.jsx("span",{className:"truncate",children:s.name})]},s.path))]})}function ne(){var C,E,R;const r=O(),n=r.params,l=n.get("file"),i=n.get("wt"),a=(n.get("filter")??"").toLowerCase(),f=n.get("card")==="dirty",{icon:d}=I(),[m,p]=L.useState(H),x=new Set(m.wt),g=m.root,o=B("view:sidebar-trees",Q,{subscribe:"files"}),s=((C=o.data)==null?void 0:C.worktrees)??[],j=((E=o.data)==null?void 0:E.wtTrees)??{},u=((R=o.data)==null?void 0:R.rootTree)??[],A=t=>{const c=new Set(m.wt);c.has(t)?c.delete(t):c.add(t);const w={...m,wt:[...c]};p(w),F(w)},W=()=>{const t={...m,root:!m.root};p(t),F(t)},D=t=>{r.navigate({filter:t.trim()?t:null},{replace:!0})},N=s.length>0,z=!!a&&(s.some(t=>(j[t.path]??[]).some(c=>h(c,a)))||u.some(t=>h(t,a))),k=!a&&!!o.data&&!N&&u.length===0,S=!!a&&!!o.data&&!z;return e.jsx("div",{className:"p-2 flex flex-col h-full",children:e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[e.jsxs("div",{className:"w-full flex items-center gap-2",children:[e.jsx("input",{value:a,onChange:t=>D(t.target.value),placeholder:"过滤…","data-testid":"view-filter-input",className:"w-full h-7 px-2 text-xs rounded border border-border bg-background focus:border-primary"}),o.refreshing&&e.jsx(V,{})]}),e.jsxs("div",{className:"py-1 flex-1 min-h-0 overflow-auto flex flex-col","data-testid":"view-tree-scroller",children:[o.loading&&!o.data&&e.jsx(P,{rows:6,className:"mx-1 mt-1"}),o.error&&e.jsx(M,{message:o.error,onRetry:o.reload}),k&&e.jsx(_,{title:"暂无可展示的规格文件",hint:"约定扫描目录:openspec / docs / .zdev/apply"}),S&&e.jsx(_,{title:"无匹配结果",hint:"调整或清空过滤词后重试"}),!!o.data&&!o.error&&!k&&!S&&e.jsxs(e.Fragment,{children:[N&&s.map(t=>{const w=(j[t.path]??[]).filter(y=>h(y,a));if(!w.length&&a)return null;const T=f&&t.dirty;return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>A(t.path),"aria-expanded":!x.has(t.path),"data-drill-dirty":T?"true":void 0,className:`w-full flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md ${T?"bg-warning/10 ring-1 ring-warning":""}`,children:[e.jsx("span",{className:"h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-transform",children:d("chevron-right",x.has(t.path)?"":"rotate-90")}),e.jsx("span",{className:"h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground",children:d("git-branch")}),e.jsx("span",{className:"truncate",children:t.branch}),t.dirty&&e.jsx("span",{className:"ml-auto flex-none h-2 w-2 rounded-full bg-destructive shrink-0",title:"有未提交变更"})]}),!x.has(t.path)&&e.jsx("div",{className:"ml-2",children:w.map(y=>e.jsx(v,{node:y,depth:1,filter:a,current:i===t.path?l:null,onSelectFile:J=>r.navigate({wt:t.path,file:J})},y.name))})]},t.path)}),u.length>0&&(!a||u.some(t=>h(t,a)))&&e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:W,"aria-expanded":!g,className:"w-full flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground transition-transform ${g?"":"rotate-90"}`,children:d("chevron-right")}),e.jsx("span",{className:"h-3 w-3 shrink-0 inline-flex items-center justify-center text-muted-foreground",children:d("git-branch")}),e.jsx("span",{children:"当前分支"})]}),!g&&e.jsx("div",{className:"ml-2",children:u.filter(t=>h(t,a)).map(t=>e.jsx(v,{node:t,depth:1,filter:a,current:i?null:l,onSelectFile:c=>r.navigate({wt:null,file:c})},t.name))})]})]})]})]})})}export{ne as default};
@@ -1 +1 @@
1
- import{r as m,j as e}from"./vendor-react-OhDMXABq.js";import{R as b,F as k}from"./FileIcon-KX0Rfn5x.js";import{b as j,u as f,S,E as N,c as u,s as v,r as G}from"./index-BxPRo4R9.js";import{u as O}from"./usePluginData-BaCM6nnK.js";import{a as R}from"./fetchJson-D-dWeu1j.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";const x="zd-design-groups";function E(o){return!o||typeof o!="object"||Array.isArray(o)?!1:Object.values(o).every(a=>typeof a=="boolean")}const _=()=>G(x,{},E),w={page:"monitor",component:"blocks",icon:"shapes",token:"palette",md:"book-open",video:"video",audio:"audio-lines",pdf:"file-text",font:"type",diagram:"pen-tool"},I=[{key:"page",label:"页面"},{key:"component",label:"组件"},{key:"icon",label:"图标"},{key:"token",label:"Tokens"},{key:"md",label:"文档"},{key:"video",label:"视频"},{key:"audio",label:"音频"},{key:"pdf",label:"PDF"},{key:"font",label:"字体"},{key:"diagram",label:"图表"}];function U(){const o=j(),a=o.params,c=a.get("asset"),d=a.get("type"),r=a.get("folder");f();const t=O("design:/__design/assets",()=>R("/__design/assets",{cache:"no-store"}),{subscribe:"files"}),i=m.useMemo(()=>{const s=t.data;return s?I.map(l=>({...l,items:(s[l.key]??[]).filter(y=>!r||y.path.startsWith(r))})).filter(l=>l.items.length>0):[]},[t.data,r]),n=s=>o.navigate({type:s.type,asset:s.path}),[p,g]=m.useState(_),h=s=>{const l={...p,[s]:!(p[s]??!0)};g(l),v(x,JSON.stringify(l))};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"p-3 text-xs text-muted-foreground truncate flex-none flex items-center gap-2",children:["设计资产",t.refreshing&&e.jsx(b,{})]}),t.loading&&!t.data&&e.jsx(S,{rows:6,className:"mx-3"}),t.error&&e.jsx(N,{message:t.error,onRetry:t.reload}),!t.error&&(t.data||!t.loading)&&i.length===0&&(r?e.jsx(u,{title:"无匹配结果",hint:`目录过滤 "${r}" 无匹配资产,调整或清空后重试`}):e.jsx(u,{title:"未发现 .zdev/design 资产",hint:"运行 zdesign 生成"})),i.map(s=>e.jsx(P,{group:s,open:p[s.key]??!0,onToggle:()=>h(s.key),current:c&&d===s.key?c:null,onSelect:n},s.key))]})}function P({group:o,open:a,onToggle:c,current:d,onSelect:r}){const{icon:t}=f(),i=w[o.key];return e.jsxs("div",{className:"mb-1.5 px-1",children:[e.jsxs("button",{onClick:c,"aria-expanded":a,className:"w-full flex items-center gap-1.5 pt-2 pb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground hover:text-foreground rounded-md",children:[t("chevron-right",`h-3 w-3 shrink-0 transition-transform ${a?"rotate-90":""}`),i&&t(i,"h-3.5 w-3.5 shrink-0"),e.jsx("span",{className:"truncate",children:o.label}),e.jsx("span",{className:"ml-auto shrink-0 rounded-full bg-muted px-1.5 font-mono text-xs font-normal",children:o.items.length})]}),a&&o.items.map(n=>e.jsxs("button",{onClick:()=>r(n),className:`w-full text-left flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-muted rounded-md ${d===n.path?"bg-primary/10 text-foreground font-medium":"text-muted-foreground"}`,children:[e.jsx(k,{name:n.name,active:d===n.path}),e.jsx("span",{className:"truncate",children:n.name}),n.ext&&e.jsx("span",{className:"ml-auto font-mono text-xs text-muted-foreground/60",children:n.ext})]},n.path))]})}export{U as default};
1
+ import{r as m,j as e}from"./vendor-react-OhDMXABq.js";import{R as b,F as k}from"./FileIcon-K_Wp_ZvI.js";import{b as j,u as f,S,E as N,c as u,s as v,r as G}from"./index-DJ6COP3-.js";import{u as O}from"./usePluginData-BVQYKC-X.js";import{a as R}from"./fetchJson-D-dWeu1j.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";const x="zd-design-groups";function E(o){return!o||typeof o!="object"||Array.isArray(o)?!1:Object.values(o).every(a=>typeof a=="boolean")}const _=()=>G(x,{},E),w={page:"monitor",component:"blocks",icon:"shapes",token:"palette",md:"book-open",video:"video",audio:"audio-lines",pdf:"file-text",font:"type",diagram:"pen-tool"},I=[{key:"page",label:"页面"},{key:"component",label:"组件"},{key:"icon",label:"图标"},{key:"token",label:"Tokens"},{key:"md",label:"文档"},{key:"video",label:"视频"},{key:"audio",label:"音频"},{key:"pdf",label:"PDF"},{key:"font",label:"字体"},{key:"diagram",label:"图表"}];function U(){const o=j(),a=o.params,c=a.get("asset"),d=a.get("type"),r=a.get("folder");f();const t=O("design:/__design/assets",()=>R("/__design/assets",{cache:"no-store"}),{subscribe:"files"}),i=m.useMemo(()=>{const s=t.data;return s?I.map(l=>({...l,items:(s[l.key]??[]).filter(y=>!r||y.path.startsWith(r))})).filter(l=>l.items.length>0):[]},[t.data,r]),n=s=>o.navigate({type:s.type,asset:s.path}),[p,g]=m.useState(_),h=s=>{const l={...p,[s]:!(p[s]??!0)};g(l),v(x,JSON.stringify(l))};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"p-3 text-xs text-muted-foreground truncate flex-none flex items-center gap-2",children:["设计资产",t.refreshing&&e.jsx(b,{})]}),t.loading&&!t.data&&e.jsx(S,{rows:6,className:"mx-3"}),t.error&&e.jsx(N,{message:t.error,onRetry:t.reload}),!t.error&&(t.data||!t.loading)&&i.length===0&&(r?e.jsx(u,{title:"无匹配结果",hint:`目录过滤 "${r}" 无匹配资产,调整或清空后重试`}):e.jsx(u,{title:"未发现 .zdev/design 资产",hint:"运行 zdesign 生成"})),i.map(s=>e.jsx(P,{group:s,open:p[s.key]??!0,onToggle:()=>h(s.key),current:c&&d===s.key?c:null,onSelect:n},s.key))]})}function P({group:o,open:a,onToggle:c,current:d,onSelect:r}){const{icon:t}=f(),i=w[o.key];return e.jsxs("div",{className:"mb-1.5 px-1",children:[e.jsxs("button",{onClick:c,"aria-expanded":a,className:"w-full flex items-center gap-1.5 pt-2 pb-1 text-sm font-semibold uppercase tracking-wide text-muted-foreground hover:text-foreground rounded-md",children:[t("chevron-right",`h-3 w-3 shrink-0 transition-transform ${a?"rotate-90":""}`),i&&t(i,"h-3.5 w-3.5 shrink-0"),e.jsx("span",{className:"truncate",children:o.label}),e.jsx("span",{className:"ml-auto shrink-0 rounded-full bg-muted px-1.5 font-mono text-xs font-normal",children:o.items.length})]}),a&&o.items.map(n=>e.jsxs("button",{onClick:()=>r(n),className:`w-full text-left flex items-center gap-2 px-2.5 py-1.5 text-xs hover:bg-muted rounded-md ${d===n.path?"bg-primary/10 text-foreground font-medium":"text-muted-foreground"}`,children:[e.jsx(k,{name:n.name,active:d===n.path}),e.jsx("span",{className:"truncate",children:n.name}),n.ext&&e.jsx("span",{className:"ml-auto font-mono text-xs text-muted-foreground/60",children:n.ext})]},n.path))]})}export{U as default};
@@ -1 +1 @@
1
- import{j as e,r as u}from"./vendor-react-OhDMXABq.js";import{u as C,R as M,C as g,M as O,I as W,D as V}from"./DiagramViewer-CQYfB79k.js";import{u as v,R as L,a as R,P as _,c as T}from"./index-BxPRo4R9.js";import{m as I}from"./web-CmZk5ox_.js";import"./vendor-ui-D8qdFUhC.js";import"./fetchJson-D-dWeu1j.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function U({path:t,resolve:n}){const[o,r]=C(),m=t.split("/").pop(),c=n?n(t):"/"+encodeURI(t),d=o?`${c}${c.includes("?")?"&":"?"}v=${o}`:c;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-none px-4 py-2 border-b text-xs flex items-center gap-3",children:[e.jsx("span",{className:"font-mono text-foreground",children:m}),e.jsx("div",{className:"ml-auto",children:e.jsx(M,{onClick:r})})]}),e.jsx("iframe",{src:d,title:m,className:"flex-1 min-h-0 w-full bg-background"})]})}function $({path:t}){const{icon:n}=v();return e.jsx("div",{className:"grid place-items-center h-full text-center text-muted-foreground",children:e.jsxs("div",{children:[n("file-question","h-10 w-10 mx-auto mb-3 opacity-50"),e.jsx("p",{children:"该格式无法预览"}),e.jsx("p",{className:"mt-1 font-mono text-xs break-all",children:t})]})})}const b=176,j=400,p=176,w="zd-outline-w",q=t=>Math.min(j,Math.max(b,t));function A(){try{const t=localStorage.getItem(w);if(t===null)return p;const n=Number(t);return Number.isFinite(n)&&n>=b&&n<=j?n:p}catch{return p}}function F({containerRef:t}){const{icon:n}=v(),[o,r]=u.useState([]),[m,c]=u.useState(null),[d,N]=u.useState(A),S=(s,l)=>{const i=q(s);if(N(i),l)try{localStorage.setItem(w,String(i))}catch{}},k=()=>{N(p);try{localStorage.removeItem(w)}catch{}};u.useEffect(()=>{const s=t.current;if(!s)return;let l=!1;const i=()=>{if(l)return;const x=s.querySelectorAll("h1[id], h2[id], h3[id]"),h=[];x.forEach(f=>{var y;h.push({id:f.id,text:((y=f.textContent)==null?void 0:y.trim())??"",level:parseInt(f.tagName[1],10)})}),r(h)};i();const a=new MutationObserver(i);return a.observe(s,{childList:!0,subtree:!0,characterData:!0}),()=>{l=!0,a.disconnect()}},[t]),u.useEffect(()=>{const s=t.current;if(!s||!o.length)return;const l=new IntersectionObserver(i=>{const a=i.filter(x=>x.isIntersecting);if(a.length){const x=a.reduce((h,f)=>h.boundingClientRect.top<f.boundingClientRect.top?h:f);c(x.target.id)}},{root:s,rootMargin:"-60px 0px -70% 0px",threshold:0});return o.forEach(({id:i})=>{const a=s.querySelector(`#${CSS.escape(i)}`);a&&l.observe(a)}),()=>l.disconnect()},[o,t]);const E=s=>{var i;const l=(i=t.current)==null?void 0:i.querySelector(`#${CSS.escape(s)}`);l==null||l.scrollIntoView({behavior:"smooth",block:"start"})};return o.length?e.jsxs("nav",{className:"hidden md:flex shrink-0 border-l py-2 overflow-hidden",style:{width:`${d}px`},"aria-label":"文档大纲",children:[e.jsx(L,{orientation:"vertical",invert:!0,min:b,max:j,value:d,onChange:S,onReset:k,label:"调整大纲宽度",className:"flex-none w-1.5 cursor-col-resize self-stretch"}),e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 overflow-y-auto pl-3",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 text-sm font-medium text-muted-foreground uppercase tracking-wider",children:[n("file-text","h-3 w-3"),e.jsx("span",{children:"大纲"})]}),e.jsx("ul",{className:"space-y-0.5",children:o.map(s=>e.jsx("li",{children:e.jsx("button",{type:"button",title:s.text,onClick:()=>E(s.id),className:`w-full text-left text-sm leading-snug py-0.5 px-1.5 rounded line-clamp-2 transition-colors ${m===s.id?"bg-primary/10 text-foreground font-medium":"text-muted-foreground hover:bg-muted/70"}`,style:{paddingLeft:6+Math.min(s.level-1,2)*10},children:s.text||s.id})},s.id))})]})]}):null}function z(t){const n=t.slice(t.lastIndexOf("/")+1).toLowerCase();if(n==="justfile"||n==="makefile")return g;const o=n.lastIndexOf("."),r=o>=0?n.slice(o):"";return r===".md"||r===".markdown"?O:[".svg",".png",".jpg",".jpeg",".gif",".webp",".ico"].includes(r)?W:[".pdf",".html",".htm"].includes(r)?U:[".excalidraw",".drawio"].includes(r)?V:[".sql",".txt",".csv",".tsv",".json",".yaml",".yml",".xml",".py",".js",".ts",".java",".go",".rs",".rb",".php",".c",".cpp",".h",".cs",".swift",".kt",".scala",".sh",".bash",".zsh",".fish",".env",".gitignore",".dockerfile"].includes(r)?g:o===-1?g:$}function J({params:t}){const{icon:n}=v(),o=R(I.mode,"h-5 w-5"),r=t.get("file"),m=t.get("wt"),c=u.useRef(null),d=r?z(r):null;return u.useEffect(()=>{c.current&&(c.current.scrollTop=0)},[r]),e.jsx(_,{manifest:I,icon:o,breadcrumb:["插件",m??"当前分支",...r?[r]:[]],children:e.jsx("div",{className:"mx-auto h-full max-w-5xl bg-background border rounded-lg shadow-sm overflow-hidden flex flex-col",children:r&&d?e.jsxs("div",{className:"flex-1 min-h-0 flex overflow-hidden",children:[e.jsx("div",{ref:c,className:"flex-1 min-h-0 overflow-auto",children:e.jsx(d,{path:r})}),e.jsx(F,{containerRef:c})]}):e.jsx(T,{icon:n("eye","h-6 w-6"),title:"从左侧选择文件预览",hint:"支持 Markdown、图片、代码等格式"})})})}export{J as default};
1
+ import{j as e,r as u}from"./vendor-react-OhDMXABq.js";import{u as C,R as M,C as g,M as O,I as W,D as V}from"./DiagramViewer-CVyfeqsA.js";import{u as v,R as L,a as R,P as _,c as T}from"./index-DJ6COP3-.js";import{m as I}from"./web-CzoLB8PU.js";import"./vendor-ui-D8qdFUhC.js";import"./fetchJson-D-dWeu1j.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function U({path:t,resolve:n}){const[o,r]=C(),m=t.split("/").pop(),c=n?n(t):"/"+encodeURI(t),d=o?`${c}${c.includes("?")?"&":"?"}v=${o}`:c;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex-none px-4 py-2 border-b text-xs flex items-center gap-3",children:[e.jsx("span",{className:"font-mono text-foreground",children:m}),e.jsx("div",{className:"ml-auto",children:e.jsx(M,{onClick:r})})]}),e.jsx("iframe",{src:d,title:m,className:"flex-1 min-h-0 w-full bg-background"})]})}function $({path:t}){const{icon:n}=v();return e.jsx("div",{className:"grid place-items-center h-full text-center text-muted-foreground",children:e.jsxs("div",{children:[n("file-question","h-10 w-10 mx-auto mb-3 opacity-50"),e.jsx("p",{children:"该格式无法预览"}),e.jsx("p",{className:"mt-1 font-mono text-xs break-all",children:t})]})})}const b=176,j=400,p=176,w="zd-outline-w",q=t=>Math.min(j,Math.max(b,t));function A(){try{const t=localStorage.getItem(w);if(t===null)return p;const n=Number(t);return Number.isFinite(n)&&n>=b&&n<=j?n:p}catch{return p}}function F({containerRef:t}){const{icon:n}=v(),[o,r]=u.useState([]),[m,c]=u.useState(null),[d,N]=u.useState(A),S=(s,l)=>{const i=q(s);if(N(i),l)try{localStorage.setItem(w,String(i))}catch{}},k=()=>{N(p);try{localStorage.removeItem(w)}catch{}};u.useEffect(()=>{const s=t.current;if(!s)return;let l=!1;const i=()=>{if(l)return;const x=s.querySelectorAll("h1[id], h2[id], h3[id]"),h=[];x.forEach(f=>{var y;h.push({id:f.id,text:((y=f.textContent)==null?void 0:y.trim())??"",level:parseInt(f.tagName[1],10)})}),r(h)};i();const a=new MutationObserver(i);return a.observe(s,{childList:!0,subtree:!0,characterData:!0}),()=>{l=!0,a.disconnect()}},[t]),u.useEffect(()=>{const s=t.current;if(!s||!o.length)return;const l=new IntersectionObserver(i=>{const a=i.filter(x=>x.isIntersecting);if(a.length){const x=a.reduce((h,f)=>h.boundingClientRect.top<f.boundingClientRect.top?h:f);c(x.target.id)}},{root:s,rootMargin:"-60px 0px -70% 0px",threshold:0});return o.forEach(({id:i})=>{const a=s.querySelector(`#${CSS.escape(i)}`);a&&l.observe(a)}),()=>l.disconnect()},[o,t]);const E=s=>{var i;const l=(i=t.current)==null?void 0:i.querySelector(`#${CSS.escape(s)}`);l==null||l.scrollIntoView({behavior:"smooth",block:"start"})};return o.length?e.jsxs("nav",{className:"hidden md:flex shrink-0 border-l py-2 overflow-hidden",style:{width:`${d}px`},"aria-label":"文档大纲",children:[e.jsx(L,{orientation:"vertical",invert:!0,min:b,max:j,value:d,onChange:S,onReset:k,label:"调整大纲宽度",className:"flex-none w-1.5 cursor-col-resize self-stretch"}),e.jsxs("div",{className:"flex-1 min-w-0 min-h-0 overflow-y-auto pl-3",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 text-sm font-medium text-muted-foreground uppercase tracking-wider",children:[n("file-text","h-3 w-3"),e.jsx("span",{children:"大纲"})]}),e.jsx("ul",{className:"space-y-0.5",children:o.map(s=>e.jsx("li",{children:e.jsx("button",{type:"button",title:s.text,onClick:()=>E(s.id),className:`w-full text-left text-sm leading-snug py-0.5 px-1.5 rounded line-clamp-2 transition-colors ${m===s.id?"bg-primary/10 text-foreground font-medium":"text-muted-foreground hover:bg-muted/70"}`,style:{paddingLeft:6+Math.min(s.level-1,2)*10},children:s.text||s.id})},s.id))})]})]}):null}function z(t){const n=t.slice(t.lastIndexOf("/")+1).toLowerCase();if(n==="justfile"||n==="makefile")return g;const o=n.lastIndexOf("."),r=o>=0?n.slice(o):"";return r===".md"||r===".markdown"?O:[".svg",".png",".jpg",".jpeg",".gif",".webp",".ico"].includes(r)?W:[".pdf",".html",".htm"].includes(r)?U:[".excalidraw",".drawio"].includes(r)?V:[".sql",".txt",".csv",".tsv",".json",".yaml",".yml",".xml",".py",".js",".ts",".java",".go",".rs",".rb",".php",".c",".cpp",".h",".cs",".swift",".kt",".scala",".sh",".bash",".zsh",".fish",".env",".gitignore",".dockerfile"].includes(r)?g:o===-1?g:$}function J({params:t}){const{icon:n}=v(),o=R(I.mode,"h-5 w-5"),r=t.get("file"),m=t.get("wt"),c=u.useRef(null),d=r?z(r):null;return u.useEffect(()=>{c.current&&(c.current.scrollTop=0)},[r]),e.jsx(_,{manifest:I,icon:o,breadcrumb:["插件",m??"当前分支",...r?[r]:[]],children:e.jsx("div",{className:"mx-auto h-full max-w-5xl bg-background border rounded-lg shadow-sm overflow-hidden flex flex-col",children:r&&d?e.jsxs("div",{className:"flex-1 min-h-0 flex overflow-hidden",children:[e.jsx("div",{ref:c,className:"flex-1 min-h-0 overflow-auto",children:e.jsx(d,{path:r})}),e.jsx(F,{containerRef:c})]}):e.jsx(T,{icon:n("eye","h-6 w-6"),title:"从左侧选择文件预览",hint:"支持 Markdown、图片、代码等格式"})})})}export{J as default};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-react-OhDMXABq.js";import{d as g,u as h,a as j,b as v,E as N,S as y,f as w,P as _}from"./index-BxPRo4R9.js";import{u}from"./usePluginData-BaCM6nnK.js";import{a as m}from"./fetchJson-D-dWeu1j.js";import{m as n}from"./web-C7ddFKgL.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function k({value:i,className:l}){const r=Math.max(0,Math.min(100,i));return e.jsx("div",{className:g("rounded-[var(--radius-full)] bg-muted overflow-hidden",l),role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuetext":`${r}%`,children:e.jsx("div",{className:"h-full rounded-[var(--radius-full)] bg-primary transition-all",style:{width:`${r}%`}})})}function F(i){var d,c;const{icon:l}=h(),r=j(n.mode,"h-5 w-5"),x=v(),a=u("stats:/__stats/data",()=>m("/__stats/data",{cache:"no-store"}),{subscribe:"files"}),o=u("stats:/__detect",()=>m("/__detect",{cache:"no-store"}));if(a.error)return e.jsx("div",{className:"h-full flex flex-col",children:e.jsx(N,{message:a.error,onRetry:a.reload})});if(!a.data)return e.jsx("div",{className:"h-full p-6",children:e.jsx(y,{rows:8})});const s=a.data,f=Math.max(...s.byExt.map(t=>t.count),1),p=[{label:"文件",value:String(s.files),iconName:"file-text",drill:null},{label:"目录",value:String(s.dirs),iconName:"folder-tree",drill:null},{label:"总大小",value:w(s.totalSize),iconName:null,drill:null},{label:"Worktree",value:String(s.worktrees),iconName:"git-branch",drill:"worktree"},{label:"未提交",value:String(s.dirty??0),iconName:null,drill:"dirty"}],b=t=>x.navigate({p:"view",card:t});return e.jsx(_,{manifest:n,icon:r,breadcrumb:["插件",n.mode],children:e.jsxs("div",{className:"mx-auto h-full max-w-6xl overflow-auto rounded-lg border bg-background p-6 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-5",children:"后端 fs 扫描 + 前端渲染 · 改文件即时刷新 · 点击卡片跳转"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 mb-6",children:p.map(t=>e.jsxs("button",{type:"button",onClick:()=>t.drill&&b(t.drill),disabled:!t.drill,title:t.drill?`点击跳转至 ${t.label}`:void 0,className:`rounded-lg border bg-background p-4 text-left transition-colors ${t.drill?"hover:bg-muted/70 cursor-pointer":"cursor-default opacity-80"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-xl font-bold",children:t.value}),t.iconName&&l(t.iconName,"h-4 w-4 text-muted-foreground/50")]}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t.label})]},t.label))}),e.jsx("h2",{className:"text-xs font-medium text-muted-foreground mb-3",children:"文件类型 Top 10"}),e.jsx("div",{className:"space-y-2",children:s.byExt.map(t=>e.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"w-16 font-mono text-foreground truncate",children:t.ext}),e.jsx(k,{value:parseFloat((t.count/f*100).toFixed(1)),className:"flex-1 h-2"}),e.jsx("span",{className:"w-8 text-right font-mono text-muted-foreground",children:t.count})]},t.ext))}),e.jsxs("div",{className:"mt-5 flex items-center gap-2 text-xs",children:[o.error?e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded border text-muted-foreground border-border",children:"justfile 探测失败"}):e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded border ${(d=o.data)!=null&&d.hasJust?"text-success border-success/30 bg-success/10":"text-muted-foreground border-border"}`,children:["justfile ",(c=o.data)!=null&&c.hasJust?"✓":"✗"]}),typeof s.dirty=="number"&&e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded border ${s.dirty?"text-warning border-warning/30 bg-warning/10":"text-success border-success/30 bg-success/10"}`,children:s.dirty?`${s.dirty} 未提交`:"clean"}),e.jsxs("span",{className:"text-muted-foreground",children:["root: ",s.root]})]})]})})}export{F as default};
1
+ import{j as e}from"./vendor-react-OhDMXABq.js";import{d as g,u as h,a as j,b as v,E as N,S as y,f as w,P as _}from"./index-DJ6COP3-.js";import{u}from"./usePluginData-BVQYKC-X.js";import{a as m}from"./fetchJson-D-dWeu1j.js";import{m as n}from"./web-DBVl3bA2.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function k({value:i,className:l}){const r=Math.max(0,Math.min(100,i));return e.jsx("div",{className:g("rounded-[var(--radius-full)] bg-muted overflow-hidden",l),role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuetext":`${r}%`,children:e.jsx("div",{className:"h-full rounded-[var(--radius-full)] bg-primary transition-all",style:{width:`${r}%`}})})}function F(i){var d,c;const{icon:l}=h(),r=j(n.mode,"h-5 w-5"),x=v(),a=u("stats:/__stats/data",()=>m("/__stats/data",{cache:"no-store"}),{subscribe:"files"}),o=u("stats:/__detect",()=>m("/__detect",{cache:"no-store"}));if(a.error)return e.jsx("div",{className:"h-full flex flex-col",children:e.jsx(N,{message:a.error,onRetry:a.reload})});if(!a.data)return e.jsx("div",{className:"h-full p-6",children:e.jsx(y,{rows:8})});const s=a.data,f=Math.max(...s.byExt.map(t=>t.count),1),p=[{label:"文件",value:String(s.files),iconName:"file-text",drill:null},{label:"目录",value:String(s.dirs),iconName:"folder-tree",drill:null},{label:"总大小",value:w(s.totalSize),iconName:null,drill:null},{label:"Worktree",value:String(s.worktrees),iconName:"git-branch",drill:"worktree"},{label:"未提交",value:String(s.dirty??0),iconName:null,drill:"dirty"}],b=t=>x.navigate({p:"view",card:t});return e.jsx(_,{manifest:n,icon:r,breadcrumb:["插件",n.mode],children:e.jsxs("div",{className:"mx-auto h-full max-w-6xl overflow-auto rounded-lg border bg-background p-6 shadow-sm",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-5",children:"后端 fs 扫描 + 前端渲染 · 改文件即时刷新 · 点击卡片跳转"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 mb-6",children:p.map(t=>e.jsxs("button",{type:"button",onClick:()=>t.drill&&b(t.drill),disabled:!t.drill,title:t.drill?`点击跳转至 ${t.label}`:void 0,className:`rounded-lg border bg-background p-4 text-left transition-colors ${t.drill?"hover:bg-muted/70 cursor-pointer":"cursor-default opacity-80"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-xl font-bold",children:t.value}),t.iconName&&l(t.iconName,"h-4 w-4 text-muted-foreground/50")]}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t.label})]},t.label))}),e.jsx("h2",{className:"text-xs font-medium text-muted-foreground mb-3",children:"文件类型 Top 10"}),e.jsx("div",{className:"space-y-2",children:s.byExt.map(t=>e.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"w-16 font-mono text-foreground truncate",children:t.ext}),e.jsx(k,{value:parseFloat((t.count/f*100).toFixed(1)),className:"flex-1 h-2"}),e.jsx("span",{className:"w-8 text-right font-mono text-muted-foreground",children:t.count})]},t.ext))}),e.jsxs("div",{className:"mt-5 flex items-center gap-2 text-xs",children:[o.error?e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded border text-muted-foreground border-border",children:"justfile 探测失败"}):e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded border ${(d=o.data)!=null&&d.hasJust?"text-success border-success/30 bg-success/10":"text-muted-foreground border-border"}`,children:["justfile ",(c=o.data)!=null&&c.hasJust?"✓":"✗"]}),typeof s.dirty=="number"&&e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded border ${s.dirty?"text-warning border-warning/30 bg-warning/10":"text-success border-success/30 bg-success/10"}`,children:s.dirty?`${s.dirty} 未提交`:"clean"}),e.jsxs("span",{className:"text-muted-foreground",children:["root: ",s.root]})]})]})})}export{F as default};
@@ -1,4 +1,4 @@
1
- import{r as h,c as S,j as f}from"./vendor-react-OhDMXABq.js";import{u as ht,S as Le,E as gt,c as mt,B as $,a as pt,b as xt,P as Dt}from"./index-BxPRo4R9.js";import{F as Me}from"./FilterPills-D2zZaent.js";import{u as te}from"./vendor-ui-D8qdFUhC.js";import{u as bt}from"./usePluginData-BaCM6nnK.js";import{a as $e}from"./fetchJson-D-dWeu1j.js";import{m as ge}from"./web-oi27dtPg.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function x(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function re(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function Ft(t,e){const s=x(t);return isNaN(e)?re(t,NaN):(e&&s.setDate(s.getDate()+e),s)}function vt(t,e){const s=x(t);if(isNaN(e))return re(t,NaN);if(!e)return s;const r=s.getDate(),n=re(t,s.getTime());n.setMonth(s.getMonth()+e+1,0);const i=n.getDate();return r>=i?n:(s.setFullYear(n.getFullYear(),n.getMonth(),r),s)}function W(t,e){const{years:s=0,months:r=0,weeks:n=0,days:i=0,hours:c=0,minutes:o=0,seconds:d=0}=e,a=x(t),m=r||s?vt(a,r+s*12):a,_=i||n?Ft(m,i+n*7):m,v=o+c*60,b=(d+v*60)*1e3;return re(t,_.getTime()+b)}const yt=864e5,Et=6e4,Ct=36e5;function Ie(t){const e=x(t);return e.setHours(0,0,0,0),e}function Be(t){const e=x(t),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+t-+s}function jt(t,e){const s=Ie(t),r=Ie(e),n=+s-Be(s),i=+r-Be(r);return Math.round((n-i)/yt)}function G(t,e){const s=x(t),r=x(e),n=s.getTime()-r.getTime();return n<0?-1:n>0?1:n}function wt(t,e){const s=x(t),r=x(e),n=s.getFullYear()-r.getFullYear(),i=s.getMonth()-r.getMonth();return n*12+i}function At(t,e){const s=x(t),r=x(e);return s.getFullYear()-r.getFullYear()}function zt(t,e){const s=x(t),r=x(e),n=Pe(s,r),i=Math.abs(jt(s,r));s.setDate(s.getDate()-n*i);const c=+(Pe(s,r)===-n),o=n*(i-c);return o===0?0:o}function Pe(t,e){const s=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return s<0?-1:s>0?1:s}function ye(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function Ee(t,e){return+x(t)-+x(e)}function kt(t,e,s){const r=Ee(t,e)/Ct;return ye(s==null?void 0:s.roundingMethod)(r)}function Nt(t,e,s){const r=Ee(t,e)/Et;return ye(s==null?void 0:s.roundingMethod)(r)}function Rt(t){const e=x(t);return e.setHours(23,59,59,999),e}function St(t){const e=x(t),s=e.getMonth();return e.setFullYear(e.getFullYear(),s+1,0),e.setHours(23,59,59,999),e}function Ot(t){const e=x(t);return+Rt(e)==+St(e)}function Tt(t,e){const s=x(t),r=x(e),n=G(s,r),i=Math.abs(wt(s,r));let c;if(i<1)c=0;else{s.getMonth()===1&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-n*i);let o=G(s,r)===-n;Ot(x(t))&&i===1&&G(t,r)===1&&(o=!1),c=n*(i-Number(o))}return c===0?0:c}function Lt(t,e,s){const r=Ee(t,e)/1e3;return ye(s==null?void 0:s.roundingMethod)(r)}function Mt(t,e){const s=x(t),r=x(e),n=G(s,r),i=Math.abs(At(s,r));s.setFullYear(1584),r.setFullYear(1584);const c=G(s,r)===-n,o=n*(i-+c);return o===0?0:o}function $t(t){const e=x(t.start),s=x(t.end),r={},n=Mt(s,e);n&&(r.years=n);const i=W(e,{years:r.years}),c=Tt(s,i);c&&(r.months=c);const o=W(i,{months:r.months}),d=zt(s,o);d&&(r.days=d);const a=W(o,{days:r.days}),m=kt(s,a);m&&(r.hours=m);const _=W(a,{hours:r.hours}),v=Nt(s,_);v&&(r.minutes=v);const y=W(_,{minutes:r.minutes}),b=Lt(s,y);return b&&(r.seconds=b),r}const It=40,se=1e3;function Ze(t,e,s,r=It){return t-e-s<r}function Bt(t){return/^\[(ERROR|FATAL)\]/.test(t)||/^ERROR\b/.test(t)?"error":/^\[(WARN|WARNING)\]/.test(t)||/^WARN(ING)?\b/.test(t)?"warn":/^\[DEBUG\]/.test(t)||/^DEBUG\b/.test(t)?"info":/^\[(INFO|DOWNLOAD|PROGRESS)\]/.test(t)||/^INFO\b/.test(t)?"success":"plain"}function Fe(t){switch(Bt(t)){case"error":return"text-destructive";case"warn":return"text-warning";case"info":return"text-info";case"success":return"text-success";default:return"text-terminal-fg"}}function Pt(t,e){if(!e)return null;const s=t.toLowerCase(),r=e.toLowerCase(),n=[];let i=0,c=!1;for(;i<t.length;){const o=s.indexOf(r,i);if(o<0){n.push({text:t.slice(i),hit:!1});break}o>i&&n.push({text:t.slice(i,o),hit:!1}),n.push({text:t.slice(o,o+r.length),hit:!0}),c=!0,i=o+r.length}return c?n:null}var et={};const N=[[{color:"0, 0, 0",class:"ansi-black"},{color:"187, 0, 0",class:"ansi-red"},{color:"0, 187, 0",class:"ansi-green"},{color:"187, 187, 0",class:"ansi-yellow"},{color:"0, 0, 187",class:"ansi-blue"},{color:"187, 0, 187",class:"ansi-magenta"},{color:"0, 187, 187",class:"ansi-cyan"},{color:"255,255,255",class:"ansi-white"}],[{color:"85, 85, 85",class:"ansi-bright-black"},{color:"255, 85, 85",class:"ansi-bright-red"},{color:"0, 255, 0",class:"ansi-bright-green"},{color:"255, 255, 85",class:"ansi-bright-yellow"},{color:"85, 85, 255",class:"ansi-bright-blue"},{color:"255, 85, 255",class:"ansi-bright-magenta"},{color:"85, 255, 255",class:"ansi-bright-cyan"},{color:"255, 255, 255",class:"ansi-bright-white"}]],Zt=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;class I{static escapeForHtml(e){return new I().escapeForHtml(e)}static linkify(e){return new I().linkify(e)}static ansiToHtml(e,s){return new I().ansiToHtml(e,s)}static ansiToJson(e,s){return new I().ansiToJson(e,s)}static ansiToText(e){return new I().ansiToText(e)}constructor(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0,this.decorations=[]}setupPalette(){this.PALETTE_COLORS=[];for(let n=0;n<2;++n)for(let i=0;i<8;++i)this.PALETTE_COLORS.push(N[n][i].color);let e=[0,95,135,175,215,255],s=(n,i,c)=>e[n]+", "+e[i]+", "+e[c];for(let n=0;n<6;++n)for(let i=0;i<6;++i)for(let c=0;c<6;++c)this.PALETTE_COLORS.push(s(n,i,c));let r=8;for(let n=0;n<24;++n,r+=10)this.PALETTE_COLORS.push(r+", "+r+", "+r)}escapeForHtml(e){return e.replace(/[&<>\"]/gm,s=>s=="&"?"&amp;":s=='"'?"&quot;":s=="<"?"&lt;":s==">"?"&gt;":"")}linkify(e){return e.replace(Zt,s=>`<a href="${s}">${s}</a>`)}ansiToHtml(e,s){return this.process(e,s,!0)}ansiToJson(e,s){return s=s||{},s.json=!0,s.clearLine=!1,this.process(e,s,!0)}ansiToText(e){return this.process(e,{},!1)}process(e,s,r){let n=this,i=e.split(/\033\[/),c=i.shift();s==null&&(s={}),s.clearLine=/\r/.test(e);let o=i.map(d=>this.processChunk(d,s,r));if(s&&s.json){let d=n.processChunkJson("");return d.content=c,d.clearLine=s.clearLine,o.unshift(d),s.remove_empty&&(o=o.filter(a=>!a.isEmpty())),o}else o.unshift(c);return o.join("")}processChunkJson(e,s,r){s=typeof s>"u"?{}:s;let n=s.use_classes=typeof s.use_classes<"u"&&s.use_classes,i=s.key=n?"class":"color",c={content:e,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:s.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!c.content},o=e.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!o)return c;c.content=o[4];let d=o[2].split(";");if(o[1]!==""||o[3]!=="m"||!r)return c;let a=this;for(;d.length>0;){let m=d.shift(),_=parseInt(m);if(isNaN(_)||_===0)a.fg=a.bg=null,a.decorations=[];else if(_===1)a.decorations.push("bold");else if(_===2)a.decorations.push("dim");else if(_===3)a.decorations.push("italic");else if(_===4)a.decorations.push("underline");else if(_===5)a.decorations.push("blink");else if(_===7)a.decorations.push("reverse");else if(_===8)a.decorations.push("hidden");else if(_===9)a.decorations.push("strikethrough");else if(_===21)a.removeDecoration("bold");else if(_===22)a.removeDecoration("bold"),a.removeDecoration("dim");else if(_===23)a.removeDecoration("italic");else if(_===24)a.removeDecoration("underline");else if(_===25)a.removeDecoration("blink");else if(_===27)a.removeDecoration("reverse");else if(_===28)a.removeDecoration("hidden");else if(_===29)a.removeDecoration("strikethrough");else if(_===39)a.fg=null;else if(_===49)a.bg=null;else if(_>=30&&_<38)a.fg=N[0][_%10][i];else if(_>=90&&_<98)a.fg=N[1][_%10][i];else if(_>=40&&_<48)a.bg=N[0][_%10][i];else if(_>=100&&_<108)a.bg=N[1][_%10][i];else if(_===38||_===48){let v=_===38;if(d.length>=1){let y=d.shift();if(y==="5"&&d.length>=1){let b=parseInt(d.shift());if(b>=0&&b<=255)if(!n)this.PALETTE_COLORS||a.setupPalette(),v?a.fg=this.PALETTE_COLORS[b]:a.bg=this.PALETTE_COLORS[b];else{let w=b>=16?"ansi-palette-"+b:N[b>7?1:0][b%8].class;v?a.fg=w:a.bg=w}}else if(y==="2"&&d.length>=3){let b=parseInt(d.shift()),w=parseInt(d.shift()),B=parseInt(d.shift());if(b>=0&&b<=255&&w>=0&&w<=255&&B>=0&&B<=255){let A=b+", "+w+", "+B;n?v?(a.fg="ansi-truecolor",a.fg_truecolor=A):(a.bg="ansi-truecolor",a.bg_truecolor=A):v?a.fg=A:a.bg=A}}}}}return a.fg===null&&a.bg===null&&a.decorations.length===0||(c.fg=a.fg,c.bg=a.bg,c.fg_truecolor=a.fg_truecolor,c.bg_truecolor=a.bg_truecolor,c.decorations=a.decorations,c.decoration=a.decorations.slice(-1).pop()||null,c.was_processed=!0),c}processChunk(e,s,r){s=s||{};let n=this.processChunkJson(e,s,r),i=s.use_classes;if(n.decorations=n.decorations.filter(_=>{if(_==="reverse"){n.fg||(n.fg=N[0][7][i?"class":"color"]),n.bg||(n.bg=N[0][0][i?"class":"color"]);let v=n.fg;n.fg=n.bg,n.bg=v;let y=n.fg_truecolor;return n.fg_truecolor=n.bg_truecolor,n.bg_truecolor=y,n.isInverted=!0,!1}return!0}),s.json)return n;if(n.isEmpty())return"";if(!n.was_processed)return n.content;let c=[],o=[],d=[],a={},m=_=>{let v=[],y;for(y in _)_.hasOwnProperty(y)&&v.push("data-"+y+'="'+this.escapeForHtml(_[y])+'"');return v.length>0?" "+v.join(" "):""};return n.isInverted&&(a["ansi-is-inverted"]="true"),n.fg&&(i?(c.push(n.fg+"-fg"),n.fg_truecolor!==null&&(a["ansi-truecolor-fg"]=n.fg_truecolor,n.fg_truecolor=null)):c.push("color:rgb("+n.fg+")")),n.bg&&(i?(c.push(n.bg+"-bg"),n.bg_truecolor!==null&&(a["ansi-truecolor-bg"]=n.bg_truecolor,n.bg_truecolor=null)):c.push("background-color:rgb("+n.bg+")")),n.decorations.forEach(_=>{if(i){o.push("ansi-"+_);return}_==="bold"?o.push("font-weight:bold"):_==="dim"?o.push("opacity:0.5"):_==="italic"?o.push("font-style:italic"):_==="hidden"?o.push("visibility:hidden"):_==="strikethrough"?d.push("line-through"):d.push(_)}),d.length&&o.push("text-decoration:"+d.join(" ")),i?'<span class="'+c.concat(o).join(" ")+'"'+m(a)+">"+n.content+"</span>":'<span style="'+c.concat(o).join(";")+'"'+m(a)+">"+n.content+"</span>"}removeDecoration(e){const s=this.decorations.indexOf(e);s>=0&&this.decorations.splice(s,1)}}var Ht=I,ie={exports:{}};function Ce(t){if(!t)return"";if(!/\r/.test(t))return t;for(t=t.replace(/\r+\n/gm,`
1
+ import{r as h,c as S,j as f}from"./vendor-react-OhDMXABq.js";import{u as ht,S as Le,E as gt,c as mt,B as $,a as pt,b as xt,P as Dt}from"./index-DJ6COP3-.js";import{F as Me}from"./FilterPills-CPr9zkF3.js";import{u as te}from"./vendor-ui-D8qdFUhC.js";import{u as bt}from"./usePluginData-BVQYKC-X.js";import{a as $e}from"./fetchJson-D-dWeu1j.js";import{m as ge}from"./web-CXsIp7nc.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function x(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function re(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function Ft(t,e){const s=x(t);return isNaN(e)?re(t,NaN):(e&&s.setDate(s.getDate()+e),s)}function vt(t,e){const s=x(t);if(isNaN(e))return re(t,NaN);if(!e)return s;const r=s.getDate(),n=re(t,s.getTime());n.setMonth(s.getMonth()+e+1,0);const i=n.getDate();return r>=i?n:(s.setFullYear(n.getFullYear(),n.getMonth(),r),s)}function W(t,e){const{years:s=0,months:r=0,weeks:n=0,days:i=0,hours:c=0,minutes:o=0,seconds:d=0}=e,a=x(t),m=r||s?vt(a,r+s*12):a,_=i||n?Ft(m,i+n*7):m,v=o+c*60,b=(d+v*60)*1e3;return re(t,_.getTime()+b)}const yt=864e5,Et=6e4,Ct=36e5;function Ie(t){const e=x(t);return e.setHours(0,0,0,0),e}function Be(t){const e=x(t),s=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return s.setUTCFullYear(e.getFullYear()),+t-+s}function jt(t,e){const s=Ie(t),r=Ie(e),n=+s-Be(s),i=+r-Be(r);return Math.round((n-i)/yt)}function G(t,e){const s=x(t),r=x(e),n=s.getTime()-r.getTime();return n<0?-1:n>0?1:n}function wt(t,e){const s=x(t),r=x(e),n=s.getFullYear()-r.getFullYear(),i=s.getMonth()-r.getMonth();return n*12+i}function At(t,e){const s=x(t),r=x(e);return s.getFullYear()-r.getFullYear()}function zt(t,e){const s=x(t),r=x(e),n=Pe(s,r),i=Math.abs(jt(s,r));s.setDate(s.getDate()-n*i);const c=+(Pe(s,r)===-n),o=n*(i-c);return o===0?0:o}function Pe(t,e){const s=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return s<0?-1:s>0?1:s}function ye(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function Ee(t,e){return+x(t)-+x(e)}function kt(t,e,s){const r=Ee(t,e)/Ct;return ye(s==null?void 0:s.roundingMethod)(r)}function Nt(t,e,s){const r=Ee(t,e)/Et;return ye(s==null?void 0:s.roundingMethod)(r)}function Rt(t){const e=x(t);return e.setHours(23,59,59,999),e}function St(t){const e=x(t),s=e.getMonth();return e.setFullYear(e.getFullYear(),s+1,0),e.setHours(23,59,59,999),e}function Ot(t){const e=x(t);return+Rt(e)==+St(e)}function Tt(t,e){const s=x(t),r=x(e),n=G(s,r),i=Math.abs(wt(s,r));let c;if(i<1)c=0;else{s.getMonth()===1&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-n*i);let o=G(s,r)===-n;Ot(x(t))&&i===1&&G(t,r)===1&&(o=!1),c=n*(i-Number(o))}return c===0?0:c}function Lt(t,e,s){const r=Ee(t,e)/1e3;return ye(s==null?void 0:s.roundingMethod)(r)}function Mt(t,e){const s=x(t),r=x(e),n=G(s,r),i=Math.abs(At(s,r));s.setFullYear(1584),r.setFullYear(1584);const c=G(s,r)===-n,o=n*(i-+c);return o===0?0:o}function $t(t){const e=x(t.start),s=x(t.end),r={},n=Mt(s,e);n&&(r.years=n);const i=W(e,{years:r.years}),c=Tt(s,i);c&&(r.months=c);const o=W(i,{months:r.months}),d=zt(s,o);d&&(r.days=d);const a=W(o,{days:r.days}),m=kt(s,a);m&&(r.hours=m);const _=W(a,{hours:r.hours}),v=Nt(s,_);v&&(r.minutes=v);const y=W(_,{minutes:r.minutes}),b=Lt(s,y);return b&&(r.seconds=b),r}const It=40,se=1e3;function Ze(t,e,s,r=It){return t-e-s<r}function Bt(t){return/^\[(ERROR|FATAL)\]/.test(t)||/^ERROR\b/.test(t)?"error":/^\[(WARN|WARNING)\]/.test(t)||/^WARN(ING)?\b/.test(t)?"warn":/^\[DEBUG\]/.test(t)||/^DEBUG\b/.test(t)?"info":/^\[(INFO|DOWNLOAD|PROGRESS)\]/.test(t)||/^INFO\b/.test(t)?"success":"plain"}function Fe(t){switch(Bt(t)){case"error":return"text-destructive";case"warn":return"text-warning";case"info":return"text-info";case"success":return"text-success";default:return"text-terminal-fg"}}function Pt(t,e){if(!e)return null;const s=t.toLowerCase(),r=e.toLowerCase(),n=[];let i=0,c=!1;for(;i<t.length;){const o=s.indexOf(r,i);if(o<0){n.push({text:t.slice(i),hit:!1});break}o>i&&n.push({text:t.slice(i,o),hit:!1}),n.push({text:t.slice(o,o+r.length),hit:!0}),c=!0,i=o+r.length}return c?n:null}var et={};const N=[[{color:"0, 0, 0",class:"ansi-black"},{color:"187, 0, 0",class:"ansi-red"},{color:"0, 187, 0",class:"ansi-green"},{color:"187, 187, 0",class:"ansi-yellow"},{color:"0, 0, 187",class:"ansi-blue"},{color:"187, 0, 187",class:"ansi-magenta"},{color:"0, 187, 187",class:"ansi-cyan"},{color:"255,255,255",class:"ansi-white"}],[{color:"85, 85, 85",class:"ansi-bright-black"},{color:"255, 85, 85",class:"ansi-bright-red"},{color:"0, 255, 0",class:"ansi-bright-green"},{color:"255, 255, 85",class:"ansi-bright-yellow"},{color:"85, 85, 255",class:"ansi-bright-blue"},{color:"255, 85, 255",class:"ansi-bright-magenta"},{color:"85, 255, 255",class:"ansi-bright-cyan"},{color:"255, 255, 255",class:"ansi-bright-white"}]],Zt=/(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;class I{static escapeForHtml(e){return new I().escapeForHtml(e)}static linkify(e){return new I().linkify(e)}static ansiToHtml(e,s){return new I().ansiToHtml(e,s)}static ansiToJson(e,s){return new I().ansiToJson(e,s)}static ansiToText(e){return new I().ansiToText(e)}constructor(){this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null,this.bright=0,this.decorations=[]}setupPalette(){this.PALETTE_COLORS=[];for(let n=0;n<2;++n)for(let i=0;i<8;++i)this.PALETTE_COLORS.push(N[n][i].color);let e=[0,95,135,175,215,255],s=(n,i,c)=>e[n]+", "+e[i]+", "+e[c];for(let n=0;n<6;++n)for(let i=0;i<6;++i)for(let c=0;c<6;++c)this.PALETTE_COLORS.push(s(n,i,c));let r=8;for(let n=0;n<24;++n,r+=10)this.PALETTE_COLORS.push(r+", "+r+", "+r)}escapeForHtml(e){return e.replace(/[&<>\"]/gm,s=>s=="&"?"&amp;":s=='"'?"&quot;":s=="<"?"&lt;":s==">"?"&gt;":"")}linkify(e){return e.replace(Zt,s=>`<a href="${s}">${s}</a>`)}ansiToHtml(e,s){return this.process(e,s,!0)}ansiToJson(e,s){return s=s||{},s.json=!0,s.clearLine=!1,this.process(e,s,!0)}ansiToText(e){return this.process(e,{},!1)}process(e,s,r){let n=this,i=e.split(/\033\[/),c=i.shift();s==null&&(s={}),s.clearLine=/\r/.test(e);let o=i.map(d=>this.processChunk(d,s,r));if(s&&s.json){let d=n.processChunkJson("");return d.content=c,d.clearLine=s.clearLine,o.unshift(d),s.remove_empty&&(o=o.filter(a=>!a.isEmpty())),o}else o.unshift(c);return o.join("")}processChunkJson(e,s,r){s=typeof s>"u"?{}:s;let n=s.use_classes=typeof s.use_classes<"u"&&s.use_classes,i=s.key=n?"class":"color",c={content:e,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,isInverted:!1,clearLine:s.clearLine,decoration:null,decorations:[],was_processed:!1,isEmpty:()=>!c.content},o=e.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!o)return c;c.content=o[4];let d=o[2].split(";");if(o[1]!==""||o[3]!=="m"||!r)return c;let a=this;for(;d.length>0;){let m=d.shift(),_=parseInt(m);if(isNaN(_)||_===0)a.fg=a.bg=null,a.decorations=[];else if(_===1)a.decorations.push("bold");else if(_===2)a.decorations.push("dim");else if(_===3)a.decorations.push("italic");else if(_===4)a.decorations.push("underline");else if(_===5)a.decorations.push("blink");else if(_===7)a.decorations.push("reverse");else if(_===8)a.decorations.push("hidden");else if(_===9)a.decorations.push("strikethrough");else if(_===21)a.removeDecoration("bold");else if(_===22)a.removeDecoration("bold"),a.removeDecoration("dim");else if(_===23)a.removeDecoration("italic");else if(_===24)a.removeDecoration("underline");else if(_===25)a.removeDecoration("blink");else if(_===27)a.removeDecoration("reverse");else if(_===28)a.removeDecoration("hidden");else if(_===29)a.removeDecoration("strikethrough");else if(_===39)a.fg=null;else if(_===49)a.bg=null;else if(_>=30&&_<38)a.fg=N[0][_%10][i];else if(_>=90&&_<98)a.fg=N[1][_%10][i];else if(_>=40&&_<48)a.bg=N[0][_%10][i];else if(_>=100&&_<108)a.bg=N[1][_%10][i];else if(_===38||_===48){let v=_===38;if(d.length>=1){let y=d.shift();if(y==="5"&&d.length>=1){let b=parseInt(d.shift());if(b>=0&&b<=255)if(!n)this.PALETTE_COLORS||a.setupPalette(),v?a.fg=this.PALETTE_COLORS[b]:a.bg=this.PALETTE_COLORS[b];else{let w=b>=16?"ansi-palette-"+b:N[b>7?1:0][b%8].class;v?a.fg=w:a.bg=w}}else if(y==="2"&&d.length>=3){let b=parseInt(d.shift()),w=parseInt(d.shift()),B=parseInt(d.shift());if(b>=0&&b<=255&&w>=0&&w<=255&&B>=0&&B<=255){let A=b+", "+w+", "+B;n?v?(a.fg="ansi-truecolor",a.fg_truecolor=A):(a.bg="ansi-truecolor",a.bg_truecolor=A):v?a.fg=A:a.bg=A}}}}}return a.fg===null&&a.bg===null&&a.decorations.length===0||(c.fg=a.fg,c.bg=a.bg,c.fg_truecolor=a.fg_truecolor,c.bg_truecolor=a.bg_truecolor,c.decorations=a.decorations,c.decoration=a.decorations.slice(-1).pop()||null,c.was_processed=!0),c}processChunk(e,s,r){s=s||{};let n=this.processChunkJson(e,s,r),i=s.use_classes;if(n.decorations=n.decorations.filter(_=>{if(_==="reverse"){n.fg||(n.fg=N[0][7][i?"class":"color"]),n.bg||(n.bg=N[0][0][i?"class":"color"]);let v=n.fg;n.fg=n.bg,n.bg=v;let y=n.fg_truecolor;return n.fg_truecolor=n.bg_truecolor,n.bg_truecolor=y,n.isInverted=!0,!1}return!0}),s.json)return n;if(n.isEmpty())return"";if(!n.was_processed)return n.content;let c=[],o=[],d=[],a={},m=_=>{let v=[],y;for(y in _)_.hasOwnProperty(y)&&v.push("data-"+y+'="'+this.escapeForHtml(_[y])+'"');return v.length>0?" "+v.join(" "):""};return n.isInverted&&(a["ansi-is-inverted"]="true"),n.fg&&(i?(c.push(n.fg+"-fg"),n.fg_truecolor!==null&&(a["ansi-truecolor-fg"]=n.fg_truecolor,n.fg_truecolor=null)):c.push("color:rgb("+n.fg+")")),n.bg&&(i?(c.push(n.bg+"-bg"),n.bg_truecolor!==null&&(a["ansi-truecolor-bg"]=n.bg_truecolor,n.bg_truecolor=null)):c.push("background-color:rgb("+n.bg+")")),n.decorations.forEach(_=>{if(i){o.push("ansi-"+_);return}_==="bold"?o.push("font-weight:bold"):_==="dim"?o.push("opacity:0.5"):_==="italic"?o.push("font-style:italic"):_==="hidden"?o.push("visibility:hidden"):_==="strikethrough"?d.push("line-through"):d.push(_)}),d.length&&o.push("text-decoration:"+d.join(" ")),i?'<span class="'+c.concat(o).join(" ")+'"'+m(a)+">"+n.content+"</span>":'<span style="'+c.concat(o).join(";")+'"'+m(a)+">"+n.content+"</span>"}removeDecoration(e){const s=this.decorations.indexOf(e);s>=0&&this.decorations.splice(s,1)}}var Ht=I,ie={exports:{}};function Ce(t){if(!t)return"";if(!/\r/.test(t))return t;for(t=t.replace(/\r+\n/gm,`
2
2
  `);/\r./.test(t);)t=t.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm,function(e,s,r){return r+s.slice(r.length)});return t}function qt(t){for(var e=0,s=0;s<t.length;s++)t[e].length<=t[s].length&&(e=s);return e}function He(t){if(!/\r/.test(t))return t;for(var e=t.split("\r"),s=[];e.length>0;){var r=qt(e);s.push(e[r]),e=e.slice(r+1)}return s.join("\r")}function Yt(t){if(!t)return"";if(!/\r/.test(t))return t;if(!/\n/.test(t))return He(t);t=t.replace(/\r+\n/gm,`
3
3
  `);var e=t.lastIndexOf(`
4
4
  `);return Ce(t.slice(0,e))+`
@@ -1 +1 @@
1
- import{j as e,r as h}from"./vendor-react-OhDMXABq.js";import{F as M}from"./FilterPills-D2zZaent.js";import{E as $,u as k,a as A,b as P,P as L,c as U,r as T,s as W}from"./index-BxPRo4R9.js";import{u as v,R as y,D as z,C as D,M as H,I as J}from"./DiagramViewer-CQYfB79k.js";import{f as K,v as X}from"./fetchJson-D-dWeu1j.js";import{m as w}from"./web-CBXj6xFf.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function B({path:t}){const[s,a]=v(),c="/__design/asset?path="+encodeURIComponent(t)+(s?"&v="+s:"");return e.jsxs("div",{className:"relative h-full",children:[e.jsx("div",{className:"absolute right-3 top-3 z-10",children:e.jsx(y,{onClick:a})}),e.jsx("iframe",{src:c,title:"预览",className:"w-full h-full border-0 bg-white"})]})}const C=/^(#|rgb|rgba|hsl|hsla|oklch|oklab|color\()/i,R=/font|family|type/i;function G(t){const s=t.match(/--[A-Za-z0-9_-]+\s*:\s*[^;}\n]+/g)??[];if(!s.length)return[];const a=r=>{const o=r.indexOf(":"),x=r.slice(0,o).trim(),g=r.slice(o+1).trim();return{name:x,value:g}},c=r=>/^(#([0-9a-fA-F]{3,8})\b|rgb|rgba|hsl|hsla|oklch|oklab|color\()/i.test(r),i=r=>R.test(r),u=s.map(a),d=u.filter(r=>c(r.value)),m=u.filter(r=>!c(r.value)&&i(r.name)),l=u.filter(r=>!c(r.value)&&!i(r.name)),n=[];return d.length&&n.push({label:`配色 · ${d.length}`,items:d}),m.length&&n.push({label:`字体 · ${m.length}`,items:m}),l.length&&n.push({label:`其他 · ${l.length}`,items:l}),n}function Y({path:t}){const[s,a]=h.useState(null),[c,i]=h.useState(null),[u,d]=v(),m=h.useRef(null);return h.useEffect(()=>{let l=!1;const n=m.current!==t;m.current=t,n?(a(null),i(null)):s===null&&i(null);async function r(){try{const o=await K("/__design/asset?path="+encodeURIComponent(t),{cache:"no-store"});if(l)return;a(G(o)),i(null)}catch(o){l||i(X(o))}}return r(),()=>{l=!0}},[t,u]),c&&s===null?e.jsx("div",{className:"h-full flex flex-col p-4",children:e.jsx($,{message:c,onRetry:d})}):s===null?e.jsx("p",{className:"p-3 text-xs text-muted-foreground",children:"解析中…"}):s.length?e.jsxs("div",{className:"relative p-8 flex flex-col gap-7",children:[e.jsx("div",{className:"absolute right-6 top-4 z-10",children:e.jsx(y,{onClick:d})}),s.map(l=>{const n=l.items.some(o=>C.test(o.value)),r=l.items.some(o=>R.test(o.name));return e.jsxs("section",{children:[e.jsx("div",{className:"mb-3 text-sm font-semibold uppercase text-muted-foreground",children:l.label}),n?e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(var(--token-card-min-w), 1fr))"},children:l.items.filter(o=>C.test(o.value)).map(({name:o,value:x})=>e.jsxs("div",{className:"overflow-hidden rounded-lg border bg-background",children:[e.jsx("div",{className:"h-[var(--design-preview-h)] border-b",style:{background:x}}),e.jsx("div",{className:"px-2.5 pt-2 font-mono text-sm break-all",children:o}),e.jsx("div",{className:"px-2.5 pb-2 text-xs text-muted-foreground",children:x})]},o))}):r?e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(var(--token-card-min-w), 1fr))"},children:l.items.map(({name:o,value:x})=>e.jsxs("div",{className:"overflow-hidden rounded-lg border bg-background",children:[e.jsx("div",{className:"grid h-[var(--design-preview-h)] place-items-center text-2xl",style:{fontFamily:x},children:"Aa"}),e.jsx("div",{className:"px-2.5 font-mono text-sm",children:o})]},o))}):e.jsx("div",{className:"flex flex-col gap-1",children:l.items.map(({name:o,value:x})=>e.jsxs("div",{className:"flex justify-between gap-3 px-2.5 py-1.5 rounded border bg-background text-xs",children:[e.jsx("span",{className:"font-mono",children:o}),e.jsx("span",{className:"text-muted-foreground",children:x})]},o))})]},l.label)})]}):e.jsx("p",{className:"p-3 text-xs",children:"未发现 CSS 变量"})}const p=t=>"/__design/asset?path="+encodeURIComponent(t);function V(){const[t,s]=v();return{bust:a=>t?`${a}&v=${t}`:a,refresh:s}}function j({onClick:t}){return e.jsx("div",{className:"absolute right-3 top-3 z-10",children:e.jsx(y,{onClick:t})})}function Z({path:t}){return e.jsx(H,{path:t,resolve:p})}function q({path:t}){return e.jsx(J,{path:t,resolve:p})}function Q({path:t}){return e.jsx(D,{path:t,resolve:p})}function ee({path:t}){return e.jsx(z,{path:t,resolve:p})}function te({path:t}){const{bust:s,refresh:a}=V();return e.jsxs("div",{className:"relative grid place-items-center p-8",children:[e.jsx(j,{onClick:a}),e.jsx("video",{src:s(p(t)),controls:!0,className:"max-w-full max-h-[80vh] rounded border"})]})}function se({path:t}){const{bust:s,refresh:a}=V();return e.jsxs("div",{className:"relative grid place-items-center p-8",children:[e.jsx(j,{onClick:a}),e.jsx("audio",{src:s(p(t)),controls:!0,className:"w-full max-w-2xl"})]})}function ne({path:t}){const{bust:s,refresh:a}=V();return e.jsxs("div",{className:"relative grid place-items-center p-8 h-full",children:[e.jsx(j,{onClick:a}),e.jsx("iframe",{src:s(p(t)),title:"PDF",className:"w-full h-full max-h-[80vh] rounded border bg-white"})]})}function re({path:t}){const[s,a]=v(),c=h.useRef(null),[i,u]=h.useState("");return h.useEffect(()=>{let d=!1;const m=c.current!==t;c.current=t;let l="",n=null;return m&&u(""),fetch(p(t)).then(r=>r.blob()).then(async r=>{var o;if(!d){if(l=URL.createObjectURL(r),n=new FontFace("zd-font-preview",`url(${l})`),await n.load(),d){(o=n.dispose)==null||o.call(n);return}document.fonts.add(n),u(t.split("/").pop()??t)}}).catch(()=>{d||u(t.split("/").pop()??t)}),()=>{var r;if(d=!0,n)try{document.fonts.delete(n),(r=n.dispose)==null||r.call(n)}catch{}l&&URL.revokeObjectURL(l)}},[t,s]),e.jsxs("div",{className:"relative h-full overflow-auto p-8 grid gap-6 place-content-center text-center",children:[e.jsx(j,{onClick:a}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono break-all",children:t}),e.jsx("div",{className:"text-5xl",style:{fontFamily:i?"'zd-font-preview', serif":"serif"},children:"Aa 字体预览 0123"})]})}function oe({path:t}){const{icon:s}=k();return e.jsx("div",{className:"grid place-items-center h-full text-center text-muted-foreground",children:e.jsxs("div",{children:[s("image-off","h-10 w-10 mx-auto mb-3 opacity-50"),e.jsx("p",{children:"该格式无法预览"}),e.jsx("p",{className:"mt-1 font-mono text-xs break-all",children:t})]})})}const le={page:B,icon:q,token:Y,md:Z,video:te,audio:se,pdf:ne,component:Q,font:re,diagram:ee};function ae(t){return le[t]??oe}const E="zd-design-viewport",ie={mode:0,w:1024,h:768},ce=[0,768,375],S=280,F=3e3,_=400,I=3e3;function de(t){if(!t||typeof t!="object")return!1;const s=t,a=ce.includes(s.mode)||s.mode==="custom",c=typeof s.w=="number"&&Number.isFinite(s.w)&&s.w>=S&&s.w<=F,i=typeof s.h=="number"&&Number.isFinite(s.h)&&s.h>=_&&s.h<=I;return a&&c&&i}const ue=()=>T(E,{...ie},de);function N(t){W(E,JSON.stringify(t))}function me({mode:t,onMode:s,w:a,h:c,onW:i,onH:u}){const{icon:d}=k(),m=[{v:0,icon:d("monitor","h-3.5 w-3.5"),label:"桌面"},{v:768,icon:d("tablet","h-3.5 w-3.5"),label:"768"},{v:375,icon:d("smartphone","h-3.5 w-3.5"),label:"375"},{v:"custom",icon:d("sliders-horizontal","h-3.5 w-3.5"),label:"自定义"}],l="w-[var(--design-input-w)] h-7 px-1 text-center text-xs rounded border border-border bg-background text-foreground [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none focus:border-primary";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 rounded-md border border-border p-0.5 bg-muted",children:e.jsx(M,{items:m.map(n=>({key:String(n.v),label:n.label,renderLabel:()=>e.jsxs(e.Fragment,{children:[n.icon,e.jsx("span",{className:"hidden sm:inline",children:n.label})]})})),value:String(t),onChange:n=>s(n==="0"?0:n==="custom"?"custom":Number(n)),ariaLabel:"视口模式"})}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("input",{type:"number",value:a,min:S,max:F,step:8,onChange:n=>i(Number(n.target.value)),"aria-label":"自定义宽度",className:l}),e.jsx("span",{className:"text-muted-foreground/70",children:"×"}),e.jsx("input",{type:"number",value:c,min:_,max:I,step:8,onChange:n=>u(Number(n.target.value)),"aria-label":"自定义高度",className:l}),e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"px"})]})]})}function Ne({params:t}){const{icon:s}=k(),a=A(w.mode,"h-5 w-5");P();const c=t.get("type")??"",i=t.get("asset"),[u,d]=h.useState(ue),m=b=>{const f={...u,mode:b};d(f),N(f)},l=b=>{const f={...u,w:b};d(f),N(f)},n=b=>{const f={...u,h:b};d(f),N(f)},{mode:r,w:o,h:x}=u,g=i?ae(c):null,O=r===0?"桌面":r==="custom"?`${o} × ${x}`:`${r}px`;return e.jsx(L,{manifest:w,icon:a,breadcrumb:["插件",w.mode,...c?[c]:[],...i?[i]:[]],children:e.jsx("div",{className:"mx-auto h-full flex flex-col bg-background border rounded-lg shadow-sm overflow-hidden",children:i&&g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[var(--design-toolbar-h)] flex-none flex items-center justify-between px-3.5 border-b bg-background text-xs",children:[e.jsx("span",{className:"font-mono truncate",children:i}),e.jsx("span",{className:"text-muted-foreground ml-3 flex-none",children:O}),e.jsx(me,{mode:r,onMode:m,w:o,h:x,onW:l,onH:n})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c==="page"?e.jsx("div",{className:"mx-auto bg-background overflow-hidden",style:{maxWidth:r===0?void 0:r==="custom"?o:r,height:r==="custom"?x:"100%"},children:e.jsx(g,{path:i})}):e.jsx("div",{className:"mx-auto max-w-5xl h-full overflow-auto",children:e.jsx(g,{path:i})})})]}):e.jsx(U,{icon:s("palette","h-6 w-6"),title:"从左侧选择一个资产预览",hint:"点左侧折叠钮展开资产树 · 改文件即时刷新"})})})}export{Ne as default};
1
+ import{j as e,r as h}from"./vendor-react-OhDMXABq.js";import{F as M}from"./FilterPills-CPr9zkF3.js";import{E as $,u as k,a as A,b as P,P as L,c as U,r as T,s as W}from"./index-DJ6COP3-.js";import{u as v,R as y,D as z,C as D,M as H,I as J}from"./DiagramViewer-CVyfeqsA.js";import{f as K,v as X}from"./fetchJson-D-dWeu1j.js";import{m as w}from"./web-BJGOy2bk.js";import"./vendor-ui-D8qdFUhC.js";import"./index-D7HrI6pR.js";import"./client-Cw4K1Nx3.js";function B({path:t}){const[s,a]=v(),c="/__design/asset?path="+encodeURIComponent(t)+(s?"&v="+s:"");return e.jsxs("div",{className:"relative h-full",children:[e.jsx("div",{className:"absolute right-3 top-3 z-10",children:e.jsx(y,{onClick:a})}),e.jsx("iframe",{src:c,title:"预览",className:"w-full h-full border-0 bg-white"})]})}const C=/^(#|rgb|rgba|hsl|hsla|oklch|oklab|color\()/i,R=/font|family|type/i;function G(t){const s=t.match(/--[A-Za-z0-9_-]+\s*:\s*[^;}\n]+/g)??[];if(!s.length)return[];const a=r=>{const o=r.indexOf(":"),x=r.slice(0,o).trim(),g=r.slice(o+1).trim();return{name:x,value:g}},c=r=>/^(#([0-9a-fA-F]{3,8})\b|rgb|rgba|hsl|hsla|oklch|oklab|color\()/i.test(r),i=r=>R.test(r),u=s.map(a),d=u.filter(r=>c(r.value)),m=u.filter(r=>!c(r.value)&&i(r.name)),l=u.filter(r=>!c(r.value)&&!i(r.name)),n=[];return d.length&&n.push({label:`配色 · ${d.length}`,items:d}),m.length&&n.push({label:`字体 · ${m.length}`,items:m}),l.length&&n.push({label:`其他 · ${l.length}`,items:l}),n}function Y({path:t}){const[s,a]=h.useState(null),[c,i]=h.useState(null),[u,d]=v(),m=h.useRef(null);return h.useEffect(()=>{let l=!1;const n=m.current!==t;m.current=t,n?(a(null),i(null)):s===null&&i(null);async function r(){try{const o=await K("/__design/asset?path="+encodeURIComponent(t),{cache:"no-store"});if(l)return;a(G(o)),i(null)}catch(o){l||i(X(o))}}return r(),()=>{l=!0}},[t,u]),c&&s===null?e.jsx("div",{className:"h-full flex flex-col p-4",children:e.jsx($,{message:c,onRetry:d})}):s===null?e.jsx("p",{className:"p-3 text-xs text-muted-foreground",children:"解析中…"}):s.length?e.jsxs("div",{className:"relative p-8 flex flex-col gap-7",children:[e.jsx("div",{className:"absolute right-6 top-4 z-10",children:e.jsx(y,{onClick:d})}),s.map(l=>{const n=l.items.some(o=>C.test(o.value)),r=l.items.some(o=>R.test(o.name));return e.jsxs("section",{children:[e.jsx("div",{className:"mb-3 text-sm font-semibold uppercase text-muted-foreground",children:l.label}),n?e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(var(--token-card-min-w), 1fr))"},children:l.items.filter(o=>C.test(o.value)).map(({name:o,value:x})=>e.jsxs("div",{className:"overflow-hidden rounded-lg border bg-background",children:[e.jsx("div",{className:"h-[var(--design-preview-h)] border-b",style:{background:x}}),e.jsx("div",{className:"px-2.5 pt-2 font-mono text-sm break-all",children:o}),e.jsx("div",{className:"px-2.5 pb-2 text-xs text-muted-foreground",children:x})]},o))}):r?e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:"repeat(auto-fill, minmax(var(--token-card-min-w), 1fr))"},children:l.items.map(({name:o,value:x})=>e.jsxs("div",{className:"overflow-hidden rounded-lg border bg-background",children:[e.jsx("div",{className:"grid h-[var(--design-preview-h)] place-items-center text-2xl",style:{fontFamily:x},children:"Aa"}),e.jsx("div",{className:"px-2.5 font-mono text-sm",children:o})]},o))}):e.jsx("div",{className:"flex flex-col gap-1",children:l.items.map(({name:o,value:x})=>e.jsxs("div",{className:"flex justify-between gap-3 px-2.5 py-1.5 rounded border bg-background text-xs",children:[e.jsx("span",{className:"font-mono",children:o}),e.jsx("span",{className:"text-muted-foreground",children:x})]},o))})]},l.label)})]}):e.jsx("p",{className:"p-3 text-xs",children:"未发现 CSS 变量"})}const p=t=>"/__design/asset?path="+encodeURIComponent(t);function V(){const[t,s]=v();return{bust:a=>t?`${a}&v=${t}`:a,refresh:s}}function j({onClick:t}){return e.jsx("div",{className:"absolute right-3 top-3 z-10",children:e.jsx(y,{onClick:t})})}function Z({path:t}){return e.jsx(H,{path:t,resolve:p})}function q({path:t}){return e.jsx(J,{path:t,resolve:p})}function Q({path:t}){return e.jsx(D,{path:t,resolve:p})}function ee({path:t}){return e.jsx(z,{path:t,resolve:p})}function te({path:t}){const{bust:s,refresh:a}=V();return e.jsxs("div",{className:"relative grid place-items-center p-8",children:[e.jsx(j,{onClick:a}),e.jsx("video",{src:s(p(t)),controls:!0,className:"max-w-full max-h-[80vh] rounded border"})]})}function se({path:t}){const{bust:s,refresh:a}=V();return e.jsxs("div",{className:"relative grid place-items-center p-8",children:[e.jsx(j,{onClick:a}),e.jsx("audio",{src:s(p(t)),controls:!0,className:"w-full max-w-2xl"})]})}function ne({path:t}){const{bust:s,refresh:a}=V();return e.jsxs("div",{className:"relative grid place-items-center p-8 h-full",children:[e.jsx(j,{onClick:a}),e.jsx("iframe",{src:s(p(t)),title:"PDF",className:"w-full h-full max-h-[80vh] rounded border bg-white"})]})}function re({path:t}){const[s,a]=v(),c=h.useRef(null),[i,u]=h.useState("");return h.useEffect(()=>{let d=!1;const m=c.current!==t;c.current=t;let l="",n=null;return m&&u(""),fetch(p(t)).then(r=>r.blob()).then(async r=>{var o;if(!d){if(l=URL.createObjectURL(r),n=new FontFace("zd-font-preview",`url(${l})`),await n.load(),d){(o=n.dispose)==null||o.call(n);return}document.fonts.add(n),u(t.split("/").pop()??t)}}).catch(()=>{d||u(t.split("/").pop()??t)}),()=>{var r;if(d=!0,n)try{document.fonts.delete(n),(r=n.dispose)==null||r.call(n)}catch{}l&&URL.revokeObjectURL(l)}},[t,s]),e.jsxs("div",{className:"relative h-full overflow-auto p-8 grid gap-6 place-content-center text-center",children:[e.jsx(j,{onClick:a}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono break-all",children:t}),e.jsx("div",{className:"text-5xl",style:{fontFamily:i?"'zd-font-preview', serif":"serif"},children:"Aa 字体预览 0123"})]})}function oe({path:t}){const{icon:s}=k();return e.jsx("div",{className:"grid place-items-center h-full text-center text-muted-foreground",children:e.jsxs("div",{children:[s("image-off","h-10 w-10 mx-auto mb-3 opacity-50"),e.jsx("p",{children:"该格式无法预览"}),e.jsx("p",{className:"mt-1 font-mono text-xs break-all",children:t})]})})}const le={page:B,icon:q,token:Y,md:Z,video:te,audio:se,pdf:ne,component:Q,font:re,diagram:ee};function ae(t){return le[t]??oe}const E="zd-design-viewport",ie={mode:0,w:1024,h:768},ce=[0,768,375],S=280,F=3e3,_=400,I=3e3;function de(t){if(!t||typeof t!="object")return!1;const s=t,a=ce.includes(s.mode)||s.mode==="custom",c=typeof s.w=="number"&&Number.isFinite(s.w)&&s.w>=S&&s.w<=F,i=typeof s.h=="number"&&Number.isFinite(s.h)&&s.h>=_&&s.h<=I;return a&&c&&i}const ue=()=>T(E,{...ie},de);function N(t){W(E,JSON.stringify(t))}function me({mode:t,onMode:s,w:a,h:c,onW:i,onH:u}){const{icon:d}=k(),m=[{v:0,icon:d("monitor","h-3.5 w-3.5"),label:"桌面"},{v:768,icon:d("tablet","h-3.5 w-3.5"),label:"768"},{v:375,icon:d("smartphone","h-3.5 w-3.5"),label:"375"},{v:"custom",icon:d("sliders-horizontal","h-3.5 w-3.5"),label:"自定义"}],l="w-[var(--design-input-w)] h-7 px-1 text-center text-xs rounded border border-border bg-background text-foreground [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none focus:border-primary";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 rounded-md border border-border p-0.5 bg-muted",children:e.jsx(M,{items:m.map(n=>({key:String(n.v),label:n.label,renderLabel:()=>e.jsxs(e.Fragment,{children:[n.icon,e.jsx("span",{className:"hidden sm:inline",children:n.label})]})})),value:String(t),onChange:n=>s(n==="0"?0:n==="custom"?"custom":Number(n)),ariaLabel:"视口模式"})}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("input",{type:"number",value:a,min:S,max:F,step:8,onChange:n=>i(Number(n.target.value)),"aria-label":"自定义宽度",className:l}),e.jsx("span",{className:"text-muted-foreground/70",children:"×"}),e.jsx("input",{type:"number",value:c,min:_,max:I,step:8,onChange:n=>u(Number(n.target.value)),"aria-label":"自定义高度",className:l}),e.jsx("span",{className:"text-sm text-muted-foreground/70",children:"px"})]})]})}function Ne({params:t}){const{icon:s}=k(),a=A(w.mode,"h-5 w-5");P();const c=t.get("type")??"",i=t.get("asset"),[u,d]=h.useState(ue),m=b=>{const f={...u,mode:b};d(f),N(f)},l=b=>{const f={...u,w:b};d(f),N(f)},n=b=>{const f={...u,h:b};d(f),N(f)},{mode:r,w:o,h:x}=u,g=i?ae(c):null,O=r===0?"桌面":r==="custom"?`${o} × ${x}`:`${r}px`;return e.jsx(L,{manifest:w,icon:a,breadcrumb:["插件",w.mode,...c?[c]:[],...i?[i]:[]],children:e.jsx("div",{className:"mx-auto h-full flex flex-col bg-background border rounded-lg shadow-sm overflow-hidden",children:i&&g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-[var(--design-toolbar-h)] flex-none flex items-center justify-between px-3.5 border-b bg-background text-xs",children:[e.jsx("span",{className:"font-mono truncate",children:i}),e.jsx("span",{className:"text-muted-foreground ml-3 flex-none",children:O}),e.jsx(me,{mode:r,onMode:m,w:o,h:x,onW:l,onH:n})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c==="page"?e.jsx("div",{className:"mx-auto bg-background overflow-hidden",style:{maxWidth:r===0?void 0:r==="custom"?o:r,height:r==="custom"?x:"100%"},children:e.jsx(g,{path:i})}):e.jsx("div",{className:"mx-auto max-w-5xl h-full overflow-auto",children:e.jsx(g,{path:i})})})]}):e.jsx(U,{icon:s("palette","h-6 w-6"),title:"从左侧选择一个资产预览",hint:"点左侧折叠钮展开资产树 · 改文件即时刷新"})})})}export{Ne as default};