dsh-motion-ui 0.5.6 → 0.7.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.
- package/CHANGELOG.md +121 -0
- package/README.md +112 -4
- package/VERIFICATION.md +145 -0
- package/client.js +4869 -22533
- package/examples/mechanism-assembly.json +50 -0
- package/examples/mechanism-crank.json +103 -0
- package/examples/mechanism-gears.json +103 -0
- package/index.js +52 -15
- package/lib/assets/echarts-core.js +47 -0
- package/lib/assets/echarts-full.js +78 -0
- package/lib/assets/katex-fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/lib/assets/katex-fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/lib/assets/katex.css +1 -0
- package/lib/assets/mermaid.js +3644 -0
- package/lib/assets/standalone-runtime.css +1 -0
- package/lib/assets/standalone-runtime.js +330 -0
- package/lib/assets/three.js +3842 -0
- package/lib/assets/visual.css +1 -0
- package/lib/assets/visual.js +416 -0
- package/lib/author-expression.js +3 -2
- package/lib/authoring-guide.js +4 -3
- package/lib/build-info.js +1 -1
- package/lib/canvas-system.js +3 -3
- package/lib/catalog.js +94 -92
- package/lib/components.js +11 -6
- package/lib/delivery.js +18 -0
- package/lib/diagnostics-route.js +6 -0
- package/lib/document-update.js +27 -0
- package/lib/export-runtime-bundle.js +1 -1
- package/lib/expressive-examples.js +6 -0
- package/lib/fence-feedback.js +61 -0
- package/lib/fence-route.js +14 -0
- package/lib/fences.js +9 -0
- package/lib/freeform.js +4 -3
- package/lib/inspection.js +3 -2
- package/lib/links.js +13 -0
- package/lib/mechanism-catalog.js +24 -0
- package/lib/mechanism-css.js +13 -0
- package/lib/mechanism-entry.js +20 -0
- package/lib/mechanism-geometry.js +62 -0
- package/lib/mechanism-render.js +24 -0
- package/lib/mechanism-runtime-bundle.js +2 -0
- package/lib/mechanism-scenes.js +20 -0
- package/lib/motion-library.js +18 -0
- package/lib/normalize-authoring.js +52 -3
- package/lib/normalize-visual.js +36 -0
- package/lib/presentation.js +1 -1
- package/lib/protocol.js +361 -318
- package/lib/sandbox.js +2 -0
- package/lib/scene-library.js +13 -0
- package/lib/store.js +17 -2
- package/lib/stream.js +12 -0
- package/lib/style-system.js +28 -0
- package/lib/text-document.js +25 -0
- package/lib/text-guide.js +13 -0
- package/lib/third-party/anatomy-LICENSE.txt +21 -0
- package/lib/third-party/anatomy-NOTICE.md +13 -0
- package/lib/third-party/anatomy-iso.mjs +674 -0
- package/lib/third-party/bundled/@braintree_sanitize-url-LICENSE +21 -0
- package/lib/third-party/bundled/@iconify_utils-license.txt +21 -0
- package/lib/third-party/bundled/@mermaid-js_parser-LICENSE +21 -0
- package/lib/third-party/bundled/@upsetjs_venn.js-LICENSE +22 -0
- package/lib/third-party/bundled/cose-base-LICENSE +21 -0
- package/lib/third-party/bundled/cytoscape-LICENSE +19 -0
- package/lib/third-party/bundled/cytoscape-cose-bilkent-LICENSE +21 -0
- package/lib/third-party/bundled/cytoscape-fcose-LICENSE +19 -0
- package/lib/third-party/bundled/cytoscape-license-update.mjs +32 -0
- package/lib/third-party/bundled/d3-LICENSE +13 -0
- package/lib/third-party/bundled/d3-array-LICENSE +27 -0
- package/lib/third-party/bundled/d3-axis-LICENSE +13 -0
- package/lib/third-party/bundled/d3-brush-LICENSE +13 -0
- package/lib/third-party/bundled/d3-chord-LICENSE +13 -0
- package/lib/third-party/bundled/d3-color-LICENSE +13 -0
- package/lib/third-party/bundled/d3-contour-LICENSE +13 -0
- package/lib/third-party/bundled/d3-delaunay-LICENSE +14 -0
- package/lib/third-party/bundled/d3-dispatch-LICENSE +13 -0
- package/lib/third-party/bundled/d3-drag-LICENSE +13 -0
- package/lib/third-party/bundled/d3-dsv-LICENSE +13 -0
- package/lib/third-party/bundled/d3-ease-LICENSE +28 -0
- package/lib/third-party/bundled/d3-fetch-LICENSE +13 -0
- package/lib/third-party/bundled/d3-force-LICENSE +13 -0
- package/lib/third-party/bundled/d3-format-LICENSE +13 -0
- package/lib/third-party/bundled/d3-geo-LICENSE +34 -0
- package/lib/third-party/bundled/d3-hierarchy-LICENSE +13 -0
- package/lib/third-party/bundled/d3-interpolate-LICENSE +13 -0
- package/lib/third-party/bundled/d3-path-LICENSE +27 -0
- package/lib/third-party/bundled/d3-polygon-LICENSE +13 -0
- package/lib/third-party/bundled/d3-quadtree-LICENSE +13 -0
- package/lib/third-party/bundled/d3-random-LICENSE +13 -0
- package/lib/third-party/bundled/d3-sankey-LICENSE +27 -0
- package/lib/third-party/bundled/d3-scale-LICENSE +13 -0
- package/lib/third-party/bundled/d3-scale-chromatic-LICENSE +28 -0
- package/lib/third-party/bundled/d3-selection-LICENSE +13 -0
- package/lib/third-party/bundled/d3-shape-LICENSE +13 -0
- package/lib/third-party/bundled/d3-time-LICENSE +13 -0
- package/lib/third-party/bundled/d3-time-format-LICENSE +13 -0
- package/lib/third-party/bundled/d3-timer-LICENSE +13 -0
- package/lib/third-party/bundled/d3-transition-LICENSE +13 -0
- package/lib/third-party/bundled/d3-zoom-LICENSE +13 -0
- package/lib/third-party/bundled/dagre-d3-es-LICENSE.md +23 -0
- package/lib/third-party/bundled/dayjs-LICENSE +21 -0
- package/lib/third-party/bundled/delaunator-LICENSE +15 -0
- package/lib/third-party/bundled/dompurify-LICENSE +202 -0
- package/lib/third-party/bundled/dompurify-LICENSE-MPL +373 -0
- package/lib/third-party/bundled/echarts-LICENSE +222 -0
- package/lib/third-party/bundled/echarts-NOTICE +5 -0
- package/lib/third-party/bundled/es-toolkit-LICENSE +21 -0
- package/lib/third-party/bundled/es-toolkit-NOTICE +39 -0
- package/lib/third-party/bundled/internmap-LICENSE +13 -0
- package/lib/third-party/bundled/katex-LICENSE +21 -0
- package/lib/third-party/bundled/khroma-license +21 -0
- package/lib/third-party/bundled/layout-base-LICENSE +21 -0
- package/lib/third-party/bundled/lodash-es-LICENSE +47 -0
- package/lib/third-party/bundled/marked-LICENSE.md +44 -0
- package/lib/third-party/bundled/mermaid-LICENSE +21 -0
- package/lib/third-party/bundled/react-LICENSE +21 -0
- package/lib/third-party/bundled/react-dom-LICENSE +21 -0
- package/lib/third-party/bundled/robust-predicates-LICENSE +24 -0
- package/lib/third-party/bundled/roughjs-LICENSE +21 -0
- package/lib/third-party/bundled/scheduler-LICENSE +21 -0
- package/lib/third-party/bundled/stylis-LICENSE +21 -0
- package/lib/third-party/bundled/three-LICENSE +21 -0
- package/lib/third-party/bundled/ts-dedent-LICENSE +21 -0
- package/lib/third-party/bundled/tslib-LICENSE.txt +12 -0
- package/lib/third-party/bundled/uuid-LICENSE.md +9 -0
- package/lib/third-party/bundled/zrender-LICENSE +29 -0
- package/lib/third-party/dsh-genui-LICENSE.txt +21 -0
- package/lib/third-party/dsh-genui-NOTICE.md +26 -0
- package/lib/third-party/echarts-LICENSE.txt +222 -0
- package/lib/third-party/echarts-NOTICE.txt +5 -0
- package/lib/third-party/katex-LICENSE.txt +21 -0
- package/lib/third-party/lucian-uxui-LICENSE.txt +21 -0
- package/lib/third-party/lucian-uxui-NOTICE.md +1 -0
- package/lib/third-party/mermaid-LICENSE.txt +21 -0
- package/lib/third-party/three-LICENSE.txt +21 -0
- package/lib/tool-schema.js +20 -9
- package/lib/typography.js +16 -0
- package/lib/ui-intent.js +15 -14
- package/lib/ui-skill.js +54 -47
- package/lib/visual-assets.js +7 -0
- package/lib/visual-defaults.js +2 -0
- package/lib/visual-guard.js +2 -0
- package/lib/visual-styles.js +142 -0
- package/lib/visual.js +40 -0
- package/package.json +20 -5
- package/skills/intelligent-ui/SKILL.md +22 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var ne=["h1","h2","h3","body","muted","caption"],te=["primary","danger","success","ghost"],ie=["success","warn","danger","accent"],re=["text","email","password","color"],se=["info","success","warning","error"],U=["bars","line","donut"],oe=["line","area","scatter"],ae=["16:9","4:3","1:1","9:16"],ue=["box","sphere","cone","cylinder","torus"],le=["file","dir"],de=["architecture","it-state","flowchart","sequence","state","er","timeline","swimlane","quadrant","radar","loop","nested","tree","org-chart","layers","venn","pyramid","bar","line","gantt","scatter","high-level","process","medallion","data-flow","dp-integration","dp-security-matrix"],ce=["focal","backend","store","external","input","optional","security"],fe=["light","dark","editorial"],pe=["solid","dashed","accent","link"],me=["auto","orthogonal","straight"],ge=["bar","line","area","pie","scatter","radar","gauge","funnel","treemap","sankey","graph","heatmap","bigline","wordCloud"],tn=["hero"],ye=["bar","ring"],be=["info","success","warning","danger"],he=["accent","success","warning","danger"],Ee=["text","num","delta","bar","badge","spark","ring","index","group"],b=(t,i,r={},e={})=>{let s=Object.fromEntries(Object.entries(i).filter(([u])=>u!=="type"&&!t.includes(u))),n=e.oneOfRequired??[],o=e.conditionalRequired??[],a=[...n.map(u=>({kind:"one-of-required",fields:u})),...o];return{required:t,fields:i,optional:s,aliases:r,valueAliases:e.valueAliases??{},oneOfRequired:n,conditionalRequired:o,rules:a,enums:e.enums??{},nested:e.nested??{},...e.validator===void 0?{}:{validator:e.validator}}},G=(t,i,r={},e={},s={})=>({required:t,fields:i,enums:e,nested:r,aliases:s}),h={type:"string",span:"number",id:"string"},De=G(["label","value"],{label:"string",value:"number",color:"string"}),rn=G(["label","data"],{label:"string",color:"string",data:"array"},{data:De}),sn=G(["title"],{title:"string",desc:"string"}),on=G(["key","value"],{key:"string",value:"string"},{},{},{label:"key"}),an=G(["title"],{title:"string",desc:"string",time:"string"}),un=G(["path","newText"],{path:"string",oldText:"string-or-null",newText:"string"}),ln=G(["name","value"],{name:"string",value:"number",min:"number",max:"number",step:"number",animateTo:"number",durationMs:"number",loop:"boolean"}),dn=G(["expr"],{expr:"string",label:"string",color:"string",kind:"string",params:"array"},{params:ln},{kind:oe}),cn=G(["shape"],{shape:"string",color:"string",position:"array",rotation:"array",scale:"unknown",size:"unknown"},{},{shape:ue});function Oe(t){return G(["name"],{name:"string",type:"string",children:"array"},t>0?{children:Oe(t-1)}:{},{type:le},{label:"name"})}var fn=Oe(6),pn=G(["label","items"],{label:"string",items:"nodes",content:"nodes"}),mn=G(["title","items"],{title:"string",items:"nodes"}),gn=G(["id","label"],{id:"string",label:"string",sub:"string",type:"string",x:"number",y:"number",w:"number",h:"number",tag:"string"},{},{type:ce}),yn=G(["from","to"],{from:"string",to:"string",label:"string",kind:"string",route:"string"},{},{kind:pe,route:me}),bn=G(["label"],{label:"string",x:"number",y:"number",w:"number",h:"number"}),hn=G([],{paper:"string","paper-2":"string",ink:"string",muted:"string",soft:"string",rule:"string",accent:"string","accent-tint":"string",link:"string"}),V=b(["items"],{title:"string",gap:"number",panel:"boolean",append:"boolean",items:"nodes"});var T={accordion:b(["items"],{...h,items:"array"},{},{nested:{items:mn}}),audio:b(["src"],{...h,src:"string",alt:"string",loop:"boolean"},{url:"src",link:"src"}),avatar:b(["name"],{...h,name:"string",color:"string"}),badge:b(["label"],{...h,label:"string",tone:"string",icon:"string"},{text:"label",value:"label"},{enums:{tone:ie}}),breadcrumb:b(["items"],{...h,items:"array"}),button:b(["label"],{...h,label:"string",tone:"string",full:"boolean",small:"boolean",icon:"string",action:"string"},{},{enums:{tone:te}}),callout:b(["content"],{...h,title:"string",content:"string",tone:"string"},{kind:"tone",text:"content",body:"content",desc:"content"},{enums:{tone:se},valueAliases:{tone:{danger:"error",warn:"warning"}}}),card:b(["items"],{...h,title:"string",items:"nodes",tone:"string",accent:"string"},{label:"title",content:"items"},{enums:{tone:be}}),chart:b([],{...h,kind:"string",data:"array",series:"array",horizontal:"boolean",stacked:"boolean",filter:"string",palette:"array"},{},{oneOfRequired:[["data","series"]],conditionalRequired:[{kind:"required-if",when:{field:"kind",equals:"donut"},required:["data"]}],nested:{data:De,series:rn},enums:{kind:U},validator:{name:"chart-renderability"}}),checkbox:b(["label"],{...h,label:"string",checked:"boolean",action:"string",group:"string"}),code:b(["code"],{...h,lang:"string",code:"string",title:"string",wrap:"boolean"},{content:"code",text:"code"}),col:b(["items"],{...h,items:"nodes",gap:"number"}),copy:b(["text"],{...h,label:"string",text:"string"},{content:"text",code:"text",value:"text"}),diagram:b(["kind","nodes"],{...h,kind:"string",variant:"string",title:"string",nodes:"array",edges:"array",zones:"array",theme:"object"},{},{nested:{nodes:gn,edges:yn,zones:bn,theme:hn},enums:{kind:de,variant:fe}}),diff:b(["diffs"],{...h,diffs:"array"},{items:"diffs",files:"diffs"},{nested:{diffs:un}}),divider:b([],h),echart:b([],{...h,title:"string",height:"number",preset:"string",data:"array",series:"array",links:"array",palette:"array",option:"object"},{},{oneOfRequired:[["option","data","series","links"]],enums:{preset:ge}}),"file-tree":b(["items"],{...h,items:"array"},{nodes:"items"},{nested:{items:fn}}),grid:b(["items"],{...h,cols:"number",items:"nodes"}),image:b(["src"],{...h,src:"string",alt:"string"},{url:"src",link:"src"}),input:b([],{...h,label:"string",placeholder:"string",value:"string",inputType:"string",action:"string",id:"string"},{},{enums:{inputType:re}}),json:b(["value"],{...h,value:"unknown"}),keyvalue:b(["pairs"],{...h,pairs:"array"},{items:"pairs",rows:"pairs",entries:"pairs"},{nested:{pairs:on}}),link:b(["label"],{...h,label:"string",href:"string"}),list:b(["items"],{...h,items:"array",filter:"string"}),mermaid:b(["code"],{...h,code:"string"}),svg:b(["code"],{...h,code:"string",title:"string",height:"number"}),plot:b(["series"],{...h,series:"array",xMin:"number",xMax:"number",yMin:"number",yMax:"number",title:"string"},{},{nested:{series:dn}}),progress:b(["value"],{...h,value:"number",label:"string",valueLabel:"string",variant:"string",target:"number"},{},{enums:{variant:ye}}),quiz:b(["question","options"],{...h,question:"string",options:"array",explanation:"string",id:"string",action:"string"},{title:"question",text:"question",choices:"options",items:"options"}),radio:b(["options"],{...h,label:"string",options:"array",selected:"number",action:"string",group:"string",answer:"unknown",explanation:"string"},{items:"options"}),row:b(["items"],{...h,items:"nodes",wrap:"boolean",spacer:"boolean"}),scene3d:b(["meshes"],{...h,title:"string",meshes:"array",ambient:"number",background:"string"},{},{nested:{meshes:cn}}),select:b(["options"],{...h,label:"string",options:"array",action:"string",selected:"number",id:"string"},{items:"options"}),slider:b([],{...h,label:"string",min:"number",max:"number",step:"number",value:"number",action:"string",id:"string"}),spacer:b([],h),hero:b(["title"],{...h,title:"string",subtitle:"string",value:"string",label:"string",delta:"string",spark:"array",tone:"string"},{},{enums:{tone:he}}),stat:b(["label","value"],{...h,label:"string",value:"string",delta:"string",spark:"array",size:"string"},{},{enums:{size:tn}}),steps:b(["steps"],{...h,steps:"array",current:"number"},{items:"steps"},{nested:{steps:sn}}),submit:b(["label"],{...h,label:"string",action:"string",resetAction:"string",groups:"array"}),switch:b(["label"],{...h,label:"string",checked:"boolean",action:"string"}),table:b(["columns","rows"],{...h,columns:"array",rows:"array",types:"array",total:"boolean",details:"array",filter:"string",filterColumn:"number",sortField:"string",export:"boolean"},{headers:"columns",data:"rows",items:"rows"}),tabs:b(["tabs"],{...h,tabs:"array"},{},{nested:{tabs:pn}}),text:b(["content"],{...h,content:"string",size:"string",center:"boolean",copyable:"boolean",title:"string"},{text:"content"},{enums:{size:ne}}),textarea:b([],{...h,label:"string",placeholder:"string",rows:"number",value:"string",action:"string",id:"string"}),timeline:b(["items"],{...h,items:"array"},{},{nested:{items:an}}),video:b(["src"],{...h,src:"string",alt:"string",poster:"string",loop:"boolean",muted:"boolean",aspectRatio:"string"},{url:"src",link:"src"},{enums:{aspectRatio:ae}})},q=new Set(Object.keys(T));function N(t){if(typeof t!="object"||t===null)return!1;let i=t;return typeof i.type!="string"||i.type===""?!1:Array.isArray(i.items)?q.has(i.type):!0}function z(t){if(typeof t!="object"||t===null)return null;let i=t;if(typeof i.type!="string"||i.type==="")return null;let r=q.has(i.type)?T[i.type]:void 0,e=typeof i.title=="string"&&r!==void 0&&!("title"in r.fields)?i.title:void 0,s={...t};return e!==void 0&&delete s.title,{items:[s],...e!==void 0?{title:e}:{},...i.panel===!0?{panel:!0}:{},...i.append===!0?{append:!0}:{}}}function Me(t){if(typeof t!="object"||t===null||N(t))return!1;let i=t;return!(!Array.isArray(i.items)||i.title!==void 0&&typeof i.title!="string"||i.gap!==void 0&&typeof i.gap!="number")}var m={maxDepth:8,maxNodes:200,maxString:2e3,maxCode:12e3,maxMermaid:8e3,maxGridCols:12,maxTabs:12,maxAccordionItems:24,maxListItems:50,maxOptions:50,maxTableRows:50,maxTableCols:12,maxChartPoints:60,maxPlotSeries:8,maxPlotParams:6,maxMeshes:5,maxQuizOptions:8,maxSteps:24,maxTimelineItems:24,maxBreadcrumbItems:12,maxKeyValuePairs:24,maxTreeDepth:6,maxDiagramNodes:9,maxDiagramEdges:12,maxDiagramZones:3,maxDiagramFocal:2,maxDiagramLabel:14,maxEChartOptionDepth:10,maxEChartArrayLen:500,maxEChartOptionNodes:2e3};function ke(t){let i=t.columns,r=Array.isArray(i)&&i.length>0,e=r&&Array.isArray(i)&&typeof i[0]=="object"&&i[0]!==null?i.map($n):i,s=kn(e),n=t.rows!==void 0?t.rows:t.data;if(Array.isArray(n)&&n.length>0&&typeof n[0]=="object"&&n[0]!==null&&!Array.isArray(n[0])){let u=Array.isArray(t.columns)&&t.columns.length>0&&typeof t.columns[0]=="object"&&t.columns[0]!==null?t.columns.map(Sn).filter(d=>d!==void 0):Object.keys(n[0]);n=n.map(d=>u.map(c=>wn(d[c])))}let o=null;if(!r&&Array.isArray(n)&&n.length>0&&Array.isArray(n[0])){let u=xe(n),d=u.length===0?null:An(u);d!==null&&xe(d.rows).length===d.rows.length&&(o=d,s=d.columns.map(c=>c.slice(0,128)))}if(s.length===0&&!Array.isArray(t.columns))return null;let a=xe(o===null?n:o.rows);return Array.isArray(n)?{columns:s.slice(0,m.maxTableCols),rows:a}:null}function I(t){return ke(t)?.rows??[]}function xn(t,i){return!Array.isArray(t)||!Array.isArray(i)||i[0]!=="group"?!1:String(t[0]??"").trim()!==""&&t.slice(1).every(r=>String(r??"").trim()==="")}function C(t,i){let r=I(t);return i>=0&&i<r.length&&!xn(r[i],t.types)}function kn(t){if(!Array.isArray(t))return[];let i=[];for(let r of t){if(i.length>=m.maxTableCols)break;if(typeof r=="string")i.push(r.slice(0,128));else if(r!==null&&typeof r=="object"){let e=r,s=typeof e.label=="string"?e.label:typeof e.value=="string"?e.value:typeof e.title=="string"?e.title:JSON.stringify(r);i.push(s.slice(0,128))}}return i}function xe(t){if(!Array.isArray(t))return[];let i=[];for(let r of t){if(i.length>=m.maxTableRows)break;if(!Array.isArray(r))continue;let e=[];for(let s of r){if(e.length>=m.maxTableCols)break;typeof s=="string"?e.push(s.slice(0,256)):typeof s=="number"&&Number.isFinite(s)&&e.push(s)}e.length>0&&i.push(e)}return i}function An(t){let i=t[0];if(i===void 0||i.length===0)return null;let r=t.slice(1);if(r.length===0){let e=i.map(s=>String(s).trim());return e.every(s=>s!=="")?{columns:e,rows:[]}:null}return r.every(e=>e.length===i.length)?{columns:i.map(e=>String(e).trim()),rows:r}:{columns:Array.from({length:i.length},(e,s)=>`\u5217${s+1}`),rows:t}}function Sn(t){if(t===null||typeof t!="object"||Array.isArray(t))return;let i=t;for(let r of["key","dataIndex","title","label"])if(typeof i[r]=="string"&&i[r]!=="")return i[r]}function wn(t){return typeof t=="string"||typeof t=="number"&&Number.isFinite(t)?t:t==null?"":JSON.stringify(t)}function $n(t){if(t===null||typeof t!="object"||Array.isArray(t))return String(t);let i=t;for(let r of["title","label","key","dataIndex"])if(typeof i[r]=="string"&&i[r]!=="")return i[r];return JSON.stringify(t)}function O(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}function Ae(t){let i=O(t);return i!==void 0&&typeof i.type=="string"}var Gn=["label","value","delta","spark","size"],Rn={label:"title",name:"title",description:"desc",content:"desc",text:"desc",body:"desc",detail:"desc"};function Tn(t,i,r){if(t.length===0)return null;let e=[];for(let s=0;s<t.length;s++){let n=t[s],o=O(n);if(o===void 0)return null;if(Ae(n)){e.push(r(n,`${i}.items[${s}]`));continue}if(typeof o.label!="string"&&typeof o.value!="string")return null;let a={type:"stat"};for(let u of Gn)o[u]!==void 0&&(a[u]=o[u]);e.push(a)}return e}function Cn(t,i,r,e){let s=T[r];if(s===void 0)return t;let n={...t};for(let[o,a]of Object.entries(s.aliases)){if(!(o in n))continue;let u=`${i}.${o}`,d=a in n;d||(n[a]=n[o]),delete n[o],e.push({kind:"alias",path:u,message:d?`${u} is ignored because canonical field '${a}' is present`:`${u} normalized/adopted as '${a}'`,type:r,field:o,canonical:a})}for(let[o,a]of Object.entries(s.valueAliases)){let u=n[o];if(typeof u!="string")continue;let d=a[u];d===void 0||d===u||(n[o]=d,e.push({kind:"alias",path:`${i}.${o}`,message:`${i}.${o} '${u}' normalized to '${d}'`,type:r,field:o,canonical:d}))}return n}function Se(t,i,r,e,s){if(Array.isArray(t))return t.map((a,u)=>Se(a,i,`${r}[${u}]`,e,s));let n=O(t);if(n===void 0)return t;let o={...n};for(let[a,u]of Object.entries(i.aliases))!(a in o)||u in o||(o[u]=o[a],delete o[a],s.push({kind:"alias",path:`${r}.${a}`,message:`${r}.${a} normalized/adopted as '${u}'`,type:e,field:a,canonical:u}));for(let[a,u]of Object.entries(i.nested))o[a]!==void 0&&(o[a]=Se(o[a],u,`${r}.${a}`,e,s));return o}function we(t){if(Array.isArray(t))return t.map(we);let i=O(t);if(i===void 0)return t;let r={...i};return r.type===void 0&&Array.isArray(r.children)&&(r.type="dir"),r.children!==void 0&&(r.children=we(r.children)),r}function $e(t,i,r){if(!Ae(t))return t;let e=t.type,s=T[e];if(s===void 0)return t;let n=Cn(t,i,e,r);for(let[u,d]of Object.entries(s.nested))n[u]!==void 0&&(n[u]=Se(n[u],d,`${i}.${u}`,e,r));let o=(u,d)=>$e(u,d,r),a=(u,d)=>Array.isArray(u)?u.map((c,f)=>o(c,`${d}[${f}]`)):u;if(e==="file-tree"&&n.items!==void 0&&(n.items=we(n.items)),e==="stat"&&Array.isArray(n.items)&&n.label===void 0&&n.value===void 0){let u=Tn(n.items,i,o);if(u!==null)return r.push({kind:"alias",path:`${i}.items`,message:`${i}.items normalized into a row of 'stat' nodes`,type:e,field:"items",canonical:"row"}),{type:"row",items:u,...n.span!==void 0?{span:n.span}:{}}}if(e==="row"||e==="col"||e==="grid"||e==="card"||e==="file-tree"||e==="timeline"||e==="breadcrumb")e!=="file-tree"&&e!=="timeline"&&e!=="breadcrumb"&&(n.items=a(n.items,`${i}.items`));else if(e==="list"&&Array.isArray(n.items))n.items=n.items.map((u,d)=>{if(Ae(u))return o(u,`${i}.items[${d}]`);if(Array.isArray(u)&&u.length===1&&typeof u[0]=="string")return u[0];let c=O(u);if(c===void 0)return u;let f={...c},g=`${i}.items[${d}]`;for(let[x,$]of Object.entries(Rn)){if(!(x in f))continue;let J=$ in f;J||(f[$]=f[x]),delete f[x],r.push({kind:"alias",path:`${g}.${x}`,type:e,field:x,canonical:$,message:J?`${g}.${x} is ignored because canonical field '${$}' is present`:`${g}.${x} normalized/adopted as '${$}'`})}return!("title"in f)&&typeof f.desc=="string"&&(f.title=f.desc,delete f.desc,r.push({kind:"alias",path:`${g}.desc`,type:e,field:"desc",canonical:"title",message:`${g}.desc normalized/adopted as 'title'`})),f});else if(e==="keyvalue"&&Array.isArray(n.pairs))n.pairs.length>0&&n.pairs.every(u=>Array.isArray(u))&&(n.pairs=n.pairs.map(u=>{let d=u;return{key:d[0],value:d.length>1?d[1]:""}}));else if(e==="tabs"&&Array.isArray(n.tabs))n.tabs=n.tabs.map((u,d)=>{let c=O(u);if(c===void 0)return u;let f={...c};if("content"in f){let g=`${i}.tabs[${d}].content`,x="items"in f;x||(f.items=f.content),delete f.content,r.push({kind:"alias",path:g,message:x?`${g} is ignored because canonical field 'items' is present`:`${g} normalized/adopted as 'items'`,type:e,field:"content",canonical:"items"})}return f.items=Array.isArray(f.items)?f.items.map((g,x)=>o(g,`${i}.tabs[${d}].items[${x}]`)):f.items===void 0?[]:[o(f.items,`${i}.tabs[${d}].items[0]`)],f});else if(e==="accordion"&&Array.isArray(n.items))n.items=n.items.map((u,d)=>{let c=O(u);return c===void 0?u:{...c,items:Array.isArray(c.items)?c.items.map((f,g)=>o(f,`${i}.items[${d}].items[${g}]`)):c.items}});else if(e==="table"&&Array.isArray(n.details)){let u={columns:n.columns,rows:n.rows,types:n.types};n.details=n.details.map((d,c)=>!Array.isArray(d)||!C(u,c)?d:d.map((f,g)=>o(f,`${i}.details[${c}][${g}]`)))}return n}function Ie(t){let i=[];if(typeof t=="string")try{let s=JSON.parse(t);(O(s)!==void 0||Array.isArray(s))&&(t=s,i.push({kind:"alias",path:"spec",message:"double-encoded JSON string unwrapped into a spec value"}))}catch{}Array.isArray(t)&&t.length>0&&(t={items:t},i.push({kind:"alias",path:"items",message:"root array normalized into an items envelope"}));let r=O(t);if(r===void 0)return{value:t,warnings:i};let e={...r};return N(e)?{value:$e(e,"spec",i),warnings:i}:(Array.isArray(e.items)&&(e.items=e.items.map((s,n)=>$e(s,`items[${n}]`,i))),{value:e,warnings:i})}function F(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}function _e(t){let i=F(t);return i!==void 0&&typeof i.type=="string"}function Ge(t,i,r){if(!_e(t))return;let e=t.type,s=T[e];if(s===void 0)return;r(t,i,s);let n=(o,a)=>Ge(o,a,r);if((e==="row"||e==="col"||e==="grid"||e==="card")&&Array.isArray(t.items))t.items.forEach((o,a)=>n(o,`${i}.items[${a}]`));else if(e==="list"&&Array.isArray(t.items))t.items.forEach((o,a)=>n(o,`${i}.items[${a}]`));else if(e==="tabs"&&Array.isArray(t.tabs))t.tabs.forEach((o,a)=>{let u=F(o);u!==void 0&&(Array.isArray(u.items)?u.items.forEach((d,c)=>n(d,`${i}.tabs[${a}].items[${c}]`)):n(u.items,`${i}.tabs[${a}].items`))});else if(e==="accordion"&&Array.isArray(t.items))t.items.forEach((o,a)=>{let u=F(o);u?.items!==void 0&&Array.isArray(u.items)&&u.items.forEach((d,c)=>n(d,`${i}.items[${a}].items[${c}]`))});else if(e==="table"&&Array.isArray(t.details)){let o={columns:t.columns,rows:t.rows,types:t.types};t.details.forEach((a,u)=>{Array.isArray(a)&&C(o,u)&&a.forEach((d,c)=>n(d,`${i}.details[${u}][${c}]`))})}}function B(t,i,r,e){t.push({kind:"unknown-field",path:`${i}.${r}`,message:`${i}.${r}: unknown field for '${e}'`,type:e,field:r})}function Y(t,i,r,e,s){let n=F(t);if(n!==void 0){for(let o of Object.keys(n))o in r.fields||B(s,i,o,e);for(let[o,a]of Object.entries(r.nested)){let u=n[o];Array.isArray(u)?u.forEach((d,c)=>Y(d,`${i}.${o}[${c}]`,a,e,s)):u!==void 0&&Y(u,`${i}.${o}`,a,e,s)}}}function Nn(t,i,r,e){for(let[s,n]of Object.entries(r.nested)){let o=t[s];Array.isArray(o)?o.forEach((a,u)=>Y(a,`${i}.${s}[${u}]`,n,t.type,e)):o!==void 0&&Y(o,`${i}.${s}`,n,t.type,e)}}function Pe(t){let i=[],r=F(t);if(r===void 0)return i;let e=(s,n,o)=>{for(let a of Object.keys(s))a==="type"||a in o.fields||B(i,n,a,s.type);Nn(s,n,o,i),s.type==="list"&&Array.isArray(s.items)&&s.items.forEach((a,u)=>{if(_e(a))return;let d=F(a);if(d!==void 0)for(let c of Object.keys(d)){if(c==="title"||c==="desc")continue;let f=`${n}.items[${u}]`;i.push({kind:"unknown-field",path:`${f}.${c}`,message:`${f}.${c}: list items render 'title' and 'desc' only \u2014 '${c}' is dropped`,type:"list",field:c})}})};if(Array.isArray(r.items)&&!N(r)){for(let s of Object.keys(r))s in V.fields||B(i,"spec",s,"spec");r.items.forEach((s,n)=>Ge(s,`items[${n}]`,e))}else if(typeof r.type=="string")Ge(r,"spec",e);else for(let s of Object.keys(r))s in V.fields||B(i,"spec",s,"spec");return i}function ve(t,i){let r=(s,n,o)=>{o>m.maxDepth||s.forEach((a,u)=>e(a,`${n}[${u}]`,o))},e=(s,n,o)=>{if(!(o>m.maxDepth)&&(i(s,n),!(o>=m.maxDepth)))switch(s.type){case"row":case"col":case"grid":case"card":r(s.items,`${n}.items`,o+1);break;case"tabs":s.tabs.forEach((a,u)=>r(a.items,`${n}.tabs[${u}].items`,o+1));break;case"accordion":s.items.forEach((a,u)=>r(a.items,`${n}.items[${u}].items`,o+1));break;case"list":s.items.forEach((a,u)=>{a!==null&&typeof a=="object"&&"type"in a&&e(a,`${n}.items[${u}]`,o+1)});break;case"table":s.details?.slice(0,I(s).length).forEach((a,u)=>{a!==null&&C(s,u)&&r(a,`${n}.details[${u}]`,o+1)});break}};r(t.items,"items",0)}function Re(t){let i=new Map,r=new Map,e=[],s=[];ve(t,(n,o)=>{if(n.type==="submit"){n.groups!==void 0&&s.push({groups:n.groups,path:o});return}let a,u;switch(n.type){case"radio":if(n.group===void 0)return;a={kind:"radio",key:n.group,label:n.label??n.group,options:n.options.slice(0,m.maxOptions),...n.answer===void 0?{}:{answer:n.answer},...n.explanation===void 0?{}:{explanation:n.explanation}},u=`${o}.group`;break;case"checkbox":if(n.group===void 0)return;a={kind:"checkbox",key:n.group},u=`${o}.group`;break;case"input":case"textarea":case"select":case"slider":if(n.id===void 0)return;a={kind:"field",key:n.id,fieldType:n.type,secret:n.type==="input"&&n.inputType==="password"},u=`${o}.id`;break;default:return}if(a===void 0)return;let d=i.get(a.key);if(d!==void 0){(d.kind!=="checkbox"||a.kind!=="checkbox")&&e.push(`${u} conflicts with ${r.get(a.key)}: submission key '${a.key}' is already used`);return}i.set(a.key,a),r.set(a.key,u)});for(let{groups:n,path:o}of s){let a=new Set;n.forEach((u,d)=>{let c=`${o}.groups[${d}]`;a.has(u)&&e.push(`${c}: duplicate submission member '${u}'`),a.add(u);let f=i.get(u);f===void 0?e.push(`${c}: submit.groups references unknown submission member '${u}'`):f.kind==="field"&&f.secret&&e.push(`${c}: submit.groups cannot require secret field '${u}'`)})}return{registry:{members:i},diagnostics:e}}function En(t,i){return typeof t=="string"&&i.includes(t)}function p(t,i){return typeof t=="string"?t.slice(0,i):void 0}var Dn=/^(?:#[\da-fA-F]{3,8}|rgba?\([^)]{0,64}\)|hsla?\([^)]{0,64}\)|var\(--dsw-[\w-]+(?:,\s*#[0-9a-fA-F]{3,8})?\))$/;function E(t){if(typeof t!="string")return;let i=t.trim();return i.length<=64&&Dn.test(i)?i:void 0}function qe(t){if(typeof t!="string")return;let i=t.trim();if(!(i.length>2048))return/^https?:\/\//i.test(i)||/^mailto:[^@\s]+@[^@\s]+$/i.test(i)?i:void 0}function K(t){if(typeof t!="string")return;let i=t.trim();if(!(i===""||i.length>2048)){if(/^https?:\/\//i.test(i))return i;if(!(/^[a-z][a-z0-9+.-]*:/i.test(i)||/^[/\\]{2}/.test(i)))return i}}function k(t,i,r){return typeof t=="number"&&Number.isFinite(t)?Math.min(r,Math.max(i,t)):void 0}function D(t,i,r){return typeof t=="number"&&Number.isFinite(t)?Math.min(r,Math.max(i,Math.trunc(t))):void 0}function w(t,i){return En(t,i)?t:void 0}function y(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}function l(t,i){return i===void 0?{}:{[t]:i}}function On(t){if(t.length>2048)return;let i=t.indexOf("#"),r=i<0?t:t.slice(0,i);if(r.includes("?"))return;let e;try{e=decodeURIComponent(r)}catch{return}if(e===""||/[\u0000-\u001f\u007f]/.test(e)||/^[\\/]{2}/.test(e)||/^[a-z][a-z\d+.-]*:/i.test(e)&&!/^[a-z]:[\\/]/i.test(e))return;if(i<0)return{path:e};let s=/^L([1-9]\d*)(?:-L([1-9]\d*))?$/.exec(t.slice(i+1));if(s===null)return;let n=Number(s[1]),o=s[2]===void 0?n:Number(s[2]);if(!(!Number.isSafeInteger(n)||!Number.isSafeInteger(o)||o<n))return{path:e,line:n}}function ze(t){let i=qe(t);if(i!==void 0)return{type:"external",href:i};if(typeof t!="string")return{type:"invalid"};let r=On(t.trim());return r===void 0?{type:"invalid"}:{type:"file",file:r}}function H(t,i){switch(i){case"string":return typeof t=="string";case"string-or-null":return t===null||typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"nodes":return Array.isArray(t);case"array":return Array.isArray(t);case"object":return y(t)!==void 0;case"unknown":return!0}}function j(t){switch(t){case"string-or-null":return"a string or null";case"number":return"a finite number";case"boolean":return"a boolean";case"nodes":case"array":return"an array";case"object":return"an object";case"unknown":return"a value";default:return"a string"}}function v(t,i,r){return t.some(e=>e.startsWith(`${i}.${r} `)||e.includes(`'${r}'`)||e.includes(`requires ${r}`))}function Ke(t,i,r,e,s=[]){for(let[n,o]of Object.entries(r.fields))s.includes(n)||t[n]===void 0||!H(t[n],o)&&!v(e,i,n)&&e.push(`${i}.${n} must be ${j(o)}`);for(let[n,o]of Object.entries(r.enums))s.includes(n)||t[n]===void 0||!H(t[n],"string")||!o.includes(t[n])&&!v(e,i,n)&&e.push(`${i}.${n} must be one of ${o.join(", ")}`)}function W(t,i,r,e){let s=y(t);if(s===void 0){e.push(`${i} must be an object`);return}for(let n of r.required){let o=r.fields[n];s[n]===void 0?v(e,i,n)||e.push(`${i}: requires ${n}${o===void 0?"":` (${j(o)})`}`):o!==void 0&&!H(s[n],o)&&(v(e,i,n)||e.push(`${i}.${n} must be ${j(o)}`))}for(let[n,o]of Object.entries(r.fields))s[n]!==void 0&&!H(s[n],o)&&(v(e,i,n)||e.push(`${i}.${n} must be ${j(o)}`));for(let[n,o]of Object.entries(r.enums))s[n]!==void 0&&typeof s[n]=="string"&&!o.includes(s[n])&&(v(e,i,n)||e.push(`${i}.${n} must be one of ${o.join(", ")}`));for(let[n,o]of Object.entries(r.nested)){let a=s[n];a!==void 0&&(Array.isArray(a)?a.forEach((u,d)=>W(u,`${i}.${n}[${d}]`,o,e)):W(a,`${i}.${n}`,o,e))}}function Mn(t,i,r,e){for(let[s,n]of Object.entries(r.nested)){let o=t[s];o!==void 0&&(Array.isArray(o)?o.forEach((a,u)=>W(a,`${i}.${s}[${u}]`,n,e)):W(o,`${i}.${s}`,n,e))}}function He(t){let i=t.rows!==void 0?t.rows:t.data;return!Array.isArray(i)||i.length===0?!1:Array.isArray(i[0])}function In(t,i,r,e){let s=String(t.type),n=a=>v(e,i,a),o=s==="table"&&He(t)?"columns":null;for(let a of r.required){let u=r.fields[a];if(u===void 0||t[a]===void 0){a!==o&&!n(a)&&e.push(`${i}: type '${s}' requires ${a}${u===void 0?"":` (${j(u)})`}`);continue}!H(t[a],u)&&!n(a)&&e.push(`${i}.${a} must be ${j(u)}`)}Ke(t,i,r,e,["type"]);for(let a of r.oneOfRequired)!a.some(u=>t[u]!==void 0)&&!e.some(u=>u.includes(`requires ${a.join(" or ")}`))&&e.push(`${i}: type '${s}' requires one of ${a.join(" or ")}`);for(let a of r.conditionalRequired)if(t[a.when.field]===a.when.equals)for(let u of a.required)t[u]===void 0&&!n(u)&&e.push(`${i}: type '${s}' requires ${u}${a.message===void 0?"":` (${a.message})`}`);Mn(t,i,r,e)}function _(t,i,r){if(!Array.isArray(t))return[];let e=[];for(let s of t){if(i.remaining<=0)break;i.remaining-=1;let n=Je(s,i,r);n!==null&&e.push(n)}return e}function Fe(t){if(!Array.isArray(t))return;let i=[];for(let r of t.slice(0,12)){let e=E(r);e!==void 0&&i.push(e)}return i.length>0?i:void 0}function je(t){if(!Array.isArray(t))return;let i=[];for(let r of t.slice(0,60)){let e=typeof r=="number"?r:Number(r);if(!Number.isFinite(e))return;i.push(e)}return i.length>=2?i:void 0}function Je(t,i,r){let e=_n(t,i,r);if(e===null)return null;let s=D(y(t)?.span,2,12),n=p(y(t)?.id,64);return{...e,...l("span",s),...l("id",n)}}function _n(t,i,r){if(r>m.maxDepth)return null;let e=y(t);if(e===void 0)return null;let s=e.type;if(typeof s!="string")return null;switch(s){case"text":{let n=p(e.content,m.maxString)??p(e.text,m.maxString);return n===void 0?null:{type:"text",content:n,...l("copyable",e.copyable===!0?!0:void 0),...l("title",p(e.title,m.maxString)),...l("size",w(e.size,ne)),...l("center",e.center===!0?!0:void 0)}}case"row":return{type:"row",items:_(e.items,i,r+1),...l("wrap",e.wrap===!0?!0:void 0),...l("spacer",e.spacer===!0?!0:void 0)};case"col":return{type:"col",items:_(e.items,i,r+1),...l("gap",k(e.gap,0,96))};case"grid":return{type:"grid",cols:D(e.cols,1,m.maxGridCols)??1,items:_(e.items,i,r+1)};case"card":return{type:"card",items:_(e.items,i,r+1),...l("title",p(e.title,m.maxString)),...l("tone",w(e.tone,be)),...l("accent",E(e.accent))};case"button":{let n=p(e.label,m.maxString);return n===void 0?null:{type:"button",label:n,...l("tone",w(e.tone,te)),...l("full",e.full===!0?!0:void 0),...l("small",e.small===!0?!0:void 0),...l("icon",p(e.icon,64)),...l("action",p(e.action,200))}}case"input":return{type:"input",...l("label",p(e.label,m.maxString)),...l("placeholder",p(e.placeholder,m.maxString)),...l("value",p(e.value,m.maxString)),...l("inputType",w(e.inputType,re)),...l("action",p(e.action,200)),...l("id",p(e.id,200))};case"select":{let n=Q(e.options,m.maxOptions,m.maxString);return n===void 0?null:{type:"select",options:n,...l("label",p(e.label,m.maxString)),...l("action",p(e.action,200)),...l("selected",D(e.selected,0,n.length-1)),...l("id",p(e.id,200))}}case"checkbox":{let n=p(e.label,m.maxString);return n===void 0?null:{type:"checkbox",label:n,...l("checked",e.checked===!0?!0:void 0),...l("action",p(e.action,200)),...l("group",p(e.group,200))}}case"link":{let n=p(e.label,m.maxString);if(n===void 0)return null;let o=ze(e.href),a=o.type==="external"?o.href:o.type==="file"?String(e.href).trim():void 0;return{type:"link",label:n,...l("href",a)}}case"image":{let n=K(e.src);return n===void 0?null:{type:"image",src:n,...l("alt",p(e.alt,m.maxString))}}case"audio":{let n=K(e.src);return n===void 0?null:{type:"audio",src:n,...l("alt",p(e.alt,m.maxString)),...l("loop",e.loop===!0?!0:void 0)}}case"video":{let n=K(e.src);return n===void 0?null:{type:"video",src:n,...l("alt",p(e.alt,m.maxString)),...l("poster",K(e.poster)),...l("loop",e.loop===!0?!0:void 0),...l("muted",e.muted===!0?!0:void 0),...l("aspectRatio",w(e.aspectRatio,ae))}}case"badge":{let n=p(e.label,m.maxString)??p(e.text,m.maxString)??p(e.value,m.maxString);return n===void 0?null:{type:"badge",label:n,...l("tone",w(e.tone,ie)),...l("icon",p(e.icon,64))}}case"hero":{let n=p(e.title,m.maxString);return n===void 0?null:{type:"hero",title:n,...l("subtitle",p(e.subtitle,m.maxString)),...l("value",p(e.value,128)),...l("label",p(e.label,m.maxString)),...l("delta",p(e.delta,64)),...l("spark",je(e.spark)),...l("tone",w(e.tone,he))}}case"stat":{let n=p(e.label,m.maxString),o=p(e.value,128);return n===void 0||o===void 0?null:{type:"stat",label:n,value:o,...l("delta",p(e.delta,64)),...l("spark",je(e.spark)),...l("size",e.size==="hero"?"hero":void 0)}}case"progress":{let n=k(e.value,0,100);return n===void 0?null:{type:"progress",value:n,...l("label",p(e.label,m.maxString)),...l("valueLabel",p(e.valueLabel,64)),...l("variant",w(e.variant,ye)),...l("target",k(e.target,0,100))}}case"divider":return{type:"divider"};case"spacer":return{type:"spacer"};case"avatar":{let n=p(e.name,64);return n===void 0?null:{type:"avatar",name:n,...l("color",E(e.color))}}case"list":{let n=Pn(e.items,m.maxListItems,i,r+1);return n===void 0?null:{type:"list",items:n,...l("filter",p(e.filter,64))}}case"table":{let n=ke(e);if(n===null)return null;let{columns:o,rows:a}=n,u=Array.isArray(e.types)?e.types:void 0,d=u===void 0?void 0:o.map((g,x)=>{let $=u[x];return typeof $=="string"&&Ee.includes($)?$:"text"}),c=Array.isArray(e.details)?e.details:void 0,f=c===void 0?void 0:a.map((g,x)=>{if(!C({columns:o,rows:a,types:d},x))return null;let $=_(c[x],i,r+1);return $.length===0?null:$});return{type:"table",columns:o,rows:a,...l("types",d),...l("total",e.total===!0?!0:void 0),...l("export",e.export===!0?!0:void 0),...l("filter",p(e.filter,64)),...l("filterColumn",D(e.filterColumn,0,m.maxTableCols-1)),...l("sortField",p(e.sortField,64)),...l("details",f!==void 0&&f.some(g=>g!==null)?f:void 0)}}case"chart":{let n=Te(e.data,m.maxChartPoints),o=Array.isArray(e.series)?Le(e.series,m.maxPlotSeries,m.maxChartPoints):void 0;return n===void 0&&o===void 0?null:{type:"chart",data:n??[],...l("kind",w(e.kind,U)),...l("series",o),...l("horizontal",e.horizontal===!0?!0:void 0),...l("stacked",e.stacked===!0?!0:void 0),...l("filter",p(e.filter,64)),...l("palette",Fe(e.palette))}}case"tabs":{let n=vn(e.tabs,i,r);return n===void 0?null:{type:"tabs",tabs:n}}case"plot":{let n=qn(e.series,m.maxPlotSeries);return n===void 0?null:{type:"plot",series:n,...l("xMin",k(e.xMin,-1e6,1e6)),...l("xMax",k(e.xMax,-1e6,1e6)),...l("yMin",k(e.yMin,-1e9,1e9)),...l("yMax",k(e.yMax,-1e9,1e9)),...l("title",p(e.title,m.maxString))}}case"callout":{let n=p(e.content,m.maxString);return n===void 0?null:{type:"callout",content:n,...l("tone",w(e.tone,se)),...l("title",p(e.title,m.maxString))}}case"steps":{let n=zn(e.steps);return n===void 0?null:{type:"steps",steps:n,...l("current",D(e.current,0,n.length))}}case"keyvalue":{let n=Fn(e.pairs,m.maxKeyValuePairs);return n===void 0?null:{type:"keyvalue",pairs:n}}case"diff":{let n=jn(e.diffs);return n===void 0?null:{type:"diff",diffs:n}}case"json":return"value"in e?{type:"json",value:e.value}:null;case"code":{let n=p(e.code,m.maxCode);return n===void 0?null:{type:"code",code:n,...l("lang",p(e.lang,64)),...l("title",p(e.title,m.maxString)),...l("wrap",e.wrap===!0?!0:void 0)}}case"radio":{let n=Q(e.options,m.maxOptions,m.maxString);return n===void 0?null:{type:"radio",options:n,...l("label",p(e.label,m.maxString)),...l("selected",D(e.selected,0,n.length-1)),...l("action",p(e.action,200)),...l("group",p(e.group,200)),...l("answer",typeof e.answer=="number"&&Number.isFinite(e.answer)&&e.answer>=0&&e.answer<n.length?Math.trunc(e.answer):typeof e.answer=="string"?e.answer.slice(0,512):void 0),...l("explanation",p(e.explanation,m.maxString))}}case"submit":{let n=p(e.label,m.maxString),o=p(e.action,200);return n===void 0?null:{type:"submit",label:n,...l("action",o),...l("resetAction",p(e.resetAction,200)),...l("groups",Q(e.groups,m.maxOptions,200))}}case"switch":{let n=p(e.label,m.maxString);return n===void 0?null:{type:"switch",label:n,...l("checked",e.checked===!0?!0:void 0),...l("action",p(e.action,200))}}case"slider":{let n=k(e.min,-1e9,1e9)??0,o=k(e.max,-1e9,1e9)??100,a=Math.min(n,o),u=Math.max(n,o),d=k(e.step,1e-9,Math.max(u-a,1e-9)),c=k(e.value,a,u)??a;return{type:"slider",min:a,max:u,...l("step",d),value:c,...l("label",p(e.label,m.maxString)),...l("action",p(e.action,200)),...l("id",p(e.id,200))}}case"textarea":return{type:"textarea",...l("label",p(e.label,m.maxString)),...l("placeholder",p(e.placeholder,m.maxString)),...l("rows",D(e.rows,1,30)),...l("value",p(e.value,m.maxString)),...l("action",p(e.action,200)),...l("id",p(e.id,200))};case"accordion":{let n=Ln(e.items,i,r);return n===void 0?null:{type:"accordion",items:n}}case"copy":{let n=p(e.text,m.maxCode);return n===void 0?null:{type:"copy",text:n,...l("label",p(e.label,128))}}case"svg":{let n=p(e.code,m.maxCode);return n===void 0?null:{type:"svg",code:n,...l("title",p(e.title,m.maxString)),...l("height",D(e.height,100,800))}}case"mermaid":{let n=p(e.code,m.maxMermaid);return n===void 0?null:{type:"mermaid",code:n}}case"scene3d":{let n=Vn(e.meshes);return n===void 0?null:{type:"scene3d",meshes:n,...l("title",p(e.title,m.maxString)),...l("ambient",k(e.ambient,0,2)),...l("background",E(e.background))}}case"diagram":return Bn(e);case"timeline":{let n=Yn(e.items,m.maxTimelineItems);return n===void 0?null:{type:"timeline",items:n}}case"file-tree":{let n=Qn(e.items,m.maxListItems);return n===void 0?null:{type:"file-tree",items:n}}case"breadcrumb":{let n=Q(e.items,m.maxBreadcrumbItems,m.maxString);return n===void 0?null:{type:"breadcrumb",items:n}}case"quiz":{let n=p(e.question,m.maxString),o=Zn(e.options,e.answer);return n===void 0||o===void 0?null:{type:"quiz",question:n,options:o,...l("explanation",p(e.explanation,m.maxString)),...l("id",p(e.id,200)),...l("action",p(e.action,200))}}case"echart":{let n=e.data!==void 0?Te(e.data,m.maxChartPoints):void 0,o=e.series!==void 0&&Array.isArray(e.series)?Le(e.series,m.maxPlotSeries,m.maxChartPoints):void 0,a=Array.isArray(e.links)?e.links.slice(0,m.maxChartPoints).flatMap(c=>{let f=y(c),g=f===void 0?void 0:p(f.from,64),x=f===void 0?void 0:p(f.to,64);return g===void 0||x===void 0?[]:[{from:g,to:x,...l("value",k(f.value,0,1e9))}]}):void 0,u=e.option!==void 0?Ce(e.option,0,{count:m.maxEChartOptionNodes}):void 0,d=u===void 0||typeof u!="object"||u===null||Array.isArray(u)?void 0:u;return d===void 0&&n===void 0&&o===void 0&&(a===void 0||a.length===0)?null:{type:"echart",...l("title",p(e.title,m.maxString)),...l("height",D(e.height,100,800)),...l("preset",w(e.preset,ge)),...l("data",n),...l("series",o),...l("links",a!==void 0&&a.length>0?a:void 0),...l("palette",Fe(e.palette)),...l("option",d)}}default:return t}}function Q(t,i,r){if(!Array.isArray(t))return;let e=[];for(let s of t){if(e.length>=i)break;if(typeof s=="string")e.push(s.slice(0,r));else if(s!==null&&typeof s=="object"){let n=s,o=typeof n.label=="string"?n.label:typeof n.value=="string"?n.value:typeof n.title=="string"?n.title:JSON.stringify(s);e.push(o.slice(0,r))}}return e}function Pn(t,i,r,e){if(!Array.isArray(t))return;let s=[];for(let n of t){if(s.length>=i)break;if(typeof n=="string"){s.push(n.slice(0,m.maxString));continue}let o=y(n);if(o!==void 0&&typeof o.type=="string"){if(r.remaining<=0)break;r.remaining-=1;let u=Je(o,r,e);u!==null&&s.push(u);continue}let a=o===void 0?void 0:p(o.title,m.maxString);a!==void 0&&s.push({title:a,...l("desc",p(o?.desc,m.maxString))})}return s}function Te(t,i){if(!Array.isArray(t))return;let r=[];for(let e of t){if(r.length>=i)break;let s=y(e),n=s===void 0?void 0:p(s.label,128),o=s===void 0?void 0:k(s.value,-1e12,1e12);n===void 0||o===void 0||r.push({label:n,value:o,...l("color",s===void 0?void 0:E(s.color))})}return r}function Le(t,i,r){if(!Array.isArray(t))return;let e=[];for(let s of t){if(e.length>=i)break;let n=y(s),o=n===void 0?void 0:p(n.label,128),a=n===void 0?void 0:Te(n.data,r);o===void 0||a===void 0||e.push({label:o,data:a,...l("color",n===void 0?void 0:E(n.color))})}return e}function vn(t,i,r){if(!Array.isArray(t))return;let e=[];for(let s of t){if(e.length>=m.maxTabs)break;let n=y(s),o=n===void 0?void 0:p(n.label,128);if(o===void 0||n===void 0)continue;let a=n.items!==void 0?n.items:n.content!==void 0?Array.isArray(n.content)?n.content:[n.content]:void 0;e.push({label:o,items:_(a,i,r+1)})}return e}function qn(t,i){if(!Array.isArray(t))return;let r=[];for(let e of t){if(r.length>=i)break;let s=y(e),n=s===void 0?void 0:p(s.expr,512);if(n===void 0||s===void 0)continue;let o=[];if(Array.isArray(s.params))for(let a of s.params){if(o.length>=m.maxPlotParams)break;let u=y(a),d=u===void 0?void 0:p(u.name,64),c=u===void 0?void 0:k(u.value,-1e9,1e9);d===void 0||c===void 0||o.push({name:d,value:c,...l("min",u===void 0?void 0:k(u.min,-1e9,1e9)),...l("max",u===void 0?void 0:k(u.max,-1e9,1e9)),...l("step",u===void 0?void 0:k(u.step,1e-9,1e9)),...l("animateTo",u===void 0?void 0:k(u.animateTo,-1e9,1e9)),...l("durationMs",u===void 0?void 0:k(u.durationMs,1,12e4)),...l("loop",u===void 0?void 0:u.loop===!0?!0:void 0)})}r.push({expr:n,...l("label",p(s.label,128)),...l("color",E(s.color)),...l("kind",w(s.kind,oe)),...l("params",o.length>0?o:void 0)})}return r}function zn(t){if(!Array.isArray(t))return;let i=[];for(let r of t){if(i.length>=m.maxSteps)break;let e=y(r),s=e===void 0?void 0:p(e.title,256);s!==void 0&&i.push({title:s,...l("desc",e===void 0?void 0:p(e.desc,m.maxString))})}return i}function Fn(t,i){if(!Array.isArray(t))return;let r=[];for(let e of t){if(r.length>=i)break;let s=y(e),n=s===void 0?void 0:p(s.key,256),o=s===void 0?void 0:p(s.value,m.maxString);n===void 0||o===void 0||r.push({key:n,value:o})}return r}function jn(t){if(!Array.isArray(t))return;let i=[];for(let r of t){if(i.length>=24)break;let e=y(r),s=e===void 0?void 0:p(e.path,1024),n=e===void 0?void 0:p(e.newText,2e4);if(s===void 0||n===void 0)continue;let o=e===void 0?void 0:e.oldText;i.push({path:s,newText:n,oldText:o===null||typeof o!="string"?null:o.slice(0,2e4)})}return i}function Ln(t,i,r){if(!Array.isArray(t))return;let e=[];for(let s of t){if(e.length>=m.maxAccordionItems)break;let n=y(s),o=n===void 0?void 0:p(n.title,256);o===void 0||n===void 0||e.push({title:o,items:_(n.items,i,r+1)})}return e}function Vn(t){if(!Array.isArray(t))return;let i=[];for(let r of t){if(i.length>=m.maxMeshes)break;let e=y(r),s=e===void 0?void 0:w(e.shape,ue);if(s===void 0)continue;let n=e===void 0?void 0:k(e.scale,-1e6,1e6)??Z(e.scale),o=e===void 0?void 0:k(e.size,-1e6,1e6)??Z(e.size);i.push({shape:s,...l("color",e===void 0?void 0:E(e.color)),...l("position",e===void 0?void 0:Z(e.position)),...l("rotation",e===void 0?void 0:Z(e.rotation)),...l("scale",n),...l("size",o)})}return i}function Z(t){if(!Array.isArray(t)||t.length!==3)return;let[i,r,e]=t;if(!(typeof i!="number"||!Number.isFinite(i)||typeof r!="number"||!Number.isFinite(r)||typeof e!="number"||!Number.isFinite(e)))return[Math.min(1e6,Math.max(-1e6,i)),Math.min(1e6,Math.max(-1e6,r)),Math.min(1e6,Math.max(-1e6,e))]}function P(t,i,r){return Math.min(r,Math.max(i,Math.round(t/4)*4))}function Kn(t){if(!Array.isArray(t))return;let i=[],r=new Set;for(let e of t){if(i.length>=m.maxDiagramNodes)break;let s=y(e);if(s===void 0)continue;let n=p(s.id,128),o=p(s.label,m.maxString);if(n===void 0||o===void 0||r.has(n))continue;r.add(n);let a=w(s.type,ce),u=s.x===void 0?void 0:P(k(s.x,-1e6,1e6)??0,0,1e6),d=s.y===void 0?void 0:P(k(s.y,-1e6,1e6)??0,0,1e6),c=s.w===void 0?void 0:P(k(s.w,-1e6,1e6)??96,40,2e3),f=s.h===void 0?void 0:P(k(s.h,-1e6,1e6)??48,24,1200);i.push({id:n,label:o,...l("sub",p(s.sub,256)),...l("type",a),...l("x",u),...l("y",d),...l("w",c),...l("h",f),...l("tag",p(s.tag,32))})}return i}function Hn(t){if(t===void 0)return[];if(!Array.isArray(t))return;let i=[];for(let r of t){if(i.length>=m.maxDiagramEdges)break;let e=y(r);if(e===void 0)continue;let s=p(e.from,128),n=p(e.to,128);s===void 0||n===void 0||i.push({from:s,to:n,...l("label",p(e.label,m.maxDiagramLabel)),...l("kind",w(e.kind,pe)),...l("route",w(e.route,me))})}return i}function Jn(t){let i=y(t);if(i===void 0)return;let r={};for(let e of["paper","paper-2","ink","muted","soft","rule","accent","accent-tint","link"]){let s=E(i[e]);s!==void 0&&(r[e]=s)}return Object.keys(r).length===0?void 0:r}function Un(t){if(t===void 0)return[];if(!Array.isArray(t))return;let i=[];for(let r of t){if(i.length>=m.maxDiagramZones)break;let e=y(r);if(e===void 0)continue;let s=p(e.label,64);s!==void 0&&i.push({label:s,...l("x",e.x===void 0?void 0:P(k(e.x,-1e6,1e6)??0,0,1e6)),...l("y",e.y===void 0?void 0:P(k(e.y,-1e6,1e6)??0,0,1e6)),...l("w",e.w===void 0?void 0:P(k(e.w,-1e6,1e6)??100,40,2e3)),...l("h",e.h===void 0?void 0:P(k(e.h,-1e6,1e6)??100,40,1200))})}return i}function Bn(t){let i=y(t);if(i===void 0)return null;let r=w(i.kind,de);if(r===void 0)return null;let e=Kn(i.nodes);if(e===void 0)return null;let s=Hn(i.edges);if(s===void 0)return null;let n=Un(i.zones);return n===void 0?null:{type:"diagram",kind:r,nodes:e,edges:s,...l("zones",n.length>0?n:void 0),...l("variant",w(i.variant,fe)),...l("title",p(i.title,256)),...l("theme",Jn(i.theme))}}function Yn(t,i){if(!Array.isArray(t))return;let r=[];for(let e of t){if(r.length>=i)break;let s=y(e),n=s===void 0?void 0:p(s.title,256);n!==void 0&&r.push({title:n,...l("desc",s===void 0?void 0:p(s.desc,m.maxString)),...l("time",s===void 0?void 0:p(s.time,128))})}return r}function Qn(t,i){return Ue(t,i,m.maxTreeDepth)}function Ue(t,i,r){if(!Array.isArray(t))return;let e=[];for(let s of t){if(e.length>=i)break;let n=y(s),o=n===void 0?void 0:p(n.name,256);if(o===void 0)continue;let a=n!==void 0&&r>0&&Array.isArray(n.children)?Ue(n.children,i,r-1):void 0;e.push({name:o,...l("type",n===void 0?void 0:w(n.type,le)),...l("children",a)})}return e}function Zn(t,i){if(!Array.isArray(t))return;let r=[];for(let s of t){if(r.length>=m.maxQuizOptions)break;let n=y(s),o=typeof s=="string"?p(s,512):n===void 0?void 0:p(n.label,512);o!==void 0&&r.push({label:o,...l("correct",n===void 0?void 0:n.correct===!0?!0:void 0),...l("feedback",n===void 0?void 0:p(n.feedback,m.maxString))})}if(r.length===0)return;if(r.some(s=>s.correct===!0))return r;let e=typeof i=="number"&&Number.isFinite(i)?Math.trunc(i):typeof i=="string"?r.findIndex(s=>s.label===i.slice(0,512)):-1;return e<0||e>=r.length?r:r.map((s,n)=>n===e?{...s,correct:!0}:s)}var Wn=/<(?:script|img|svg|iframe|video|audio|object|embed|source)\b|on[a-z]+\s*=|javascript:/i;function Ce(t,i,r){if(r.count<=0||(r.count-=1,i>m.maxEChartOptionDepth))return;if(typeof t=="string"){let n=t.slice(0,m.maxString);return n.toLowerCase().includes("url(")||Wn.test(n)?void 0:n}if(typeof t=="number"&&Number.isFinite(t)||typeof t=="boolean")return t;if(t===null)return null;if(Array.isArray(t)){let n=Math.min(t.length,m.maxEChartArrayLen),o=[];for(let a=0;a<n;a++){let u=Ce(t[a],i+1,r);u!==void 0&&o.push(u)}return o.length>0||t.length===0?o:void 0}let e=y(t);if(e===void 0)return;let s={};for(let[n,o]of Object.entries(e)){let a=Ce(o,i+1,r);a!==void 0&&(n==="tooltip"&&typeof a=="object"&&a!==null&&!Array.isArray(a)&&(a.renderMode="richText"),s[n]=a)}return Object.keys(s).length>0||Object.keys(e).length===0?s:void 0}function Be(t){let i=y(t);if(i===void 0)return null;if(N(t)){let e=z(t);return e===null?null:Be(e)}if(!Array.isArray(i.items))return null;let r={remaining:m.maxNodes};return{...l("title",p(i.title,m.maxString)),...l("gap",k(i.gap,0,96)),...l("panel",i.panel===!0?!0:void 0),...l("append",i.append===!0?!0:void 0),items:_(i.items,r,0)}}function Xn(t,i=Number.POSITIVE_INFINITY){let r=0,e=n=>{if(Array.isArray(n))for(let o of n){if(r>=i)return;r+=1;let a=y(o);if(a!==void 0){if(a.type==="tabs"&&Array.isArray(a.tabs))for(let u of a.tabs){if(r>=i)return;let d=y(u);d!==void 0&&e(d.items)}else if(a.type==="accordion"&&Array.isArray(a.items))for(let u of a.items){if(r>=i)return;let d=y(u);d!==void 0&&e(d.items)}else if((a.type==="row"||a.type==="col"||a.type==="grid"||a.type==="card")&&Array.isArray(a.items))e(a.items);else if(a.type!=="file-tree"){if(a.type==="list"&&Array.isArray(a.items))for(let u of a.items){if(r>=i)return;let d=y(u);d!==void 0&&typeof d.type=="string"&&e([d])}else if(a.type==="table"&&Array.isArray(a.details)){let u=I(a).length;for(let d=0;d<Math.min(a.details.length,u);d++){if(r>=i)return;let c=a.details[d];Array.isArray(c)&&C(a,d)&&e(c)}}}}}},s=y(t);return e(s===void 0?[]:s.items),r}var et=q;function nt(t,i,r){let e=0,s=d=>{let c=y(d);return c!==void 0&&typeof c.type=="string"&&et.has(c.type)};function n(d,c){if(Array.isArray(d)){for(let f=0;f<d.length;f++)if(o(d[f],`${c}[${f}]`),e>=i)return}}function o(d,c){if(e>=i||!s(d))return;let f=y(d);if(f!==void 0){if(e+=1,r(f,c),f.type==="tabs"&&Array.isArray(f.tabs))for(let g=0;g<f.tabs.length;g++)a(f.tabs[g],`${c}.tabs[${g}]`);else if(f.type==="accordion"&&Array.isArray(f.items))for(let g=0;g<f.items.length;g++)a(f.items[g],`${c}.items[${g}]`);else if((f.type==="row"||f.type==="col"||f.type==="grid"||f.type==="card")&&Array.isArray(f.items))n(f.items,`${c}.items`);else if(f.type==="list"&&Array.isArray(f.items))for(let g=0;g<f.items.length;g++)o(f.items[g],`${c}.items[${g}]`);else if(f.type==="table"&&Array.isArray(f.details)){let g=I(f).length;for(let x=0;x<Math.min(f.details.length,g);x++)Array.isArray(f.details[x])&&C(f,x)&&n(f.details[x],`${c}.details[${x}]`)}}}function a(d,c){let f=y(d);if(f===void 0)return;let g=f.items!==void 0?f.items:f.content;Array.isArray(g)?n(g,`${c}.items`):o(g,`${c}.items`)}let u=y(t);return u===void 0||(N(u)&&s(t)?o(t,"spec"):n(u.items,"items")),e}function Ye(t,i=Number.POSITIVE_INFINITY){return nt(t,i,()=>{})}function tt(t,i=Number.POSITIVE_INFINITY){return Ye(t,i)}function Qe(t){let i=[],r=y(t);if(r===void 0)return{ok:!1,errors:["spec root must be an object"]};if(N(t)){let a=z(t);return a!==null?Qe(a):{ok:!1,errors:["spec.items must be an array"]}}if(!Array.isArray(r.items))return{ok:!1,errors:["spec.items must be an array"]};Ke(r,"spec",V,i,["items"]);let e=0,s=!1,n=(a,u,d)=>{if(!s){if(!Array.isArray(a)){i.push(`${d} must be an array`);return}for(let c=0;c<a.length;c++){if(s||e>=m.maxNodes){s||(i.push(`spec exceeds ${m.maxNodes} nodes; tail elided`),s=!0);return}e+=1;let f=`${d}[${c}]`;Xe(a[c],u,f,i,n)}}};n(r.items,0,"items"),i.length===0&&i.push(...Re(r).diagnostics);let o=[...new Set(i)];return{ok:o.length===0,errors:o}}function Ze(t){let i=Ie(t),r=Be(i.value),e=Qe(i.value),s=Ye(i.value,m.maxNodes+1),n=r===null?0:tt(r),o=r===null?0:Xn(r),a=e.errors.filter(u=>!u.includes(": unknown type "));return r!==null&&a.length===0&&a.push(...Re(r).diagnostics),s>n&&a.push(`repair dropped ${s-n} declared native node(s): declared ${s}, rendered ${n}`),{value:i.value,normalized:i.value,repaired:r,spec:r,errors:[...new Set(a)],warnings:[...i.warnings,...Pe(i.value)],declaredCount:s,renderedCount:o,declaredNativeCount:s,renderedNativeCount:n,renderedTotalCount:o}}function it(t){return t.errors.length>0&&t.errors.every(i=>i.startsWith("spec exceeds ")||i.startsWith("repair dropped "))&&t.renderedNativeCount===m.maxNodes&&t.declaredNativeCount===m.maxNodes+1}function Ne(t){return t.spec!==null&&(t.errors.length===0||it(t))}var rt=/^(items\[\d+\](?:\.(?:items\[\d+\]|tabs\[\d+\]\.items\[\d+\]|details\[\d+\](?:\[\d+\])?))*)/;function st(t){let i=rt.exec(t);return i===null?null:i[1]??null}function Ve(t,i){let r=[...i.matchAll(/(?:^|\.)(items|tabs|details)\[(\d+)\]|\[(\d+)\]/g)];if(r.length===0||r[r.length-1][1]==="tabs")return;let e=t;for(let s=0;s<r.length;s++){let n=r[s],o=n[1]===void 0?e:y(e)?.[n[1]],a=Number(n[2]??n[3]);if(!Array.isArray(o)||a>=o.length)return;if(s===r.length-1)return{array:o,index:a,preserveIndex:n[1]==="details"};if(e=o[a],e===void 0)return}}function ot(t){try{return y(JSON.parse(JSON.stringify(t)))??null}catch{return null}}function at(t){if(Ne(t))return t.spec;if(t.spec===null)return null;let i=y(t.value);if(i===void 0)return null;let r=new Set,e=new Set;for(let d of t.errors){if(d.startsWith("spec exceeds "))continue;let c=st(d);c!==null&&(d===`${c}.details must not contain more entries than rows`?e.add(c):r.add(c))}if(r.size===0&&e.size===0)return null;let s=ot(N(i)?z(i):i);if(s===null)return null;let n=[...r].map(d=>Ve(s,d)).filter(d=>d!==void 0),o=[...e].map(d=>Ve(s,d)).filter(d=>d!==void 0);for(let{array:d,index:c}of o){let f=y(d[c]);f?.type==="table"&&Array.isArray(f.details)&&(f.details.length=Math.min(f.details.length,I(f).length))}let a=new Map;for(let{array:d,index:c,preserveIndex:f}of n){if(f){d[c]=null;continue}let g=a.get(d);g===void 0?a.set(d,[c]):g.push(c)}for(let[d,c]of a){c.sort((f,g)=>g-f);for(let f of c)d.splice(f,1)}let u=Ze(s);return!Ne(u)||u.renderedNativeCount===0?null:u.spec}function We(t,i,r){if(Array.isArray(t))for(let e=0;e<t.length;e++){let s=y(t[e]),n=`${i}[${e}]`;if(s===void 0){r.push(`${n} must be an object`);continue}typeof s.label!="string"&&r.push(`${n}.label must be a string`),(typeof s.value!="number"||!Number.isFinite(s.value))&&r.push(`${n}.value must be a finite number`),s.color!==void 0&&typeof s.color!="string"&&r.push(`${n}.color must be a string`)}}function ut(t,i,r){if(Array.isArray(t))for(let e=0;e<t.length;e++){let s=y(t[e]),n=`${i}[${e}]`;if(s===void 0){r.push(`${n} must be an object`);continue}typeof s.label!="string"&&r.push(`${n}.label must be a string`),s.color!==void 0&&typeof s.color!="string"&&r.push(`${n}.color must be a string`),Array.isArray(s.data)||r.push(`${n}.data must be an array`),We(s.data,`${n}.data`,r)}}function lt(t,i,r){!Array.isArray(t.data)&&!Array.isArray(t.series)&&r.push(`${i}: type 'chart' requires data or series (array)`),t.variant!==void 0&&r.push(`${i}.variant is unsupported; use kind`),t.data!==void 0&&!Array.isArray(t.data)&&r.push(`${i}.data must be an array`),t.series!==void 0&&!Array.isArray(t.series)&&r.push(`${i}.series must be an array`),t.kind!==void 0&&(typeof t.kind!="string"||!U.includes(t.kind))&&r.push(`${i}.kind must be bars, line, or donut`);let e=t.kind===void 0?"bars":t.kind,s=Array.isArray(t.series)?t.series:void 0;if(Array.isArray(t.data)&&t.data.length===0&&(s===void 0||s.length===0)&&r.push(`${i}.data must not be empty`),s!==void 0){s.length===0&&r.push(`${i}.series must not be empty`),e==="donut"&&r.push(`${i}.series is only supported for bars and line`);for(let n=0;n<s.length;n++){let o=y(s[n]);o!==void 0&&Array.isArray(o.data)&&o.data.length===0&&r.push(`${i}.series[${n}].data must not be empty`)}}e==="donut"&&t.data===void 0&&r.push(`${i}.data is required for donut`),e==="line"&&t.data===void 0&&(s===void 0||s.length===0)&&r.push(`${i}.data is required for line (or provide series)`),We(t.data,`${i}.data`,r),ut(t.series,`${i}.series`,r)}function dt(t,i,r){if(Array.isArray(t))for(let e=0;e<t.length;e++){let s=t[e];if(y(s)===void 0){if(!Array.isArray(s)){r.push(`${i}[${e}] must be an array or object`);continue}for(let n=0;n<s.length;n++){let o=s[n];typeof o!="string"&&(typeof o!="number"||!Number.isFinite(o))&&r.push(`${i}[${e}][${n}] must be a string or finite number`)}}}}function Xe(t,i,r,e,s){if(i>m.maxDepth){e.push(`${r}: exceeds max depth ${m.maxDepth}`);return}let n=y(t);if(n===void 0){e.push(`${r}: must be an object`);return}let o=n.type;if(typeof o!="string"){e.push(`${r}: missing string 'type'`);return}let a=c=>{n[c]!==void 0&&typeof n[c]!="string"&&e.push(`${r}: '${c}' must be a string`)},u=c=>{n[c]!==void 0&&(typeof n[c]!="number"||!Number.isFinite(n[c]))&&e.push(`${r}: '${c}' must be a finite number`)};switch(o){case"text":typeof n.content!="string"&&typeof n.text!="string"&&e.push(`${r}: type 'text' requires content or text (string)`),a("content"),a("text");break;case"row":case"col":case"card":case"grid":Array.isArray(n.items)||e.push(`${r}: type '${o}' requires items (array)`),s(n.items,i+1,`${r}.items`),o==="grid"&&u("cols");break;case"button":case"checkbox":case"link":case"switch":typeof n.label!="string"&&e.push(`${r}: type '${o}' requires label (string)`),a("label");break;case"image":case"audio":case"video":typeof n.src!="string"&&e.push(`${r}: type '${o}' requires src (string)`),a("src"),a("alt"),o==="video"&&a("poster");break;case"slider":a("label"),u("min"),u("max"),u("step"),u("value");break;case"input":case"textarea":a("label"),a("placeholder"),a("value");break;case"select":case"radio":Array.isArray(n.options)||e.push(`${r}: type '${o}' requires options (array)`);break;case"submit":typeof n.label!="string"&&e.push(`${r}: type 'submit' requires label (string)`);break;case"badge":typeof n.label!="string"&&typeof n.text!="string"&&typeof n.value!="string"&&e.push(`${r}: type 'badge' requires label, text, or value (string)`),a("label"),a("text"),a("value");break;case"hero":typeof n.title!="string"&&e.push(`${r}: type 'hero' requires title (string)`),a("subtitle");break;case"stat":typeof n.label!="string"&&e.push(`${r}: type 'stat' requires label (string)`),typeof n.value!="string"&&e.push(`${r}: type 'stat' requires value (string)`),a("delta");break;case"progress":(typeof n.value!="number"||!Number.isFinite(n.value)||n.value<0||n.value>100)&&e.push(`${r}: type 'progress' requires value (number 0..100)`),u("value");break;case"avatar":typeof n.name!="string"&&e.push(`${r}: type 'avatar' requires name (string)`);break;case"list":if(Array.isArray(n.items)||e.push(`${r}: type 'list' requires items (array)`),Array.isArray(n.items))for(let c=0;c<n.items.length;c++){let f=y(n.items[c]);f!==void 0&&typeof f.type=="string"&&Xe(f,i+1,`${r}.items[${c}]`,e,s)}break;case"table":if(!Array.isArray(n.columns)&&!He(n)&&e.push(`${r}: type 'table' requires columns (array)`),Array.isArray(n.rows)||e.push(`${r}: type 'table' requires rows (array)`),n.types!==void 0&&!Array.isArray(n.types)&&e.push(`${r}.types must be an array of column cell types`),n.details!==void 0&&!Array.isArray(n.details)&&e.push(`${r}.details must be an array aligned with rows`),Array.isArray(n.details)){let c={columns:n.columns,rows:n.rows,types:n.types},f=I(c).length;n.details.length>f&&e.push(`${r}.details must not contain more entries than rows`);for(let g=0;g<Math.min(n.details.length,f);g++){let x=n.details[g];if(!(x===null||!C(c,g))){if(!Array.isArray(x)){e.push(`${r}.details[${g}] must be an array or null`);continue}s(x,i+1,`${r}.details[${g}]`)}}}dt(n.rows,`${r}.rows`,e);break;case"chart":lt(n,r,e);break;case"tabs":{if(Array.isArray(n.tabs)||e.push(`${r}: type 'tabs' requires tabs (array)`),Array.isArray(n.tabs))for(let c=0;c<n.tabs.length;c++){let f=y(n.tabs[c]);if(f===void 0){e.push(`${r}.tabs[${c}] must be an object`);continue}typeof f.label!="string"&&e.push(`${r}.tabs[${c}].label must be a string`),s(f.items,i+1,`${r}.tabs[${c}].items`)}break}case"plot":Array.isArray(n.series)||e.push(`${r}: type 'plot' requires series (array)`);break;case"callout":typeof n.content!="string"&&e.push(`${r}: type 'callout' requires content (string)`);break;case"steps":Array.isArray(n.steps)||e.push(`${r}: type 'steps' requires steps (array)`);break;case"keyvalue":Array.isArray(n.pairs)||e.push(`${r}: type 'keyvalue' requires pairs (array)`);break;case"diff":Array.isArray(n.diffs)||e.push(`${r}: type 'diff' requires diffs (array)`);break;case"json":"value"in n||e.push(`${r}: type 'json' requires value`);break;case"code":typeof n.code!="string"&&e.push(`${r}: type 'code' requires code (string)`);break;case"accordion":if(Array.isArray(n.items)||e.push(`${r}: type 'accordion' requires items (array)`),Array.isArray(n.items))for(let c=0;c<n.items.length;c++){let f=y(n.items[c]);if(f===void 0){e.push(`${r}.items[${c}] must be an object`);continue}typeof f.title!="string"&&e.push(`${r}.items[${c}].title must be a string`),s(f.items,i+1,`${r}.items[${c}].items`)}break;case"copy":typeof n.text!="string"&&e.push(`${r}: type 'copy' requires text (string)`);break;case"svg":typeof n.code!="string"&&e.push(`${r}: type 'svg' requires code (string)`),u("height");break;case"mermaid":typeof n.code!="string"&&e.push(`${r}: type 'mermaid' requires code (string)`);break;case"scene3d":Array.isArray(n.meshes)||e.push(`${r}: type 'scene3d' requires meshes (array)`);break;case"timeline":Array.isArray(n.items)||e.push(`${r}: type 'timeline' requires items (array)`);break;case"file-tree":Array.isArray(n.items)||e.push(`${r}: type 'file-tree' requires items (array)`);break;case"breadcrumb":Array.isArray(n.items)||e.push(`${r}: type 'breadcrumb' requires items (array)`);break;case"quiz":typeof n.question!="string"&&e.push(`${r}: type 'quiz' requires question (string)`),Array.isArray(n.options)||e.push(`${r}: type 'quiz' requires options (array)`);break;case"diagram":typeof n.kind!="string"&&e.push(`${r}: type 'diagram' requires kind (string)`),Array.isArray(n.nodes)||e.push(`${r}: type 'diagram' requires nodes (array)`),n.edges!==void 0&&!Array.isArray(n.edges)&&e.push(`${r}: type 'diagram' requires edges (array) when present`);break;case"echart":n.option===void 0&&n.data===void 0&&n.series===void 0&&(!Array.isArray(n.links)||n.links.length===0)&&e.push(`${r}: type 'echart' requires option, data, series, or links`),u("height");break;default:e.push(`${r}: unknown type '${o}' (custom renderer?)`)}let d=T[o];d!==void 0&&In(n,r,d,e)}var ct=32,en=ct;function ft(t){let i=[],r=[],e=u=>{r.length>=en&&r.shift(),r.push(u)},s=!1,n=!1,o=0;for(;o<t.length;o++){let u=t[o];if(s){n?n=!1:u==="\\"?n=!0:u==='"'&&(s=!1);continue}if(u==='"'){s=!0;continue}if(u==="{"||u==="["){i.push(u);continue}if(u==="}"||u==="]"){if(i.pop()!==(u==="}"?"{":"["))break;u==="}"&&i.length===2&&i[0]==="{"&&i[1]==="["&&e({end:o+1,closingSuffix:"]}"}),i.length===0&&e({end:o+1,closingSuffix:""});continue}}r.sort((u,d)=>d.end-u.end);let a=[];for(let u of r)(a.length===0||a[a.length-1].end!==u.end)&&a.push(u);return{candidates:a.slice(0,en),scannedChars:o}}function nn(t,i){try{let r=JSON.parse(t);if(typeof r=="string")try{r=JSON.parse(r)}catch{return null}return Me(r)?r:Array.isArray(r)&&r.length>0?{items:r}:i?z(r):null}catch{return null}}function pt(t){let i=t.trim();if(i==="")return null;let r=nn(i,!0);if(r!==null)return r;let{candidates:e}=ft(i);for(let s of e){let n=nn(i.slice(0,s.end)+s.closingSuffix,!1);if(n!==null)return n}return null}function mt(t){try{return JSON.parse(t),null}catch{}return xt(t,!1)}var X=32,gt=4096;function L(t){return t===" "||t===" "||t===`
|
|
2
|
+
`||t==="\r"}function yt(t,i,r,e,s){let n=Math.min(t.length,i+gt),o=i+1,a=()=>{for(;o<n&&L(t[o]);)o++};if(a(),o>=n)return!0;if(r)return t[o]===":";let u=e.length-1;if(t[o]===":")return!1;for(;t[o]==="}"||t[o]==="]";){let c=e[u];if(c===void 0)return!1;if(t[o]===c.closer)u--;else if(!s)return!1;if(o++,a(),o>=n)return!0;if(u<0)return s}if(t[o]!==",")return!1;let d=e[u];if(d===void 0)return!1;if(o++,a(),o>=n||t[o]===d.closer)return!0;if(d.closer==="]")return/["[{tfn\-0-9]/.test(t[o]);if(t[o]!=='"')return!1;for(o++;o<n;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"')return o++,a(),o>=n||t[o]===":";if(t[o].charCodeAt(0)<32)return!1;o++}return!0}function bt(t,i,r){let e="",s=[],n=!1,o=!1,a=!1,u=!1,d=0,c=0,f=0,g=!1,x=[],$=()=>{let R=s[s.length-1];R!==void 0&&(R.expecting="comma")};for(let R=0;R<t.length;R++){let A=t[R];if(u){n&&A==='"'&&(a=!0),e+=A,u=!1;continue}if(n){if(A==="\\"){e+=A,u=!0;continue}if(A!=='"'){e+=A;continue}let S=R+1;for(;S<t.length&&L(t[S]);)S++;let M=!o&&(!a&&",}]:".includes(t[S]??"\0")||s[s.length-1]?.closer==="]"&&t[S]===",");if(!r.has(R)&&(M||yt(t,R,o,s,i))){n=!1,e+=A;let ee=s[s.length-1];o?ee!==void 0&&(ee.expecting="colon"):($(),ee!==void 0&&a&&(x.length===X&&x.shift(),x.push(R)))}else e+='\\"',a=!0,d++;continue}if(A==='"'){o=s[s.length-1]?.expecting==="key",a=!1,n=!0,e+=A;continue}if(A==="{"||A==="["){$(),s.push({closer:A==="{"?"}":"]",expecting:A==="{"?"key":"value"}),e+=A;continue}if(A==="}"||A==="]"){s[s.length-1]?.closer===A?(s.pop(),e+=A,s.length===0&&c===0&&(c=e.length,f=R+1)):i?d++:e+=A;continue}if(A===","){let S=R+1;for(;S<t.length&&L(t[S]);)S++;if(S===t.length||t[S]==="}"||t[S]==="]"){d++;continue}let M=s[s.length-1];M!==void 0&&(M.expecting=M.closer==="}"?"key":"value")}else if(A===":"){let S=s[s.length-1];S!==void 0&&(S.expecting="value")}else if(!L(A)&&s[s.length-1]?.expecting==="value"){let S=R+1;for(;S<t.length&&!L(t[S])&&!'{}[],:"'.includes(t[S]);)S++;let M=t.slice(R,S);/^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)$/.test(M)||(g=!0),$(),e+=M,R=S-1;continue}e+=A}let J=n;if(i)for(n&&(e+='"',d++);s.length>0;)e+=s.pop().closer,d++;return{text:e,repairs:d,rootEnd:c,rawRootEnd:f,choices:x,unfinishedString:J,invalidValue:g}}function ht(t){let i=[],r=!1,e=!1,s=!1;for(let n=0;n<t.length;n++){let o=t[n];if(e){e=!1;continue}if(r){o==="\\"?e=!0:o==='"'&&(r=!1);continue}if(!s){if(L(o))continue;if(o!=="{"&&o!=="[")return null;s=!0}if(o==='"'){r=!0;continue}if(o==="{"||o==="[")i.push(o==="{"?"}":"]");else if(o==="}"||o==="]"){if(i.pop()!==o)return null;if(i.length===0){let a=t.slice(0,n+1).trimEnd();try{return JSON.parse(a),a}catch{return null}}}}return null}function xt(t,i){let r=ht(t);if(r!==null)return i?{text:r,repairs:1}:null;let e=[[]],s=null;for(let n=0;n<X&&e.length>0;n++){let o=e.pop(),a=bt(t,i,new Set(o));if(a.repairs>0&&!(o.length>0&&a.unfinishedString))try{return JSON.parse(a.text),{text:a.text,repairs:a.repairs}}catch{}if(i&&a.rootEnd>0&&(s===null||a.rawRootEnd>s.rawEnd)){let d=a.text.slice(0,a.rootEnd).trimEnd();try{JSON.parse(d),s={text:d,repairs:a.repairs+1,rawEnd:a.rawRootEnd}}catch{}}if(a.invalidValue)continue;let u=o[o.length-1]??-1;for(let d of a.choices)d>u&&e.push([...o,d]);e.length>X&&e.splice(0,e.length-X)}return s!==null?{text:s.text,repairs:s.repairs}:null}export{T as COMPONENT_SCHEMAS,q as GENUI_NATIVE_TYPES,Ne as isRenderableProcess,pt as parsePartialGenuiSpec,at as partialRepairGenuiSpec,Ze as processGenuiSpec,mt as repairFenceJson};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {STYLE_SYSTEM,grammarPrompt,grammarExample} from './style-system.js';
|
|
2
|
+
// Stable user-facing IDs and palettes. Grammar and component tokens live together
|
|
3
|
+
// in style-system.js; the second example remains a small authored HTML/SVG surface.
|
|
4
|
+
export const DEFAULT_VISUAL_STYLE='prismframe';
|
|
5
|
+
const PALETTES=[
|
|
6
|
+
{
|
|
7
|
+
"id": "editorial",
|
|
8
|
+
"name": "清爽阅读",
|
|
9
|
+
"preview": {
|
|
10
|
+
"bg": "#fff",
|
|
11
|
+
"ink": "#182537",
|
|
12
|
+
"accent": "#3e60d3",
|
|
13
|
+
"soft": "#f4f6fa",
|
|
14
|
+
"line": "#dfe5ed"
|
|
15
|
+
},
|
|
16
|
+
"canvasExample": {
|
|
17
|
+
"tool": "render_canvas",
|
|
18
|
+
"args": {
|
|
19
|
+
"title": "三步发布",
|
|
20
|
+
"fallback": "三步发布,静态排版示例。",
|
|
21
|
+
"html": "<section><h2>把一件事讲清楚</h2><div class=\"steps\"><p><b>01 整理</b><span>补齐说明与许可</span></p><p><b>02 验证</b><span>检查安装与运行</span></p><p><b>03 发布</b><span>记录本次变化</span></p></div></section>",
|
|
22
|
+
"css": "section{padding:20px;border:1px solid var(--canvas-line);border-radius:16px}h2{font-size:24px;margin:0 0 20px}.steps{display:grid;grid-template-columns:repeat(3,1fr);gap:20px}p{margin:0}b,span{display:block}span{color:var(--canvas-muted);margin-top:8px}@media(max-width:520px){.steps{grid-template-columns:1fr}}"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "soft",
|
|
28
|
+
"name": "柔和彩色",
|
|
29
|
+
"preview": {
|
|
30
|
+
"bg": "#fbf8ff",
|
|
31
|
+
"ink": "#32294c",
|
|
32
|
+
"accent": "#7954bb",
|
|
33
|
+
"soft": "#eee5fa",
|
|
34
|
+
"line": "#e6dcf2"
|
|
35
|
+
},
|
|
36
|
+
"canvasExample": {
|
|
37
|
+
"tool": "render_canvas",
|
|
38
|
+
"args": {
|
|
39
|
+
"title": "本周阅读计划",
|
|
40
|
+
"fallback": "本周阅读计划,静态排版示例。",
|
|
41
|
+
"html": "<section><span class=\"tag\">轻松开始</span><h2>每天一点,稳稳前进</h2><div class=\"plan\"><p><b>20 分钟</b><span>专注阅读</span></p><p><b>1 个收获</b><span>写下自己的理解</span></p></div></section>",
|
|
42
|
+
"css": "section{padding:24px;border-radius:24px;border:1px solid var(--canvas-line);background:linear-gradient(130deg,color-mix(in srgb,#9567d4 12%,var(--canvas-bg)),color-mix(in srgb,#58b7ae 9%,var(--canvas-bg)));color:var(--canvas-ink)}.tag{display:inline-block;border-radius:999px;padding:5px 12px;background:var(--canvas-bg);color:var(--canvas-accent)}h2{font-size:26px;margin:14px 0 20px}.plan{display:flex;flex-wrap:wrap;gap:24px}.plan p{margin:0;flex:1 1 180px;padding:18px;border-radius:18px;background:color-mix(in srgb,var(--canvas-bg) 80%,transparent)}b,span{display:block}b{font-size:22px}.plan span{margin-top:8px;color:var(--canvas-muted)}"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "technical",
|
|
48
|
+
"name": "技术图解",
|
|
49
|
+
"preview": {
|
|
50
|
+
"bg": "#f8fafb",
|
|
51
|
+
"ink": "#1b3440",
|
|
52
|
+
"accent": "#087e8b",
|
|
53
|
+
"soft": "#e7f1f3",
|
|
54
|
+
"line": "#cedde2"
|
|
55
|
+
},
|
|
56
|
+
"canvasExample": {
|
|
57
|
+
"tool": "render_canvas",
|
|
58
|
+
"args": {
|
|
59
|
+
"title": "请求处理流程",
|
|
60
|
+
"fallback": "请求处理流程,静态排版示例。",
|
|
61
|
+
"html": "<section><header><small>REQUEST FLOW</small><h2>输入 → 处理 → 输出</h2></header><div class=\"flow\"><div><i>01</i><b>输入</b><p>接收需求</p></div><span>→</span><div><i>02</i><b>处理</b><p>校验与计算</p></div><span>→</span><div><i>03</i><b>输出</b><p>返回反馈</p></div></div></section>",
|
|
62
|
+
"css": "section{padding:20px;border:1px solid var(--canvas-line);border-radius:10px}small,i{font:14px ui-monospace,monospace;color:var(--canvas-accent)}h2{font-size:24px;margin:8px 0 20px}.flow{display:flex;gap:12px;align-items:center}.flow div{flex:1;padding:16px;border:1px solid var(--canvas-line);border-radius:10px}.flow b,.flow i{display:block}.flow b{margin-top:10px;font-size:19px}p{margin:6px 0 0;color:var(--canvas-muted)}@media(max-width:520px){.flow{flex-direction:column}.flow div{width:100%}.flow>span{transform:rotate(90deg)}}"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "expressive",
|
|
68
|
+
"name": "活力展示",
|
|
69
|
+
"preview": {
|
|
70
|
+
"bg": "#fff9f2",
|
|
71
|
+
"ink": "#362820",
|
|
72
|
+
"accent": "#bd4b26",
|
|
73
|
+
"soft": "#ffead8",
|
|
74
|
+
"line": "#edd7c5"
|
|
75
|
+
},
|
|
76
|
+
"canvasExample": {
|
|
77
|
+
"tool": "render_canvas",
|
|
78
|
+
"args": {
|
|
79
|
+
"title": "从第一步开始",
|
|
80
|
+
"fallback": "从第一步开始,静态排版示例。",
|
|
81
|
+
"html": "<section><div class=\"number\">01</div><div class=\"copy\"><span>今天的重点</span><h2>先做出一个<br>能演示的版本</h2><p>只保留一条主线,尽早获得反馈。</p></div></section>",
|
|
82
|
+
"css": "section{display:flex;align-items:center;gap:24px;padding:24px;border:1px solid var(--canvas-line);border-radius:22px;background:color-mix(in srgb,#f0984a 8%,var(--canvas-bg));color:var(--canvas-ink)}.number{font:800 54px/1 system-ui;padding:22px;border-radius:20px;color:var(--canvas-ink);background:color-mix(in srgb,#f0984a 28%,var(--canvas-bg))}.copy>span{font-size:14px;color:var(--canvas-muted)}h2{font-size:28px;line-height:1.3;margin:10px 0}p{margin:0;color:var(--canvas-muted)}@media(max-width:520px){section{align-items:flex-start;flex-direction:column}.number{font-size:36px;padding:16px}}"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "prismframe",
|
|
88
|
+
"name": "明亮扁平",
|
|
89
|
+
"preview": {
|
|
90
|
+
"bg": "#ecf6ff",
|
|
91
|
+
"ink": "#193858",
|
|
92
|
+
"accent": "#3182d9",
|
|
93
|
+
"soft": "#d3e8fc",
|
|
94
|
+
"line": "#9ec9ef"
|
|
95
|
+
},
|
|
96
|
+
"canvasExample": {
|
|
97
|
+
"tool": "render_canvas",
|
|
98
|
+
"args": {
|
|
99
|
+
"title": "三步让解释更清楚",
|
|
100
|
+
"fallback": "三步让解释更清楚,静态排版示例。",
|
|
101
|
+
"html": "<section><h2>把复杂问题讲清楚</h2><div class=\"cards\"><article><span>01</span><h3>明确目标</h3><p>先回答要解决什么。</p></article><article><span>02</span><h3>解释关系</h3><p>让图形承担说明。</p></article><article><span>03</span><h3>给出行动</h3><p>收成一个可执行步骤。</p></article></div></section>",
|
|
102
|
+
"css": "section{padding:24px 24px 30px;border-radius:26px;background:color-mix(in srgb,#3182d9 9%,var(--canvas-bg));color:var(--canvas-ink);font-family:ui-rounded,system-ui,sans-serif}h2{font-size:26px;line-height:1.35;margin:0 0 20px}.cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}article{padding:20px;border:1.5px solid color-mix(in srgb,#3182d9 45%,var(--canvas-line));border-radius:22px;background:var(--canvas-bg);box-shadow:4px 6px 0 color-mix(in srgb,#3182d9 18%,var(--canvas-bg)),0 8px 16px #1637590b}article>span{color:var(--canvas-accent);font-size:14px;font-weight:700}h3{font-size:20px;margin:12px 0 8px}p{margin:0;line-height:1.6;color:var(--canvas-muted)}@media(max-width:580px){.cards{grid-template-columns:1fr}}"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"id": "aurora",
|
|
108
|
+
"name": "柔光渐彩",
|
|
109
|
+
"preview": {
|
|
110
|
+
"bg": "#f4f2ee",
|
|
111
|
+
"ink": "#16151b",
|
|
112
|
+
"accent": "#6a57f2",
|
|
113
|
+
"soft": "#f5f3ef",
|
|
114
|
+
"line": "#e2dfda"
|
|
115
|
+
},
|
|
116
|
+
"canvasExample": {
|
|
117
|
+
"tool": "render_canvas",
|
|
118
|
+
"args": {
|
|
119
|
+
"title": "选择一个方案",
|
|
120
|
+
"fallback": "点击选择此方案,本地记录选择状态。",
|
|
121
|
+
"state": {
|
|
122
|
+
"selected": {
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"default": false
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"html": "<section class=\"choice\"><h2>先选择,再继续</h2><p>渐变扩散和文字换位由实际操作触发。</p><button class=\"action\" type=\"button\" aria-pressed=\"false\"><i aria-hidden=\"true\"></i><span class=\"label\"><b>选择此方案</b><b aria-hidden=\"true\">选择此方案</b></span><span class=\"orb\" aria-hidden=\"true\">→</span></button><p class=\"status\" role=\"status\">尚未选择</p></section>",
|
|
128
|
+
"css": ".choice{padding:24px;border:1px solid var(--canvas-line);border-radius:26px;background:var(--canvas-bg);color:var(--canvas-ink)}h2{font-size:24px;margin:0 0 10px}p{color:var(--canvas-muted);line-height:1.7}.action{position:relative;isolation:isolate;overflow:hidden;display:inline-flex;align-items:center;gap:18px;min-height:54px;padding:8px 8px 8px 24px;border:0;border-radius:999px;background:var(--canvas-ink);color:var(--canvas-bg);translate:var(--x,0px) var(--y,0px);box-shadow:0 16px 28px -22px #54457988;transition:translate .7s cubic-bezier(.34,1.45,.64,1)}.action>i{position:absolute;inset:0;z-index:-1;background:linear-gradient(115deg,#7051ed,#326fce 55%,#188e97);clip-path:circle(21px at calc(100% - 29px) 50%);transition:clip-path .7s cubic-bezier(.2,.8,.2,1)}.action:is(:hover,:focus-visible){color:white}.action:is(:hover,:focus-visible)>i{clip-path:circle(160% at calc(100% - 29px) 50%)}.label{position:relative;overflow:hidden;line-height:1.5}.label b{display:block;transition:transform .55s cubic-bezier(.34,1.45,.64,1),opacity .3s}.label b+b{position:absolute;left:0;top:0;transform:translateY(130%);opacity:0}.action:is(:hover,:focus-visible) b:first-child{transform:translateY(-130%);opacity:0}.action:is(:hover,:focus-visible) b+b{transform:none;opacity:1}.orb{display:grid;place-items:center;width:42px;height:42px;border-radius:50%;background:linear-gradient(135deg,#438eff,#27b6ba);color:white;font-size:22px}.status{margin-bottom:0}@media(prefers-reduced-motion:reduce){.action,.action *{transition:none!important;translate:none!important}}",
|
|
129
|
+
"script": "const root=document.querySelector(\".choice\"),button=root.querySelector(\"button\");button.addEventListener(\"click\",()=>DSHUI.setState({selected:!DSHUI.snapshot.state.selected}));DSHUI.subscribe(({state})=>{button.setAttribute(\"aria-pressed\",String(state.selected));root.querySelectorAll(\"b\").forEach(b=>b.textContent=state.selected?\"取消选择\":\"选择此方案\");root.querySelector(\".status\").textContent=state.selected?\"已选择此方案\":\"尚未选择\"});button.addEventListener(\"pointermove\",e=>{if(matchMedia(\"(prefers-reduced-motion: reduce)\").matches)return;const r=button.getBoundingClientRect();button.style.setProperty(\"--x\",((e.clientX-r.left-r.width/2)*.035)+\"px\");button.style.setProperty(\"--y\",((e.clientY-r.top-r.height/2)*.07)+\"px\")});button.addEventListener(\"pointerleave\",()=>{button.style.setProperty(\"--x\",\"0px\");button.style.setProperty(\"--y\",\"0px\")});"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
export const VISUAL_STYLES=Object.freeze(PALETTES.map(({canvasExample,...s})=>Object.freeze({...s,description:STYLE_SYSTEM[s.id].description,prompt:grammarPrompt(s.id),examples:[grammarExample(s.id),canvasExample]})));
|
|
135
|
+
export const VISUAL_STYLE_IDS=Object.freeze(VISUAL_STYLES.map(s=>s.id));
|
|
136
|
+
export function visualStyle(id=DEFAULT_VISUAL_STYLE){
|
|
137
|
+
const style=VISUAL_STYLES.find(s=>s.id===id);
|
|
138
|
+
if(!style)throw Error('DSH UI: unknown visualStyle; use '+VISUAL_STYLE_IDS.join('/'));
|
|
139
|
+
return style;
|
|
140
|
+
}
|
|
141
|
+
export function stylePrompt(id){const s=visualStyle(id);return `## 用户选择的视觉风格:${s.name} (${s.id})\n采用${s.name}风格。\n${s.prompt}\n这套风格替代通用指导和旧案例中的默认配色、材质与圆角建议。只影响新生成内容的视觉方向;协议、工具入口、状态、权限、准确性、可读性与必要功能要求保持不变。引导模式下原生文本、卡片、指标、控件和代码块会自动跟随当前所选视觉风格;整份 UI 的原生内容和 HTML/SVG 应使用一致的色彩与层级。原生组件会改变表面、层级、控件与流程形态。通常省略 size/weight/color 和 presentation.accent,让所选风格管理默认层级;只有用户明确指定或确有语义强调才覆盖。不要每种风格都手写同一套字号。title 已显示文档标题,正文不再重复相同标题;模型负责根据上述构图原则组织内容,不要所有风格都生成等大卡片网格。少量语义色强调真实重点。不要为了给原生内容上色而额外生成 HTML。确实需要特殊图解时再使用小画布。用户在当前请求中明确指定的风格优先。不要为展示风格增加不必要的画布、代码、动画或工具调用。`}
|
|
142
|
+
export function styleExamples(id){return visualStyle(id).examples.map(example=>JSON.stringify(example)).join('\n')}
|
package/lib/visual.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {processGenuiSpec,isRenderableProcess,partialRepairGenuiSpec,GENUI_NATIVE_TYPES,COMPONENT_SCHEMAS} from './visual-guard.js';
|
|
2
|
+
import {normalizeVisual} from './normalize-visual.js';
|
|
3
|
+
export const VISUAL_TYPES=Object.freeze([...GENUI_NATIVE_TYPES]);
|
|
4
|
+
export const visualCatalog=()=>COMPONENT_SCHEMAS;
|
|
5
|
+
export const VISUAL_INTERFACE='Extended visuals: render_ui({document:{title,items:[...]}}) accepts native charts, ECharts, local function plots, quiz/radio-submit grading, forms, tabs, tables, diagrams, Mermaid, SVG, media and 3D. ui_catalog({topic:"visual"}) gives exact fields/examples. V1 may embed {id,type:"visual",spec:{items:[...]}} beside native controls/canvas. Engines load locally on demand. Important form state is saved; local interactions never require model inference. action intents only enqueue a user-requested follow-up, subject to ordinary host tool permissions. Direct dsh-ui/motion-ui JSON fences and svg fences also work; choose one delivery path per UI, do not repeat tool source as a fence. Previews stay read-only until the whole reply ends. Do not collect secrets. No design template or visual style is imposed.';
|
|
6
|
+
export function validateVisual(value){
|
|
7
|
+
const encoded=JSON.stringify(value);if(!encoded||new TextEncoder().encode(encoded).length>131072)throw Error('DSH UI: visual spec exceeds 128 KiB');
|
|
8
|
+
const processed=processGenuiSpec(normalizeVisual(value,COMPONENT_SCHEMAS)),spec=isRenderableProcess(processed)?processed.spec:partialRepairGenuiSpec(processed);
|
|
9
|
+
if(!spec||!processed.renderedNativeCount)throw Error('DSH UI: visual spec: '+(processed.errors.slice(0,4).join('; ')||'requires registered components'));
|
|
10
|
+
// Critical questions/controls must not quietly disappear in partial repair.
|
|
11
|
+
const critical=new Set(['quiz','radio','submit','input','textarea','select','slider','checkbox','switch']);
|
|
12
|
+
const inventory=(items,path='items',result=[])=>{for(const[n,v]of (Array.isArray(items)?items:[]).entries()){if(!v||typeof v!=='object')continue;const at=path+'['+n+']';if(critical.has(v.type))result.push({type:v.type,id:v.id??v.group??v.question??v.label,path:at});if(['row','col','grid','card'].includes(v.type))inventory(v.items,at+'.items',result);if(v.type==='tabs')for(const[i,t]of (v.tabs??[]).entries())inventory(t.items,at+'.tabs['+i+'].items',result);if(v.type==='accordion')for(const[i,t]of (v.items??[]).entries())inventory(t.items,at+'.items['+i+'].items',result)}return result};
|
|
13
|
+
const source=normalizeVisual(value,COMPONENT_SCHEMAS),before=inventory(source.items),after=inventory(spec.items);
|
|
14
|
+
const available=[...after],missing=before.filter(v=>{const i=available.findIndex(n=>n.type===v.type&&n.id===v.id);if(i<0)return true;available.splice(i,1);return false});
|
|
15
|
+
if(missing.length)throw Error('DSH UI: critical component was rejected at '+missing.map(v=>v.path+' ('+v.type+')').join(', ')+'. '+processed.errors.slice(0,4).join('; '));
|
|
16
|
+
const stableIds=new Set();function walk(items){for(const n of items){if(n.id!==undefined){if(stableIds.has(n.id))throw Error('DSH UI: duplicate extended component id '+n.id);stableIds.add(n.id)}if(!VISUAL_TYPES.includes(n.type))throw Error('DSH UI: unsupported visual component '+n.type);if(n.type==='input'&&n.inputType==='password')throw Error('DSH UI: do not collect passwords or secrets in a UI');if(n.type!=='file-tree'&&Array.isArray(n.items))walk(n.items.filter(x=>x&&typeof x==='object'&&'type'in x));for(const t of n.tabs??[])walk(t.items??[]);if(n.type==='table')for(const d of n.details??[])if(d)walk(d)}}walk(spec.items);
|
|
17
|
+
// Persistent composer-dock placement belongs to the upstream host plugin.
|
|
18
|
+
// Motion UI consistently uses its inline markers and native sidebar.
|
|
19
|
+
delete spec.panel;delete spec.append;
|
|
20
|
+
return {spec,warnings:processed.errors.slice(0,12),count:processed.renderedNativeCount};
|
|
21
|
+
}
|
|
22
|
+
export function visualDocument(value){
|
|
23
|
+
if(Array.isArray(value))value={items:value};
|
|
24
|
+
const {spec,warnings}=validateVisual(value),title=spec.title||'可视化';
|
|
25
|
+
const texts=[];function gather(v){if(!v||typeof v!=='object')return;for(const[k,x]of Object.entries(v)){if(['title','content','label','question','explanation','alt'].includes(k)&&typeof x==='string')texts.push(x);else if(x&&typeof x==='object')Array.isArray(x)?x.forEach(gather):gather(x)}}gather(spec);
|
|
26
|
+
return {version:1,title,fallback:texts.join('\n').slice(0,8192)||title,nodes:[{id:'visual',type:'visual',spec,warnings}]};
|
|
27
|
+
}
|
|
28
|
+
export const VISUAL_GUIDE=`Extended native visuals (no HTML/CSS required): render_ui({document:{title:"...",items:[...]}}). This is a supported alternative to version:1/nodes; do not mix the two root languages. Component fields use this compact vocabulary:
|
|
29
|
+
text {type,content,size?:"h1"|"h2"|"h3"|"body"|"muted",copyable?:true,title?}; row/col/grid/card {type,items:[components],title?,cols?,gap?}; stat {type,label,value:string,delta?}; callout {type,title?,content,tone:"info"|"success"|"warning"|"error"}; list {type,items:[strings]}; keyvalue {type,pairs:[{key,value}]}; timeline {type,items:[{title,desc,time}]}; file-tree {type,items:[{name,type:"file"|"dir",children?}]}; tabs {type,tabs:[{label,items:[components]}]}; accordion {type,items:[{title,items:[components]}]}; code {type,lang,code,title?,wrap?}; json {type,value}; copy {type,label,text}; svg {type,title,code:completeSVG}; image/audio/video {type,src,alt,poster?}. Media uses user-controlled playback and browser-reachable http(s) or same-origin URLs, never local file URLs or credentials.
|
|
30
|
+
table {type,columns:[strings],rows:[[scalars]],types?:["text"|"num"|"delta"|"bar"|"badge"],filter?:inputId,filterColumn?:zeroBasedColumnIndex,export?:true}. Sorting and filtering stay local. Add input {type,id,label,placeholder} with matching filter ID for long data.
|
|
31
|
+
chart {type,kind:"bars"|"line"|"donut",data:[{label,value:number}],series?:[{label,data:[{label,value}]}],horizontal?,stacked?}. echart {type,title,height?,preset:"bar"|"line"|"area"|"pie"|"scatter"|"radar"|"gauge"|"funnel"|"treemap"|"sankey"|"graph"|"heatmap"|"bigline"|"wordCloud",data?,series?,links?:[{from,to,value}],option?:JSON}. Use compact chart for small comparisons; lazy ECharts for richer graphs. No executable formatters/functions in option.
|
|
32
|
+
plot {type,title,xMin,xMax,series:[{expr:"a*sin(x)",label,params:[{name:"a",value:1,min:0,max:5}]}]} redraws locally; expressions use a safe parser, never JS. mermaid {type,code} for automatic graph layout; diagram {type,kind:"architecture",nodes:[{id,label,type:"focal"|"backend"|"store"|"external",x,y,w,h}],edges:[{from,to,label?}]} for designed diagrams. scene3d {type,title,meshes:[{shape:"box"|"sphere"|"cone"|"cylinder"|"torus",position:[x,y,z],color?,size?}]} supports local orbit/zoom (1..5 objects).
|
|
33
|
+
quiz {type,id,question,options:[{label,correct?:true,feedback?}],explanation} grades locally, retry included. When the user wants one check for all questions, NEVER use separate quiz nodes. Use radio for every question and one submit with all groups. Multi-question paper: radio {type,group,label,options:[strings],answer:index,explanation}, then submit {type,label,groups:[groupIds]}; all answers required, grade locally. Form: input/textarea/select/slider with id; checkbox with group; submit {type,label,groups:[requiredIds],action:"Describe the requested next model task"}. action is an intent sent only after user gesture, never a shell command or direct host tool. State changes, grading, selection, reset and plots do not call the model. Never request credentials or secrets.
|
|
34
|
+
Reusable text with copyable:true and all code blocks show a compact upper-right copy button. Copy preserves literal source and never executes code. Ordinary explanation need not use a copy panel. Extended visuals can also be embedded inside a v1 document as {id,type:"visual",spec:{title,items:[...]}} beside native state controls and sandbox nodes. Every extended component may use a unique id; keep it unchanged when updating/reordering to retain its view state. Each visual owns its saved form state; use native state/derived or a canvas when exact shared calculations are needed. Multiple independent UIs per answer retain their own styles and parameters. After a tool succeeds, place its documentId marker exactly as instructed; do not repeat its source as a fence. ui_catalog topic=visual supplies full field reference and examples. Alternative direct delivery: write extended {title,items:[...]} JSON in a dsh-ui or motion-ui fenced block inside your assistant answer; complete components preview progressively, then save and activate after the whole turn. Standalone svg fences also render safely. UUID-only dsh-ui markers still refer to tool documents. Choose ONE path per UI; never duplicate the same UI as both tool and source fence. Direct source fences also appear in the native Intelligent UI sidebar. Keep UI text in the user's language. Progressive views remain read-only until the whole reply finishes.`;
|
|
35
|
+
export const VISUAL_EXAMPLES=[
|
|
36
|
+
{title:'本地小测验',items:[{type:'quiz',id:'q',question:'哪种操作无需再次调用模型?',options:[{label:'滑块调整图中参数',correct:true,feedback:'本地计算即可即时更新。'},{label:'查询今天的天气',feedback:'需要获取外部信息。'}],explanation:'本地交互优先,外部查询交给 Agent。'}]},
|
|
37
|
+
{title:'函数探索',items:[{type:'plot',title:'振幅变化',xMin:-6.28,xMax:6.28,series:[{expr:'a*sin(x)',label:'正弦曲线',params:[{name:'a',value:1,min:0,max:3}]}]}]},
|
|
38
|
+
{title:'示例销量',items:[{type:'input',id:'search',label:'筛选商品'},{type:'table',columns:['商品','数量'],rows:[['示例 A',12],['示例 B',24]],filter:'search',types:['text','num']},{type:'chart',kind:'donut',data:[{label:'示例 A',value:12},{label:'示例 B',value:24}]}]}
|
|
39
|
+
];
|
|
40
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-motion-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Interactive UI, HTML/SVG animation and local calculations for DeepSeek Harness Web, with injected design guidance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -45,14 +45,21 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
49
48
|
"@deepseek-ai/dsh-home-paths": "0.2.0-rc.2",
|
|
50
|
-
"
|
|
49
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
50
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
51
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
54
|
+
"echarts": "^6.1.0",
|
|
55
|
+
"echarts-wordcloud": "^2.1.0",
|
|
53
56
|
"esbuild": "^0.25.0",
|
|
57
|
+
"katex": "^0.19.0",
|
|
58
|
+
"mdast-util-from-markdown": "^2.0.3",
|
|
59
|
+
"mermaid": "^11.16.1",
|
|
54
60
|
"react": "^18.3.1",
|
|
55
|
-
"react-dom": "^18.3.1"
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
62
|
+
"three": "^0.180.0"
|
|
56
63
|
},
|
|
57
64
|
"dependencies": {
|
|
58
65
|
"@deepseek-ai/schemastery": "^3.18.4"
|
|
@@ -73,5 +80,13 @@
|
|
|
73
80
|
"generative-ui",
|
|
74
81
|
"interactive-ui",
|
|
75
82
|
"svg"
|
|
76
|
-
]
|
|
83
|
+
],
|
|
84
|
+
"overrides": {
|
|
85
|
+
"mermaid": {
|
|
86
|
+
"katex": "$katex"
|
|
87
|
+
},
|
|
88
|
+
"echarts-wordcloud": {
|
|
89
|
+
"echarts": "$echarts"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
77
92
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
生成 UI 时直接使用已注册的 render_ui/render_canvas;不需要先 grep、glob 或用 Shell 查找 DSH 安装源码。协议疑问以本说明和 ui_catalog 为准。这不限制为完成用户实际任务、读取真实数据而使用文件或搜索工具。
|
|
4
4
|
|
|
5
|
-
`round(x)` 只有一个参数,等同 JavaScript `Math.round`:取最近整数,恰好一半时朝正无穷方向取整,如 `round(2.5)=3`、`round(-2.5)=-2
|
|
5
|
+
`round(x)` 只有一个参数,等同 JavaScript `Math.round`:取最近整数,恰好一半时朝正无穷方向取整,如 `round(2.5)=3`、`round(-2.5)=-2`。它不是向上取整;原生公式支持 `ceil(x)` 向上取整、`floor(x)` 向下取整(各一个参数);房间数直接用 `{expr:"ceil(state.people / 2)"}`,无需画布或条件链。指标 decimals 只控制显示精度,不改变计算值。
|
|
6
6
|
|
|
7
|
-
简单公式优先使用 `{expr:"state.V * state.V / state.R"}`,例如 `derived.power` 的表达式,然后用 `{ref:"derived.power"}` 在指标中显示。支持四则运算、比较、三元条件、括号、`min/max/round/abs`;字符串使用双引号,引用写完整的 `state.x/data.x/derived.x/item.x`。这会编译为现有解释器协议,不执行任意 JavaScript。复杂动画仍使用画布。
|
|
7
|
+
简单公式优先使用 `{expr:"state.V * state.V / state.R"}`,例如 `derived.power` 的表达式,然后用 `{ref:"derived.power"}` 在指标中显示。支持四则运算、比较、三元条件、括号、`min/max/round/ceil/floor/abs`;字符串使用双引号,引用写完整的 `state.x/data.x/derived.x/item.x`。这会编译为现有解释器协议,不执行任意 JavaScript。复杂动画仍使用画布。
|
|
8
8
|
|
|
9
9
|
这是插件主动注入的能力指导;无需用户重复提供,也不依赖你先调用目录才获得这些规则。它是基于公开项目设计思想编写的 DSH 技能,不是 OpenAI 的内部提示词。以下协议与宿主工具权限共同约束输出。
|
|
10
10
|
|
|
@@ -94,3 +94,23 @@ inspect_ui 默认返回紧凑摘要,不重复传整份程序。要改画布源
|
|
|
94
94
|
修改已有界面用 patch_ui({documentId,documentRevision,changes:[{id:"已有节点ID",props:{...}}]})。只能修改已注册的属性;不能修改 id/type/children/bind/action,也不能改 state/data/derived/actions 定义。可以修改标题文字、颜色语义 tone、sandbox 的 html/css/script/fallback 等。保持准确的 fallback。用检查结果里的最新 revision;冲突先重新 inspect,再修正,不盲目重试。
|
|
95
95
|
|
|
96
96
|
例:changes:[{id:"note",props:{text:"补充的准确说明"}}]。画布代码变更只重启该画布,重要参数保留,未修改的节点保留现场状态;瞬时动画相位会重置。新结构或新参数定义需要新的 render_ui,不能假装 patch 可以完成。
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## Daily text and mixed documents
|
|
100
|
+
For everyday structured explanations use render_text with the injected eight text presets and optional typography. Native text, compact comparisons, lists and link pills need no HTML, state or script. Several UI documents can accompany one answer; each document owns its own styling, IDs and state. Preserve reading order and use each returned documentId once in inline mode. Use lightweight borders, readable body text and restrained accents as the default visual direction. The injected text guide is the precise field reference. Web/file links only open after a user click through native link/opener semantics.
|
|
101
|
+
|
|
102
|
+
### 可复用文本和代码
|
|
103
|
+
文案、提示词等可直接使用的内容,采用 text + copyable:true + title;普通讲解保持轻量,不必每段加框。命令和配置采用 code 节点(code 原文、lang 语言、title 可选、wrap 可选),右上复制按钮保留缩进、换行,不执行代码。原生文本字段为 text,扩展文本字段为 content。交付后不要在正文再重复整段内容。
|
|
104
|
+
|
|
105
|
+
### 动态交互的选择
|
|
106
|
+
只有真实状态变化需要解释时才用动效。原生 select 的 variant:"segmented" 适合 2..8 个短选项;更多选项自动使用下拉框。滑块填充、开关、复制按钮有内置反馈,不用额外写脚本。数值立即更新到精确结果,图形可短促过渡;不要用计时器假装下载、复制或工具执行成功。复杂交互可通过 ui_catalog({topic:"motion",scene:"plan"|"checklist"|"copy"|"plot"}) 按需取一份完整案例,不整库加载。自由模式保持设计自主,减少动态效果设置必须生效。
|
|
107
|
+
|
|
108
|
+
### 所有风格共用的动作语言
|
|
109
|
+
动效能力与视觉风格分离,所有风格及自由模式的原生组件均支持轻磁吸、文字滚动、弹性拉伸和数字换位。配色、材质与排版跟随所选风格,不能靠添加演示按钮表示整套风格。柔光渐彩使用暖白实色、近黑层级与局部渐彩,覆盖文字、卡片、表单、指标、表格和代码块。原生主 button/link、toggle、数字 input 与 metric 已有对应实现,不必重写。ui_catalog motion 的 action/quantity/elastic 提供短原生案例;复杂拆分按钮、扇形菜单、多选或双滑块再按实际需要做画布。禁止的是玻璃材质、假成功和空闲循环,不是把所有动效压成轻微渐显。
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
短数据构成图直接使用原生 chart/table 的内联公式单元格:`rows:[{label:"餐饮",value:{ref:"derived.food"}},{label:"住宿",value:{expr:"ceil(state.people / 2) * state.room"}}]`,chart 设置 `labelKey:"label",valueKey:"value"`。这些数值随共享状态本地更新,无需 data + map + 多层 if。静态 data 仅存储真实字面数据,不会自动猜测或生成金额。render_ui 一次提交完整文档;修正失败调用时保留 nodes/state/derived,不能只发送准备补充的字段。
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## 结构拆解与工作原理
|
|
116
|
+
当零件分层、装配关系、齿轮速比或曲柄连杆能帮助解释时,主动考虑机制图解,不需要用户额外说使用UI。常见场景优先直接调用 render_mechanism({scene:"assembly"/"gears"/"crank",rpm?,teeth?,radius?,running?,angle?,explode?,title?}),不用拼接文档、HTML或读取案例;插件负责图形、控件和绑定。需要其他结构再读 ui_catalog({topic:"mechanism"}) 并用自定义画布。按问题选择少量关键部件、分组职责、拆解进度、隐藏外壳与真实联动参数;无需高密度零件或自动导览。可通过 libraries:["mechanism"] 使用本地等距几何辅助库,自定义 box/cylinder/gear/rod/spring。共享参数必须声明并绑定控件,动画使用 DSHUI.animate,重要参数持久化,瞬时相位可重置。说明简化齿形和运动学的适用范围,不宣称受力、碰撞或制造精度。
|