@uibot/registry 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +59 -0
  2. package/dist/distribution-snapshot.d.ts +22 -0
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +11 -11
  5. package/dist/resource-query.d.ts +4 -0
  6. package/dist/resources.d.ts +3 -0
  7. package/dist/resources.js +3 -3
  8. package/dist/shadcn/r/admin-apps.json +61 -0
  9. package/dist/shadcn/r/admin-chats.json +54 -0
  10. package/dist/shadcn/r/admin-error-401.json +54 -0
  11. package/dist/shadcn/r/admin-error-403.json +54 -0
  12. package/dist/shadcn/r/admin-error-404.json +54 -0
  13. package/dist/shadcn/r/admin-error-500.json +54 -0
  14. package/dist/shadcn/r/admin-error-503.json +54 -0
  15. package/dist/shadcn/r/admin-forgot-password.json +59 -0
  16. package/dist/shadcn/r/admin-help.json +53 -0
  17. package/dist/shadcn/r/admin-otp.json +59 -0
  18. package/dist/shadcn/r/admin-overview.json +62 -0
  19. package/dist/shadcn/r/admin-settings-account.json +61 -0
  20. package/dist/shadcn/r/admin-settings-appearance.json +61 -0
  21. package/dist/shadcn/r/admin-settings-display.json +61 -0
  22. package/dist/shadcn/r/admin-settings-notifications.json +61 -0
  23. package/dist/shadcn/r/admin-settings-profile.json +61 -0
  24. package/dist/shadcn/r/admin-settings.json +65 -0
  25. package/dist/shadcn/r/admin-shell.json +11 -5
  26. package/dist/shadcn/r/admin-sign-in-2.json +67 -0
  27. package/dist/shadcn/r/admin-sign-in.json +59 -0
  28. package/dist/shadcn/r/admin-sign-up.json +59 -0
  29. package/dist/shadcn/r/admin-tasks.json +66 -0
  30. package/dist/shadcn/r/admin-users.json +66 -0
  31. package/dist/shadcn/r/auth-01.json +24 -0
  32. package/dist/shadcn/r/auth-02.json +24 -0
  33. package/dist/shadcn/r/auth-03.json +24 -0
  34. package/dist/shadcn/r/auth-04.json +24 -0
  35. package/dist/shadcn/r/auth-05.json +24 -0
  36. package/dist/shadcn/r/auth-centered.json +61 -0
  37. package/dist/shadcn/r/auth-enterprise.json +61 -0
  38. package/dist/shadcn/r/auth-primitives.json +58 -0
  39. package/dist/shadcn/r/auth-recovery.json +64 -0
  40. package/dist/shadcn/r/auth-registration.json +63 -0
  41. package/dist/shadcn/r/auth-split.json +67 -0
  42. package/dist/shadcn/r/auth.json +13 -13
  43. package/dist/shadcn/r/charts.json +1 -1
  44. package/dist/shadcn/r/chat-artifact.json +49 -0
  45. package/dist/shadcn/r/chat-focused.json +49 -0
  46. package/dist/shadcn/r/chat-history.json +49 -0
  47. package/dist/shadcn/r/chat-knowledge.json +49 -0
  48. package/dist/shadcn/r/chat-support.json +49 -0
  49. package/dist/shadcn/r/chat-workspace.json +136 -0
  50. package/dist/shadcn/r/collection-cell-editor.json +6 -6
  51. package/dist/shadcn/r/collection-panel-drawer.json +2 -2
  52. package/dist/shadcn/r/collection-record-menu.json +2 -2
  53. package/dist/shadcn/r/collection-shared.json +2 -2
  54. package/dist/shadcn/r/commerce-workspace.json +69 -0
  55. package/dist/shadcn/r/console-billing.json +68 -0
  56. package/dist/shadcn/r/console-page.json +289 -0
  57. package/dist/shadcn/r/console-shell.json +29 -0
  58. package/dist/shadcn/r/content.json +1 -1
  59. package/dist/shadcn/r/creation-html-generation.json +3 -3
  60. package/dist/shadcn/r/creation-reference-generation.json +3 -3
  61. package/dist/shadcn/r/creation-revision-export.json +3 -3
  62. package/dist/shadcn/r/creation-shared.json +3 -3
  63. package/dist/shadcn/r/creation-variant-compare.json +4 -4
  64. package/dist/shadcn/r/creation-workspace.json +4 -4
  65. package/dist/shadcn/r/crm-workspace.json +73 -0
  66. package/dist/shadcn/r/dashboard.json +1 -1
  67. package/dist/shadcn/r/data-studio.json +1 -1
  68. package/dist/shadcn/r/data-table.json +25 -7
  69. package/dist/shadcn/r/data.json +81 -11
  70. package/dist/shadcn/r/document-assistant.json +54 -0
  71. package/dist/shadcn/r/document-library.json +49 -0
  72. package/dist/shadcn/r/document-reading.json +49 -0
  73. package/dist/shadcn/r/document-workspace.json +164 -0
  74. package/dist/shadcn/r/document-writing.json +49 -0
  75. package/dist/shadcn/r/drilldown-menu.json +233 -0
  76. package/dist/shadcn/r/education-workspace.json +82 -0
  77. package/dist/shadcn/r/feedback.json +6 -6
  78. package/dist/shadcn/r/field.json +1 -1
  79. package/dist/shadcn/r/form.json +11 -11
  80. package/dist/shadcn/r/grid.json +1 -1
  81. package/dist/shadcn/r/interactive.json +1 -1
  82. package/dist/shadcn/r/item-grid.json +219 -0
  83. package/dist/shadcn/r/kanban.json +1 -1
  84. package/dist/shadcn/r/layout.json +196 -16
  85. package/dist/shadcn/r/marketing.json +1 -1
  86. package/dist/shadcn/r/nav.json +3 -3
  87. package/dist/shadcn/r/presentation.json +1 -1
  88. package/dist/shadcn/r/preview-device-frame.json +2 -2
  89. package/dist/shadcn/r/primitives.json +2 -2
  90. package/dist/shadcn/r/sections.json +1 -1
  91. package/dist/shadcn/r/shadcn-admin-shell.json +1 -1
  92. package/dist/shadcn/r/shadcn-admin.json +23 -22
  93. package/dist/shadcn/r/sidebar-01.json +42 -0
  94. package/dist/shadcn/r/sidebar-02.json +42 -0
  95. package/dist/shadcn/r/sidebar-03.json +30 -0
  96. package/dist/shadcn/r/sidebar-04.json +30 -0
  97. package/dist/shadcn/r/sidebar-05.json +36 -0
  98. package/dist/shadcn/r/sidebar-06.json +42 -0
  99. package/dist/shadcn/r/sidebar-07.json +54 -0
  100. package/dist/shadcn/r/sidebar-08.json +54 -0
  101. package/dist/shadcn/r/sidebar-09.json +36 -0
  102. package/dist/shadcn/r/sidebar-10.json +66 -0
  103. package/dist/shadcn/r/sidebar-11.json +30 -0
  104. package/dist/shadcn/r/sidebar-12.json +48 -0
  105. package/dist/shadcn/r/sidebar-13.json +30 -0
  106. package/dist/shadcn/r/sidebar-14.json +30 -0
  107. package/dist/shadcn/r/sidebar-15.json +84 -0
  108. package/dist/shadcn/r/sidebar-16.json +66 -0
  109. package/dist/shadcn/r/sidebar-drilldown.json +29 -0
  110. package/dist/shadcn/r/sidebar-primitives.json +155 -0
  111. package/dist/shadcn/r/uibot-base.json +3 -3
  112. package/dist/shadcn/r/workspace.json +3 -3
  113. package/dist/shadcn/registry.json +987 -175
  114. package/dist/shadcn.d.ts +0 -39
  115. package/dist/solution-composition.d.ts +45 -0
  116. package/dist/solution-regions.d.ts +3 -0
  117. package/dist/solution-spec.d.ts +7 -0
  118. package/dist/template-source.d.ts +2 -0
  119. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Fixed registry distribution
2
+
3
+ `uibot.distribution.snapshot.v1` binds the public bundle hash, explicit resource/package
4
+ versions and hashes to final registry item bytes, file targets/lengths/hashes, exact direct
5
+ npm versions, and MIT/ISC license files. `snapshotId` is SHA-256 over canonical JSON with
6
+ sorted object keys, excluding only `snapshotId`; transport origin and timestamps are absent.
7
+ `resourceHash` describes the author resource, not its installable bytes. Public discovery
8
+ exposes references; the full manifest is a separate immutable artifact. `release.sourceHash`
9
+ continues to hash only index/showcases/documents; the snapshot binds that hash separately.
10
+
11
+ The build reads local author sources and the Bun lockfile, pins npm requirements before
12
+ serializing registry items, and copies those exact bytes to `snapshots/<id>/r/`.
13
+ A local registry closure with missing dependencies, target conflicts or inconsistent npm
14
+ versions fails the build. Resources requiring external shadcn registry items have an explicit
15
+ `snapshotUnavailable` reason, with no mutable fallback. No network fetch during generation.
16
+
17
+ ## Save, verify, install
18
+
19
+ Use the candidate CLI (or a packed CLI from the same candidate), with an explicit bundle:
20
+
21
+ ```sh
22
+ uibot resource install-plan template:console-billing --source https://your-portal/resources/bundle.json --export ./uibot-snapshot
23
+ uibot resource install-plan template:console-billing --verify ./uibot-snapshot
24
+ uibot snapshot-serve ./uibot-snapshot --port 4444
25
+ ```
26
+
27
+ A local bundle path is also accepted. Export fetches and verifies the entire selected closure
28
+ and licenses in memory before writing any destination. All destinations pass lexical and
29
+ canonical containment checks and an existing-file comparison before the first write.
30
+ Identical repeated exports succeed; conflicting files or symlinks fail without overwriting
31
+ local edits. Use a dedicated, single-writer destination. An I/O failure during writing can
32
+ leave an incomplete export: verification must succeed before consumption.
33
+
34
+ The saved directory includes `snapshot.json`, `selection.json`, `r/*.json` and `licenses/*`.
35
+ Verification and serving use only these files, without contacting the original portal.
36
+ The server binds to loopback, validates before listening, serves verified bytes held in memory,
37
+ and returns 404 for every missing dependency. It never proxies to the mutable registry.
38
+
39
+ Merge the server's printed mapping into the host `components.json`, keeping existing settings:
40
+
41
+ ```json
42
+ { "registries": { "@uibot": "http://127.0.0.1:4444/r/{name}.json" } }
43
+ ```
44
+
45
+ Then run the server's printed pinned `bunx shadcn@4.23.0 add <local-item-url>` command.
46
+ The installer may format/transform source and normalize dependency ranges; the verified hashes
47
+ describe its registry inputs, not host output bytes. Retain the snapshot license files with
48
+ redistributed source, including the Lucide/Feather notice that a TSX transformer may remove.
49
+ Do not use `--overwrite`: resolve existing-file conflicts explicitly and retain host edits.
50
+ The official shadcn installer owns host file placement, aliases, CSS and dependency installation;
51
+ the snapshot exporter never writes application source. npm packages and their transitive graph
52
+ still require a host frozen lockfile and registry/cache access. Registry offline availability
53
+ is not offline npm availability. Integrity hashes are not signatures or publication receipts:
54
+ select a trusted bundle and pin its expected identity with `--snapshot <sha256>` on export and verify.
55
+
56
+ `@uibot/registry` exports Node integrity helpers. `@uibot/registry/resources` remains
57
+ browser-safe and read-only. HTTP/MCP install-plan returns the same identity and closure;
58
+ CLI-only export/verify and loopback serving are not MCP tools. This does not discover plugins,
59
+ change capabilities, establish host acceptance, publish packages or deploy a service.
@@ -0,0 +1,22 @@
1
+ import type { DistributionSnapshot, DistributionSnapshotResource } from "@uibot/contracts";
2
+ export declare function distributionSha256(bytes: string | Uint8Array): string;
3
+ export declare function distributionCanonicalJson(value: unknown): string;
4
+ export declare function assertDistributionPath(path: string): void;
5
+ export declare function snapshotDependencyName(ref: string): string;
6
+ export declare function describeDistributionItem(name: string, bytes: Uint8Array): DistributionSnapshot["items"][string];
7
+ export declare function distributionClosure(items: DistributionSnapshot["items"], entrypoints: readonly string[]): string[];
8
+ export declare function createDistributionSnapshot(input: {
9
+ bundleHash: string;
10
+ version: string;
11
+ resources: Record<string, Omit<DistributionSnapshotResource, "closure">>;
12
+ items: Record<string, Uint8Array>;
13
+ licenseFiles: Record<string, Uint8Array>;
14
+ }): DistributionSnapshot;
15
+ export declare function assertDistributionSnapshot(value: unknown, expectedId?: string): asserts value is DistributionSnapshot;
16
+ /** Verify the entire selected closure in memory. No filesystem, fetch or install effects. */
17
+ export declare function verifyDistributionSnapshot(snapshot: DistributionSnapshot, resourceId: string, files: ReadonlyMap<string, Uint8Array>, expectedId: string): {
18
+ snapshotId: string;
19
+ resourceId: string;
20
+ closure: string[];
21
+ npmDependencies: Record<string, string>;
22
+ };
package/dist/index.d.ts CHANGED
@@ -101,3 +101,4 @@ export * from "./resource-aliases.js";
101
101
  export * from "./resource-query.js";
102
102
  export * from "./resource-receipt.js";
103
103
  export * from "./public-resources.js";
104
+ export * from "./distribution-snapshot.js";
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  // @bun
2
- import{lstatSync as Pr,mkdirSync as He,readFileSync as Sr,realpathSync as Ir,writeFileSync as We}from"fs";import{basename as Ar,dirname as me,isAbsolute as wr,resolve as D,sep as qe}from"path";function Ze(e){let t=e.lockfilePath??"uibot.artifacts.lock.json",r=e.manifest.items??[],n=new Map;for(let s of r)n.set(s.name,s);if(e.lockfile===null)return{ok:!1,lockfilePath:t,registryName:e.manifest.name,lockCount:0,manifestCount:r.length,drifts:[{name:"*",kind:"missing-in-lock",detail:"lockfile missing or unreadable"}]};let o=[],i=new Set;for(let s of e.lockfile.artifacts??[]){i.add(s.name);let l=n.get(s.name);if(!l){o.push({name:s.name,kind:"missing-in-manifest",lockVersion:s.version,detail:`locked ${s.name}@${s.version} not present in registry manifest`});continue}let c=Xe(l);if(c&&c!==s.version)o.push({name:s.name,kind:"version-mismatch",lockVersion:s.version,manifestVersion:c,detail:`${s.name}: lock ${s.version} \u2260 registry ${c}`})}return{ok:o.length===0,lockfilePath:t,registryName:e.manifest.name,lockCount:(e.lockfile.artifacts??[]).length,manifestCount:r.length,drifts:o}}function Xe(e){return e.artifact?.version??e.version}function et(){return{version:1,artifacts:[]}}function tt(e){return{version:1,artifacts:e}}import{readFileSync as rt,realpathSync as ye}from"fs";import{resolve as B,relative as nt,dirname as ot,extname as it,sep as re}from"path";function st(e){if(e.endsWith(".css"))return"style";if(e.endsWith(".tsx")||e.endsWith(".jsx"))return"component";if(/(^|\/)use-[^/]+\.ts$/.test(e))return"hook";return"lib"}function at(e){let t=e.readFile??((c)=>rt(c,"utf8")),r=new Map,n=(c,d=B(e.sourceDir))=>{let u=nt(d,B(c));if(u===".."||u.startsWith(`..${re}`)||u.startsWith(re))throw Error(`Block dependency outside sourceDir: ${c}`);return u.replaceAll(re,"/")},o=(c)=>{if(n(B(e.sourceDir,c)),!e.readFile)n(ye(B(e.sourceDir,c)),ye(e.sourceDir));let d=r.get(c);if(d!==void 0)return d;let u=t(B(e.sourceDir,c));return r.set(c,u),u},i=(c)=>{let d=new Map,u=(f)=>{if(d.has(f))return;let p=o(f);d.set(f,{path:f,type:st(f),content:p});let a=p.matchAll(/(?:\bfrom\s*|\bimport\s*)["'](\.[^"']+)["']/g);for(let g of a){let y=n(B(e.sourceDir,ot(f),g[1]??"")),h=it(y)?[y]:[`${y}.ts`,`${y}.tsx`,`${y}/index.ts`,`${y}/index.tsx`],S;for(let M of h)try{o(M),S=M;break}catch(T){if(T instanceof Error&&T.message.includes("outside sourceDir"))throw T}if(!S)throw Error(`Unresolved block dependency: ${f} -> ${g[1]}`);u(S)}};return u(c),[...d.values()]},s=(c)=>{let d=new Set;for(let u of c){if(typeof u.content!=="string")continue;for(let f of u.content.matchAll(/(?:\bfrom\s*|\bimport\s*)["']([^."'/][^"']*|@[^"']+)["']/g)){let p=f[1]??"";if(p.startsWith("node:"))continue;let a=p.startsWith("@")?p.split("/").slice(0,2).join("/"):p.split("/")[0]??"";if(a==="react"||a==="react-dom"||a.startsWith("@uibot/"))continue;d.add(a)}}return[...d].sort()},l=[];for(let c of Object.keys(e.catalog)){let d=e.blockFileMap[c];if(d===void 0)continue;let u=e.catalog[c];if(u===void 0)continue;let f=o(d),p=i(d),a=s(p);l.push({name:c,category:u.category,description:u.description,sourceCode:f,files:p,catalogEntry:u,...a.length>0?{dependencies:a}:{}})}return l}function Zr(e){return e.flatMap((t)=>at(t))}import{readdirSync as ct,readFileSync as lt,statSync as dt}from"fs";import{basename as ut,join as pt}from"path";var gt="0.1.0";function he(e){let{dir:t}=e,r;try{r=ct(t)}catch{return[]}let n=e.defaultVersion??gt,o=e.defaultLevel??"L4",i=e.defaultCategory??"template",s=[];for(let l of r){if(!/\.ya?ml$/i.test(l))continue;let c=pt(t,l);try{if(!dt(c).isFile())continue}catch{continue}let d=lt(c,"utf8");if(!d.trim())continue;let u=ut(l).replace(/\.ya?ml$/i,""),f=ft(u),p=yt(u),a=ht(d)??`${p} template`;s.push({name:f,version:n,title:p,description:a,yaml:d,absolutePath:c,templateContract:{name:f,description:a,level:o,category:i,keywords:[f,u.toLowerCase(),"uibot-template",...e.extraKeywords??[]],composedFrom:Ct(d)}})}return s.sort((l,c)=>l.name.localeCompare(c.name))}function mt(e){let t=new Map;for(let r of e)for(let n of he(r)){let o=t.get(n.name);if(o)throw Error(`duplicate template source name "${n.name}": ${o.absolutePath} and ${n.absolutePath}`);t.set(n.name,n)}return[...t.values()].sort((r,n)=>r.name.localeCompare(n.name))}function Ce(e){return{kind:"template",name:e.name,version:e.version,files:[{path:`${e.name}.yaml`,type:"template",content:e.yaml,target:`${e.name}.yaml`}],templateContract:e.templateContract}}function ne(e){return{name:e.name,kind:"template",title:e.title,description:e.description,artifact:Ce(e)}}function ft(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function yt(e){return e.replace(/[-_]+/g," ").replace(/\b\w/g,(t)=>t.toUpperCase())}function ht(e){return(e.match(/^\s*title:\s*["']?(.+?)["']?\s*$/m)??e.match(/^\s*-\s*id:.*\n\s*path:.*\n\s*title:\s*["']?(.+?)["']?\s*$/m))?.[1]?.trim()}function Ct(e){let t=new Set;for(let r of e.matchAll(/^\s*-\s*type:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}for(let r of e.matchAll(/^\s*template:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}return[...t].sort()}var bt="0.1.0";function Rt(e,t={}){return{kind:"component",name:e.name,version:t.defaultVersion??bt,runtime:t.runtime??"react",files:e.files,...e.dependencies?{dependencies:e.dependencies}:{},...e.registryDependencies?{registryDependencies:e.registryDependencies}:{},...e.catalogEntry.tags?{tags:e.catalogEntry.tags}:{},catalogEntry:e.catalogEntry}}function be(e,t={}){return{name:e.name,kind:"component",title:e.catalogEntry.name,description:e.description??e.catalogEntry.description,artifact:Rt(e,t)}}function on(e,t){let r={...t.runtime?{runtime:t.runtime}:{},...t.defaultVersion?{defaultVersion:t.defaultVersion}:{}},n=e.map((i)=>be(i,r)),o=(t.templates??[]).map((i)=>ne(i));return{name:t.name,items:[...n,...o]}}function sn(e,t={}){return be(e,t)}var Pt={spec:["html","markdown","zip"],prototype:["html","zip"],deck:["html","pptx","zip"],poster:["html","zip"]},eo=Array.from(new Set(Object.values(Pt).flat()));var Re=["component","template","design-guide","example","skill","block","package","theme"],Q=["experimental","candidate","recommended"],xe=["declared","verified","external-consumer"],J=["missing","declared","verified","external-consumer"],q=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure","packed-install","typecheck","browser"],St=Object.freeze([Object.freeze({name:"manifest",summary:"Describe query operations and list the derived resource index.",positionals:Object.freeze([]),options:Object.freeze([])}),Object.freeze({name:"search",summary:"Search resources with deterministic bilingual ranking and reasons.",positionals:Object.freeze([Object.freeze({name:"text",property:"text",type:"string",required:!1})]),options:Object.freeze([Object.freeze({name:"kind",property:"kinds",type:"resource-kind",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"tag",property:"tags",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"category",property:"categories",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"capability",property:"capabilities",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"maturity",property:"maturities",type:"resource-maturity",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"limit",property:"limit",type:"positive-integer"})])}),Object.freeze({name:"get",summary:"Resolve one canonical resource id or unambiguous alias.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])}),Object.freeze({name:"build",summary:"Plan dependency closure and gaps without writing or installing.",positionals:Object.freeze([Object.freeze({name:"root",property:"roots",type:"string",required:!0,variadic:!0})]),options:Object.freeze([])}),Object.freeze({name:"docs",summary:"Read curated public documentation for one resource.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([{name:"locale",property:"locale",type:"string"},{name:"page",property:"page",type:"positive-integer"}])}),Object.freeze({name:"examples",summary:"Read one bounded page of examples and exact dependencies. Follow nextPage for complete source.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([{name:"page",property:"page",type:"positive-integer"}])}),Object.freeze({name:"install-plan",summary:"Describe distribution channels without installing or writing.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])})]);var oe="uibot.registry.item.v1";var It=["background","foreground","card","card-foreground","popover","popover-foreground","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","border","input","ring","destructive","destructive-foreground","success","success-foreground","warning","warning-foreground"],io=[...It,"radius","font-display","font-body","font-mono"];var At="https://ui.shadcn.com/schema/registry.json",wt="https://ui.shadcn.com/schema/registry-item.json",vt=["clsx","tailwind-merge"],Et="components/uibot",Dt="lib",Tt="@uibot",Ot="uibot/templates",ie="uibot-base",ke="uibot-theme";function se(e){return e.replace(/\./g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Pe(e,t){let r=e.sourceCode;if(r=r.replace(/import\s+(type\s+)?(\{[^}]*\})\s+from\s+["']@uibot\/renderer-react["'];?/g,(i,s,l)=>`import ${s??"type "}${l} from "${t.rendererShimImport}";`),t.contractsShimImport){let i=t.contractsShimImport;r=r.replace(/import\s+(type\s+)?(\{[^}]*\})\s+from\s+["']@uibot\/contracts["'];?/g,(s,l,c)=>`import ${l??"type "}${c} from "${i}";`)}let n=new Set;r=r.replace(/\bReact\.([A-Z]\w*)/g,(i,s)=>(n.add(s),s));let o=!1;if(r=r.replace(/(?:^|\n)function cn\([\s\S]*?\)\s*(?::[^\n{]+)?\{[\s\S]*?\n\}\n?/,()=>(o=!0,`
3
- `)),o){let i=`import { cn } from "${t.cnUtilImport}";
2
+ import{lstatSync as zr,mkdirSync as at,readFileSync as qr,realpathSync as Hr,writeFileSync as ct}from"fs";import{basename as Kr,dirname as Ie,isAbsolute as Wr,resolve as O,sep as ot}from"path";function mt(e){let t=e.lockfilePath??"uibot.artifacts.lock.json",r=e.manifest.items??[],i=new Map;for(let o of r)i.set(o.name,o);if(e.lockfile===null)return{ok:!1,lockfilePath:t,registryName:e.manifest.name,lockCount:0,manifestCount:r.length,drifts:[{name:"*",kind:"missing-in-lock",detail:"lockfile missing or unreadable"}]};let n=[],a=new Set;for(let o of e.lockfile.artifacts??[]){a.add(o.name);let s=i.get(o.name);if(!s){n.push({name:o.name,kind:"missing-in-manifest",lockVersion:o.version,detail:`locked ${o.name}@${o.version} not present in registry manifest`});continue}let c=ft(s);if(c&&c!==o.version)n.push({name:o.name,kind:"version-mismatch",lockVersion:o.version,manifestVersion:c,detail:`${o.name}: lock ${o.version} \u2260 registry ${c}`})}return{ok:n.length===0,lockfilePath:t,registryName:e.manifest.name,lockCount:(e.lockfile.artifacts??[]).length,manifestCount:r.length,drifts:n}}function ft(e){return e.artifact?.version??e.version}function yt(){return{version:1,artifacts:[]}}function ht(e){return{version:1,artifacts:e}}import{readFileSync as bt,realpathSync as we}from"fs";import{resolve as z,relative as Ct,dirname as Rt,extname as xt,sep as pe}from"path";function kt(e){if(e.endsWith(".css"))return"style";if(e.endsWith(".tsx")||e.endsWith(".jsx"))return"component";if(/(^|\/)use-[^/]+\.ts$/.test(e))return"hook";return"lib"}function St(e){let t=e.readFile??((c)=>bt(c,"utf8")),r=new Map,i=(c,l=z(e.sourceDir))=>{let u=Ct(l,z(c));if(u===".."||u.startsWith(`..${pe}`)||u.startsWith(pe))throw Error(`Block dependency outside sourceDir: ${c}`);return u.replaceAll(pe,"/")},n=(c)=>{if(i(z(e.sourceDir,c)),!e.readFile)i(we(z(e.sourceDir,c)),we(e.sourceDir));let l=r.get(c);if(l!==void 0)return l;let u=t(z(e.sourceDir,c));return r.set(c,u),u},a=(c)=>{let l=new Map,u=(f)=>{if(l.has(f))return;let p=n(f);l.set(f,{path:f,type:kt(f),content:p});let d=p.matchAll(/(?:\bfrom\s*|\bimport\s*)["'](\.[^"']+)["']/g);for(let m of d){let y=i(z(e.sourceDir,Rt(f),m[1]??"")),h=xt(y)?[y]:[`${y}.ts`,`${y}.tsx`,`${y}/index.ts`,`${y}/index.tsx`],A;for(let N of h)try{n(N),A=N;break}catch(_){if(_ instanceof Error&&_.message.includes("outside sourceDir"))throw _}if(!A)throw Error(`Unresolved block dependency: ${f} -> ${m[1]}`);u(A)}};return u(c),[...l.values()]},o=(c)=>{let l=new Set;for(let u of c){if(typeof u.content!=="string")continue;for(let f of u.content.matchAll(/(?:\bfrom\s*|\bimport\s*)["']([^."'/][^"']*|@[^"']+)["']/g)){let p=f[1]??"";if(p.startsWith("node:"))continue;let d=p.startsWith("@")?p.split("/").slice(0,2).join("/"):p.split("/")[0]??"";if(d==="react"||d==="react-dom"||d.startsWith("@uibot/"))continue;l.add(d)}}return[...l].sort()},s=[];for(let c of Object.keys(e.catalog)){let l=e.blockFileMap[c];if(l===void 0)continue;let u=e.catalog[c];if(u===void 0)continue;let f=n(l),p=a(l),d=o(p);s.push({name:c,category:u.category,description:u.description,sourceCode:f,files:p,catalogEntry:u,...d.length>0?{dependencies:d}:{}})}return s}function Cn(e){return e.flatMap((t)=>St(t))}import{readdirSync as It,readFileSync as At,statSync as wt}from"fs";import{basename as Pt,join as vt}from"path";var Et="0.1.0";function Pe(e){let{dir:t}=e,r;try{r=It(t)}catch{return[]}let i=e.defaultVersion??Et,n=e.defaultLevel??"L4",a=e.defaultCategory??"template",o=[];for(let s of r){if(!/\.ya?ml$/i.test(s))continue;let c=vt(t,s);try{if(!wt(c).isFile())continue}catch{continue}let l=At(c,"utf8");if(!l.trim())continue;let u=Pt(s).replace(/\.ya?ml$/i,""),f=Tt(u),p=Ot(u),d=_t(l)??`${p} template`;o.push({name:f,version:i,title:p,description:d,yaml:l,absolutePath:c,templateContract:{name:f,description:d,level:n,category:a,keywords:[f,u.toLowerCase(),"uibot-template",...e.extraKeywords??[]],composedFrom:Ft(l)}})}return o.sort((s,c)=>s.name.localeCompare(c.name))}function Dt(e){let t=new Map;for(let r of e)for(let i of Pe(r)){let n=t.get(i.name);if(n)throw Error(`duplicate template source name "${i.name}": ${n.absolutePath} and ${i.absolutePath}`);t.set(i.name,i)}return[...t.values()].sort((r,i)=>r.name.localeCompare(i.name))}function ve(e){return{kind:"template",name:e.name,version:e.version,files:[{path:`${e.name}.yaml`,type:"template",content:e.yaml,target:`${e.name}.yaml`}],templateContract:e.templateContract}}function ge(e){return{name:e.name,kind:"template",title:e.title,description:e.description,artifact:ve(e)}}function Tt(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function Ot(e){return e.replace(/[-_]+/g," ").replace(/\b\w/g,(t)=>t.toUpperCase())}function _t(e){return(e.match(/^\s*title:\s*["']?(.+?)["']?\s*$/m)??e.match(/^\s*-\s*id:.*\n\s*path:.*\n\s*title:\s*["']?(.+?)["']?\s*$/m))?.[1]?.trim()}function Ft(e){let t=new Set;for(let r of e.matchAll(/^\s*-\s*type:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let i=r[1]?.trim();if(i)t.add(i)}for(let r of e.matchAll(/^\s*template:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let i=r[1]?.trim();if(i)t.add(i)}return[...t].sort()}var Mt="0.1.0";function Nt(e,t={}){return{kind:"component",name:e.name,version:t.defaultVersion??Mt,runtime:t.runtime??"react",files:e.files,...e.dependencies?{dependencies:e.dependencies}:{},...e.registryDependencies?{registryDependencies:e.registryDependencies}:{},...e.catalogEntry.tags?{tags:e.catalogEntry.tags}:{},catalogEntry:e.catalogEntry}}function Ee(e,t={}){return{name:e.name,kind:"component",title:e.catalogEntry.name,description:e.description??e.catalogEntry.description,artifact:Nt(e,t)}}function An(e,t){let r={...t.runtime?{runtime:t.runtime}:{},...t.defaultVersion?{defaultVersion:t.defaultVersion}:{}},i=e.map((a)=>Ee(a,r)),n=(t.templates??[]).map((a)=>ge(a));return{name:t.name,items:[...i,...n]}}function wn(e,t={}){return Ee(e,t)}import{posix as L}from"path";var jt={spec:["html","markdown","zip"],prototype:["html","zip"],deck:["html","pptx","zip"],poster:["html","zip"]},Ri=Array.from(new Set(Object.values(jt).flat()));var De=["component","template","design-guide","example","skill","block","package","theme"],te=["experimental","candidate","recommended"],Te=["declared","verified","external-consumer"],re=["missing","declared","verified","external-consumer"],Y=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure","packed-install","typecheck","browser"],Vt=Object.freeze([Object.freeze({name:"manifest",summary:"Describe query operations and list the derived resource index.",positionals:Object.freeze([]),options:Object.freeze([])}),Object.freeze({name:"search",summary:"Search resources with deterministic bilingual ranking and reasons.",positionals:Object.freeze([Object.freeze({name:"text",property:"text",type:"string",required:!1})]),options:Object.freeze([...[["function","functions"],["scenario","scenarios"],["unit","units"],["industry","industries"]].map(([e,t])=>Object.freeze({name:e,property:t,type:"string",multiple:!0,cliEncoding:"comma-separated"})),Object.freeze({name:"kind",property:"kinds",type:"resource-kind",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"tag",property:"tags",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"category",property:"categories",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"capability",property:"capabilities",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"maturity",property:"maturities",type:"resource-maturity",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"limit",property:"limit",type:"positive-integer"})])}),Object.freeze({name:"get",summary:"Resolve one canonical resource id or unambiguous alias.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])}),Object.freeze({name:"build",summary:"Plan dependency closure and gaps without writing or installing.",positionals:Object.freeze([Object.freeze({name:"root",property:"roots",type:"string",required:!0,variadic:!0})]),options:Object.freeze([])}),Object.freeze({name:"docs",summary:"Read curated public documentation for one resource.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([{name:"locale",property:"locale",type:"string"},{name:"page",property:"page",type:"positive-integer"}])}),Object.freeze({name:"examples",summary:"Read one bounded page of examples and exact dependencies. Follow nextPage for complete source.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([{name:"page",property:"page",type:"positive-integer"}])}),Object.freeze({name:"install-plan",summary:"Describe distribution channels and fixed snapshot identity/closure without installing or writing.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])})]);var me="uibot.registry.item.v1";var $t=["background","foreground","card","card-foreground","popover","popover-foreground","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","border","input","ring","destructive","destructive-foreground","success","success-foreground","warning","warning-foreground"],Ai=[...$t,"radius","font-display","font-body","font-mono"];var D=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),k=(e)=>typeof e==="string"&&e.length>0&&!["__proto__","prototype","constructor"].includes(e),Oe=(e)=>D(e)&&Object.entries(e).every(([t,r])=>k(t)&&k(r));function Li(e){if(e.composition===void 0)return;let t=e.composition;if(!D(t)||t.schema!=="uibot.solution-composition.v1"||!Array.isArray(t.pages))throw Error("invalid-solution-composition");let r=new Set;for(let i of t.pages){if(!D(i)||!k(i.resourceId)||!k(i.version)||typeof i.sourceHash!=="string"||!/^[a-f0-9]{64}$/.test(i.sourceHash)||!k(i.sourcePageId)||!k(i.targetPageId)||r.has(i.targetPageId)||!D(i.baseline)||i.baseline.id!==i.targetPageId||typeof i.baseline.path!=="string"||!Array.isArray(i.baseline.blocks)||!D(i.bindings)||!["source","target"].includes(String(i.bindings.layout))||!Oe(i.bindings.paths)||!Oe(i.bindings.connections)||i.bindings.frame!==void 0&&(!D(i.bindings.frame)||Object.keys(i.bindings.frame).some((n)=>!["props","slots","events"].includes(n)))||i.detached!==void 0&&typeof i.detached!=="boolean"||i.configuration!==void 0&&(!D(i.configuration)||Object.entries(i.configuration).some(([n,a])=>!k(n)||!["string","number","boolean"].includes(typeof a)||typeof a==="number"&&!Number.isFinite(a))))throw Error("invalid-solution-adoption");r.add(i.targetPageId)}if(t.regions!==void 0){if(!Array.isArray(t.regions))throw Error("invalid-solution-regions");let i=new Set;for(let n of t.regions){if(!D(n)||!k(n.resourceId)||!k(n.version)||typeof n.sourceHash!=="string"||!/^[a-f0-9]{64}$/.test(n.sourceHash)||!k(n.targetPageId)||i.has(n.targetPageId)||!k(n.role)||n.target!=="page-frame"||!k(n.contentBlockId)||!D(n.baseline)||!k(n.baseline.type))throw Error("invalid-solution-region");i.add(n.targetPageId)}}}var Ut="https://ui.shadcn.com/schema/registry.json",zt="https://ui.shadcn.com/schema/registry-item.json",qt=["clsx","tailwind-merge"],Ht="components/uibot",Kt="lib",Wt="@uibot",Gt="uibot/templates",fe="uibot-base",_e="uibot-theme";function ye(e){return e.replace(/\./g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function Fe(e,t){let r=e.sourceCode;if(r=r.replace(/import\s+(type\s+)?(\{[^}]*\})\s+from\s+["']@uibot\/renderer-react["'];?/g,(o,s,c)=>`import ${s??"type "}${c} from "${t.rendererShimImport}";`),t.contractsShimImport){let o=t.contractsShimImport;r=r.replace(/import\s+(type\s+)?(\{[^}]*\})\s+from\s+["']@uibot\/contracts["'];?/g,(s,c,l)=>`import ${c??"type "}${l} from "${o}";`)}let i=new Set,n=new Set(["Children","Component","PureComponent","Fragment","StrictMode","Profiler","Suspense","Activity","ViewTransition"]);r=r.replace(/\bReact\.([A-Z]\w*)/g,(o,s)=>{if(n.has(s))return o;return i.add(s),s});let a=!1;if(r=r.replace(/(?:^|\n)function cn\([\s\S]*?\)\s*(?::[^\n{]+)?\{[\s\S]*?\n\}\n?/,()=>(a=!0,`
3
+ `)),a){let o=`import { cn } from "${t.cnUtilImport}";
4
4
  `,s=r.indexOf(`
5
- `,r.indexOf("import "));if(s>=0)r=`${r.slice(0,s+1)}${i}${r.slice(s+1)}`;else r=i+r}if(n.size>0){let i=[...n].sort().join(", "),s=/import\s+type\s+\{([^}]*)\}\s+from\s+["']react["'];?/;if(s.test(r))r=r.replace(s,(l,c)=>`import type { ${[...new Set([...c.split(",").map((u)=>u.trim()).filter(Boolean),...n])].sort().join(", ")} } from "react";`);else{let l=`import type { ${i} } from "react";
6
- `,c=r.indexOf(`
7
- `,r.indexOf("import "));if(c>=0)r=`${r.slice(0,c+1)}${l}${r.slice(c+1)}`;else r=l+r}}return`${r.replace(/\n{3,}/g,`
5
+ `,r.indexOf("import "));if(s>=0)r=`${r.slice(0,s+1)}${o}${r.slice(s+1)}`;else r=o+r}if(i.size>0){let o=[...i].sort().join(", "),s=/import\s+type\s+\{([^}]*)\}\s+from\s+["']react["'];?/;if(s.test(r))r=r.replace(s,(c,l)=>`import type { ${[...new Set([...l.split(",").map((f)=>f.trim()).filter(Boolean),...i])].sort().join(", ")} } from "react";`);else{let c=`import type { ${o} } from "react";
6
+ `,l=r.indexOf(`
7
+ `,r.indexOf("import "));if(l>=0)r=`${r.slice(0,l+1)}${c}${r.slice(l+1)}`;else r=c+r}}return`${r.replace(/\n{3,}/g,`
8
8
 
9
9
  `).trimStart().trimEnd()}
10
- `}function _t(e){let t={category:e.category,level:e.level};if(e.props)t.props=e.props;if(e.slots)t.slots=e.slots;if(e.events)t.events=e.events;if(e.usageScenarios)t.scenarios=e.usageScenarios;if(e.constraints)t.constraints=e.constraints;return t}function li(e){return{light:Se(e,":root"),dark:Se(e,".dark")}}function Se(e,t){let r={},n=new RegExp(`${Ae(t)}\\s*\\{`,"g"),o;while((o=n.exec(e))!==null){let i=o.index+o[0].length,s=1,l=i;for(;l<e.length&&s>0;l++){let d=e[l];if(d==="{")s++;else if(d==="}")s--}let c=e.slice(i,l-1);for(let d of c.matchAll(/--([\w-]+)\s*:\s*([^;]+);/g)){let u=d[1],f=d[2];if(u!==void 0&&f!==void 0)r[u]=f.trim()}}return r}function Ae(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function di(e,t){let r=t.sharedDependencies??vt,n=t.channel??"public",o=Lt(t),i=(t.componentsDir??Et).replace(/\/$/,""),s=(t.libDir??Dt).replace(/\/$/,""),l=`${s}/uibot-renderer.ts`,c=`${s}/utils.ts`,d=`${s}/uibot-contracts.ts`,u="@/lib/uibot-renderer",f="@/lib/utils",p="@/lib/uibot-contracts",a={},g={name:ie,type:"registry:lib",description:"UIBot runtime base: RendererComponent type shim + cn util. Pulled automatically by every UIBot block.",dependencies:r,files:[{path:l,content:t.rendererShimContent,type:"registry:lib"},{path:c,content:t.cnUtilContent,type:"registry:lib"},...t.contractsShimContent?[{path:d,content:t.contractsShimContent,type:"registry:lib"}]:[]],meta:{base:!0}};if(a[ie]=g,t.cssVars)a[ke]={name:ke,type:"registry:theme",description:"UIBot OKLCH palette for the semantic tokens the blocks use. Optional: skip it when the host defines its own.",files:[],cssVars:t.cssVars};let y=new Map,h=new Map,S=new Map,M=new Map;for(let m of e){let A=m.files[0]?.path??`${se(m.name)}.tsx`,x=m.channel??"public",C=M.get(A);if(C&&C!==x)throw Error(`${A} mixes ${C} and ${x} blocks; split the file`);M.set(A,x)}for(let m of e){if((m.channel??"public")!==n)continue;let x=m.files[0]?.path??`${se(m.name)}.tsx`,C=y.get(x);if(!C){let R=se(Vt(x,m.name)),Y=Pe(m,{rendererShimImport:"@/lib/uibot-renderer",cnUtilImport:"@/lib/utils",...t.contractsShimContent?{contractsShimImport:"@/lib/uibot-contracts"}:{}}),O=`${i}/${R}.tsx`,j={schema:oe,item:R,channel:n,components:[]};S.set(R,j),C={name:R,type:"registry:ui",description:m.description??m.catalogEntry.description,dependencies:["react",...m.dependencies??[]],registryDependencies:[o(ie)],files:m.files.length<=1?[{path:O,target:O,content:Y,type:"registry:ui"}]:m.files.map((G)=>{if(typeof G.content!=="string")throw Error(`Missing block source content: ${G.path}`);let fe=`${i}/${G.path.replace(/^blocks\//,"")}`;return{path:fe,target:fe,content:Pe({...m,sourceCode:G.content},{rendererShimImport:"@/lib/uibot-renderer",cnUtilImport:"@/lib/utils",...t.contractsShimContent?{contractsShimImport:"@/lib/uibot-contracts"}:{}}),type:"registry:ui"}}),meta:{..._t(m.catalogEntry),provides:[m.name],uibot:j}},y.set(x,C),a[R]=C}else{let R=C.meta;if(R.provides&&!R.provides.includes(m.name))R.provides.push(m.name)}let w=S.get(C.name);if(w?.components&&!h.has(m.name))w.components.push(Bt(m,C,i)),h.set(m.name,C.name)}for(let[m,A]of S){let x=a[m];if(!x)continue;A.components?.sort((w,R)=>w.name.localeCompare(R.name));let C=`${i}/${m}.uibot.json`;x.files.push({path:C,target:C,content:`${JSON.stringify(A,null,2)}
11
- `,type:"registry:ui"})}let T={},te=(t.templates??[]).filter((m)=>(m.channel??"public")===n),Je=new Set(te.map((m)=>m.name));for(let m of te){if(a[m.name])throw Error(`template item "${m.name}" collides with a component item`);let A=m.templateContract.composedFrom??[],x=new Set,C=[];for(let O of A){let j=h.get(O);if(j)x.add(o(j));else if(Je.has(O)&&O!==m.name)x.add(o(O));else C.push(O)}if(C.length>0)T[m.name]=C;let w=`${s}/${Ot}`,R=`${m.name}.uibot.yaml`,Y={schema:oe,item:m.name,channel:n,template:{file:R,contract:m.templateContract}};a[m.name]={name:m.name,type:"registry:block",description:m.description,registryDependencies:[...x].sort(),files:[{path:`${w}/${R}`,target:`${w}/${R}`,content:m.yaml,type:"registry:lib"},{path:`${w}/${m.name}.uibot.json`,target:`${w}/${m.name}.uibot.json`,content:`${JSON.stringify(Y,null,2)}
12
- `,type:"registry:lib"}],meta:{uibot:Y}}}return Mt(a,t.composites??[],{channel:n,ref:o,componentsDir:i}),{registry:{$schema:At,name:t.registryName,...t.homepage?{homepage:t.homepage}:{},items:Object.values(a).map((m)=>({name:m.name,type:m.type,...m.description?{description:m.description}:{},...m.registryDependencies?{registryDependencies:m.registryDependencies}:{},...m.dependencies?{dependencies:m.dependencies}:{}}))},items:a,unresolvedTemplateTypes:T}}function Mt(e,t,r){let n=new Map;for(let o of t){if(n.has(o.name)||e[o.name])throw Error(`composite item "${o.name}" collides with another item`);n.set(o.name,o)}for(let o of t){let i=o.channel??"public",s=Ie(o),l=new Set(o.files.map((d)=>d.path));for(let d of o.requires??[]){let u=n.get(d);if(!u)throw Error(`composite "${o.name}" requires unknown "${d}"`);if((u.channel??"public")!==i)throw Error(`composite "${o.name}" (${i}) requires "${d}" from another channel`);if(Ie(u)!==s)throw Error(`composite "${o.name}" requires "${d}" from another directory`);for(let f of u.files)l.add(f.path)}for(let d of o.files){if(!we.test(d.path))throw Error(`composite "${o.name}" file "${d.path}" must be a plain relative path`);for(let u of Ft(d.content)){if(!u.startsWith("./")||u.includes("/../"))throw Error(`${o.name}/${d.path} imports ${u}; only ./ imports within the item directory are allowed`);let f=u.slice(2).replace(/\.js$/,"");if(![f,`${f}.ts`,`${f}.tsx`,`${f}/index.ts`,`${f}/index.tsx`].some((a)=>l.has(a)))throw Error(`${o.name}/${d.path} imports ${u}, which no required item ships`)}}if(i!==r.channel)continue;let c=o.files.map((d)=>{let u=`${r.componentsDir}/${s}/${d.path}`;return{path:u,target:u,content:d.content,type:d.path.endsWith(".tsx")?"registry:component":"registry:lib"}});e[o.name]={name:o.name,type:o.type,description:o.description,dependencies:["react",...o.dependencies??[]],registryDependencies:[...o.primitives??[],...(o.requires??[]).map(r.ref)],files:c,meta:{composite:!0,channel:i}}}}var we=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/i;function Ie(e){if(!we.test(e.dir)||e.dir.split("/").includes(".."))throw Error(`composite "${e.name}" dir "${e.dir}" must be a plain relative path`);return e.dir}function Ft(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),r=[],n=[/\bfrom\s*["'](\.{1,2}\/[^"']+)["']/g,/\bimport\s*["'](\.{1,2}\/[^"']+)["']/g,/\bimport\s*\(\s*["'](\.{1,2}\/[^"']+)["']\s*\)/g];for(let o of n)for(let i of t.matchAll(o))r.push(i[1]??"");return r}function Lt(e){if(e.baseUrl){let r=e.baseUrl.replace(/\/$/,"");return(n)=>`${r}/r/${n}.json`}let t=e.namespace??Tt;if(!/^@[a-z0-9][a-z0-9-]*$/.test(t))throw Error(`registry namespace must look like "@uibot", got "${t}"`);return(r)=>`${t}/${r}`}function Bt(e,t,r){let n=e.name.replace(/\./g,""),o=`${r}/`,i=t.files.find((s)=>s.path.startsWith(o)&&/\.(tsx|ts)$/.test(s.path)&&Nt(s.content,n));if(!i)throw Error(`block "${e.name}" has no named export "${n}" in item "${t.name}"`);return{name:e.name,export:n,module:i.path.slice(o.length),catalog:e.catalogEntry}}function Nt(e,t){let r=Ae(t),n=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"");if(new RegExp(`export\\s+(?:const|let|function|class)\\s+${r}\\b`).test(n))return!0;for(let o of n.matchAll(/export\s*\{([^}]*)\}/g)){let i=(o[1]??"").split(",").map((l)=>{let[,c]=l.trim().split(/\s+as\s+/);return(c??l.trim().replace(/^type\s+/,"")).trim()}),s=(o[1]??"").split(",").map((l)=>l.trim()).filter((l)=>l.startsWith("type ")).map((l)=>l.replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim());if(i.includes(t)&&!s.includes(t))return!0}return!1}function Vt(e,t){return(e.split("/").pop()??t).replace(/\.(tsx|ts|jsx|js)$/,"")||t}var ui=wt;function Ut(e="/api/registry"){let t=(e||"/api/registry").trim(),r=t.startsWith("/")?t:`/${t}`;return r.length>1?r.replace(/\/$/,""):r}function z(e,t=200){return Response.json(e,{status:t})}function gi(e){let t=Ut(e.basePath),r=`${t}/registry.json`,n=`${t}/artifacts/`,o=new Map(e.manifest.items.map((i)=>[i.name,i]));return async function(s){let l=new URL(s.url);if(s.method!=="GET")return z({error:"Method not allowed"},405);if(l.pathname===r)return z(e.manifest);if(l.pathname.startsWith(n)){let c=l.pathname.slice(n.length),d=decodeURIComponent(c.endsWith(".json")?c.slice(0,-5):c),u=o.get(d);if(!u)return z({error:`Artifact '${d}' not found`},404);return z(u)}return z({error:"Not found"},404)}}var ae="uibot.resource.admission.v1",jt=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure"],$t=["packed-install","typecheck","browser"],yi=["invalid-admission-manifest","invalid-admission-record","invalid-admission-check","duplicate-admission-record","unknown-admission-resource","missing-source-metadata","missing-license-metadata","dependency-closure-failed"];class ve extends Error{expected;actual;code="resource-admission-index-mismatch";constructor(e,t){super(`resource admission index mismatch: expected ${e}, received ${t}`);this.expected=e;this.actual=t;this.name="ResourceAdmissionIndexMismatchError"}}class Ee extends Error{issueCount;code="resource-admission-report-rejected";constructor(e){super(`resource admission report contains ${e.toString()} issue(s)`);this.issueCount=e;this.name="ResourceAdmissionReportRejectedError"}}class De extends Error{code="resource-admission-report-not-derived";constructor(){super("resource admission report must come directly from assessResourceAdmissions");this.name="ResourceAdmissionReportNotDerivedError"}}var qt=new Set(q),zt=new Set(J),Te=new WeakSet,Z={missing:0,declared:1,verified:2,"external-consumer":3};function Ht(e,t){return e<t?-1:e>t?1:0}function N(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function X(e,t){let r=new Set(t);return Object.keys(e).every((n)=>r.has(n))}function Oe(e){return[...new Set(e.map((t)=>t.trim()).filter(Boolean))].sort(Ht)}function Wt(e,t,r,n){if(!N(r)||!X(r,["status","evidence"])){n.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} must contain only status and evidence`});return}if(typeof r.status!=="string"||!zt.has(r.status)||r.status==="missing"){n.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} status must be declared, verified or external-consumer`});return}if(!Array.isArray(r.evidence)||r.evidence.length===0||r.evidence.some((o)=>typeof o!=="string"||!o.trim())){n.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} evidence must be a non-empty string array`});return}return{status:r.status,evidence:Oe(r.evidence)}}function Kt(e){if(e===void 0)return;if(!N(e)||!X(e,["source","version","license"]))return;if(Object.values(e).some((r)=>r!==void 0&&typeof r!=="string"))return;return{...typeof e.source==="string"&&e.source.trim()?{source:e.source.trim()}:{},...typeof e.version==="string"&&e.version.trim()?{version:e.version.trim()}:{},...typeof e.license==="string"&&e.license.trim()?{license:e.license.trim()}:{}}}function Yt(e,t){let r=new Map,n=[];if(!N(t)||!X(t,["schemaVersion","records"])||t.schemaVersion!==ae||!Array.isArray(t.records))return n.push({code:"invalid-admission-manifest",detail:`expected ${ae} with a records array`}),{records:r,issues:n};let o=new Set(e.resources.map((i)=>i.id));for(let i of t.records){if(!N(i)||!X(i,["resourceId","provenance","checks"])||typeof i.resourceId!=="string"||!i.resourceId.trim()||!N(i.checks)){n.push({code:"invalid-admission-record",...N(i)&&typeof i.resourceId==="string"?{resourceId:i.resourceId}:{},detail:"record must contain only resourceId, optional provenance and checks"});continue}let s=i.resourceId.trim();if(r.has(s)){n.push({code:"duplicate-admission-record",resourceId:s,detail:s});continue}if(!o.has(s)){n.push({code:"unknown-admission-resource",resourceId:s,detail:s});continue}let l=Kt(i.provenance);if(i.provenance!==void 0&&!l){n.push({code:"invalid-admission-record",resourceId:s,detail:"provenance must contain only string source, version and license fields"});continue}let c={},d=!1;for(let[u,f]of Object.entries(i.checks)){if(!qt.has(u)){n.push({code:"invalid-admission-check",resourceId:s,detail:`unknown receipt check: ${u}`}),d=!0;continue}let p=u,a=Wt(s,p,f,n);if(a)c[p]=a;else d=!0}if(d)continue;r.set(s,{resourceId:s,...l?{provenance:l}:{},checks:c})}return{records:r,issues:n}}function Gt(e){let t=new Map(e.resources.map((o)=>[o.id,o])),r=new Map;function n(o,i,s,l){if(r.has(o)||l.has(i))return;if(s.has(i)){r.set(o,`dependency cycle reached ${i}`);return}let c=t.get(i);if(!c){r.set(o,`missing dependency ${i}`);return}s.add(i);for(let d of c.dependencies)if(n(o,d,s,l),r.has(o))break;s.delete(i),l.add(i)}for(let o of e.resources)n(o.id,o.id,new Set,new Set);return r}var Qt=/^(unknown|unlicensed|none|n\/?a)$/i,Jt=/^SPDX-License-Identifier:\s*(\S+)/im,Zt=/^(?:the\s+)?(mit|apache(?:\s+license(?:\s*,?\s*version\s*2\.0)?)?|bsd-2-clause|bsd-3-clause|isc|unlicense)\b/i;function F(e){let t=e?.trim();if(!t||Qt.test(t))return;return t}function Xt(e){if(!e?.trim())return;let t=e.match(Jt)?.[1];if(t)return F(t);let r=e.match(Zt)?.[1];if(!r)return;let n=r.toLowerCase();if(n.startsWith("mit"))return"MIT";if(n.startsWith("apache"))return"Apache-2.0";if(n.startsWith("bsd-2"))return"BSD-2-Clause";if(n.startsWith("bsd-3"))return"BSD-3-Clause";if(n==="isc")return"ISC";if(n==="unlicense")return"Unlicense";return}function hi(e){return F(e.frontmatterLicense)??F(e.packageJsonLicense)??Xt(e.licenseFileText)}function _e(e){return Boolean(F(e))}var H={states:/\b(disabled|loading|error|empty|pending|busy|children|active|muted|boolean-state)\b/i,accessibility:/\b(label|aria|accessible|alt|role)\b/i,"light-theme":/:root\b|\b(light(?:-theme)?|theme token|css variables?)\b/i,"dark-theme":/\b(dark(?:-theme)?)\b/i,responsive:/\b(size|responsive|breakpoint|sm|md|lg|xl|full)\b/i};function ce(e,t){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let n of e)ce(n,t);return}let r=e;for(let[n,o]of Object.entries(r)){if(t.push(n),n==="type"&&o==="boolean")t.push("boolean-state");ce(o,t)}}function er(e){let t=[];return ce(e.props,t),[e.name,e.description,...e.tags??[],...e.usageScenarios??[],...e.constraints??[],...t,...Object.keys(e.slots??{}),...Object.keys(e.events??{}),e.slots&&Object.keys(e.slots).length>0?"empty":""].join(`
13
- `)}function Ci(e,t={}){let r=[er(e),t.sourceText??"",t.stylesText??""].join(`
14
- `);return{contract:Boolean(e.props&&Object.keys(e.props).length>0||e.events&&Object.keys(e.events).length>0||e.slots&&Object.keys(e.slots).length>0)?"verified":"declared",states:H.states.test(r)?"verified":"missing",accessibility:H.accessibility.test(r)?"verified":"missing","light-theme":H["light-theme"].test(r)?"verified":"missing","dark-theme":H["dark-theme"].test(r)?"verified":"missing",responsive:H.responsive.test(r)?"verified":"missing"}}function tr(e){return{source:"declared",license:_e(e.source.license)?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"}}function rr(e){if(!jt.every((n)=>Z[e[n]]>=Z.verified))return"experimental";return $t.every((n)=>e[n]==="external-consumer")?"recommended":"candidate"}function Me(e){let t=JSON.stringify({schemaVersion:e.schemaVersion,resources:e.resources.map((o)=>({id:o.id,kind:o.kind,title:o.title,description:o.description,...o.category?{category:o.category}:{},tags:o.tags,aliases:o.aliases,capabilities:o.capabilities,dependencies:o.dependencies,source:o.source})),aliases:e.aliases}),r=0xcbf29ce484222325n,n=0x100000001b3n;for(let o of new TextEncoder().encode(t))r^=BigInt(o),r=BigInt.asUintN(64,r*n);return`fnv1a64:${r.toString(16).padStart(16,"0")}`}function nr(e,t,r){let n=tr(e),o=[`resource://${e.source.type}/${e.source.id}`,`resource://contract/${e.id}`],i=[];if(r)i.push({code:"dependency-closure-failed",resourceId:e.id,check:"dependency-closure",detail:r});else n["dependency-closure"]="verified",o.push(`resource://index/${e.id}`);if(t)for(let c of q){if(c==="dependency-closure")continue;let d=t.checks[c];if(!d)continue;if(c==="source"&&Z[d.status]>=Z.verified&&(!t.provenance?.source||!t.provenance.version)){i.push({code:"missing-source-metadata",resourceId:e.id,check:c,detail:"verified source requires provenance.source and provenance.version"});continue}if(c==="license"&&!_e(t.provenance?.license)){i.push({code:"missing-license-metadata",resourceId:e.id,check:c,detail:"license evidence requires a concrete provenance.license"});continue}if(n[c]=d.status,o.push(...d.evidence),c==="source"&&t.provenance?.source)o.push(t.provenance.source)}let s=rr(n),l={level:s==="recommended"?"external-consumer":s==="candidate"?"verified":"declared",maturity:s,checks:n,evidence:Oe(o)};return Object.freeze(l.checks),Object.freeze(l.evidence),Object.freeze(l),Object.freeze(i),Object.freeze({resourceId:e.id,receipt:l,issues:i})}function bi(e,t){let r=Yt(e,t),n=Gt(e),o=e.resources.map((c)=>nr(c,r.records.get(c.id),n.get(c.id))),i=[...r.issues,...o.flatMap((c)=>c.issues)],s=Object.fromEntries(Q.map((c)=>[c,0]));for(let c of o)s[c.receipt.maturity]+=1;Object.freeze(o),Object.freeze(s);for(let c of i)Object.freeze(c);Object.freeze(i);let l=Object.freeze({schemaVersion:ae,indexFingerprint:Me(e),resources:o,counts:s,issues:i});return Te.add(l),l}function Ri(e,t){if(!Te.has(t))throw new De;if(t.issues.length>0)throw new Ee(t.issues.length);let r=Me(e);if(r!==t.indexFingerprint)throw new ve(t.indexFingerprint,r);let n=new Map(t.resources.map((i)=>[i.resourceId,i.receipt])),o=e.resources.map((i)=>{let s=n.get(i.id);if(!s)return i;return Object.freeze({...i,receipt:s})});return Object.freeze(o),Object.freeze({schemaVersion:e.schemaVersion,resources:o,aliases:e.aliases})}var or="uibot.resource.index.v1",Pi=["invalid-resource-source-id","duplicate-resource-id","dangling-resource-dependency","ambiguous-resource-dependency"];class U extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceIndexError"}}function k(e,t){return e<t?-1:e>t?1:0}function b(e){return e.normalize("NFKC").replace(/([\p{Lu}]+)([\p{Lu}][\p{Ll}])/gu,"$1 $2").replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim().replace(/\s+/g," ")}function ir(e){let t=b(e).replace(/ /g,"-");if(!t)throw new U("invalid-resource-source-id",e);return t}function v(e,t){return`${e}:${ir(t)}`}function ee(e){let t=new Map;for(let r of e){let n=r?.trim();if(!n)continue;let o=b(n);if(!o||t.has(o))continue;t.set(o,n)}return[...t.entries()].sort(([r],[n])=>k(r,n)).map(([,r])=>r)}function W(e){return{level:"declared",maturity:"experimental",checks:{source:"declared",license:e?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"},evidence:[]}}function sr(e){let t=F(e.license);return{type:e.type,id:e.id,...e.version?{version:e.version}:{},...e.url?{url:e.url}:{},...t?{license:t}:{}}}function V(e){return{id:e.id,kind:e.kind,title:e.title,description:e.description,...e.category?{category:e.category}:{},tags:ee(e.tags),aliases:ee(e.aliases),capabilities:ee(e.capabilities),dependencies:[...new Set(e.dependencies)].sort(k),source:sr(e.source),receipt:e.receipt}}function ar(e){return(e.body.split(/\r?\n/).map((r)=>r.replace(/^#+\s*/,"").trim()).find(Boolean)??e.title).slice(0,240)}function cr(e){return Object.freeze(e.tags),Object.freeze(e.aliases),Object.freeze(e.capabilities),Object.freeze(e.dependencies),Object.freeze(e.source),Object.freeze(e.receipt.checks),Object.freeze(e.receipt.evidence),Object.freeze(e.receipt),Object.freeze(e)}function lr(e){let t=new Map;for(let r of Object.keys(e).sort(k)){let n=e[r];if(!n)continue;let o=v("component",r);for(let i of ee([r,n.name])){let s=b(i),l=t.get(s)??[];if(!l.includes(o))l.push(o);t.set(s,l.sort(k))}}return t}function dr(e,t,r){let n=r.get(b(e))??[];if(n.length===0)throw new U("dangling-resource-dependency",`${t} -> ${v("component",e)}`);if(n.length>1)throw new U("ambiguous-resource-dependency",`${t} -> ${e}: ${n.join(",")}`);return n[0]}function ur(e,t,r,n){let o=e.startsWith("template:")?e.slice(9):e;if(Object.hasOwn(n,o))return v("template",o);return dr(e,t,r)}function K(e,t,r){return F(r?.[e]??t)}function Si(e){return Object.entries(e).filter(([,t])=>t.level==="L4").sort(([t],[r])=>k(t,r)).map(([t,r])=>({id:`${t}-example`,title:`${r.name} Example`,description:r.description,category:r.category,tags:r.keywords,aliases:[`${t} example`,`${r.name} example`],capabilities:["example:template"],dependencies:[v("template",t)]}))}function Ii(e){let t=e.components??{},r=e.templates??{},n=e.designGuides??[],o=e.examples??[],i=e.skills??[],s=e.licenses,l=lr(t),c=[];for(let a of Object.keys(t).sort(k)){let g=t[a];if(!g)continue;let y=v("component",a),h=K(y,void 0,s);c.push(V({id:y,kind:"component",title:g.name,description:g.description,category:g.category,tags:g.tags??[],aliases:[a,g.name],capabilities:["catalog:component"],dependencies:[],source:{type:"catalog",id:a,...h?{license:h}:{}},receipt:W(Boolean(h))}))}for(let a of Object.keys(r).sort(k)){let g=r[a];if(!g)continue;let y=v("template",a),h=K(y,void 0,s);c.push(V({id:y,kind:"template",title:g.name,description:g.description,category:g.category,tags:g.keywords,aliases:[a,g.name],capabilities:[],dependencies:(g.composedFrom??[]).map((S)=>ur(S,y,l,r)),source:{type:"template-contract",id:a,...h?{license:h}:{}},receipt:W(Boolean(h))}))}for(let a of[...n].sort((g,y)=>k(g.id,y.id))){let g=v("design-guide",a.id),y=K(g,void 0,s);c.push(V({id:g,kind:"design-guide",title:a.title,description:ar(a),category:a.category,tags:a.tags,aliases:[a.id,a.title],capabilities:["designMd:source"],dependencies:[],source:{type:"design-md",id:a.id,...a.sourceUrl?{url:a.sourceUrl}:{},...y?{license:y}:{}},receipt:W(Boolean(y))}))}for(let a of[...o].sort((g,y)=>k(g.id,y.id))){let g=v("example",a.id),y=K(g,a.license,s);c.push(V({id:g,kind:"example",title:a.title,description:a.description,...a.category?{category:a.category}:{},tags:a.tags??[],aliases:[a.id,a.title,...a.aliases??[]],capabilities:a.capabilities??[],dependencies:a.dependencies??[],source:{type:"example",id:a.id,...a.version?{version:a.version}:{},...a.sourceUrl?{url:a.sourceUrl}:{},...y?{license:y}:{}},receipt:W(Boolean(y))}))}for(let a of[...i].sort((g,y)=>k(g.id,y.id))){let g=v("skill",a.id),y=K(g,void 0,s);c.push(V({id:g,kind:"skill",title:a.title,description:a.description?.trim()||a.title,tags:[...a.tags??[],...a.triggers??[]],aliases:[a.id,a.title,...a.triggers??[]],capabilities:["skill:definition"],dependencies:[],source:{type:"skill",id:a.id,...a.version?{version:a.version}:{},...y?{license:y}:{}},receipt:W(Boolean(y))}))}for(let a of e.additional??[])c.push(V(a));c.sort((a,g)=>k(a.id,g.id));let d=new Set;for(let a of c){if(d.has(a.id))throw new U("duplicate-resource-id",a.id);d.add(a.id)}for(let a of c)for(let g of a.dependencies)if(!d.has(g))throw new U("dangling-resource-dependency",`${a.id} -> ${g}`);let u=new Map;for(let a of c)for(let g of a.aliases){let y=b(g);if(!y)continue;let h=u.get(y)??new Set;h.add(a.id),u.set(y,h)}let f=Object.freeze(Object.fromEntries([...u.entries()].sort(([a],[g])=>k(a,g)).map(([a,g])=>[a,Object.freeze([...g].sort(k))]))),p=Object.freeze(c.map(cr));return Object.freeze({schemaVersion:or,resources:p,aliases:f})}var pr=[["data table","data grid","datatable","table","\u8868\u683C","\u6570\u636E\u8868","\u6570\u636E\u8868\u683C"],["button","action button","\u6309\u94AE","\u64CD\u4F5C\u6309\u94AE"],["dashboard","admin dashboard","\u4EEA\u8868\u76D8","\u540E\u53F0","\u7BA1\u7406\u540E\u53F0"],["kanban","kanban board","\u770B\u677F","\u4EFB\u52A1\u770B\u677F"],["form","input form","\u8868\u5355","\u8F93\u5165\u8868\u5355"],["navigation","nav","sidebar","\u5BFC\u822A","\u4FA7\u8FB9\u680F"]],gr=Object.freeze(pr.map((e)=>Object.freeze([...e]))),Fe=new Map;for(let e of gr){let t=Object.freeze([...new Set(e.map(b).filter(Boolean))].sort());for(let r of t)Fe.set(r,t)}function le(e){let t=b(e);return Fe.get(t)??Object.freeze([t])}var Ti=["resource-query-empty","resource-query-invalid-limit","resource-not-found","resource-alias-ambiguous"];class I extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceQueryError"}}var ge=Object.freeze({"exact-id":1000,"exact-title":900,alias:800,tag:600,capability:500,category:400,token:200,fuzzy:100}),mr=Object.freeze(Object.keys(ge)),Le=new Map(mr.map((e,t)=>[e,t])),Be=new Map([["component",0],["template",1],["design-guide",2],["example",3],["skill",4]]);function P(e,t){return e<t?-1:e>t?1:0}function Ne(e){return new Set((e??[]).map(b).filter(Boolean))}function de(e,t){let r=Ne(t);if(r.size===0)return!0;let n=Ne(e);return[...r].some((o)=>n.has(o))}function fr(e,t){if(t.kinds?.length&&!t.kinds.includes(e.kind))return!1;if(!de(e.tags,t.tags))return!1;if(!de(e.category?[e.category]:[],t.categories))return!1;if(!de(e.capabilities,t.capabilities))return!1;if(t.maturities?.length&&!t.maturities.includes(e.receipt.maturity))return!1;return!0}function yr(e){return Boolean(e.kinds?.length||e.tags?.length||e.categories?.length||e.capabilities?.length||e.maturities?.length)}function E(e,t,r,n=ge[t]){if(e.some((o)=>o.code===t&&o.value===r))return;e.push({code:t,value:r,score:n})}function ue(e,t){return e.find((r)=>b(r)===t)}function pe(e){return[e.id,e.title,...e.aliases,...e.tags,...e.category?[e.category]:[],...e.capabilities]}function hr(e,t,r){if(Math.abs(e.length-t.length)>r)return r+1;let n=Array.from({length:t.length+1},(o,i)=>i);for(let o=1;o<=e.length;o+=1){let i=[o],s=o;for(let l=1;l<=t.length;l+=1){let c=(n[l-1]??r+1)+(e[o-1]===t[l-1]?0:1),d=Math.min((n[l]??r+1)+1,(i[l-1]??r+1)+1,c);i.push(d),s=Math.min(s,d)}if(s>r)return r+1;n=i}return n[t.length]??r+1}function Cr(e,t){let r=b(t),n=[];if(b(e.id)===r)E(n,"exact-id",e.id);if(b(e.title)===r)E(n,"exact-title",e.title);let o=ue(e.aliases,r);if(o)E(n,"alias",o);let i=ue(e.tags,r);if(i)E(n,"tag",i);let s=ue(e.capabilities,r);if(s)E(n,"capability",s);if(e.category&&b(e.category)===r)E(n,"category",e.category);if(!o){let d=le(r).filter((f)=>f!==r),u=new Set(pe(e).map(b));if(d.some((f)=>u.has(f)))E(n,"alias",t.trim())}let l=r.split(" ").filter(Boolean),c=b(pe(e).join(" "));if(l.length>0&&l.every((d)=>c.includes(d)))E(n,"token",t.trim());if(n.length===0&&r.length>=4){let d;for(let u of pe(e)){let f=b(u);if(f.length<4)continue;let p=hr(r,f,2);if(p<=2&&(!d||p<d.distance||p===d.distance&&P(u,d.value)<0))d={value:u,distance:p}}if(d)E(n,"fuzzy",d.value,ge.fuzzy-d.distance)}return n.sort((d,u)=>{if(d.score!==u.score)return u.score-d.score;return(Le.get(d.code)??99)-(Le.get(u.code)??99)||P(d.value,u.value)})}function Ve(e,t,r){if(t.has(r))return[r];let n=b(r),o=e.aliases[n];if(o?.length)return[...o];let i=new Set;for(let s of le(n))for(let l of e.aliases[s]??[])i.add(l);return[...i].sort(P)}function Ue(e,t){return new I("resource-alias-ambiguous",`${e.trim()}: ${t.join(",")}`)}function je(e){let t=new Map(e.resources.map((n)=>[n.id,n]));function r(n){let o=n.trim(),i=Ve(e,t,o);if(i.length===0)throw new I("resource-not-found",o);if(i.length>1)throw Ue(o,i);let s=i[0],l=s?t.get(s):void 0;if(!l)throw new I("resource-not-found",o);return l}return Object.freeze({manifest:()=>e,search(n){let o=n.text?.trim()??"";if(!o&&!yr(n))throw new I("resource-query-empty","text or filter is required");if(n.limit!==void 0&&(!Number.isInteger(n.limit)||n.limit<=0))throw new I("resource-query-invalid-limit",String(n.limit));let i=e.resources.filter((s)=>fr(s,n)).map((s)=>{let l=o?Cr(s,o):[];return{resource:s,score:l.reduce((c,d)=>c+d.score,0),reasons:l}}).filter((s)=>!o||s.reasons.length>0).sort((s,l)=>l.score-s.score||P(s.resource.id,l.resource.id));return n.limit===void 0?i:i.slice(0,n.limit)},get:r,build(n){if(n.length===0||n.every((p)=>!p.trim()))throw new I("resource-query-empty","at least one build root is required");let o=[],i=new Set;for(let p of n){let a=p.trim(),g=Ve(e,t,a);if(g.length===0)o.push({id:a,reason:"missing-resource"});else if(g.length>1)throw Ue(a,g);else{let y=g[0];if(y)i.add(y)}}let s=new Set,l=new Set,c=new Set,d=[],u=[],f=(p,a)=>{if(s.has(p))return;if(l.has(p)){o.push({id:p,...a?{requiredBy:a}:{},reason:"dependency-cycle"});return}let g=t.get(p);if(!g){o.push({id:p,...a?{requiredBy:a}:{},reason:"missing-resource"});return}l.add(p),c.add(p);let y=[...g.dependencies].sort((h,S)=>{let M=t.get(h),T=t.get(S);return(Be.get(M?.kind??"")??99)-(Be.get(T?.kind??"")??99)||P(h,S)});for(let h of y)u.push({from:p,to:h,relation:"depends-on"}),f(h,p);l.delete(p),s.add(p),d.push(p)};for(let p of[...i].sort(P))f(p);return{roots:[...i].sort(P),nodes:[...c].sort(P).map((p)=>{let a=t.get(p);if(!a)throw new I("resource-not-found",p);return{id:p,kind:a.kind,maturity:a.receipt.maturity}}),edges:u.sort((p,a)=>P(p.from,a.from)||P(p.to,a.to)),order:d,gaps:o.sort((p,a)=>P(p.id,a.id)||P(p.requiredBy??"",a.requiredBy??"")||P(p.reason,a.reason))}}})}function br(e){if(!e||typeof e!=="object")throw Error("invalid-public-resource-bundle");kr(e);let t=e;if(t.schemaVersion!=="uibot.public-resources.v1"||typeof t.release?.version!=="string"||!/^[a-f0-9]{64}$/.test(t.release?.sourceHash)||t.index?.schemaVersion!=="uibot.resource.index.v1"||!Array.isArray(t.index.resources)||!t.index.aliases||!t.showcases)throw Error("invalid-public-resource-bundle");if(t.documents&&(!Array.isArray(t.documents)||t.documents.some((n)=>typeof n.title!=="string"||typeof n.markdown!=="string"||!/^\/(?:en\/)?docs\/[a-z0-9-]+$/.test(n.path))))throw Error("invalid-public-documentation");let r=new Set;for(let n of t.index.resources){if(!n||typeof n.id!=="string"||r.has(n.id)||!Re.includes(n.kind)||!n.id.startsWith(`${n.kind}:`)||typeof n.description!=="string"||typeof n.title!=="string"||!Array.isArray(n.dependencies)||!n.source||!n.receipt||!Array.isArray(n.aliases)||!Array.isArray(n.tags)||!Array.isArray(n.capabilities)||![n.aliases,n.dependencies,n.tags,n.capabilities].every((i)=>i.every((s)=>typeof s==="string"&&s.length<=1000))||!["catalog","template-contract","design-md","example","skill","registry","package","theme"].includes(n.source.type)||typeof n.source.id!=="string"||!Q.includes(n.receipt.maturity)||!xe.includes(n.receipt.level)||!Array.isArray(n.receipt.evidence)||!n.receipt.evidence.every((i)=>typeof i==="string")||!q.every((i)=>J.includes(n.receipt.checks?.[i])))throw Error("invalid-public-resource");r.add(n.id);let o=t.showcases[n.id];if(!o||o.resourceId!==n.id||typeof o.docs?.zh!=="string"||typeof o.docs?.en!=="string"||!Array.isArray(o.examples)||!Array.isArray(o.distributions))throw Error("invalid-resource-showcase");if(typeof o.title?.zh!=="string"||typeof o.title?.en!=="string"||o.examples.some((i)=>!i||typeof i.id!=="string"||typeof i.title!=="string"||typeof i.code!=="string"||!["spec","tsx","source"].includes(i.mode)||!["tsx","json","yaml","css","ts"].includes(i.language)||!Array.isArray(i.dependencies)||!i.dependencies.every((s)=>typeof s==="string"))||o.distributions.some((i)=>!i||!["spec","npm","shadcn"].includes(i.channel)||typeof i.name!=="string"||!/^[@a-zA-Z0-9._/-]+$/.test(i.name)||typeof i.version!=="string"||!["source","published"].includes(i.availability)))throw Error("invalid-resource-content")}for(let[n,o]of Object.entries(t.index.aliases))if(!n||!Array.isArray(o)||o.some((i)=>!r.has(i)))throw Error("invalid-public-resource-alias");if(Object.keys(t.showcases).some((n)=>!r.has(n)))throw Error("unexpected-public-resource-showcase");for(let n of t.index.resources)for(let o of n.dependencies)if(!r.has(o))throw Error("invalid-public-resource-dependency")}function Li(e){br(e),e=JSON.parse(JSON.stringify(e));let t=(o)=>{if(o&&typeof o==="object"){for(let i of Object.values(o))t(i);Object.freeze(o)}};t(e);let r=je(e.index),n=(o)=>{let i=r.get(o),s=e.showcases[i.id];if(!s)throw new I("resource-not-found",i.id);return s};return Object.freeze({...r,docs(o,i="zh",s=1){if(i!=="zh"&&i!=="en")throw Error("unsupported-resource-locale");let l=n(o);return{resourceId:l.resourceId,locale:i,...Rr(l.docs[i],s),release:e.release}},examples(o,i=1){let s=n(o);return{resourceId:s.resourceId,...xr(s.examples,i),release:e.release}},installPlan(o){let i=n(o);return{resourceId:i.resourceId,distributions:i.distributions,dependencies:r.build([i.resourceId]),release:e.release}}})}var _=24000;function $e(e,t){if(!Number.isSafeInteger(e)||e<1||e>Math.max(1,t))throw new I("resource-query-invalid-limit","page is outside the available range")}function Rr(e,t){let r=Math.max(1,Math.ceil(e.length/_));return $e(t,r),{markdown:e.slice((t-1)*_,t*_),page:t,totalPages:r,...t<r?{nextPage:t+1}:{}}}function xr(e,t){let r=e.flatMap((n)=>Array.from({length:Math.max(1,Math.ceil(n.code.length/_))},(o,i)=>({...n,code:n.code.slice(i*_,(i+1)*_),codeOffset:i*_,codeLength:n.code.length,complete:n.code.length<=_})));return $e(t,r.length),{examples:r.slice(t-1,t),page:t,totalPages:r.length,...t<r.length?{nextPage:t+1}:{}}}function kr(e){let t=0,r=0,n=new Set,o=(i,s)=>{if(++t>300000||s>64)throw Error("public-resource-budget-exceeded");if(typeof i==="string"){if(r+=new TextEncoder().encode(i).length,r>16777216)throw Error("public-resource-budget-exceeded")}else if(i&&typeof i==="object"){if(n.has(i))throw Error("invalid-public-resource-cycle");let l=Object.getPrototypeOf(i);if(!Array.isArray(i)&&l!==Object.prototype&&l!==null)throw Error("invalid-public-resource-object");n.add(i);for(let[c,d]of Object.entries(i))o(c,s+1),o(d,s+1);n.delete(i)}else if(i!==null&&typeof i!=="boolean"&&(typeof i!=="number"||!Number.isFinite(i)))throw Error("invalid-public-resource-json")};o(e,1)}function vr(e){if(!e.name)throw Error("Artifact registry manifest requires a name");return e}function Er(e){if(!e.name)throw Error("Plugin distribution manifest requires a name");return e}class Dr{id;priority;items;constructor(e,t,r){this.id=e;this.priority=t;this.items=r}get(e){return this.items[e]}}class Tr{id;priority;items;constructor(e,t,r){this.id=e;this.priority=t;this.items=r}get(e){return this.items[e]}}async function Ke(e,t){let r=await fetch(e,t?{headers:t}:{});if(!r.ok)throw Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);return await r.json()}async function Or(e,t){let r=e.endsWith("/registry.json")?e:`${e.replace(/\/$/,"")}/registry.json`,n=await Ke(r,t);return vr(n)}async function _r(e,t){let r=e.endsWith("/plugins.json")?e:`${e.replace(/\/$/,"")}/plugins.json`,n=await Ke(r,t);return Er(n)}class Mr{options;id;priority;manifestPromise;constructor(e){this.options=e;this.id=e.id??e.registryUrl,this.priority=e.priority}getManifest(){return this.manifestPromise??=Or(this.options.registryUrl,this.options.headers),this.manifestPromise}async get(e){return(await this.getManifest()).items.find((r)=>r.name===e)}}class Fr{options;id;priority;manifestPromise;constructor(e){this.options=e;this.id=e.id??e.registryUrl,this.priority=e.priority}getManifest(){return this.manifestPromise??=_r(this.options.registryUrl,this.options.headers),this.manifestPromise}async get(e){return(await this.getManifest()).plugins.find((r)=>r.pluginId===e)}}class Lr{sources;constructor(e){this.sources=e}async resolve(e){let t=[...this.sources].sort((r,n)=>r.priority-n.priority);for(let r of t){let n=await r.get(e);if(n)return n}return}}class Br{sources;constructor(e){this.sources=e}async resolve(e){let t=[...this.sources].sort((r,n)=>r.priority-n.priority);for(let r of t){let n=await r.get(e);if(n)return n}return}}var Nr="uibot.artifacts.lock.json";function Vr(e){return D(e,"components","registry")}function Ur(e){return D(e,"templates","registry")}function jr(e,t){if(e.kind==="component")return D(t.componentsDir??Vr(t.workspaceRoot));return D(t.templatesDir??Ur(t.workspaceRoot))}function $r(e){return D(e.workspaceRoot,e.lockfilePath??Nr)}function qr(e){try{return JSON.parse(Sr(e,"utf8"))}catch{return{version:1,artifacts:[]}}}function zr(e,t){He(me(e),{recursive:!0}),We(e,`${JSON.stringify(t,null,2)}
15
- `,"utf8")}function Hr(e,t){return{version:1,artifacts:[...e.artifacts.filter((n)=>n.name!==t.name),t].sort((n,o)=>n.name.localeCompare(o.name))}}function Wr(e){if(e.kind==="component")return{components:{[e.name]:e.catalogEntry}};return{templates:{[e.name]:e.templateContract}}}class L extends Error{artifactName;offendingPath;baseDir;constructor(e,t,r){super(`Artifact "${e}" file path escapes workspace: "${t}" resolves outside "${r}"`);this.artifactName=e;this.offendingPath=t;this.baseDir=r;this.name="ArtifactContainmentError"}}function Ye(e,t){let r=t.endsWith(qe)?t:t+qe;return e===t||e.startsWith(r)}function ze(e){let t=D(e),r=[];while(!0)try{return Pr(t),D(Ir(t),...r)}catch(n){if(n.code!=="ENOENT")throw n;let o=me(t);if(o===t)throw n;r.unshift(Ar(t)),t=o}}function Ge(e,t,r,n){try{let o=ze(t),i=ze(e);if(!Ye(i,o))throw new L(r,n,t)}catch(o){if(o instanceof L)throw o;throw new L(r,n,t)}}function Qe(e,t,r){if(e.includes("\x00"))throw new L(r,e,t);if(wr(e))throw new L(r,e,t);let n=D(t,e);if(!Ye(n,t))throw new L(r,e,t);return Ge(n,t,r,e),n}function Kr(e,t){let r=[];for(let n of e.files){let o=n.target??n.path;r.push(Qe(o,t,e.name))}return r}function Ui(e,t){let r=D(t.workspaceRoot),n=jr(e,t);Ge(n,r,e.name,n);let o=Qe(e.name,n,e.name),i=Kr(e,o),s=[];for(let f=0;f<e.files.length;f++){let p=e.files[f],a=i[f];He(me(a),{recursive:!0}),We(a,p.content??"","utf8"),s.push(a)}let l={name:e.name,version:e.version,source:t.source??"registry",installedAt:new Date().toISOString()},c=$r(t),d=qr(c),u=Hr(d,l);return zr(c,u),{artifactLock:l,catalogPatch:Wr(e),writtenFiles:s}}export{L as ArtifactContainmentError,Lr as ArtifactRegistryResolver,Dr as MemoryArtifactRegistrySource,Tr as MemoryPluginRegistrySource,Br as PluginRegistryResolver,yi as RESOURCE_ADMISSION_ERROR_CODES,ae as RESOURCE_ADMISSION_SCHEMA_VERSION,$t as RESOURCE_EXTERNAL_CHECKS,Pi as RESOURCE_INDEX_ERROR_CODES,or as RESOURCE_INDEX_SCHEMA_VERSION,jt as RESOURCE_PREFLIGHT_CHECKS,gr as RESOURCE_QUERY_ALIAS_GROUPS,Ti as RESOURCE_QUERY_ERROR_CODES,St as RESOURCE_QUERY_OPERATION_MANIFEST,ge as RESOURCE_QUERY_SCORE_WEIGHTS,Mr as RemoteArtifactRegistrySource,Fr as RemotePluginRegistrySource,ve as ResourceAdmissionIndexMismatchError,De as ResourceAdmissionReportNotDerivedError,Ee as ResourceAdmissionReportRejectedError,U as ResourceIndexError,I as ResourceQueryError,ui as SHADCN_REGISTRY_ITEM_SCHEMA,ie as UIBOT_BASE_ITEM,ke as UIBOT_THEME_ITEM,Ri as applyResourceAdmissionReport,Qe as assertPathContained,br as assertPublicResourceBundle,bi as assessResourceAdmissions,Si as buildExamplesFromL4Templates,Ii as buildResourceIndex,di as buildShadcnRegistry,on as buildUiBotRegistryManifest,_t as catalogEntryToMeta,Zr as collectAllBlockSources,at as collectBlockSources,he as collectTemplateSources,mt as collectTemplateSourcesFromDirs,Ze as compareLockToManifest,Li as createPublicResourceQueryService,je as createResourceQueryService,gi as createUIBotRegistryHttpHandler,hi as deriveResourceLicense,sn as emitArtifactJson,et as emptyLockfile,Ci as evaluateCatalogPreflight,le as expandResourceQueryAliases,Or as fetchArtifactRegistryManifest,_r as fetchPluginDistributionManifest,Ui as installArtifactToWorkspace,tt as lockfileWith,Ut as normalizeRegistryBasePath,b as normalizeResourceAlias,F as normalizeResourceLicense,li as parseOklchCssVars,Er as parsePluginDistributionManifest,vr as parseRegistryManifest,Me as resourceAdmissionIndexFingerprint,ne as templateSourceToRegistryItem,be as toArtifactRegistryItem,Rt as toComponentArtifact,se as toItemName,v as toResourceId,Ce as toTemplateArtifact,Pe as transformBlockSource};
10
+ `}function Yt(e){let t={category:e.category,level:e.level};if(e.props)t.props=e.props;if(e.slots)t.slots=e.slots;if(e.events)t.events=e.events;if(e.usageScenarios)t.scenarios=e.usageScenarios;if(e.constraints)t.constraints=e.constraints;return t}function ts(e){return{light:Me(e,":root"),dark:Me(e,".dark")}}function Me(e,t){let r={},i=new RegExp(`${Le(t)}\\s*\\{`,"g"),n;while((n=i.exec(e))!==null){let a=n.index+n[0].length,o=1,s=a;for(;s<e.length&&o>0;s++){let l=e[s];if(l==="{")o++;else if(l==="}")o--}let c=e.slice(a,s-1);for(let l of c.matchAll(/--([\w-]+)\s*:\s*([^;]+);/g)){let u=l[1],f=l[2];if(u!==void 0&&f!==void 0)r[u]=f.trim()}}return r}function Le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function rs(e,t){let r=t.sharedDependencies??qt,i=t.channel??"public",n=Zt(t),a=(t.componentsDir??Ht).replace(/\/$/,""),o=(t.libDir??Kt).replace(/\/$/,""),s=`${o}/uibot-renderer.ts`,c=`${o}/utils.ts`,l=`${o}/uibot-contracts.ts`,u="@/lib/uibot-renderer",f="@/lib/utils",p="@/lib/uibot-contracts",d={},m={name:fe,type:"registry:lib",description:"UIBot runtime base: RendererComponent type shim + cn util. Pulled automatically by every UIBot block.",dependencies:r,files:[{path:s,content:t.rendererShimContent,type:"registry:lib"},{path:c,content:t.cnUtilContent,type:"registry:lib"},...t.contractsShimContent?[{path:l,content:t.contractsShimContent,type:"registry:lib"}]:[]],meta:{base:!0}};if(d[fe]=m,t.cssVars)d[_e]={name:_e,type:"registry:theme",description:"UIBot OKLCH palette for the semantic tokens the blocks use. Optional: skip it when the host defines its own.",files:[],cssVars:t.cssVars};let y=new Map,h=new Map,A=new Map,N=new Map;for(let g of e){let v=g.files[0]?.path??`${ye(g.name)}.tsx`,x=g.channel??"public",b=N.get(v);if(b&&b!==x)throw Error(`${v} mixes ${b} and ${x} blocks; split the file`);N.set(v,x)}for(let g of e){if((g.channel??"public")!==i)continue;let x=g.files[0]?.path??`${ye(g.name)}.tsx`,b=y.get(x);if(!b){let R=ye(rr(x,g.name)),ee=Fe(g,{rendererShimImport:"@/lib/uibot-renderer",cnUtilImport:"@/lib/utils",...t.contractsShimContent?{contractsShimImport:"@/lib/uibot-contracts"}:{}}),F=`${a}/${R}.tsx`,W={schema:me,item:R,channel:i,components:[]};A.set(R,W),b={name:R,type:"registry:ui",description:g.description??g.catalogEntry.description,dependencies:["react",...g.dependencies??[]],registryDependencies:[n(fe)],files:g.files.length<=1?[{path:F,target:F,content:ee,type:"registry:ui"}]:g.files.map((G)=>{if(typeof G.content!=="string")throw Error(`Missing block source content: ${G.path}`);let Ae=`${a}/${G.path.replace(/^blocks\//,"")}`;return{path:Ae,target:Ae,content:Fe({...g,sourceCode:tr(G.path,G.content,g)},{rendererShimImport:"@/lib/uibot-renderer",cnUtilImport:"@/lib/utils",...t.contractsShimContent?{contractsShimImport:"@/lib/uibot-contracts"}:{}}),type:"registry:ui"}}),meta:{...Yt(g.catalogEntry),provides:[g.name],uibot:W}},y.set(x,b),d[R]=b}else{let R=b.meta;if(R.provides&&!R.provides.includes(g.name))R.provides.push(g.name)}let E=A.get(b.name);if(E?.components&&!h.has(g.name))E.components.push(Xt(g,b,a)),h.set(g.name,b.name)}for(let[g,v]of A){let x=d[g];if(!x)continue;v.components?.sort((E,R)=>E.name.localeCompare(R.name));let b=`${a}/${g}.uibot.json`;x.files.push({path:b,target:b,content:`${JSON.stringify(v,null,2)}
11
+ `,type:"registry:ui"})}let _={},ue=(t.templates??[]).filter((g)=>(g.channel??"public")===i),gt=new Set(ue.map((g)=>g.name));for(let g of ue){if(d[g.name])throw Error(`template item "${g.name}" collides with a component item`);let v=g.templateContract.composedFrom??[],x=new Set,b=[];for(let F of v){let W=h.get(F);if(W)x.add(n(W));else if(gt.has(F)&&F!==g.name)x.add(n(F));else b.push(F)}if(b.length>0)_[g.name]=b;let E=`${o}/${Gt}`,R=`${g.name}.uibot.yaml`,ee={schema:me,item:g.name,channel:i,template:{file:R,contract:g.templateContract}};d[g.name]={name:g.name,type:"registry:block",description:g.description,registryDependencies:[...x].sort(),files:[{path:`${E}/${R}`,target:`${E}/${R}`,content:g.yaml,type:"registry:lib"},{path:`${E}/${g.name}.uibot.json`,target:`${E}/${g.name}.uibot.json`,content:`${JSON.stringify(ee,null,2)}
12
+ `,type:"registry:lib"}],meta:{uibot:ee}}}return Jt(d,t.composites??[],{channel:i,ref:n,componentsDir:a}),{registry:{$schema:Ut,name:t.registryName,...t.homepage?{homepage:t.homepage}:{},items:Object.values(d).map((g)=>({name:g.name,type:g.type,...g.description?{description:g.description}:{},...g.registryDependencies?{registryDependencies:g.registryDependencies}:{},...g.dependencies?{dependencies:g.dependencies}:{}}))},items:d,unresolvedTemplateTypes:_}}function Jt(e,t,r){let i=new Map;for(let n of t){if(i.has(n.name)||e[n.name])throw Error(`composite item "${n.name}" collides with another item`);i.set(n.name,n)}for(let n of t){let a=n.channel??"public",o=Ne(n),s=new Set(n.files.map((l)=>l.path));for(let l of n.requires??[]){let u=i.get(l);if(!u)throw Error(`composite "${n.name}" requires unknown "${l}"`);if((u.channel??"public")!==a)throw Error(`composite "${n.name}" (${a}) requires "${l}" from another channel`);if(Ne(u)!==o)throw Error(`composite "${n.name}" requires "${l}" from another directory`);for(let f of u.files)s.add(f.path)}for(let l of n.files){if(!Be.test(l.path))throw Error(`composite "${n.name}" file "${l.path}" must be a plain relative path`);for(let u of Qt(l.content)){if(!u.startsWith("./")||u.includes("/../"))throw Error(`${n.name}/${l.path} imports ${u}; only ./ imports within the item directory are allowed`);let f=u.slice(2).replace(/\.js$/,"");if(![f,`${f}.ts`,`${f}.tsx`,`${f}/index.ts`,`${f}/index.tsx`].some((d)=>s.has(d)))throw Error(`${n.name}/${l.path} imports ${u}, which no required item ships`)}}if(a!==r.channel)continue;let c=n.files.map((l)=>{let u=`${r.componentsDir}/${o}/${l.path}`;return{path:u,target:u,content:l.content,type:l.path.endsWith(".tsx")?"registry:component":"registry:lib"}});e[n.name]={name:n.name,type:n.type,description:n.description,dependencies:["react",...n.dependencies??[]],registryDependencies:[...n.primitives??[],...(n.requires??[]).map(r.ref)],files:c,meta:{composite:!0,channel:a}}}}var Be=/^[a-z0-9][a-z0-9._-]*(\/[a-z0-9][a-z0-9._-]*)*$/i;function Ne(e){if(!Be.test(e.dir)||e.dir.split("/").includes(".."))throw Error(`composite "${e.name}" dir "${e.dir}" must be a plain relative path`);return e.dir}function Qt(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(^|[^:])\/\/.*$/gm,"$1"),r=[],i=[/\bfrom\s*["'](\.{1,2}\/[^"']+)["']/g,/\bimport\s*["'](\.{1,2}\/[^"']+)["']/g,/\bimport\s*\(\s*["'](\.{1,2}\/[^"']+)["']\s*\)/g];for(let n of i)for(let a of t.matchAll(n))r.push(a[1]??"");return r}function Zt(e){if(e.baseUrl){let r=e.baseUrl.replace(/\/$/,"");return(i)=>`${r}/r/${i}.json`}let t=e.namespace??Wt;if(!/^@[a-z0-9][a-z0-9-]*$/.test(t))throw Error(`registry namespace must look like "@uibot", got "${t}"`);return(r)=>`${t}/${r}`}function Xt(e,t,r){let i=e.name.replace(/\./g,""),n=`${r}/`,a=t.files.find((o)=>o.path.startsWith(n)&&/\.(tsx|ts)$/.test(o.path)&&er(o.content,i));if(!a)throw Error(`block "${e.name}" has no named export "${i}" in item "${t.name}"`);return{name:e.name,export:i,module:a.path.slice(n.length),catalog:e.catalogEntry}}function er(e,t){let r=Le(t),i=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"");if(new RegExp(`export\\s+(?:const|let|function|class)\\s+${r}\\b`).test(i))return!0;for(let n of i.matchAll(/export\s*\{([^}]*)\}/g)){let a=(n[1]??"").split(",").map((s)=>{let[,c]=s.trim().split(/\s+as\s+/);return(c??s.trim().replace(/^type\s+/,"")).trim()}),o=(n[1]??"").split(",").map((s)=>s.trim()).filter((s)=>s.startsWith("type ")).map((s)=>s.replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim());if(a.includes(t)&&!o.includes(t))return!0}return!1}function tr(e,t,r){let i=new Set(r.files.map((a)=>a.path)),n=(a)=>a.replace(/^blocks\//,"");return t.replace(/((?:\bfrom\s*|\bimport\s*)["'])(\.[^"']+)(["'])/g,(a,o,s,c)=>{let l=L.normalize(L.join(L.dirname(e),s)),f=(L.extname(l)?[l]:[l,`${l}.ts`,`${l}.tsx`,`${l}/index.ts`,`${l}/index.tsx`]).find((d)=>i.has(d));if(!f)return a;let p=L.relative(L.dirname(n(e)),n(f));if(!L.extname(s))p=p.replace(/\.(tsx?|jsx?)$/,"");if(!p.startsWith("."))p=`./${p}`;return o+p+c})}function rr(e,t){return(e.split("/").pop()??t).replace(/\.(tsx|ts|jsx|js)$/,"")||t}var ns=zt;function nr(e="/api/registry"){let t=(e||"/api/registry").trim(),r=t.startsWith("/")?t:`/${t}`;return r.length>1?r.replace(/\/$/,""):r}function J(e,t=200){return Response.json(e,{status:t})}function os(e){let t=nr(e.basePath),r=`${t}/registry.json`,i=`${t}/artifacts/`,n=new Map(e.manifest.items.map((a)=>[a.name,a]));return async function(o){let s=new URL(o.url);if(o.method!=="GET")return J({error:"Method not allowed"},405);if(s.pathname===r)return J(e.manifest);if(s.pathname.startsWith(i)){let c=s.pathname.slice(i.length),l=decodeURIComponent(c.endsWith(".json")?c.slice(0,-5):c),u=n.get(l);if(!u)return J({error:`Artifact '${l}' not found`},404);return J(u)}return J({error:"Not found"},404)}}var he="uibot.resource.admission.v1",ir=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure"],or=["packed-install","typecheck","browser"],cs=["invalid-admission-manifest","invalid-admission-record","invalid-admission-check","duplicate-admission-record","unknown-admission-resource","missing-source-metadata","missing-license-metadata","dependency-closure-failed"];class je extends Error{expected;actual;code="resource-admission-index-mismatch";constructor(e,t){super(`resource admission index mismatch: expected ${e}, received ${t}`);this.expected=e;this.actual=t;this.name="ResourceAdmissionIndexMismatchError"}}class Ve extends Error{issueCount;code="resource-admission-report-rejected";constructor(e){super(`resource admission report contains ${e.toString()} issue(s)`);this.issueCount=e;this.name="ResourceAdmissionReportRejectedError"}}class $e extends Error{code="resource-admission-report-not-derived";constructor(){super("resource admission report must come directly from assessResourceAdmissions");this.name="ResourceAdmissionReportNotDerivedError"}}var sr=new Set(Y),ar=new Set(re),Ue=new WeakSet,ne={missing:0,declared:1,verified:2,"external-consumer":3};function cr(e,t){return e<t?-1:e>t?1:0}function q(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function ie(e,t){let r=new Set(t);return Object.keys(e).every((i)=>r.has(i))}function ze(e){return[...new Set(e.map((t)=>t.trim()).filter(Boolean))].sort(cr)}function lr(e,t,r,i){if(!q(r)||!ie(r,["status","evidence"])){i.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} must contain only status and evidence`});return}if(typeof r.status!=="string"||!ar.has(r.status)||r.status==="missing"){i.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} status must be declared, verified or external-consumer`});return}if(!Array.isArray(r.evidence)||r.evidence.length===0||r.evidence.some((n)=>typeof n!=="string"||!n.trim())){i.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} evidence must be a non-empty string array`});return}return{status:r.status,evidence:ze(r.evidence)}}function dr(e){if(e===void 0)return;if(!q(e)||!ie(e,["source","version","license"]))return;if(Object.values(e).some((r)=>r!==void 0&&typeof r!=="string"))return;return{...typeof e.source==="string"&&e.source.trim()?{source:e.source.trim()}:{},...typeof e.version==="string"&&e.version.trim()?{version:e.version.trim()}:{},...typeof e.license==="string"&&e.license.trim()?{license:e.license.trim()}:{}}}function ur(e,t){let r=new Map,i=[];if(!q(t)||!ie(t,["schemaVersion","records"])||t.schemaVersion!==he||!Array.isArray(t.records))return i.push({code:"invalid-admission-manifest",detail:`expected ${he} with a records array`}),{records:r,issues:i};let n=new Set(e.resources.map((a)=>a.id));for(let a of t.records){if(!q(a)||!ie(a,["resourceId","provenance","checks"])||typeof a.resourceId!=="string"||!a.resourceId.trim()||!q(a.checks)){i.push({code:"invalid-admission-record",...q(a)&&typeof a.resourceId==="string"?{resourceId:a.resourceId}:{},detail:"record must contain only resourceId, optional provenance and checks"});continue}let o=a.resourceId.trim();if(r.has(o)){i.push({code:"duplicate-admission-record",resourceId:o,detail:o});continue}if(!n.has(o)){i.push({code:"unknown-admission-resource",resourceId:o,detail:o});continue}let s=dr(a.provenance);if(a.provenance!==void 0&&!s){i.push({code:"invalid-admission-record",resourceId:o,detail:"provenance must contain only string source, version and license fields"});continue}let c={},l=!1;for(let[u,f]of Object.entries(a.checks)){if(!sr.has(u)){i.push({code:"invalid-admission-check",resourceId:o,detail:`unknown receipt check: ${u}`}),l=!0;continue}let p=u,d=lr(o,p,f,i);if(d)c[p]=d;else l=!0}if(l)continue;r.set(o,{resourceId:o,...s?{provenance:s}:{},checks:c})}return{records:r,issues:i}}function pr(e){let t=new Map(e.resources.map((n)=>[n.id,n])),r=new Map;function i(n,a,o,s){if(r.has(n)||s.has(a))return;if(o.has(a)){r.set(n,`dependency cycle reached ${a}`);return}let c=t.get(a);if(!c){r.set(n,`missing dependency ${a}`);return}o.add(a);for(let l of c.dependencies)if(i(n,l,o,s),r.has(n))break;o.delete(a),s.add(a)}for(let n of e.resources)i(n.id,n.id,new Set,new Set);return r}var gr=/^(unknown|unlicensed|none|n\/?a)$/i,mr=/^SPDX-License-Identifier:\s*(\S+)/im,fr=/^(?:the\s+)?(mit|apache(?:\s+license(?:\s*,?\s*version\s*2\.0)?)?|bsd-2-clause|bsd-3-clause|isc|unlicense)\b/i;function B(e){let t=e?.trim();if(!t||gr.test(t))return;return t}function yr(e){if(!e?.trim())return;let t=e.match(mr)?.[1];if(t)return B(t);let r=e.match(fr)?.[1];if(!r)return;let i=r.toLowerCase();if(i.startsWith("mit"))return"MIT";if(i.startsWith("apache"))return"Apache-2.0";if(i.startsWith("bsd-2"))return"BSD-2-Clause";if(i.startsWith("bsd-3"))return"BSD-3-Clause";if(i==="isc")return"ISC";if(i==="unlicense")return"Unlicense";return}function ls(e){return B(e.frontmatterLicense)??B(e.packageJsonLicense)??yr(e.licenseFileText)}function qe(e){return Boolean(B(e))}var Q={states:/\b(disabled|loading|error|empty|pending|busy|children|active|muted|boolean-state)\b/i,accessibility:/\b(label|aria|accessible|alt|role)\b/i,"light-theme":/:root\b|\b(light(?:-theme)?|theme token|css variables?)\b/i,"dark-theme":/\b(dark(?:-theme)?)\b/i,responsive:/\b(size|responsive|breakpoint|sm|md|lg|xl|full)\b/i};function be(e,t){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let i of e)be(i,t);return}let r=e;for(let[i,n]of Object.entries(r)){if(t.push(i),i==="type"&&n==="boolean")t.push("boolean-state");be(n,t)}}function hr(e){let t=[];return be(e.props,t),[e.name,e.description,...e.tags??[],...e.usageScenarios??[],...e.constraints??[],...t,...Object.keys(e.slots??{}),...Object.keys(e.events??{}),e.slots&&Object.keys(e.slots).length>0?"empty":""].join(`
13
+ `)}function ds(e,t={}){let r=[hr(e),t.sourceText??"",t.stylesText??""].join(`
14
+ `);return{contract:Boolean(e.props&&Object.keys(e.props).length>0||e.events&&Object.keys(e.events).length>0||e.slots&&Object.keys(e.slots).length>0)?"verified":"declared",states:Q.states.test(r)?"verified":"missing",accessibility:Q.accessibility.test(r)?"verified":"missing","light-theme":Q["light-theme"].test(r)?"verified":"missing","dark-theme":Q["dark-theme"].test(r)?"verified":"missing",responsive:Q.responsive.test(r)?"verified":"missing"}}function br(e){return{source:"declared",license:qe(e.source.license)?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"}}function Cr(e){if(!ir.every((i)=>ne[e[i]]>=ne.verified))return"experimental";return or.every((i)=>e[i]==="external-consumer")?"recommended":"candidate"}function He(e){let t=JSON.stringify({schemaVersion:e.schemaVersion,resources:e.resources.map((n)=>({id:n.id,kind:n.kind,title:n.title,description:n.description,...n.category?{category:n.category}:{},tags:n.tags,aliases:n.aliases,capabilities:n.capabilities,dependencies:n.dependencies,source:n.source})),aliases:e.aliases}),r=0xcbf29ce484222325n,i=0x100000001b3n;for(let n of new TextEncoder().encode(t))r^=BigInt(n),r=BigInt.asUintN(64,r*i);return`fnv1a64:${r.toString(16).padStart(16,"0")}`}function Rr(e,t,r){let i=br(e),n=[`resource://${e.source.type}/${e.source.id}`,`resource://contract/${e.id}`],a=[];if(r)a.push({code:"dependency-closure-failed",resourceId:e.id,check:"dependency-closure",detail:r});else i["dependency-closure"]="verified",n.push(`resource://index/${e.id}`);if(t)for(let c of Y){if(c==="dependency-closure")continue;let l=t.checks[c];if(!l)continue;if(c==="source"&&ne[l.status]>=ne.verified&&(!t.provenance?.source||!t.provenance.version)){a.push({code:"missing-source-metadata",resourceId:e.id,check:c,detail:"verified source requires provenance.source and provenance.version"});continue}if(c==="license"&&!qe(t.provenance?.license)){a.push({code:"missing-license-metadata",resourceId:e.id,check:c,detail:"license evidence requires a concrete provenance.license"});continue}if(i[c]=l.status,n.push(...l.evidence),c==="source"&&t.provenance?.source)n.push(t.provenance.source)}let o=Cr(i),s={level:o==="recommended"?"external-consumer":o==="candidate"?"verified":"declared",maturity:o,checks:i,evidence:ze(n)};return Object.freeze(s.checks),Object.freeze(s.evidence),Object.freeze(s),Object.freeze(a),Object.freeze({resourceId:e.id,receipt:s,issues:a})}function us(e,t){let r=ur(e,t),i=pr(e),n=e.resources.map((c)=>Rr(c,r.records.get(c.id),i.get(c.id))),a=[...r.issues,...n.flatMap((c)=>c.issues)],o=Object.fromEntries(te.map((c)=>[c,0]));for(let c of n)o[c.receipt.maturity]+=1;Object.freeze(n),Object.freeze(o);for(let c of a)Object.freeze(c);Object.freeze(a);let s=Object.freeze({schemaVersion:he,indexFingerprint:He(e),resources:n,counts:o,issues:a});return Ue.add(s),s}function ps(e,t){if(!Ue.has(t))throw new $e;if(t.issues.length>0)throw new Ve(t.issues.length);let r=He(e);if(r!==t.indexFingerprint)throw new je(t.indexFingerprint,r);let i=new Map(t.resources.map((a)=>[a.resourceId,a.receipt])),n=e.resources.map((a)=>{let o=i.get(a.id);if(!o)return a;return Object.freeze({...a,receipt:o})});return Object.freeze(n),Object.freeze({schemaVersion:e.schemaVersion,resources:n,aliases:e.aliases})}var xr="uibot.resource.index.v1",fs=["invalid-resource-source-id","duplicate-resource-id","dangling-resource-dependency","ambiguous-resource-dependency"];class K extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceIndexError"}}function S(e,t){return e<t?-1:e>t?1:0}function C(e){return e.normalize("NFKC").replace(/([\p{Lu}]+)([\p{Lu}][\p{Ll}])/gu,"$1 $2").replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim().replace(/\s+/g," ")}function kr(e){let t=C(e).replace(/ /g,"-");if(!t)throw new K("invalid-resource-source-id",e);return t}function T(e,t){return`${e}:${kr(t)}`}function oe(e){let t=new Map;for(let r of e){let i=r?.trim();if(!i)continue;let n=C(i);if(!n||t.has(n))continue;t.set(n,i)}return[...t.entries()].sort(([r],[i])=>S(r,i)).map(([,r])=>r)}function Z(e){return{level:"declared",maturity:"experimental",checks:{source:"declared",license:e?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"},evidence:[]}}function Sr(e){let t=B(e.license);return{type:e.type,id:e.id,...e.version?{version:e.version}:{},...e.sourceHash?{sourceHash:e.sourceHash}:{},...e.packageName?{packageName:e.packageName}:{},...e.url?{url:e.url}:{},...t?{license:t}:{}}}function H(e){return{id:e.id,kind:e.kind,title:e.title,description:e.description,...e.category?{category:e.category}:{},tags:oe(e.tags),aliases:oe(e.aliases),capabilities:oe(e.capabilities),dependencies:[...new Set(e.dependencies)].sort(S),source:Sr(e.source),receipt:e.receipt,...e.solution?{solution:structuredClone(e.solution)}:{}}}function Ir(e){return(e.body.split(/\r?\n/).map((r)=>r.replace(/^#+\s*/,"").trim()).find(Boolean)??e.title).slice(0,240)}function Ar(e){if(e.solution){let t=(r)=>{if(r&&typeof r==="object"){for(let i of Object.values(r))t(i);Object.freeze(r)}};t(e.solution)}return Object.freeze(e.tags),Object.freeze(e.aliases),Object.freeze(e.capabilities),Object.freeze(e.dependencies),Object.freeze(e.source),Object.freeze(e.receipt.checks),Object.freeze(e.receipt.evidence),Object.freeze(e.receipt),Object.freeze(e)}function wr(e){let t=new Map;for(let r of Object.keys(e).sort(S)){let i=e[r];if(!i)continue;let n=T("component",r);for(let a of oe([r,i.name])){let o=C(a),s=t.get(o)??[];if(!s.includes(n))s.push(n);t.set(o,s.sort(S))}}return t}function Pr(e,t,r){let i=r.get(C(e))??[];if(i.length===0)throw new K("dangling-resource-dependency",`${t} -> ${T("component",e)}`);if(i.length>1)throw new K("ambiguous-resource-dependency",`${t} -> ${e}: ${i.join(",")}`);return i[0]}function vr(e,t,r,i){let n=e.startsWith("template:")?e.slice(9):e;if(Object.hasOwn(i,n))return T("template",n);return Pr(e,t,r)}function X(e,t,r){return B(r?.[e]??t)}function ys(e){return Object.entries(e).filter(([,t])=>t.level==="L4").sort(([t],[r])=>S(t,r)).map(([t,r])=>({id:`${t}-example`,title:`${r.name} Example`,description:r.description,category:r.category,tags:r.keywords,aliases:[`${t} example`,`${r.name} example`],capabilities:["example:template"],dependencies:[T("template",t)]}))}function hs(e){let t=e.components??{},r=e.templates??{},i=e.designGuides??[],n=e.examples??[],a=e.skills??[],o=e.licenses,s=wr(t),c=[];for(let d of Object.keys(t).sort(S)){let m=t[d];if(!m)continue;let y=T("component",d),h=X(y,void 0,o);c.push(H({id:y,kind:"component",title:m.name,description:m.description,category:m.category,tags:m.tags??[],aliases:[d,m.name],capabilities:["catalog:component"],dependencies:[],source:{type:"catalog",id:d,...h?{license:h}:{}},receipt:Z(Boolean(h))}))}for(let d of Object.keys(r).sort(S)){let m=r[d];if(!m)continue;let y=T("template",d),h=X(y,void 0,o);c.push(H({id:y,kind:"template",title:m.name,description:m.description,category:m.category,tags:m.keywords,aliases:[d,m.name],capabilities:[],dependencies:(m.composedFrom??[]).map((A)=>vr(A,y,s,r)),source:{type:"template-contract",id:d,...h?{license:h}:{}},receipt:Z(Boolean(h))}))}for(let d of[...i].sort((m,y)=>S(m.id,y.id))){let m=T("design-guide",d.id),y=X(m,void 0,o);c.push(H({id:m,kind:"design-guide",title:d.title,description:Ir(d),category:d.category,tags:d.tags,aliases:[d.id,d.title],capabilities:["designMd:source"],dependencies:[],source:{type:"design-md",id:d.id,...d.sourceUrl?{url:d.sourceUrl}:{},...y?{license:y}:{}},receipt:Z(Boolean(y))}))}for(let d of[...n].sort((m,y)=>S(m.id,y.id))){let m=T("example",d.id),y=X(m,d.license,o);c.push(H({id:m,kind:"example",title:d.title,description:d.description,...d.category?{category:d.category}:{},tags:d.tags??[],aliases:[d.id,d.title,...d.aliases??[]],capabilities:d.capabilities??[],dependencies:d.dependencies??[],source:{type:"example",id:d.id,...d.version?{version:d.version}:{},...d.sourceUrl?{url:d.sourceUrl}:{},...y?{license:y}:{}},receipt:Z(Boolean(y))}))}for(let d of[...a].sort((m,y)=>S(m.id,y.id))){let m=T("skill",d.id),y=X(m,void 0,o);c.push(H({id:m,kind:"skill",title:d.title,description:d.description?.trim()||d.title,tags:[...d.tags??[],...d.triggers??[]],aliases:[d.id,d.title,...d.triggers??[]],capabilities:["skill:definition"],dependencies:[],source:{type:"skill",id:d.id,...d.version?{version:d.version}:{},...y?{license:y}:{}},receipt:Z(Boolean(y))}))}for(let d of e.additional??[])c.push(H(d));c.sort((d,m)=>S(d.id,m.id));let l=new Set;for(let d of c){if(l.has(d.id))throw new K("duplicate-resource-id",d.id);l.add(d.id)}for(let d of c)for(let m of d.dependencies)if(!l.has(m))throw new K("dangling-resource-dependency",`${d.id} -> ${m}`);let u=new Map;for(let d of c)for(let m of d.aliases){let y=C(m);if(!y)continue;let h=u.get(y)??new Set;h.add(d.id),u.set(y,h)}let f=Object.freeze(Object.fromEntries([...u.entries()].sort(([d],[m])=>S(d,m)).map(([d,m])=>[d,Object.freeze([...m].sort(S))]))),p=Object.freeze(c.map(Ar));return Object.freeze({schemaVersion:xr,resources:p,aliases:f})}var Er=[["chat","assistant","\u804A\u5929","\u52A9\u624B","\u5BF9\u8BDD"],["document","documents","\u6587\u6863","\u5199\u4F5C"],["auth","authentication","\u8BA4\u8BC1","\u767B\u5F55"],["data table","data grid","datatable","table","\u8868\u683C","\u6570\u636E\u8868","\u6570\u636E\u8868\u683C"],["button","action button","\u6309\u94AE","\u64CD\u4F5C\u6309\u94AE"],["dashboard","admin dashboard","\u4EEA\u8868\u76D8","\u540E\u53F0","\u7BA1\u7406\u540E\u53F0"],["kanban","kanban board","\u770B\u677F","\u4EFB\u52A1\u770B\u677F"],["form","input form","\u8868\u5355","\u8F93\u5165\u8868\u5355"],["navigation","nav","sidebar","\u5BFC\u822A","\u4FA7\u8FB9\u680F"]],Dr=Object.freeze(Er.map((e)=>Object.freeze([...e]))),Ke=new Map;for(let e of Dr){let t=Object.freeze([...new Set(e.map(C).filter(Boolean))].sort());for(let r of t)Ke.set(r,t)}function Ce(e){let t=C(e);return Ke.get(t)??Object.freeze([t])}var Ss=["resource-query-empty","resource-query-invalid-limit","resource-not-found","resource-alias-ambiguous"];class w extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceQueryError"}}var ke=Object.freeze({function:180,scenario:180,unit:180,industry:180,"exact-id":1000,"exact-title":900,alias:800,tag:600,capability:500,category:400,token:200,fuzzy:100}),Tr=Object.freeze(Object.keys(ke)),We=new Map(Tr.map((e,t)=>[e,t])),Ge=new Map([["component",0],["template",1],["design-guide",2],["example",3],["skill",4]]);function I(e,t){return e<t?-1:e>t?1:0}function Ye(e){return new Set((e??[]).map(C).filter(Boolean))}function j(e,t){let r=Ye(t);if(r.size===0)return!0;let i=Ye(e);return[...r].some((n)=>i.has(n))}function Or(e,t){if(!j(e.solution?.functions??[],t.functions))return!1;if(!j(e.solution?.scenarios??[],t.scenarios))return!1;if(!j(e.solution?[e.solution.unit]:[],t.units))return!1;if(!j(e.solution?.industries??[],t.industries))return!1;if(t.kinds?.length&&!t.kinds.includes(e.kind))return!1;if(!j(e.tags,t.tags))return!1;if(!j(e.category?[e.category]:[],t.categories))return!1;if(!j(e.capabilities,t.capabilities))return!1;if(t.maturities?.length&&!t.maturities.includes(e.receipt.maturity))return!1;return!0}function _r(e){return Boolean(e.functions?.length||e.scenarios?.length||e.units?.length||e.industries?.length||e.kinds?.length||e.tags?.length||e.categories?.length||e.capabilities?.length||e.maturities?.length)}function P(e,t,r,i=ke[t]){if(e.some((n)=>n.code===t&&n.value===r))return;e.push({code:t,value:r,score:i})}function Re(e,t){return e.find((r)=>C(r)===t)}function xe(e){return[e.id,e.title,...e.aliases,...e.tags,...e.category?[e.category]:[],...e.capabilities,...e.solution?.functions??[],...e.solution?.scenarios??[],...e.solution?.industries??[]]}function Fr(e,t,r){if(Math.abs(e.length-t.length)>r)return r+1;let i=Array.from({length:t.length+1},(n,a)=>a);for(let n=1;n<=e.length;n+=1){let a=[n],o=n;for(let s=1;s<=t.length;s+=1){let c=(i[s-1]??r+1)+(e[n-1]===t[s-1]?0:1),l=Math.min((i[s]??r+1)+1,(a[s-1]??r+1)+1,c);a.push(l),o=Math.min(o,l)}if(o>r)return r+1;i=a}return i[t.length]??r+1}function Je(e,t){let r=C(t),i=[];if(C(e.id)===r)P(i,"exact-id",e.id);if(C(e.title)===r)P(i,"exact-title",e.title);let n=Re(e.aliases,r);if(n)P(i,"alias",n);let a=Re(e.tags,r);if(a)P(i,"tag",a);let o=Re(e.capabilities,r);if(o)P(i,"capability",o);if(e.category&&C(e.category)===r)P(i,"category",e.category);if(!n){let l=Ce(r).filter((f)=>f!==r),u=new Set(xe(e).map(C));if(l.some((f)=>u.has(f)))P(i,"alias",t.trim())}let s=r.split(" ").filter(Boolean),c=C(xe(e).join(" "));if(s.length>0&&s.every((l)=>c.includes(l)))P(i,"token",t.trim());if(i.length===0&&r.length>=4){let l;for(let u of xe(e)){let f=C(u);if(f.length<4)continue;let p=Fr(r,f,2);if(p<=2&&(!l||p<l.distance||p===l.distance&&I(u,l.value)<0))l={value:u,distance:p}}if(l)P(i,"fuzzy",l.value,ke.fuzzy-l.distance)}return i.sort((l,u)=>{if(l.score!==u.score)return u.score-l.score;return(We.get(l.code)??99)-(We.get(u.code)??99)||I(l.value,u.value)})}function Qe(e,t,r){if(t.has(r))return[r];let i=C(r),n=e.aliases[i];if(n?.length)return[...n];let a=new Set;for(let o of Ce(i))for(let s of e.aliases[o]??[])a.add(s);return[...a].sort(I)}function Ze(e,t){return new w("resource-alias-ambiguous",`${e.trim()}: ${t.join(",")}`)}function Xe(e){let t=new Map(e.resources.map((i)=>[i.id,i]));function r(i){let n=i.trim(),a=Qe(e,t,n);if(a.length===0)throw new w("resource-not-found",n);if(a.length>1)throw Ze(n,a);let o=a[0],s=o?t.get(o):void 0;if(!s)throw new w("resource-not-found",n);return s}return Object.freeze({manifest:()=>e,search(i){let n=i.text?.trim()??"";if(!n&&!_r(i))throw new w("resource-query-empty","text or filter is required");if(i.limit!==void 0&&(!Number.isInteger(i.limit)||i.limit<=0))throw new w("resource-query-invalid-limit",String(i.limit));let a=e.resources.filter((o)=>Or(o,i)).filter((o)=>!n||Je(o,n).length>0).map((o)=>{let s=n?Je(o,n):[];for(let[c,l]of[[i.functions,"function"],[i.scenarios,"scenario"],[i.units,"unit"],[i.industries,"industry"]])if(c?.length)P(s,l,c.join(","));return{resource:o,score:s.reduce((c,l)=>c+l.score,0),reasons:s}}).filter((o)=>!n||o.reasons.length>0).sort((o,s)=>s.score-o.score||I(o.resource.id,s.resource.id));return i.limit===void 0?a:a.slice(0,i.limit)},get:r,build(i){if(i.length===0||i.every((p)=>!p.trim()))throw new w("resource-query-empty","at least one build root is required");let n=[],a=new Set;for(let p of i){let d=p.trim(),m=Qe(e,t,d);if(m.length===0)n.push({id:d,reason:"missing-resource"});else if(m.length>1)throw Ze(d,m);else{let y=m[0];if(y)a.add(y)}}let o=new Set,s=new Set,c=new Set,l=[],u=[],f=(p,d)=>{if(o.has(p))return;if(s.has(p)){n.push({id:p,...d?{requiredBy:d}:{},reason:"dependency-cycle"});return}let m=t.get(p);if(!m){n.push({id:p,...d?{requiredBy:d}:{},reason:"missing-resource"});return}s.add(p),c.add(p);let y=[...m.dependencies].sort((h,A)=>{let N=t.get(h),_=t.get(A);return(Ge.get(N?.kind??"")??99)-(Ge.get(_?.kind??"")??99)||I(h,A)});for(let h of y)u.push({from:p,to:h,relation:"depends-on"}),f(h,p);s.delete(p),o.add(p),l.push(p)};for(let p of[...a].sort(I))f(p);return{roots:[...a].sort(I),nodes:[...c].sort(I).map((p)=>{let d=t.get(p);if(!d)throw new w("resource-not-found",p);return{id:p,kind:d.kind,maturity:d.receipt.maturity}}),edges:u.sort((p,d)=>I(p.from,d.from)||I(p.to,d.to)),order:l,gaps:n.sort((p,d)=>I(p.id,d.id)||I(p.requiredBy??"",d.requiredBy??"")||I(p.reason,d.reason))}}})}function Mr(e){if(!e||typeof e!=="object")throw Error("invalid-public-resource-bundle");jr(e);let t=e;if(t.schemaVersion!=="uibot.public-resources.v1"||typeof t.release?.version!=="string"||!/^[a-f0-9]{64}$/.test(t.release?.sourceHash)||t.index?.schemaVersion!=="uibot.resource.index.v1"||!Array.isArray(t.index.resources)||!t.index.aliases||!t.showcases)throw Error("invalid-public-resource-bundle");if(t.documents&&(!Array.isArray(t.documents)||t.documents.some((n)=>typeof n.title!=="string"||typeof n.markdown!=="string"||!/^\/(?:en\/)?docs\/[a-z0-9-]+$/.test(n.path))))throw Error("invalid-public-documentation");let r=new Set,i=new Set;for(let n of t.index.resources){if(!n||typeof n.id!=="string"||r.has(n.id)||!De.includes(n.kind)||!n.id.startsWith(`${n.kind}:`)||typeof n.description!=="string"||typeof n.title!=="string"||!Array.isArray(n.dependencies)||!n.source||!n.receipt||!Array.isArray(n.aliases)||!Array.isArray(n.tags)||!Array.isArray(n.capabilities)||![n.aliases,n.dependencies,n.tags,n.capabilities].every((o)=>o.every((s)=>typeof s==="string"&&s.length<=1000))||!["catalog","template-contract","design-md","example","skill","registry","package","theme"].includes(n.source.type)||typeof n.source.id!=="string"||n.source.sourceHash!==void 0&&!/^[a-f0-9]{64}$/.test(n.source.sourceHash)||n.source.packageName!==void 0&&(typeof n.source.packageName!=="string"||!n.source.packageName.startsWith("@uibot/"))||!te.includes(n.receipt.maturity)||!Te.includes(n.receipt.level)||!Array.isArray(n.receipt.evidence)||!n.receipt.evidence.every((o)=>typeof o==="string")||!Y.every((o)=>re.includes(n.receipt.checks?.[o])))throw Error("invalid-public-resource");if(r.add(n.id),n.solution){let o=n.solution;if(![o.functions,o.scenarios,o.industries,o.hostRequirements,o.limitations].every((s)=>Array.isArray(s)&&s.every((c)=>typeof c==="string"&&c.length>0&&c.length<=2000))||!["page","flow","industry"].includes(o.unit)||!["interactive-demo","needs-enhancement"].includes(o.readiness)||o.members!==void 0&&(!Array.isArray(o.members)||o.members.some((s)=>typeof s.resourceId!=="string"||typeof s.version!=="string"||!s.version||s.sourceHash!==void 0&&(typeof s.sourceHash!=="string"||!/^[a-f0-9]{64}$/.test(s.sourceHash)))))throw Error("invalid-resource-solution")}let a=t.showcases[n.id];if(!a||a.resourceId!==n.id||typeof a.docs?.zh!=="string"||typeof a.docs?.en!=="string"||!Array.isArray(a.examples)||!Array.isArray(a.distributions))throw Error("invalid-resource-showcase");if(a.collection!==void 0){let o=a.collection;if(!o||typeof o.id!=="string"||!/^[a-z0-9-]+$/.test(o.id)||typeof o.group?.id!=="string"||!/^[a-z0-9-]+$/.test(o.group.id)||[o.title,o.group.title].some((s)=>!s||[s.zh,s.en].some((c)=>typeof c!=="string"||!c.trim()||c.length>200)))throw Error("invalid-resource-collection")}if(a.agentKit!==void 0){let o=a.agentKit;if(i.has(n.source?.id))throw Error("invalid-resource-agent-kit");if(i.add(n.source?.id),!o||!["skill","prompt","recipe"].includes(o.type)||(o.type==="skill"?n.kind!=="skill":n.kind!=="example")||!/^[a-z][a-z0-9-]*$/.test(n.source.id)||o.fileName!=={skill:"SKILL.md",prompt:"PROMPT.md",recipe:"RECIPE.md"}[o.type]||[o.summary?.zh,o.summary?.en].some((s)=>typeof s!=="string"||!s.trim())||!Array.isArray(o.resources)||new Set(o.resources.map((s)=>s?.id)).size!==o.resources.length||o.resources.some((s)=>!s||!n.dependencies.includes(s.id)||!t.index.resources.some((c)=>c.id===s.id&&(c.source.version??null)===s.version)||s.version!==null&&(typeof s.version!=="string"||!s.version)||typeof s.contentHash!=="string"||!/^[a-f0-9]{64}$/.test(s.contentHash)||s.sourceHash!==void 0&&(typeof s.sourceHash!=="string"||!/^[a-f0-9]{64}$/.test(s.sourceHash)))||o.resources.length!==n.dependencies.length)throw Error("invalid-resource-agent-kit")}if(a.solutionControls!==void 0){let o=new Set;if(!Array.isArray(a.solutionControls)||a.solutionControls.some((s)=>{if(!s||typeof s.id!=="string"||o.has(s.id)||typeof s.label?.zh!=="string"||typeof s.label?.en!=="string"||!Array.isArray(s.values)||!s.values.length||s.values.some((c)=>!["string","boolean","number"].includes(typeof c)||typeof c==="number"&&!Number.isFinite(c))||typeof s.target?.pageId!=="string"||typeof s.target?.property!=="string"||["__proto__","prototype","constructor"].includes(s.target.property)||s.target.blockId!==void 0&&typeof s.target.blockId!=="string")return!0;return o.add(s.id),!1}))throw Error("invalid-solution-controls")}if(a.templateContract&&(a.templateContract.name!==n.source.id||typeof a.templateContract.description!=="string"||!["L3","L4","L5"].includes(a.templateContract.level)||!["feature","template","page","app"].includes(a.templateContract.category)||!Array.isArray(a.templateContract.keywords)))throw Error("invalid-public-template-contract");if(typeof a.title?.zh!=="string"||typeof a.title?.en!=="string"||a.examples.some((o)=>!o||typeof o.id!=="string"||typeof o.title!=="string"||typeof o.code!=="string"||!["spec","tsx","source"].includes(o.mode)||!["tsx","json","yaml","css","ts"].includes(o.language)||!Array.isArray(o.dependencies)||!o.dependencies.every((s)=>typeof s==="string"))||a.distributions.some((o)=>!o||!["spec","npm","shadcn"].includes(o.channel)||typeof o.name!=="string"||!/^[@a-zA-Z0-9._/-]+$/.test(o.name)||typeof o.version!=="string"||!["source","published"].includes(o.availability)))throw Error("invalid-resource-content")}for(let[n,a]of Object.entries(t.index.aliases))if(!n||!Array.isArray(a)||a.some((o)=>!r.has(o)))throw Error("invalid-public-resource-alias");if(Object.keys(t.showcases).some((n)=>!r.has(n)))throw Error("unexpected-public-resource-showcase");for(let n of t.index.resources)for(let a of n.dependencies)if(!r.has(a))throw Error("invalid-public-resource-dependency");if(t.distributionSnapshot){let n=t.distributionSnapshot;if(!/^[a-f0-9]{64}$/.test(n.snapshotId)||n.manifestPath!==`../snapshots/${n.snapshotId}/snapshot.json`||!n.resources||!n.unavailable||!n.external||Object.entries(n.external).some(([a,o])=>!Object.hasOwn(n.unavailable,a)||!Array.isArray(o)||o.some((s)=>typeof s!=="string"||s.startsWith("@uibot/"))))throw Error("invalid-distribution-snapshot-reference");for(let[a,o]of Object.entries(n.resources))if(!r.has(a)||o.version!==(t.index.resources.find((s)=>s.id===a)?.source.version??t.release.version)||!/^[a-f0-9]{64}$/.test(o.resourceHash)||!Array.isArray(o.entrypoints)||!o.entrypoints.length||!Array.isArray(o.closure)||![...o.entrypoints,...o.closure].every((s)=>/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(s))||o.entrypoints.some((s)=>!o.closure.includes(s)))throw Error("invalid-distribution-snapshot-resource")}}function vs(e){Mr(e),e=JSON.parse(JSON.stringify(e));let t=(n)=>{if(n&&typeof n==="object"){for(let a of Object.values(n))t(a);Object.freeze(n)}};t(e);let r=Xe(e.index),i=(n)=>{let a=r.get(n),o=e.showcases[a.id];if(!o)throw new w("resource-not-found",a.id);return o};return Object.freeze({...r,get(n){let a=r.get(n),o=i(n).agentKit;return o?Object.freeze({...a,agentKit:o}):a},docs(n,a="zh",o=1){if(a!=="zh"&&a!=="en")throw Error("unsupported-resource-locale");let s=i(n);return{resourceId:s.resourceId,locale:a,...Lr(s.docs[a],o),release:e.release}},examples(n,a=1){let o=i(n);return{resourceId:o.resourceId,...Br(o.examples,a),release:e.release}},installPlan(n){let a=i(n);return{resourceId:a.resourceId,distributions:a.distributions,dependencies:r.build([a.resourceId]),release:e.release,snapshot:e.distributionSnapshot&&Object.hasOwn(e.distributionSnapshot.resources,a.resourceId)?{snapshotId:e.distributionSnapshot.snapshotId,manifestPath:e.distributionSnapshot.manifestPath,...e.distributionSnapshot.resources[a.resourceId]}:null,snapshotUnavailable:e.distributionSnapshot?.unavailable[a.resourceId]??null,install:a.distributions.map((o)=>Nr(o,e.distributionSnapshot,a.resourceId))}}})}function Nr(e,t,r){let{channel:i,name:n,version:a}=e;if(i==="npm")return{channel:i,name:n,command:`add ${n}@${a}`,note:null};if(i==="spec")return{channel:i,name:n,command:null,note:"Read the Spec through examples and compile it strictly with the matching Catalog."};let o=!!t&&Object.hasOwn(t.resources,r),s=t?.external[r]??[];return{channel:i,name:n,command:`shadcn add @uibot/${n}`,registries:{"@uibot":"/r/{name}.json"},externalRegistryDependencies:s,note:o?"A hash-pinned snapshot exists: export and verify it, then map @uibot to the local snapshot server.":s.length?`No hash-pinned snapshot: the install also pulls stock shadcn items (${s.join(", ")}) from the host's default registry. Installing through the portal mapping still works; report the files as not snapshot-verified.`:"No hash-pinned snapshot; report the files as not snapshot-verified."}}var M=24000;function et(e,t){if(!Number.isSafeInteger(e)||e<1||e>Math.max(1,t))throw new w("resource-query-invalid-limit","page is outside the available range")}function Lr(e,t){let r=Math.max(1,Math.ceil(e.length/M));return et(t,r),{markdown:e.slice((t-1)*M,t*M),page:t,totalPages:r,...t<r?{nextPage:t+1}:{}}}function Br(e,t){let r=e.flatMap((i)=>Array.from({length:Math.max(1,Math.ceil(i.code.length/M))},(n,a)=>({...i,code:i.code.slice(a*M,(a+1)*M),codeOffset:a*M,codeLength:i.code.length,complete:i.code.length<=M})));return et(t,r.length),{examples:r.slice(t-1,t),page:t,totalPages:r.length,...t<r.length?{nextPage:t+1}:{}}}function jr(e){let t=0,r=0,i=new Set,n=(a,o)=>{if(++t>300000||o>64)throw Error("public-resource-budget-exceeded");if(typeof a==="string"){if(r+=new TextEncoder().encode(a).length,r>16777216)throw Error("public-resource-budget-exceeded")}else if(a&&typeof a==="object"){if(i.has(a))throw Error("invalid-public-resource-cycle");let s=Object.getPrototypeOf(a);if(!Array.isArray(a)&&s!==Object.prototype&&s!==null)throw Error("invalid-public-resource-object");i.add(a);for(let[c,l]of Object.entries(a))n(c,o+1),n(l,o+1);i.delete(a)}else if(a!==null&&typeof a!=="boolean"&&(typeof a!=="number"||!Number.isFinite(a)))throw Error("invalid-public-resource-json")};n(e,1)}import{createHash as Vr}from"crypto";var le=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,se=/^[a-f0-9]{64}$/,ae=/^\d+\.\d+\.\d+(?:-[\w.-]+)?(?:\+[\w.-]+)?$/,tt=new TextEncoder,$r=new TextDecoder("utf-8",{fatal:!0});function de(e){return Vr("sha256").update(e).digest("hex")}function V(e){let t=0,r=(n,a)=>{if(++t>400000||a>32)throw Error("snapshot-json-budget-exceeded");if(Array.isArray(n))return n.map((o)=>r(o,a+1));if(n&&typeof n==="object"){if(Object.getPrototypeOf(n)!==Object.prototype)throw Error("snapshot-invalid-json");return Object.fromEntries(Object.keys(n).sort().map((o)=>[o,r(n[o],a+1)]))}if(n===null||typeof n==="string"||typeof n==="boolean"||typeof n==="number"&&Number.isFinite(n))return n;throw Error("snapshot-invalid-json")},i=JSON.stringify(r(e,0));if(tt.encode(i).length>16777216)throw Error("snapshot-json-budget-exceeded");return i}function ce(e){if(typeof e!=="string"||!/^[a-zA-Z0-9_./-]+$/.test(e)||e.split("/").some((t)=>!t||t==="."||t==="..")||e.startsWith("/"))throw Error(`snapshot-unsafe-path: ${e}`)}function Se(e,t){return ce(e),{path:e,bytes:t.byteLength,sha256:de(t)}}function Ur(e){if(typeof e!=="string"||!e.startsWith("@uibot/")||!le.test(e.slice(7)))throw Error(`snapshot-external-registry-dependency: ${e}`);return e.slice(7)}function rt(e,t){if(!le.test(e)||t.byteLength>16777216)throw Error("snapshot-invalid-item");let r=JSON.parse($r.decode(t));if(r.name!==e||!Array.isArray(r.files)||r.files.length>2000||(r.devDependencies?.length??0)>0)throw Error(`snapshot-invalid-item: ${e}`);let i={};for(let s of r.dependencies??[]){let c=s.lastIndexOf("@"),l=s.slice(0,c),u=s.slice(c+1);if(c<1||!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(l)||!ae.test(u)||i[l]&&i[l]!==u)throw Error(`snapshot-unpinned-npm-dependency: ${s}`);i[l]=u}let n=[...new Set((r.registryDependencies??[]).map(Ur))].sort(),a=new Set,o=r.files.map((s)=>{if(typeof s.content!=="string")throw Error(`snapshot-missing-file-content: ${e}`);let c=s.target??s.path;if(ce(c),a.has(c))throw Error(`snapshot-duplicate-target: ${c}`);return a.add(c),{...Se(s.path,tt.encode(s.content)),target:c}});return{...Se(`r/${e}.json`,t),registryDependencies:n,npmDependencies:i,files:o}}function nt(e,t){let r=new Set,i=new Set,n=(s)=>{if(!le.test(s)||!Object.hasOwn(e,s))throw Error(`snapshot-missing-item: ${s}`);if(i.has(s))throw Error(`snapshot-dependency-cycle: ${s}`);if(r.has(s))return;i.add(s);for(let c of e[s].registryDependencies)n(c);i.delete(s),r.add(s)};if(!t.length)throw Error("snapshot-empty-entrypoints");t.forEach(n);let a=new Map,o=new Map;for(let s of r){for(let c of e[s].files){let l=a.get(c.target);if(l&&l!==c.sha256)throw Error(`snapshot-target-conflict: ${c.target}`);a.set(c.target,c.sha256)}for(let[c,l]of Object.entries(e[s].npmDependencies)){if(o.has(c)&&o.get(c)!==l)throw Error(`snapshot-npm-conflict: ${c}`);o.set(c,l)}}return[...r].sort()}function Ts(e){let t=Object.fromEntries(Object.entries(e.items).map(([a,o])=>[a,rt(a,o)])),r=Object.fromEntries(Object.entries(e.resources).map(([a,o])=>[a,{...o,closure:nt(t,o.entrypoints)}])),i={schemaVersion:"uibot.distribution.snapshot.v1",bundleHash:e.bundleHash,version:e.version,namespace:"@uibot",resources:r,items:t,license:"MIT AND ISC",licenseFiles:Object.entries(e.licenseFiles).sort(([a],[o])=>a.localeCompare(o)).map(([a,o])=>Se(a,o))},n={...i,snapshotId:de(V(i))};return it(n),n}function it(e,t){if(!e||typeof e!=="object")throw Error("snapshot-invalid-manifest");V(e);let r=e,{snapshotId:i,...n}=r;if(r.schemaVersion!=="uibot.distribution.snapshot.v1"||r.namespace!=="@uibot"||r.license!=="MIT AND ISC"||!ae.test(r.version)||!se.test(r.bundleHash)||!se.test(i)||t!==void 0&&t!==i||de(V(n))!==i)throw Error("snapshot-identity-mismatch");if(!r.items||!r.resources||!Array.isArray(r.licenseFiles)||!r.licenseFiles.length)throw Error("snapshot-invalid-manifest");let a=(s)=>{if(ce(s.path),!se.test(s.sha256)||!Number.isSafeInteger(s.bytes)||s.bytes<0||s.bytes>16777216)throw Error("snapshot-invalid-file-digest")},o=new Set;for(let s of r.licenseFiles){if(a(s),!s.path.startsWith("licenses/")||o.has(s.path))throw Error("snapshot-invalid-license");o.add(s.path)}for(let[s,c]of Object.entries(r.items)){if(a(c),!le.test(s)||c.path!==`r/${s}.json`||!Array.isArray(c.registryDependencies)||!Array.isArray(c.files)||!c.npmDependencies)throw Error("snapshot-invalid-item");for(let l of c.files)a(l),ce(l.target);for(let[l,u]of Object.entries(c.npmDependencies))if(!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(l)||!ae.test(u))throw Error("snapshot-unpinned-npm-dependency")}for(let s of Object.values(r.resources))if(!ae.test(s.version)||!se.test(s.resourceHash)||!Array.isArray(s.entrypoints)||V(nt(r.items,s.entrypoints))!==V(s.closure))throw Error("snapshot-resource-closure-mismatch")}function Os(e,t,r,i){it(e,i);let n=Object.hasOwn(e.resources,t)?e.resources[t]:void 0;if(!n)throw Error(`snapshot-resource-unavailable: ${t}`);let a=(s)=>{let c=r.get(s.path);if(!c||c.byteLength!==s.bytes||de(c)!==s.sha256)throw Error(`snapshot-file-mismatch: ${s.path}`);return c},o={};for(let s of n.closure){let c=e.items[s],l=rt(s,a(c));if(V(l)!==V(c))throw Error(`snapshot-item-metadata-mismatch: ${s}`);Object.assign(o,c.npmDependencies)}return e.licenseFiles.forEach(a),{snapshotId:e.snapshotId,resourceId:t,closure:[...n.closure],npmDependencies:o}}function Gr(e){if(!e.name)throw Error("Artifact registry manifest requires a name");return e}function Yr(e){if(!e.name)throw Error("Plugin distribution manifest requires a name");return e}class Jr{id;priority;items;constructor(e,t,r){this.id=e;this.priority=t;this.items=r}get(e){return this.items[e]}}class Qr{id;priority;items;constructor(e,t,r){this.id=e;this.priority=t;this.items=r}get(e){return this.items[e]}}async function lt(e,t){let r=await fetch(e,t?{headers:t}:{});if(!r.ok)throw Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);return await r.json()}async function Zr(e,t){let r=e.endsWith("/registry.json")?e:`${e.replace(/\/$/,"")}/registry.json`,i=await lt(r,t);return Gr(i)}async function Xr(e,t){let r=e.endsWith("/plugins.json")?e:`${e.replace(/\/$/,"")}/plugins.json`,i=await lt(r,t);return Yr(i)}class en{options;id;priority;manifestPromise;constructor(e){this.options=e;this.id=e.id??e.registryUrl,this.priority=e.priority}getManifest(){return this.manifestPromise??=Zr(this.options.registryUrl,this.options.headers),this.manifestPromise}async get(e){return(await this.getManifest()).items.find((r)=>r.name===e)}}class tn{options;id;priority;manifestPromise;constructor(e){this.options=e;this.id=e.id??e.registryUrl,this.priority=e.priority}getManifest(){return this.manifestPromise??=Xr(this.options.registryUrl,this.options.headers),this.manifestPromise}async get(e){return(await this.getManifest()).plugins.find((r)=>r.pluginId===e)}}class rn{sources;constructor(e){this.sources=e}async resolve(e){let t=[...this.sources].sort((r,i)=>r.priority-i.priority);for(let r of t){let i=await r.get(e);if(i)return i}return}}class nn{sources;constructor(e){this.sources=e}async resolve(e){let t=[...this.sources].sort((r,i)=>r.priority-i.priority);for(let r of t){let i=await r.get(e);if(i)return i}return}}var on="uibot.artifacts.lock.json";function sn(e){return O(e,"components","registry")}function an(e){return O(e,"templates","registry")}function cn(e,t){if(e.kind==="component")return O(t.componentsDir??sn(t.workspaceRoot));return O(t.templatesDir??an(t.workspaceRoot))}function ln(e){return O(e.workspaceRoot,e.lockfilePath??on)}function dn(e){try{return JSON.parse(qr(e,"utf8"))}catch{return{version:1,artifacts:[]}}}function un(e,t){at(Ie(e),{recursive:!0}),ct(e,`${JSON.stringify(t,null,2)}
15
+ `,"utf8")}function pn(e,t){return{version:1,artifacts:[...e.artifacts.filter((i)=>i.name!==t.name),t].sort((i,n)=>i.name.localeCompare(n.name))}}function gn(e){if(e.kind==="component")return{components:{[e.name]:e.catalogEntry}};return{templates:{[e.name]:e.templateContract}}}class U extends Error{artifactName;offendingPath;baseDir;constructor(e,t,r){super(`Artifact "${e}" file path escapes workspace: "${t}" resolves outside "${r}"`);this.artifactName=e;this.offendingPath=t;this.baseDir=r;this.name="ArtifactContainmentError"}}function dt(e,t){let r=t.endsWith(ot)?t:t+ot;return e===t||e.startsWith(r)}function st(e){let t=O(e),r=[];while(!0)try{return zr(t),O(Hr(t),...r)}catch(i){if(i.code!=="ENOENT")throw i;let n=Ie(t);if(n===t)throw i;r.unshift(Kr(t)),t=n}}function ut(e,t,r,i){try{let n=st(t),a=st(e);if(!dt(a,n))throw new U(r,i,t)}catch(n){if(n instanceof U)throw n;throw new U(r,i,t)}}function pt(e,t,r){if(e.includes("\x00"))throw new U(r,e,t);if(Wr(e))throw new U(r,e,t);let i=O(t,e);if(!dt(i,t))throw new U(r,e,t);return ut(i,t,r,e),i}function mn(e,t){let r=[];for(let i of e.files){let n=i.target??i.path;r.push(pt(n,t,e.name))}return r}function Ns(e,t){let r=O(t.workspaceRoot),i=cn(e,t);ut(i,r,e.name,i);let n=pt(e.name,i,e.name),a=mn(e,n),o=[];for(let f=0;f<e.files.length;f++){let p=e.files[f],d=a[f];at(Ie(d),{recursive:!0}),ct(d,p.content??"","utf8"),o.push(d)}let s={name:e.name,version:e.version,source:t.source??"registry",installedAt:new Date().toISOString()},c=ln(t),l=dn(c),u=pn(l,s);return un(c,u),{artifactLock:s,catalogPatch:gn(e),writtenFiles:o}}export{U as ArtifactContainmentError,rn as ArtifactRegistryResolver,Jr as MemoryArtifactRegistrySource,Qr as MemoryPluginRegistrySource,nn as PluginRegistryResolver,cs as RESOURCE_ADMISSION_ERROR_CODES,he as RESOURCE_ADMISSION_SCHEMA_VERSION,or as RESOURCE_EXTERNAL_CHECKS,fs as RESOURCE_INDEX_ERROR_CODES,xr as RESOURCE_INDEX_SCHEMA_VERSION,ir as RESOURCE_PREFLIGHT_CHECKS,Dr as RESOURCE_QUERY_ALIAS_GROUPS,Ss as RESOURCE_QUERY_ERROR_CODES,Vt as RESOURCE_QUERY_OPERATION_MANIFEST,ke as RESOURCE_QUERY_SCORE_WEIGHTS,en as RemoteArtifactRegistrySource,tn as RemotePluginRegistrySource,je as ResourceAdmissionIndexMismatchError,$e as ResourceAdmissionReportNotDerivedError,Ve as ResourceAdmissionReportRejectedError,K as ResourceIndexError,w as ResourceQueryError,ns as SHADCN_REGISTRY_ITEM_SCHEMA,fe as UIBOT_BASE_ITEM,_e as UIBOT_THEME_ITEM,ps as applyResourceAdmissionReport,ce as assertDistributionPath,it as assertDistributionSnapshot,pt as assertPathContained,Mr as assertPublicResourceBundle,us as assessResourceAdmissions,ys as buildExamplesFromL4Templates,hs as buildResourceIndex,rs as buildShadcnRegistry,An as buildUiBotRegistryManifest,Yt as catalogEntryToMeta,Cn as collectAllBlockSources,St as collectBlockSources,Pe as collectTemplateSources,Dt as collectTemplateSourcesFromDirs,mt as compareLockToManifest,Ts as createDistributionSnapshot,vs as createPublicResourceQueryService,Xe as createResourceQueryService,os as createUIBotRegistryHttpHandler,ls as deriveResourceLicense,rt as describeDistributionItem,V as distributionCanonicalJson,nt as distributionClosure,de as distributionSha256,wn as emitArtifactJson,yt as emptyLockfile,ds as evaluateCatalogPreflight,Ce as expandResourceQueryAliases,Zr as fetchArtifactRegistryManifest,Xr as fetchPluginDistributionManifest,Ns as installArtifactToWorkspace,ht as lockfileWith,nr as normalizeRegistryBasePath,C as normalizeResourceAlias,B as normalizeResourceLicense,ts as parseOklchCssVars,Yr as parsePluginDistributionManifest,Gr as parseRegistryManifest,He as resourceAdmissionIndexFingerprint,Ur as snapshotDependencyName,ge as templateSourceToRegistryItem,Ee as toArtifactRegistryItem,Nt as toComponentArtifact,ye as toItemName,T as toResourceId,ve as toTemplateArtifact,Fe as transformBlockSource,Os as verifyDistributionSnapshot};
@@ -10,6 +10,10 @@ export declare class ResourceQueryError extends Error {
10
10
  constructor(code: ResourceQueryErrorCode, detail: string);
11
11
  }
12
12
  export declare const RESOURCE_QUERY_SCORE_WEIGHTS: Readonly<{
13
+ function: number;
14
+ scenario: number;
15
+ unit: number;
16
+ industry: number;
13
17
  "exact-id": number;
14
18
  "exact-title": number;
15
19
  alias: number;
@@ -1,3 +1,6 @@
1
1
  export * from "./resource-index.js";
2
2
  export * from "./resource-query.js";
3
3
  export * from "./public-resources.js";
4
+ export * from "./solution-spec.js";
5
+ export * from "./solution-composition.js";
6
+ export * from "./solution-regions.js";