@vendure-io/docs-provider 0.4.0 → 0.5.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.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE/C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,WAAW,EAAE,CAAC,OAAO,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC,EAAE,CAAA;IACjE,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAA;IAClB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oCAAoC;IACpC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAA;IAC3B,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAA;IACV,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,iDAAiD;IACjD,cAAc,EAAE,cAAc,CAAA;IAC9B,2CAA2C;IAC3C,UAAU,EAAE,cAAc,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,0CAA0C;IAC1C,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,kFAAkF;IAClF,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
@@ -73,18 +73,39 @@ interface NavigationNode {
73
73
  file?: string
74
74
  children?: NavigationNode[]
75
75
  badge?: string
76
+ hidden?: boolean
76
77
  }
77
78
  ```
78
79
 
79
80
  ### Properties
80
81
 
81
- | Property | Type | Required | Description |
82
- | ---------- | ------------------ | -------- | ---------------------------------------------------- |
83
- | `title` | `string` | Yes | Display title shown in navigation |
84
- | `slug` | `string` | Yes | URL slug for this node |
85
- | `file` | `string` | No | Absolute path to MDX file (leaf nodes only) |
86
- | `children` | `NavigationNode[]` | No | Nested child navigation nodes |
87
- | `badge` | `string` | No | Optional badge label (e.g., `"New"`, `"Deprecated"`) |
82
+ | Property | Type | Required | Description |
83
+ | ---------- | ------------------ | -------- | -------------------------------------------------------------------- |
84
+ | `title` | `string` | Yes | Display title shown in navigation |
85
+ | `slug` | `string` | Yes | URL slug for this node |
86
+ | `file` | `string` | No | Absolute path to MDX file (leaf nodes only) |
87
+ | `children` | `NavigationNode[]` | No | Nested child navigation nodes |
88
+ | `badge` | `string` | No | Optional badge label (e.g., `"New"`, `"Deprecated"`) |
89
+ | `hidden` | `boolean` | No | Hide this node from sidebar navigation (page remains URL-accessible) |
90
+
91
+ ### Hidden Pages
92
+
93
+ Use the `hidden` property to exclude pages from the sidebar while keeping them accessible via direct URL. This is useful for:
94
+
95
+ - Draft or work-in-progress pages
96
+ - Pages that should only be linked to from specific contexts
97
+ - Decluttering the navigation while keeping content accessible
98
+
99
+ ```typescript
100
+ {
101
+ title: 'Internal Notes',
102
+ slug: 'internal-notes',
103
+ file: file('docs/internal-notes.mdx'),
104
+ hidden: true, // Won't appear in sidebar, but /docs/internal-notes still works
105
+ }
106
+ ```
107
+
108
+ When a parent node is hidden, all its children are also hidden from the sidebar.
88
109
 
89
110
  ---
90
111
 
@@ -99,6 +120,7 @@ interface NavigationNodeInput {
99
120
  file?: string
100
121
  children?: NavigationNodeInput[]
101
122
  badge?: string
123
+ hidden?: boolean // Hide from sidebar navigation
102
124
  }
103
125
  ```
104
126
 
@@ -479,6 +501,7 @@ interface FlatNavigationNode extends NavigationNode {
479
501
  path: string // Full path from root (e.g., "getting-started/installation")
480
502
  depth: number // Depth level (0 = root)
481
503
  parentPath?: string // Parent node's path, if any
504
+ // Also inherits: title, slug, file?, children?, badge?, hidden?
482
505
  }
483
506
  ```
484
507
 
@@ -649,6 +672,61 @@ const files = getAllFilePaths(manifest)
649
672
 
650
673
  ---
651
674
 
675
+ ### filterVisibleNavigation
676
+
677
+ Filter navigation nodes to only include visible items (not hidden). Use this when rendering sidebar navigation to exclude hidden pages while keeping them URL-accessible.
678
+
679
+ ```typescript
680
+ function filterVisibleNavigation(nodes: NavigationNode[]): NavigationNode[]
681
+ ```
682
+
683
+ **Parameters:**
684
+
685
+ - `nodes` - Array of navigation nodes to filter
686
+
687
+ **Returns:** Filtered array with hidden nodes (and their children) removed
688
+
689
+ **Example:**
690
+
691
+ ```typescript
692
+ import { filterVisibleNavigation } from '@vendure-io/docs-provider/browser'
693
+
694
+ // Filter out hidden nodes before rendering sidebar
695
+ const visibleNavigation = filterVisibleNavigation(manifest.navigation)
696
+
697
+ // Use visibleNavigation for sidebar rendering
698
+ // Hidden pages remain accessible via direct URL
699
+ ```
700
+
701
+ **Behavior Notes:**
702
+
703
+ - Hidden nodes are completely removed from the result
704
+ - When a parent node is hidden, all its children are also excluded
705
+ - The original navigation structure is unmodified (returns a new array)
706
+ - Use the `/browser` entry point for client components to avoid bundling Node.js modules
707
+
708
+ ---
709
+
710
+ ## Browser Entry Point
711
+
712
+ For client-side components (React components with `'use client'`), import from the `/browser` entry point to avoid bundling Node.js modules:
713
+
714
+ ```typescript
715
+ // In client components
716
+ import { filterVisibleNavigation, type NavigationNode } from '@vendure-io/docs-provider/browser'
717
+
718
+ // The /browser entry exports all browser-safe utilities:
719
+ // - Types (NavigationNode, DocsPackageManifest, etc.)
720
+ // - Schemas (NavigationNodeSchema, etc.)
721
+ // - filterVisibleNavigation, getAllFilePaths
722
+ // - Manifest utilities (findNavigationNode, flattenNavigation, etc.)
723
+ // - Slug utilities (toSlug, slugFromFilename, etc.)
724
+ ```
725
+
726
+ The main entry point (`@vendure-io/docs-provider`) includes Node.js-only utilities like `resolveManifest` and `createNavigationFromFolder` which require `fs` access.
727
+
728
+ ---
729
+
652
730
  ## Error Classes
653
731
 
654
732
  ### ManifestValidationError
@@ -75,6 +75,51 @@ A card-style link that provides more visual prominence than a standard link. Use
75
75
  </LinkCard>
76
76
  ```
77
77
 
78
+ ### DocsLink
79
+
80
+ An inline link component that automatically prefixes relative URLs with the current documentation version and package ID. This is the recommended way to create cross-references in generated documentation.
81
+
82
+ **Key features:**
83
+
84
+ - Relative paths (starting with `/`) are automatically prefixed with `/{version}/{packageId}`
85
+ - Uses Next.js `Link` for client-side navigation (no full page reload)
86
+ - External links (`http://`, `https://`) open in a new tab
87
+ - Ideal for documentation generators that don't know the runtime context
88
+
89
+ #### Props
90
+
91
+ | Prop | Type | Required | Description |
92
+ | ---------- | ----------- | -------- | ------------------------------------------------------ |
93
+ | `href` | `string` | Yes | URL to navigate to (relative paths will be prefixed) |
94
+ | `children` | `ReactNode` | Yes | Link text content |
95
+
96
+ #### Example
97
+
98
+ ```mdx
99
+ {/* Simple type reference - will become /current/core/reference/typescript-api/request/request-context */}
100
+ See the <DocsLink href="/reference/typescript-api/request/request-context">RequestContext</DocsLink> documentation.
101
+
102
+ {/* With anchor */}
103
+ Check the <DocsLink href="/reference/typescript-api/entities/product#variants">Product.variants</DocsLink> property.
104
+
105
+ {/* External links work as expected */}
106
+ Visit the <DocsLink href="https://github.com/vendure-ecommerce/vendure">GitHub repository</DocsLink>.
107
+ ```
108
+
109
+ #### Usage in Generators
110
+
111
+ When generating documentation, use `DocsLink` for all cross-references instead of raw HTML anchor tags:
112
+
113
+ ```typescript
114
+ // Instead of:
115
+ const typeHtml = `<a href='/reference/typescript-api/request/request-context'>RequestContext</a>`
116
+
117
+ // Generate:
118
+ const typeMdx = `<DocsLink href="/reference/typescript-api/request/request-context">RequestContext</DocsLink>`
119
+ ```
120
+
121
+ The `DocsLink` component handles URL prefixing at render time, so generators don't need to know the version or package context.
122
+
78
123
  ---
79
124
 
80
125
  ## Reference Documentation Components
@@ -368,6 +413,7 @@ import type {
368
413
  GenerationInfoProps,
369
414
  GraphQLDocProps,
370
415
  LinkCardProps,
416
+ DocsLinkProps,
371
417
  MemberInfoProps,
372
418
  MemberDescriptionProps,
373
419
  CustomFieldPropertyProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure-io/docs-provider",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Contract types and utilities for Vendure documentation packages",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -21,6 +21,16 @@
21
21
  "default": "./dist/index.cjs"
22
22
  }
23
23
  },
24
+ "./browser": {
25
+ "import": {
26
+ "types": "./dist/browser.d.ts",
27
+ "default": "./dist/browser.js"
28
+ },
29
+ "require": {
30
+ "types": "./dist/browser.d.ts",
31
+ "default": "./dist/browser.cjs"
32
+ }
33
+ },
24
34
  "./loader": {
25
35
  "import": {
26
36
  "types": "./dist/loader.d.ts",
@@ -1,3 +0,0 @@
1
- "use strict";var $=Object.defineProperty;var k=(r,e,n)=>e in r?$(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var l=(r,e,n)=>k(r,typeof e!="symbol"?e+"":e,n);const b=require("gray-matter"),t=require("zod"),u=t.z.enum(["v1","v2","v3"]),m=t.z.object({indexFields:t.z.array(t.z.enum(["title","description","content","keywords"])),boosts:t.z.record(t.z.string(),t.z.number()).optional()}),h=t.z.object({repository:t.z.string().regex(/^[^/]+\/[^/]+$/,'Repository must be in format "owner/repo"'),branch:t.z.string().optional(),docsPath:t.z.string().optional()}),g=t.z.lazy(()=>t.z.object({title:t.z.string().min(1,"Navigation title is required"),slug:t.z.string().min(1,"Navigation slug is required"),file:t.z.string().optional(),children:t.z.array(g).optional(),badge:t.z.string().optional()})),f=t.z.object({id:t.z.string().min(1,"Package ID is required"),name:t.z.string().min(1,"Package name is required"),version:t.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:u,navigation:t.z.array(g),search:m.optional(),github:h.optional(),basePath:t.z.string().optional()}),z=t.z.object({title:t.z.string().min(1,"Page title is required"),description:t.z.string().optional(),keywords:t.z.array(t.z.string()).optional(),sidebarLabel:t.z.string().optional(),hidden:t.z.boolean().optional(),order:t.z.number().int().optional()}),x=t.z.object({meta:z,content:t.z.string(),filePath:t.z.string()}),M=t.z.object({manifest:f,basePath:t.z.string()}),I=t.z.object({title:t.z.string(),slug:t.z.string(),path:t.z.string()}),V=t.z.object({title:t.z.string(),slug:t.z.string(),file:t.z.string().optional(),children:t.z.array(t.z.lazy(()=>g)).optional(),badge:t.z.string().optional(),path:t.z.string(),depth:t.z.number().int().min(0),parentPath:t.z.string().optional()}),p=t.z.lazy(()=>t.z.object({title:t.z.string().min(1).optional(),slug:t.z.string().min(1).optional(),file:t.z.string().optional(),children:t.z.array(p).optional(),badge:t.z.string().optional()})),w=t.z.object({id:t.z.string().min(1,"Package ID is required"),name:t.z.string().min(1,"Package name is required"),version:t.z.string().regex(/^\d+\.\d+\.\d+/,"Version must be valid semver"),vendureVersion:u,navigation:t.z.array(p),search:m.optional(),github:h.optional(),basePath:t.z.string().optional()});class d extends Error{constructor(n,i,a){super(n);l(this,"filePath");l(this,"originalError");this.name="FrontmatterParseError",this.filePath=i,this.originalError=a}}function E(r,e){try{const{data:n,content:i}=b(r);return{meta:N(n,e),content:i.trim()}}catch(n){throw n instanceof d?n:new d(`Failed to parse frontmatter${e?` in ${e}`:""}`,e,n)}}function N(r,e){const n=z.safeParse(r);if(!n.success){const i=n.error.issues.map(a=>` - ${a.path.join(".")}: ${a.message}`).join(`
2
- `);throw new d(`Invalid frontmatter${e?` in ${e}`:""}:
3
- ${i}`,e,n.error)}return n.data}function q(r){return r.trimStart().startsWith("---")}function B(r){const{data:e}=b(r);return e}class S extends Error{constructor(n,i){super(n);l(this,"issues");this.name="ManifestValidationError",this.issues=i}}function L(r){const e=f.safeParse(r);if(!e.success){const n=e.error.issues.map(i=>`${i.path.join(".")}: ${i.message}`);throw new S("Invalid manifest",n)}return e.data}function A(r,e){const n=e.split("/").filter(Boolean);return P(r.navigation,n)}function P(r,e){if(e.length===0)return;const[n,...i]=e,a=r.find(o=>o.slug===n);if(a){if(i.length===0)return a;if(a.children)return P(a.children,i)}}function v(r){const e=[];return y(r.navigation,"",0,void 0,e),e}function y(r,e,n,i,a){for(const o of r){const s=e?`${e}/${o.slug}`:o.slug;a.push({...o,path:s,depth:n,parentPath:i}),o.children&&o.children.length>0&&y(o.children,s,n+1,s,a)}}function C(r,e){const n=e.split("/").filter(Boolean),i=[];let a=r.navigation,o="";for(const s of n){const c=a.find(F=>F.slug===s);if(!c)break;o=o?`${o}/${s}`:s,i.push({title:c.title,slug:c.slug,path:o}),a=c.children??[]}return i}function D(r){return v(r).filter(e=>e.file!==void 0)}function G(r,e){const n=D(r),i=n.findIndex(a=>a.path===e);return i===-1?{}:{prev:i>0?n[i-1]:void 0,next:i<n.length-1?n[i+1]:void 0}}function j(r,e){const n=e.split("/").filter(Boolean);if(n.length===0)return!1;if(r.slug===n[0]){if(n.length===1)return!0;if(r.children){const i=n.slice(1).join("/");return r.children.some(a=>j(a,i))}}return!1}function H(r,e){return v(r).filter(n=>n.depth===e)}exports.BreadcrumbItemSchema=I;exports.DocPageMetaSchema=z;exports.DocPageSchema=x;exports.DocsPackageManifestInputSchema=w;exports.DocsPackageManifestSchema=f;exports.FlatNavigationNodeSchema=V;exports.FrontmatterParseError=d;exports.GitHubConfigSchema=h;exports.LoadedDocsPackageSchema=M;exports.ManifestValidationError=S;exports.NavigationNodeInputSchema=p;exports.NavigationNodeSchema=g;exports.SearchConfigSchema=m;exports.VendureVersionSchema=u;exports.buildBreadcrumbs=C;exports.extractFrontmatterData=B;exports.findNavigationNode=A;exports.flattenNavigation=v;exports.getLeafNodes=D;exports.getNodesAtDepth=H;exports.getPrevNextNodes=G;exports.hasFrontmatter=q;exports.isNodeActive=j;exports.parseFrontmatter=E;exports.validateFrontmatter=N;exports.validateManifest=L;
@@ -1,228 +0,0 @@
1
- var y = Object.defineProperty;
2
- var $ = (r, n, e) => n in r ? y(r, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[n] = e;
3
- var l = (r, n, e) => $(r, typeof n != "symbol" ? n + "" : n, e);
4
- import u from "gray-matter";
5
- import { z as t } from "zod";
6
- const m = t.enum(["v1", "v2", "v3"]), f = t.object({
7
- indexFields: t.array(t.enum(["title", "description", "content", "keywords"])),
8
- boosts: t.record(t.string(), t.number()).optional()
9
- }), h = t.object({
10
- repository: t.string().regex(/^[^/]+\/[^/]+$/, 'Repository must be in format "owner/repo"'),
11
- branch: t.string().optional(),
12
- docsPath: t.string().optional()
13
- }), d = t.lazy(
14
- () => t.object({
15
- title: t.string().min(1, "Navigation title is required"),
16
- slug: t.string().min(1, "Navigation slug is required"),
17
- file: t.string().optional(),
18
- children: t.array(d).optional(),
19
- badge: t.string().optional()
20
- })
21
- ), p = t.object({
22
- id: t.string().min(1, "Package ID is required"),
23
- name: t.string().min(1, "Package name is required"),
24
- version: t.string().regex(/^\d+\.\d+\.\d+/, "Version must be valid semver"),
25
- vendureVersion: m,
26
- navigation: t.array(d),
27
- search: f.optional(),
28
- github: h.optional(),
29
- basePath: t.string().optional()
30
- }), v = t.object({
31
- title: t.string().min(1, "Page title is required"),
32
- description: t.string().optional(),
33
- keywords: t.array(t.string()).optional(),
34
- sidebarLabel: t.string().optional(),
35
- hidden: t.boolean().optional(),
36
- order: t.number().int().optional()
37
- }), V = t.object({
38
- meta: v,
39
- content: t.string(),
40
- filePath: t.string()
41
- }), E = t.object({
42
- manifest: p,
43
- basePath: t.string()
44
- }), q = t.object({
45
- title: t.string(),
46
- slug: t.string(),
47
- path: t.string()
48
- }), B = t.object({
49
- title: t.string(),
50
- slug: t.string(),
51
- file: t.string().optional(),
52
- children: t.array(t.lazy(() => d)).optional(),
53
- badge: t.string().optional(),
54
- path: t.string(),
55
- depth: t.number().int().min(0),
56
- parentPath: t.string().optional()
57
- }), b = t.lazy(
58
- () => t.object({
59
- title: t.string().min(1).optional(),
60
- slug: t.string().min(1).optional(),
61
- file: t.string().optional(),
62
- children: t.array(b).optional(),
63
- badge: t.string().optional()
64
- })
65
- ), z = t.object({
66
- id: t.string().min(1, "Package ID is required"),
67
- name: t.string().min(1, "Package name is required"),
68
- version: t.string().regex(/^\d+\.\d+\.\d+/, "Version must be valid semver"),
69
- vendureVersion: m,
70
- navigation: t.array(b),
71
- search: f.optional(),
72
- github: h.optional(),
73
- basePath: t.string().optional()
74
- });
75
- class g extends Error {
76
- constructor(e, i, a) {
77
- super(e);
78
- l(this, "filePath");
79
- l(this, "originalError");
80
- this.name = "FrontmatterParseError", this.filePath = i, this.originalError = a;
81
- }
82
- }
83
- function L(r, n) {
84
- try {
85
- const { data: e, content: i } = u(r);
86
- return {
87
- meta: x(e, n),
88
- content: i.trim()
89
- };
90
- } catch (e) {
91
- throw e instanceof g ? e : new g(
92
- `Failed to parse frontmatter${n ? ` in ${n}` : ""}`,
93
- n,
94
- e
95
- );
96
- }
97
- }
98
- function x(r, n) {
99
- const e = v.safeParse(r);
100
- if (!e.success) {
101
- const i = e.error.issues.map((a) => ` - ${a.path.join(".")}: ${a.message}`).join(`
102
- `);
103
- throw new g(
104
- `Invalid frontmatter${n ? ` in ${n}` : ""}:
105
- ${i}`,
106
- n,
107
- e.error
108
- );
109
- }
110
- return e.data;
111
- }
112
- function A(r) {
113
- return r.trimStart().startsWith("---");
114
- }
115
- function C(r) {
116
- const { data: n } = u(r);
117
- return n;
118
- }
119
- class k extends Error {
120
- constructor(e, i) {
121
- super(e);
122
- l(this, "issues");
123
- this.name = "ManifestValidationError", this.issues = i;
124
- }
125
- }
126
- function G(r) {
127
- const n = p.safeParse(r);
128
- if (!n.success) {
129
- const e = n.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`);
130
- throw new k("Invalid manifest", e);
131
- }
132
- return n.data;
133
- }
134
- function H(r, n) {
135
- const e = n.split("/").filter(Boolean);
136
- return N(r.navigation, e);
137
- }
138
- function N(r, n) {
139
- if (n.length === 0) return;
140
- const [e, ...i] = n, a = r.find((o) => o.slug === e);
141
- if (a) {
142
- if (i.length === 0) return a;
143
- if (a.children)
144
- return N(a.children, i);
145
- }
146
- }
147
- function P(r) {
148
- const n = [];
149
- return S(r.navigation, "", 0, void 0, n), n;
150
- }
151
- function S(r, n, e, i, a) {
152
- for (const o of r) {
153
- const s = n ? `${n}/${o.slug}` : o.slug;
154
- a.push({
155
- ...o,
156
- path: s,
157
- depth: e,
158
- parentPath: i
159
- }), o.children && o.children.length > 0 && S(o.children, s, e + 1, s, a);
160
- }
161
- }
162
- function R(r, n) {
163
- const e = n.split("/").filter(Boolean), i = [];
164
- let a = r.navigation, o = "";
165
- for (const s of e) {
166
- const c = a.find((j) => j.slug === s);
167
- if (!c) break;
168
- o = o ? `${o}/${s}` : s, i.push({
169
- title: c.title,
170
- slug: c.slug,
171
- path: o
172
- }), a = c.children ?? [];
173
- }
174
- return i;
175
- }
176
- function w(r) {
177
- return P(r).filter((n) => n.file !== void 0);
178
- }
179
- function W(r, n) {
180
- const e = w(r), i = e.findIndex((a) => a.path === n);
181
- return i === -1 ? {} : {
182
- prev: i > 0 ? e[i - 1] : void 0,
183
- next: i < e.length - 1 ? e[i + 1] : void 0
184
- };
185
- }
186
- function D(r, n) {
187
- const e = n.split("/").filter(Boolean);
188
- if (e.length === 0) return !1;
189
- if (r.slug === e[0]) {
190
- if (e.length === 1) return !0;
191
- if (r.children) {
192
- const i = e.slice(1).join("/");
193
- return r.children.some((a) => D(a, i));
194
- }
195
- }
196
- return !1;
197
- }
198
- function J(r, n) {
199
- return P(r).filter((e) => e.depth === n);
200
- }
201
- export {
202
- q as B,
203
- v as D,
204
- B as F,
205
- h as G,
206
- E as L,
207
- k as M,
208
- b as N,
209
- f as S,
210
- m as V,
211
- V as a,
212
- z as b,
213
- p as c,
214
- d,
215
- C as e,
216
- g as f,
217
- R as g,
218
- A as h,
219
- H as i,
220
- P as j,
221
- w as k,
222
- J as l,
223
- W as m,
224
- D as n,
225
- G as o,
226
- L as p,
227
- x as v
228
- };