dsh-motion-ui 0.5.6 → 0.6.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 +55 -0
- package/README.md +76 -4
- package/VERIFICATION.md +109 -0
- package/client.js +3764 -22300
- package/index.js +107 -81
- 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 +328 -0
- package/lib/assets/three.js +3842 -0
- package/lib/assets/visual.css +1 -0
- package/lib/assets/visual.js +414 -0
- package/lib/authoring-guide.js +2 -2
- package/lib/build-info.js +1 -1
- package/lib/canvas-system.js +3 -3
- package/lib/catalog.js +94 -92
- package/lib/components.js +9 -4
- 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/fence-feedback.js +61 -0
- package/lib/fence-route.js +14 -0
- package/lib/fences.js +9 -0
- package/lib/freeform.js +1 -1
- package/lib/inspection.js +3 -2
- package/lib/links.js +13 -0
- package/lib/normalize-authoring.js +46 -1
- package/lib/normalize-visual.js +36 -0
- package/lib/presentation.js +1 -1
- package/lib/protocol.js +348 -320
- package/lib/scene-library.js +13 -0
- package/lib/store.js +17 -2
- package/lib/stream.js +12 -0
- package/lib/text-document.js +25 -0
- package/lib/text-guide.js +13 -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/mermaid-LICENSE.txt +21 -0
- package/lib/third-party/three-LICENSE.txt +21 -0
- package/lib/tool-schema.js +17 -6
- package/lib/typography.js +16 -0
- package/lib/ui-intent.js +15 -14
- package/lib/ui-skill.js +53 -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 +30 -0
- package/lib/visual.js +40 -0
- package/package.json +92 -77
- package/skills/intelligent-ui/SKILL.md +103 -96
|
@@ -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,30 @@
|
|
|
1
|
+
// Add a style here to expose its settings card, prompt and worked examples.
|
|
2
|
+
// This registry contains design preferences only; it never changes tool permissions.
|
|
3
|
+
const native=(preset,title,blocks)=>({tool:'render_text',args:{preset,title,blocks}});
|
|
4
|
+
const canvas=(title,html,css)=>({tool:'render_canvas',args:{title,fallback:title+',静态排版示例。',html,css}});
|
|
5
|
+
export const DEFAULT_VISUAL_STYLE='prismframe';
|
|
6
|
+
export const VISUAL_STYLES=Object.freeze([
|
|
7
|
+
{id:'editorial',name:'清爽阅读',description:'轻边框 · 清晰层级 · 少量强调色',preview:{bg:'#fff',ink:'#182537',accent:'#3e60d3',soft:'#f4f6fa',line:'#dfe5ed'},
|
|
8
|
+
prompt:'采用编辑式阅读排版:中性底色、轻边框、清晰字号层级和充足但不浪费的留白。以正文、对齐比较、分隔列表和细线流程为主;强调色只标出关键结论,不给每段都套卡片,不加装饰性阴影和渐变。优先使用 render_text 的 reading/comparison/list/flow;图形确有价值时再用小画布。',
|
|
9
|
+
examples:[native('comparison','发布渠道怎么选',[{type:'row',columns:2,children:[{type:'column',children:[{type:'heading',text:'主发布平台'},{type:'text',text:'放完整资料与版本历史。'}]},{type:'column',children:[{type:'heading',text:'展示渠道'},{type:'text',text:'展示重点,并链接到完整资料。'}]}]},{type:'text',text:'各自承担一个清晰职责。',color:'muted'}]),canvas('三步发布','<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>','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}}')]},
|
|
10
|
+
{id:'soft',name:'柔和彩色',description:'柔和渐变 · 圆润分组 · 友好舒适',preview:{bg:'#fbf8ff',ink:'#32294c',accent:'#7954bb',soft:'#eee5fa',line:'#e6dcf2'},
|
|
11
|
+
prompt:'采用柔和彩色风格:低饱和紫色、蓝色或薄荷色,18..24px 圆角,轻柔渐变填充,柔和而清晰的分组。文字仍保持足够对比度;渐变放在小面积重点区,不铺满整篇,不用玻璃模糊、发光或多重阴影。日常文字用原生预设与语义色;确实需要渐变材质时使用短小静态画布,不为配色创建交互或动画。',
|
|
12
|
+
examples:[native('callout','本周只抓一个重点',[{type:'heading',text:'每天留出 20 分钟'},{type:'text',text:'先读一小节,再写下一个收获。',color:'muted'}]),canvas('本周阅读计划','<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>','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)}')]},
|
|
13
|
+
{id:'technical',name:'技术图解',description:'细线结构 · 对齐网格 · 数据优先',preview:{bg:'#f8fafb',ink:'#1b3440',accent:'#087e8b',soft:'#e7f1f3',line:'#cedde2'},
|
|
14
|
+
prompt:'采用技术图解风格:中性底色、精确对齐、细线连接、明确标签和单位、少量青色强调。数据使用等宽数字;代码或序号可用等宽字体,中文正文保持易读。优先简单流程、对比表、结构图与紧凑数据块;用有意义的箭头表达方向,不用装饰性仪表盘。圆角约 8..14px,禁止把字号缩小来塞内容。',
|
|
15
|
+
examples:[native('flow','一次请求经过什么',[{type:'steps',items:[{title:'输入',description:'接收用户需求。'},{title:'处理',description:'校验并计算结果。'},{title:'输出',description:'返回可理解的反馈。'}]}]),canvas('请求处理流程','<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>','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)}}')]},
|
|
16
|
+
{id:'expressive',name:'活力展示',description:'醒目标题 · 明快色块 · 简洁有力',preview:{bg:'#fff9f2',ink:'#362820',accent:'#bd4b26',soft:'#ffead8',line:'#edd7c5'},
|
|
17
|
+
prompt:'采用活力展示风格:醒目但不过大的标题、明快色块、清晰的大数字、圆润胶囊按钮与简洁的非对称重点。用橙色、珊瑚色或暖黄色做局部强调,并适应深浅主题。保持信息量小、重点明确;每块只有一个视觉中心,不用满屏彩色、夸张动画或海报式超大留白。原生文本可用 size/weight/语义色;特殊色块构图才使用紧凑画布。',
|
|
18
|
+
examples:[native('minimal','先完成第一步',[{type:'text',text:'先完成一个能演示的版本',size:28,weight:800},{type:'text',text:'选一条主线,今天就做出可见结果。',color:'muted'}]),canvas('从第一步开始','<section><div class="number">01</div><div class="copy"><span>今天的重点</span><h2>先做出一个<br>能演示的版本</h2><p>只保留一条主线,尽早获得反馈。</p></div></section>','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}}')]}
|
|
19
|
+
,{id:'prismframe',name:'明亮扁平',description:'浅彩背景 · 白色圆角卡片 · 彩色偏移阴影',preview:{bg:'#ecf6ff',ink:'#193858',accent:'#3182d9',soft:'#d3e8fc',line:'#9ec9ef'},
|
|
20
|
+
prompt:'采用明亮扁平风格:浅彩背景、白色大圆角卡片、细彩色边线、柔软投影与浅色偏移底面。技术介绍用浅蓝 #ECF6FF / #3182D9,机制测量用米白 #FBFAF5 / #1F9486,比较选择用暖白 #FFF8ED / #E77946,流程用浅绿 #EAF6EF / #29947A,提醒用浅珊瑚 #FFF3EF / #D8694A;每块选一套,保持文字对比度并适配深色主题。卡片圆角约 20..28px,边线约 1..2px,标题使用宿主可用的圆润字体回退,不下载字体。先排内容再排装饰:一块只解释一个主要问题,数字绑定名称、指标与单位;用比例条、格子和连接线解释关系,图形完整放在框内。简单文字仍优先 render_text;需要偏移阴影、图解构图时使用短小画布。可交替分栏、纵排、三卡布局,不能每块套同一模板。静态排版默认即可;确需入场只做一次短促渐显上移,并尊重 reduced motion。文字落稳后不持续缩放或漂移。禁止玻璃、模糊背景、出框透视、循环装饰动画;不复制视频字幕、页码、全屏画布或多余底部留白,不沿用 Occamy 的模型数据。',
|
|
21
|
+
examples:[native('list','把复杂问题拆成三层',[{type:'heading',text:'先讲清楚,再逐步展开',size:24,color:'accent'},{type:'text',text:'目标:先明确需要解决的问题。'},{type:'text',text:'机制:用一个图形解释关键关系。'},{type:'text',text:'行动:给出下一步可执行的建议。'}]),canvas('三步让解释更清楚','<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>','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}}')]}
|
|
22
|
+
]);
|
|
23
|
+
export const VISUAL_STYLE_IDS=Object.freeze(VISUAL_STYLES.map(s=>s.id));
|
|
24
|
+
export function visualStyle(id=DEFAULT_VISUAL_STYLE){
|
|
25
|
+
const style=VISUAL_STYLES.find(s=>s.id===id);
|
|
26
|
+
if(!style)throw Error('DSH UI: unknown visualStyle; use '+VISUAL_STYLE_IDS.join('/'));
|
|
27
|
+
return style;
|
|
28
|
+
}
|
|
29
|
+
export function stylePrompt(id){const s=visualStyle(id);return `## 用户选择的视觉风格:${s.name} (${s.id})\n${s.prompt}\n这套风格替代通用指导和旧案例中的默认配色、材质与圆角建议。只影响新生成内容的视觉方向;协议、工具入口、状态、权限、准确性、可读性与必要功能要求保持不变。引导模式下原生文本、卡片、指标、控件和代码块会自动跟随当前所选视觉风格;整份 UI 的原生内容和 HTML/SVG 应使用一致的色彩与层级。用原生 row/card/metric/control 等组织清晰结构,少量语义色强调重点。不要为了给原生内容上色而额外生成 HTML。确实需要特殊图解时再使用小画布。用户在当前请求中明确指定的风格优先。不要为展示风格增加不必要的画布、代码、动画或工具调用。`}
|
|
30
|
+
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,77 +1,92 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-motion-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Interactive UI, HTML/SVG animation and local calculations for DeepSeek Harness Web, with injected design guidance.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": "./index.js",
|
|
9
|
-
"./client": "./client.js",
|
|
10
|
-
"./package.json": "./package.json"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"index.js",
|
|
14
|
-
"client.js",
|
|
15
|
-
"lib",
|
|
16
|
-
"skills",
|
|
17
|
-
"examples",
|
|
18
|
-
"cordis.patch.yml",
|
|
19
|
-
"README.md",
|
|
20
|
-
"CHANGELOG.md",
|
|
21
|
-
"LICENSE",
|
|
22
|
-
"DESIGN.zh-CN.md",
|
|
23
|
-
"RELEASE-PLAN.zh-CN.md",
|
|
24
|
-
"VERIFICATION.md"
|
|
25
|
-
],
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "node scripts/build.mjs",
|
|
28
|
-
"test": "node --test tests/*.test.mjs",
|
|
29
|
-
"verify:release": "node scripts/verify-release.mjs",
|
|
30
|
-
"check": "node --check index.js && node --check client.js"
|
|
31
|
-
},
|
|
32
|
-
"dsh": {
|
|
33
|
-
"bundle": {
|
|
34
|
-
"patch": "./cordis.patch.yml"
|
|
35
|
-
},
|
|
36
|
-
"client": {
|
|
37
|
-
"platform": "web"
|
|
38
|
-
},
|
|
39
|
-
"compatibility": {
|
|
40
|
-
"dsh": "0.2.0-rc.2",
|
|
41
|
-
"node": ">=22.19",
|
|
42
|
-
"profiles": [
|
|
43
|
-
"web"
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"@deepseek-ai/dsh-
|
|
49
|
-
"@deepseek-ai/dsh-
|
|
50
|
-
"react": "^18.2.0"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-motion-ui",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Interactive UI, HTML/SVG animation and local calculations for DeepSeek Harness Web, with injected design guidance.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./client": "./client.js",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js",
|
|
14
|
+
"client.js",
|
|
15
|
+
"lib",
|
|
16
|
+
"skills",
|
|
17
|
+
"examples",
|
|
18
|
+
"cordis.patch.yml",
|
|
19
|
+
"README.md",
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"DESIGN.zh-CN.md",
|
|
23
|
+
"RELEASE-PLAN.zh-CN.md",
|
|
24
|
+
"VERIFICATION.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "node scripts/build.mjs",
|
|
28
|
+
"test": "node --test tests/*.test.mjs",
|
|
29
|
+
"verify:release": "node scripts/verify-release.mjs",
|
|
30
|
+
"check": "node --check index.js && node --check client.js"
|
|
31
|
+
},
|
|
32
|
+
"dsh": {
|
|
33
|
+
"bundle": {
|
|
34
|
+
"patch": "./cordis.patch.yml"
|
|
35
|
+
},
|
|
36
|
+
"client": {
|
|
37
|
+
"platform": "web"
|
|
38
|
+
},
|
|
39
|
+
"compatibility": {
|
|
40
|
+
"dsh": "0.2.0-rc.2",
|
|
41
|
+
"node": ">=22.19",
|
|
42
|
+
"profiles": [
|
|
43
|
+
"web"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@deepseek-ai/dsh-home-paths": "0.2.0-rc.2",
|
|
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"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"echarts": "^6.1.0",
|
|
55
|
+
"echarts-wordcloud": "^2.1.0",
|
|
56
|
+
"esbuild": "^0.25.0",
|
|
57
|
+
"katex": "^0.19.0",
|
|
58
|
+
"mdast-util-from-markdown": "^2.0.3",
|
|
59
|
+
"mermaid": "^11.16.1",
|
|
60
|
+
"react": "^18.3.1",
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
62
|
+
"three": "^0.180.0"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@deepseek-ai/schemastery": "^3.18.4"
|
|
66
|
+
},
|
|
67
|
+
"license": "MIT",
|
|
68
|
+
"repository": {
|
|
69
|
+
"type": "git",
|
|
70
|
+
"url": "git+https://github.com/Scorp1o117/dsh-motion-ui.git"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://github.com/Scorp1o117/dsh-motion-ui#readme",
|
|
73
|
+
"bugs": {
|
|
74
|
+
"url": "https://github.com/Scorp1o117/dsh-motion-ui/issues"
|
|
75
|
+
},
|
|
76
|
+
"author": "Scorp1o117",
|
|
77
|
+
"keywords": [
|
|
78
|
+
"dsh",
|
|
79
|
+
"deepseek-harness",
|
|
80
|
+
"generative-ui",
|
|
81
|
+
"interactive-ui",
|
|
82
|
+
"svg"
|
|
83
|
+
],
|
|
84
|
+
"overrides": {
|
|
85
|
+
"mermaid": {
|
|
86
|
+
"katex": "$katex"
|
|
87
|
+
},
|
|
88
|
+
"echarts-wordcloud": {
|
|
89
|
+
"echarts": "$echarts"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|