@openpkg-ts/react 0.2.5 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/styled.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  getExampleLanguage,
18
18
  getExampleTitle,
19
19
  groupMembersByKind
20
- } from "./shared/chunk-j3c78zxw.js";
20
+ } from "./shared/chunk-2t4e6p1b.js";
21
21
 
22
22
  // ../../node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs
23
23
  var require__interop_require_wildcard = __commonJS((exports) => {
@@ -3167,7 +3167,7 @@ var require_link = __commonJS((exports, module) => {
3167
3167
  });
3168
3168
 
3169
3169
  // src/adapters/spec-to-docskit.ts
3170
- import { formatSchema } from "@openpkg-ts/sdk";
3170
+ import { formatSchema } from "@openpkg-ts/sdk/browser";
3171
3171
  function specSchemaToAPISchema(schema) {
3172
3172
  if (!schema || typeof schema !== "object")
3173
3173
  return;
@@ -3292,22 +3292,185 @@ function buildImportStatement(exp, spec) {
3292
3292
  }
3293
3293
  return `import { ${alias} } from '${importPath}'`;
3294
3294
  }
3295
+ // src/adapters/spec-to-examples.ts
3296
+ function specExampleToCodeExample(example, index) {
3297
+ if (typeof example === "string") {
3298
+ return {
3299
+ id: `example-${index}`,
3300
+ label: `Example ${index + 1}`,
3301
+ code: example,
3302
+ language: "typescript"
3303
+ };
3304
+ }
3305
+ return {
3306
+ id: example.title?.toLowerCase().replace(/\s+/g, "-") ?? `example-${index}`,
3307
+ label: example.title ?? `Example ${index + 1}`,
3308
+ code: example.code,
3309
+ language: mapLanguage(example.language)
3310
+ };
3311
+ }
3312
+ function specExamplesToCodeExamples2(examples) {
3313
+ if (!examples || examples.length === 0)
3314
+ return [];
3315
+ return examples.map(specExampleToCodeExample);
3316
+ }
3317
+ function generateDefaultExample(packageName, exportName, paramNames) {
3318
+ const importLine = `import { ${exportName} } from '${packageName}';`;
3319
+ const callArgs = paramNames.length > 0 ? paramNames.join(", ") : "";
3320
+ const callLine = `const result = await ${exportName}(${callArgs});`;
3321
+ return {
3322
+ id: "default",
3323
+ label: "Basic",
3324
+ code: `${importLine}
3325
+
3326
+ ${callLine}`,
3327
+ language: "typescript"
3328
+ };
3329
+ }
3330
+ function mapLanguage(lang) {
3331
+ switch (lang) {
3332
+ case "ts":
3333
+ case "tsx":
3334
+ return "typescript";
3335
+ case "js":
3336
+ case "jsx":
3337
+ return "javascript";
3338
+ case "shell":
3339
+ return "bash";
3340
+ case "json":
3341
+ return "json";
3342
+ default:
3343
+ return "typescript";
3344
+ }
3345
+ }
3346
+ // src/adapters/spec-to-params.ts
3347
+ import { formatSchema as formatSchema2 } from "@openpkg-ts/sdk/browser";
3348
+ function specParamToNestedParam(param, parentPath) {
3349
+ const schema = param.schema;
3350
+ const type = formatSchema2(schema);
3351
+ const isRequired = param.required !== false;
3352
+ const children = extractNestedProperties(schema, param.name);
3353
+ const enumValues = extractEnumValues(schema);
3354
+ const expandable = children.length > 0;
3355
+ return {
3356
+ name: param.name,
3357
+ parentPath,
3358
+ type: expandable ? "object" : type,
3359
+ required: isRequired,
3360
+ expandable,
3361
+ description: param.description,
3362
+ anchorId: parentPath ? `${parentPath}${param.name}` : param.name,
3363
+ showAnchor: !!parentPath,
3364
+ children: children.length > 0 ? children : undefined,
3365
+ enumValues: enumValues.length > 0 ? enumValues : undefined,
3366
+ schema
3367
+ };
3368
+ }
3369
+ function specParamsToNestedParams(params) {
3370
+ return params.map((p) => specParamToNestedParam(p));
3371
+ }
3372
+ function extractNestedProperties(schema, parentName) {
3373
+ if (!schema || typeof schema !== "object")
3374
+ return [];
3375
+ const s = schema;
3376
+ if (s.type === "object" && s.properties && typeof s.properties === "object") {
3377
+ const props = s.properties;
3378
+ const required = Array.isArray(s.required) ? s.required : [];
3379
+ return Object.entries(props).map(([name, propSchema]) => {
3380
+ const propParam = {
3381
+ name,
3382
+ schema: propSchema,
3383
+ required: required.includes(name),
3384
+ description: propSchema?.description
3385
+ };
3386
+ return specParamToNestedParam(propParam, `${parentName}.`);
3387
+ });
3388
+ }
3389
+ return [];
3390
+ }
3391
+ function extractEnumValues(schema) {
3392
+ if (!schema || typeof schema !== "object")
3393
+ return [];
3394
+ const s = schema;
3395
+ if (Array.isArray(s.enum)) {
3396
+ return s.enum.map((value) => ({
3397
+ value: String(value),
3398
+ description: undefined
3399
+ }));
3400
+ }
3401
+ return [];
3402
+ }
3403
+ function resolveSchemaRef(schema, types) {
3404
+ if (!schema || typeof schema !== "object")
3405
+ return schema;
3406
+ const s = schema;
3407
+ if (typeof s.$ref === "string") {
3408
+ const refPath = s.$ref;
3409
+ const parts = refPath.split("/");
3410
+ const typeName = parts[parts.length - 1];
3411
+ if (types[typeName]) {
3412
+ return types[typeName];
3413
+ }
3414
+ }
3415
+ return schema;
3416
+ }
3295
3417
  // src/components/styled/index.ts
3296
3418
  import {
3297
3419
  CodeTabs,
3298
3420
  ImportSection
3299
3421
  } from "@openpkg-ts/ui/api";
3300
3422
 
3423
+ // src/hooks/useMethodFromSpec.ts
3424
+ import { buildSignatureString, formatSchema as formatSchema3 } from "@openpkg-ts/sdk/browser";
3425
+ import { useMemo } from "react";
3426
+ function useMethodFromSpec(spec, exportName) {
3427
+ return useMemo(() => {
3428
+ const exp = spec.exports.find((e) => e.name === exportName);
3429
+ if (!exp)
3430
+ return null;
3431
+ return extractMethodData(exp, spec);
3432
+ }, [spec, exportName]);
3433
+ }
3434
+ function useMethodsFromSpec(spec) {
3435
+ return useMemo(() => {
3436
+ return spec.exports.filter((exp) => exp.kind === "function").map((exp) => extractMethodData(exp, spec));
3437
+ }, [spec]);
3438
+ }
3439
+ function extractMethodData(exp, _spec) {
3440
+ const sig = exp.signatures?.[0];
3441
+ const params = sig?.parameters ?? [];
3442
+ const title = exp.kind === "function" ? `${exp.name}()` : exp.name;
3443
+ const signature = buildSignatureString(exp);
3444
+ const description = exp.description || sig?.description;
3445
+ const rawExamples = exp.examples || sig?.examples || [];
3446
+ const examples = rawExamples.map((ex) => typeof ex === "string" ? { code: ex } : ex);
3447
+ const returnType = sig?.returns?.schema;
3448
+ const returnTypeString = returnType ? formatSchema3(returnType) : undefined;
3449
+ const returnDescription = sig?.returns?.description;
3450
+ const isAsync = !!exp.flags?.async;
3451
+ return {
3452
+ export: exp,
3453
+ title,
3454
+ signature,
3455
+ description,
3456
+ parameters: params,
3457
+ examples,
3458
+ returnType,
3459
+ returnTypeString,
3460
+ returnDescription,
3461
+ isAsync
3462
+ };
3463
+ }
3301
3464
  // src/components/styled/sections/ClassSection.tsx
3302
- import { formatSchema as formatSchema2 } from "@openpkg-ts/sdk";
3465
+ import { formatSchema as formatSchema4 } from "@openpkg-ts/sdk/browser";
3303
3466
  import { APIParameterItem, APISection, ParameterList } from "@openpkg-ts/ui/docskit";
3304
3467
  import { jsx, jsxs } from "react/jsx-runtime";
3305
3468
 
3306
3469
  function formatMethodSignature(member) {
3307
3470
  const sig = member.signatures?.[0];
3308
3471
  const params = sig?.parameters ?? [];
3309
- const returnType = formatSchema2(sig?.returns?.schema);
3310
- const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${formatSchema2(p.schema)}`).join(", ");
3472
+ const returnType = formatSchema4(sig?.returns?.schema);
3473
+ const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${formatSchema4(p.schema)}`).join(", ");
3311
3474
  return `(${paramStr}): ${returnType}`;
3312
3475
  }
3313
3476
  function getMemberBadges(member) {
@@ -3418,7 +3581,7 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
3418
3581
  const desc = buildMemberDescription(member);
3419
3582
  return /* @__PURE__ */ jsx(APIParameterItem, {
3420
3583
  name: member.name,
3421
- type: formatSchema2(member.schema),
3584
+ type: formatSchema4(member.schema),
3422
3585
  description: badges.length > 0 ? `[${badges.join(", ")}] ${desc || ""}` : desc
3423
3586
  }, member.name);
3424
3587
  }),
@@ -3454,7 +3617,7 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
3454
3617
  const desc = buildMemberDescription(member);
3455
3618
  return /* @__PURE__ */ jsx(APIParameterItem, {
3456
3619
  name: member.name,
3457
- type: formatSchema2(member.schema),
3620
+ type: formatSchema4(member.schema),
3458
3621
  description: badges.length > 0 ? `[${badges.join(", ")}] ${desc || ""}` : desc
3459
3622
  }, member.name);
3460
3623
  })
@@ -3559,7 +3722,7 @@ function EnumPage({ export: exp, spec }) {
3559
3722
  // src/components/styled/ExportIndexPage.tsx
3560
3723
  import { cn as cn2 } from "@openpkg-ts/ui/lib/utils";
3561
3724
  import { Search } from "lucide-react";
3562
- import { useMemo, useState } from "react";
3725
+ import { useMemo as useMemo2, useState } from "react";
3563
3726
 
3564
3727
  // src/components/styled/ExportCard.tsx
3565
3728
  var import_link = __toESM(require_link(), 1);
@@ -3667,8 +3830,8 @@ function ExportIndexPage({
3667
3830
  const [searchQuery, setSearchQuery] = useState("");
3668
3831
  const [activeFilter, setActiveFilter] = useState("all");
3669
3832
  if (false) {}
3670
- const allGroups = useMemo(() => groupByKind(spec.exports), [spec.exports]);
3671
- const filteredGroups = useMemo(() => {
3833
+ const allGroups = useMemo2(() => groupByKind(spec.exports), [spec.exports]);
3834
+ const filteredGroups = useMemo2(() => {
3672
3835
  const query = searchQuery.toLowerCase().trim();
3673
3836
  return allGroups.filter((group) => activeFilter === "all" || group.kind === activeFilter).map((group) => ({
3674
3837
  ...group,
@@ -3679,7 +3842,7 @@ function ExportIndexPage({
3679
3842
  })
3680
3843
  })).filter((group) => group.exports.length > 0);
3681
3844
  }, [allGroups, searchQuery, activeFilter]);
3682
- const availableKinds = useMemo(() => allGroups.map((g) => g.kind), [allGroups]);
3845
+ const availableKinds = useMemo2(() => allGroups.map((g) => g.kind), [allGroups]);
3683
3846
  const totalExports = filteredGroups.reduce((sum, g) => sum + g.exports.length, 0);
3684
3847
  return /* @__PURE__ */ jsxs4("div", {
3685
3848
  className: cn2("doccov-index-page space-y-8 not-prose", className),
@@ -3783,7 +3946,7 @@ function ExportIndexPage({
3783
3946
  }
3784
3947
 
3785
3948
  // src/components/styled/sections/FunctionSection.tsx
3786
- import { formatSchema as formatSchema3 } from "@openpkg-ts/sdk";
3949
+ import { formatSchema as formatSchema5 } from "@openpkg-ts/sdk/browser";
3787
3950
  import { APIParameterItem as APIParameterItem3, APISection as APISection3, ParameterList as ParameterList3, ResponseBlock } from "@openpkg-ts/ui/docskit";
3788
3951
  import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
3789
3952
 
@@ -3841,7 +4004,7 @@ ${exp.name}(${sig?.parameters?.map((p) => p.name).join(", ") || ""})`,
3841
4004
  children: [
3842
4005
  /* @__PURE__ */ jsx7("span", {
3843
4006
  className: "font-mono text-sm font-medium",
3844
- children: formatSchema3(sig.returns.schema)
4007
+ children: formatSchema5(sig.returns.schema)
3845
4008
  }),
3846
4009
  sig.returns.description && /* @__PURE__ */ jsx7("span", {
3847
4010
  className: "ml-2 text-muted-foreground",
@@ -3907,15 +4070,15 @@ function FunctionPage({ export: exp, spec }) {
3907
4070
  }
3908
4071
 
3909
4072
  // src/components/styled/sections/InterfaceSection.tsx
3910
- import { formatSchema as formatSchema4 } from "@openpkg-ts/sdk";
4073
+ import { formatSchema as formatSchema6 } from "@openpkg-ts/sdk/browser";
3911
4074
  import { APIParameterItem as APIParameterItem4, APISection as APISection4, ParameterList as ParameterList4 } from "@openpkg-ts/ui/docskit";
3912
4075
  import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
3913
4076
 
3914
4077
  function formatMethodSignature2(member) {
3915
4078
  const sig = member.signatures?.[0];
3916
4079
  const params = sig?.parameters ?? [];
3917
- const returnType = formatSchema4(sig?.returns?.schema);
3918
- const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${formatSchema4(p.schema)}`).join(", ");
4080
+ const returnType = formatSchema6(sig?.returns?.schema);
4081
+ const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${formatSchema6(p.schema)}`).join(", ");
3919
4082
  return `(${paramStr}): ${returnType}`;
3920
4083
  }
3921
4084
  function formatDecorators2(decorators) {
@@ -3942,7 +4105,7 @@ function InterfaceSection({ export: exp, spec }) {
3942
4105
  const examples = specExamplesToCodeExamples(exp.examples);
3943
4106
  const importStatement = buildImportStatement(exp, spec);
3944
4107
  const typeDefinition = properties.length > 0 ? `${exp.kind === "type" ? "type" : "interface"} ${exp.name} {
3945
- ${properties.map((p) => ` ${p.name}${p.required === false ? "?" : ""}: ${formatSchema4(p.schema)};`).join(`
4108
+ ${properties.map((p) => ` ${p.name}${p.required === false ? "?" : ""}: ${formatSchema6(p.schema)};`).join(`
3946
4109
  `)}
3947
4110
  }` : `${exp.kind === "type" ? "type" : "interface"} ${exp.name} { }`;
3948
4111
  const displayExamples = examples.length > 0 ? examples : [
@@ -3994,7 +4157,7 @@ ${typeDefinition}`,
3994
4157
  properties.length > 0 && /* @__PURE__ */ jsx9(ParameterList4, {
3995
4158
  title: "Properties",
3996
4159
  children: properties.map((prop, index) => {
3997
- const type = formatSchema4(prop.schema);
4160
+ const type = formatSchema6(prop.schema);
3998
4161
  const children = specSchemaToAPISchema(prop.schema);
3999
4162
  const hasNestedProperties = children?.properties && Object.keys(children.properties).length > 0;
4000
4163
  return /* @__PURE__ */ jsx9(APIParameterItem4, {
@@ -4032,12 +4195,12 @@ function InterfacePage({ export: exp, spec }) {
4032
4195
  }
4033
4196
 
4034
4197
  // src/components/styled/sections/VariableSection.tsx
4035
- import { formatSchema as formatSchema5 } from "@openpkg-ts/sdk";
4198
+ import { formatSchema as formatSchema7 } from "@openpkg-ts/sdk/browser";
4036
4199
  import { APIParameterItem as APIParameterItem5, APISection as APISection5, ParameterList as ParameterList5 } from "@openpkg-ts/ui/docskit";
4037
4200
  import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
4038
4201
 
4039
4202
  function VariableSection({ export: exp, spec }) {
4040
- const typeValue = typeof exp.type === "string" ? exp.type : formatSchema5(exp.schema);
4203
+ const typeValue = typeof exp.type === "string" ? exp.type : formatSchema7(exp.schema);
4041
4204
  const languages = getLanguagesFromExamples(exp.examples);
4042
4205
  const examples = specExamplesToCodeExamples(exp.examples);
4043
4206
  const importStatement = buildImportStatement(exp, spec);
@@ -4191,43 +4354,1267 @@ function APIPage({
4191
4354
  });
4192
4355
  }
4193
4356
  }
4357
+ // src/components/styled/APIParameterItem.tsx
4358
+ import { cn as cn3 } from "@openpkg-ts/ui/lib/utils";
4359
+ import { Link as Link2 } from "lucide-react";
4360
+ import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
4361
+
4362
+ function APIParameterItem6({
4363
+ name,
4364
+ parentPath,
4365
+ type,
4366
+ required,
4367
+ optional,
4368
+ expandable,
4369
+ description,
4370
+ children,
4371
+ anchorId,
4372
+ showAnchor = false,
4373
+ className
4374
+ }) {
4375
+ const handleAnchorClick = () => {
4376
+ if (anchorId && typeof window !== "undefined") {
4377
+ window.location.hash = anchorId;
4378
+ navigator.clipboard?.writeText(window.location.href);
4379
+ }
4380
+ };
4381
+ return /* @__PURE__ */ jsxs9("div", {
4382
+ id: anchorId,
4383
+ className: cn3("openpkg-param", "py-5 border-b border-[var(--openpkg-border-subtle,#262626)]", "last:border-b-0", className),
4384
+ children: [
4385
+ /* @__PURE__ */ jsxs9("div", {
4386
+ className: "openpkg-param-header flex items-center gap-2.5 mb-2 flex-wrap",
4387
+ children: [
4388
+ showAnchor && /* @__PURE__ */ jsx14("button", {
4389
+ type: "button",
4390
+ onClick: handleAnchorClick,
4391
+ className: cn3("openpkg-anchor-link", "flex items-center justify-center w-4 h-4", "opacity-0 group-hover:opacity-100 hover:opacity-100", "text-[var(--openpkg-text-muted,#666666)]", "hover:text-[var(--openpkg-accent-blue,#6cb6ff)]", "cursor-pointer transition-opacity"),
4392
+ "aria-label": "Copy link",
4393
+ children: /* @__PURE__ */ jsx14(Link2, {
4394
+ size: 14
4395
+ })
4396
+ }),
4397
+ /* @__PURE__ */ jsxs9("span", {
4398
+ className: "openpkg-param-name font-mono text-sm font-semibold",
4399
+ children: [
4400
+ parentPath && /* @__PURE__ */ jsx14("span", {
4401
+ className: "text-[var(--openpkg-text-muted,#666666)]",
4402
+ children: parentPath
4403
+ }),
4404
+ /* @__PURE__ */ jsx14("span", {
4405
+ className: "text-[var(--openpkg-text-primary,#ededed)]",
4406
+ children: name
4407
+ })
4408
+ ]
4409
+ }),
4410
+ required && /* @__PURE__ */ jsx14("span", {
4411
+ className: cn3("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge,#262626)]", "text-[var(--openpkg-text-muted,#666666)]"),
4412
+ children: "Required"
4413
+ }),
4414
+ optional && /* @__PURE__ */ jsx14("span", {
4415
+ className: cn3("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge,#262626)]", "text-[var(--openpkg-text-muted,#666666)]"),
4416
+ children: "Optional"
4417
+ }),
4418
+ expandable && /* @__PURE__ */ jsx14("span", {
4419
+ className: cn3("openpkg-badge-expandable", "text-[10px] font-medium", "px-2 py-0.5 rounded", "text-[var(--openpkg-accent-purple,#c4a7e7)]", "bg-[rgba(196,167,231,0.12)]"),
4420
+ children: "Expandable"
4421
+ }),
4422
+ /* @__PURE__ */ jsx14("span", {
4423
+ className: "openpkg-param-type text-[13px] text-[var(--openpkg-text-muted,#666666)]",
4424
+ children: type
4425
+ })
4426
+ ]
4427
+ }),
4428
+ description && /* @__PURE__ */ jsx14("p", {
4429
+ className: cn3("openpkg-param-description", "text-sm text-[var(--openpkg-text-secondary,#a0a0a0)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-[13px] [&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded"),
4430
+ children: description
4431
+ }),
4432
+ children
4433
+ ]
4434
+ });
4435
+ }
4436
+ // src/components/styled/APIReferenceLayout.tsx
4437
+ import { cn as cn4 } from "@openpkg-ts/ui/lib/utils";
4438
+ import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
4439
+
4440
+ function APIReferenceLayout({
4441
+ children,
4442
+ examples,
4443
+ className,
4444
+ leftWidth = "58%",
4445
+ rightWidth = "42%"
4446
+ }) {
4447
+ return /* @__PURE__ */ jsxs10("div", {
4448
+ className: cn4("openpkg-api-layout", "max-w-[1600px] mx-auto", "flex flex-col", "lg:grid", className),
4449
+ style: {
4450
+ "--openpkg-left-width": leftWidth,
4451
+ "--openpkg-right-width": rightWidth
4452
+ },
4453
+ children: [
4454
+ /* @__PURE__ */ jsx15("div", {
4455
+ className: cn4("openpkg-api-layout-left", "py-8 px-4", "sm:py-10 sm:px-6", "lg:py-12 lg:px-12 lg:pl-16", "lg:border-r lg:border-[var(--openpkg-border-subtle,#262626)]", "openpkg-animate-fade-in"),
4456
+ style: {
4457
+ gridColumn: "1"
4458
+ },
4459
+ children
4460
+ }),
4461
+ /* @__PURE__ */ jsx15("div", {
4462
+ className: cn4("openpkg-api-layout-right", "border-t border-[var(--openpkg-border-subtle,#262626)] lg:border-t-0", "py-8 px-4", "sm:py-10 sm:px-6", "lg:sticky lg:top-0 lg:h-screen lg:overflow-y-auto", "lg:py-12 lg:px-12 lg:pl-8", "bg-[var(--openpkg-bg-root,#0c0c0c)]", "openpkg-animate-fade-in"),
4463
+ style: {
4464
+ gridColumn: "2",
4465
+ animationDelay: "100ms"
4466
+ },
4467
+ children: examples
4468
+ }),
4469
+ /* @__PURE__ */ jsx15("style", {
4470
+ dangerouslySetInnerHTML: {
4471
+ __html: `
4472
+ @media (min-width: 1024px) {
4473
+ .openpkg-api-layout {
4474
+ grid-template-columns: var(--openpkg-left-width, 58%) var(--openpkg-right-width, 42%);
4475
+ align-items: start;
4476
+ }
4477
+ }
4478
+ `
4479
+ }
4480
+ })
4481
+ ]
4482
+ });
4483
+ }
4484
+ // src/components/styled/CodePanel.tsx
4485
+ import { cn as cn5 } from "@openpkg-ts/ui/lib/utils";
4486
+ import { useMemo as useMemo3 } from "react";
4487
+ import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
4488
+
4489
+ function CodePanel({
4490
+ code,
4491
+ language = "typescript",
4492
+ showLineNumbers = false,
4493
+ className
4494
+ }) {
4495
+ const lines = useMemo3(() => code.split(`
4496
+ `), [code]);
4497
+ const highlightedLines = useMemo3(() => lines.map((line) => highlightLine(line, language)), [lines, language]);
4498
+ return /* @__PURE__ */ jsx16("div", {
4499
+ className: cn5("openpkg-code-panel", "bg-[var(--openpkg-bg-code,#0f0f18)]", "border border-[var(--openpkg-border-subtle,#262626)]", "rounded-lg overflow-hidden", "mb-3", className),
4500
+ children: /* @__PURE__ */ jsx16("div", {
4501
+ className: "openpkg-code-block p-5 overflow-x-auto",
4502
+ children: /* @__PURE__ */ jsx16("pre", {
4503
+ className: cn5("font-mono text-[13px] leading-relaxed", "text-[var(--openpkg-text-code,#e4e4e7)]", "m-0"),
4504
+ children: highlightedLines.map((html, i) => /* @__PURE__ */ jsxs11("div", {
4505
+ className: "openpkg-code-line flex",
4506
+ children: [
4507
+ showLineNumbers && /* @__PURE__ */ jsx16("span", {
4508
+ className: cn5("openpkg-line-number", "w-7 shrink-0", "text-[var(--openpkg-text-muted,#666666)]", "text-right pr-5", "select-none opacity-50"),
4509
+ children: i + 1
4510
+ }),
4511
+ /* @__PURE__ */ jsx16("span", {
4512
+ className: "openpkg-line-content flex-1",
4513
+ dangerouslySetInnerHTML: { __html: html }
4514
+ })
4515
+ ]
4516
+ }, i))
4517
+ })
4518
+ })
4519
+ });
4520
+ }
4521
+ function highlightLine(line, language) {
4522
+ if (!line.trim())
4523
+ return " ";
4524
+ let result = escapeHtml(line);
4525
+ if (language === "typescript" || language === "javascript" || language === "ts" || language === "js") {
4526
+ result = highlightTS(result);
4527
+ } else if (language === "json") {
4528
+ result = highlightJSON(result);
4529
+ } else if (language === "sql") {
4530
+ result = highlightSQL(result);
4531
+ }
4532
+ return result;
4533
+ }
4534
+ function escapeHtml(str) {
4535
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
4536
+ }
4537
+ function highlightTS(line) {
4538
+ line = line.replace(/(\/\/.*$)/g, '<span class="openpkg-syn-comment" style="color:var(--openpkg-syn-comment,#6e6a86);font-style:italic">$1</span>');
4539
+ line = line.replace(/(&#039;[^&#]*&#039;|&quot;[^&]*&quot;|`[^`]*`)/g, '<span class="openpkg-syn-string" style="color:var(--openpkg-syn-string,#9ccfd8)">$1</span>');
4540
+ const keywords = /\b(import|export|from|const|let|var|function|async|await|return|if|else|for|while|class|interface|type|extends|implements|new|this|true|false|null|undefined)\b/g;
4541
+ line = line.replace(keywords, '<span class="openpkg-syn-keyword" style="color:var(--openpkg-syn-keyword,#c4a7e7)">$1</span>');
4542
+ line = line.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/g, '<span class="openpkg-syn-function" style="color:var(--openpkg-syn-function,#ebbcba)">$1</span>');
4543
+ line = line.replace(/\b(\d+\.?\d*)\b/g, '<span class="openpkg-syn-number" style="color:var(--openpkg-syn-number,#f6c177)">$1</span>');
4544
+ line = line.replace(/([{}[\]();:,.])/g, '<span class="openpkg-syn-punctuation" style="color:var(--openpkg-syn-punctuation,#6e6a86)">$1</span>');
4545
+ return line;
4546
+ }
4547
+ function highlightJSON(line) {
4548
+ line = line.replace(/(&quot;[^&]+&quot;)\s*:/g, '<span class="openpkg-syn-property" style="color:var(--openpkg-syn-property,#c4a7e7)">$1</span>:');
4549
+ line = line.replace(/:\s*(&quot;[^&]*&quot;)/g, ': <span class="openpkg-syn-string" style="color:var(--openpkg-syn-string,#9ccfd8)">$1</span>');
4550
+ line = line.replace(/:\s*(\d+\.?\d*)/g, ': <span class="openpkg-syn-number" style="color:var(--openpkg-syn-number,#f6c177)">$1</span>');
4551
+ line = line.replace(/:\s*(true|false)/g, ': <span class="openpkg-syn-boolean" style="color:var(--openpkg-syn-boolean,#eb6f92)">$1</span>');
4552
+ line = line.replace(/:\s*(null)/g, ': <span class="openpkg-syn-keyword" style="color:var(--openpkg-syn-keyword,#c4a7e7)">$1</span>');
4553
+ line = line.replace(/([{}[\]:,])/g, '<span class="openpkg-syn-punctuation" style="color:var(--openpkg-syn-punctuation,#6e6a86)">$1</span>');
4554
+ return line;
4555
+ }
4556
+ function highlightSQL(line) {
4557
+ const keywords = /\b(SELECT|FROM|WHERE|AND|OR|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|TABLE|INDEX|DROP|ALTER|JOIN|LEFT|RIGHT|INNER|OUTER|ON|AS|ORDER|BY|GROUP|HAVING|LIMIT|OFFSET|PRIMARY|KEY|FOREIGN|REFERENCES|NOT|NULL|DEFAULT|UNIQUE|CHECK|CONSTRAINT)\b/gi;
4558
+ line = line.replace(keywords, '<span class="openpkg-syn-keyword" style="color:var(--openpkg-syn-keyword,#c4a7e7)">$1</span>');
4559
+ line = line.replace(/(&#039;[^&#]*&#039;)/g, '<span class="openpkg-syn-string" style="color:var(--openpkg-syn-string,#9ccfd8)">$1</span>');
4560
+ line = line.replace(/\b(\d+\.?\d*)\b/g, '<span class="openpkg-syn-number" style="color:var(--openpkg-syn-number,#f6c177)">$1</span>');
4561
+ return line;
4562
+ }
4563
+ // src/components/styled/CollapsiblePanel.tsx
4564
+ import { cn as cn6 } from "@openpkg-ts/ui/lib/utils";
4565
+
4566
+ // ../../node_modules/@radix-ui/react-collapsible/dist/index.mjs
4567
+ import * as React10 from "react";
4568
+
4569
+ // ../../node_modules/@radix-ui/primitive/dist/index.mjs
4570
+ var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
4571
+ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
4572
+ return function handleEvent(event) {
4573
+ originalEventHandler?.(event);
4574
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) {
4575
+ return ourEventHandler?.(event);
4576
+ }
4577
+ };
4578
+ }
4579
+
4580
+ // ../../node_modules/@radix-ui/react-context/dist/index.mjs
4581
+ import * as React from "react";
4582
+ import { jsx as jsx17 } from "react/jsx-runtime";
4583
+ function createContextScope(scopeName, createContextScopeDeps = []) {
4584
+ let defaultContexts = [];
4585
+ function createContext3(rootComponentName, defaultContext) {
4586
+ const BaseContext = React.createContext(defaultContext);
4587
+ const index = defaultContexts.length;
4588
+ defaultContexts = [...defaultContexts, defaultContext];
4589
+ const Provider = (props) => {
4590
+ const { scope, children, ...context } = props;
4591
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
4592
+ const value = React.useMemo(() => context, Object.values(context));
4593
+ return /* @__PURE__ */ jsx17(Context.Provider, { value, children });
4594
+ };
4595
+ Provider.displayName = rootComponentName + "Provider";
4596
+ function useContext2(consumerName, scope) {
4597
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
4598
+ const context = React.useContext(Context);
4599
+ if (context)
4600
+ return context;
4601
+ if (defaultContext !== undefined)
4602
+ return defaultContext;
4603
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
4604
+ }
4605
+ return [Provider, useContext2];
4606
+ }
4607
+ const createScope = () => {
4608
+ const scopeContexts = defaultContexts.map((defaultContext) => {
4609
+ return React.createContext(defaultContext);
4610
+ });
4611
+ return function useScope(scope) {
4612
+ const contexts = scope?.[scopeName] || scopeContexts;
4613
+ return React.useMemo(() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }), [scope, contexts]);
4614
+ };
4615
+ };
4616
+ createScope.scopeName = scopeName;
4617
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
4618
+ }
4619
+ function composeContextScopes(...scopes) {
4620
+ const baseScope = scopes[0];
4621
+ if (scopes.length === 1)
4622
+ return baseScope;
4623
+ const createScope = () => {
4624
+ const scopeHooks = scopes.map((createScope2) => ({
4625
+ useScope: createScope2(),
4626
+ scopeName: createScope2.scopeName
4627
+ }));
4628
+ return function useComposedScopes(overrideScopes) {
4629
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
4630
+ const scopeProps = useScope(overrideScopes);
4631
+ const currentScope = scopeProps[`__scope${scopeName}`];
4632
+ return { ...nextScopes2, ...currentScope };
4633
+ }, {});
4634
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
4635
+ };
4636
+ };
4637
+ createScope.scopeName = baseScope.scopeName;
4638
+ return createScope;
4639
+ }
4640
+
4641
+ // ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
4642
+ import * as React4 from "react";
4643
+
4644
+ // ../../node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
4645
+ import * as React2 from "react";
4646
+ var useLayoutEffect2 = globalThis?.document ? React2.useLayoutEffect : () => {};
4647
+
4648
+ // ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
4649
+ import * as React22 from "react";
4650
+
4651
+ // ../../node_modules/@radix-ui/react-use-effect-event/dist/index.mjs
4652
+ import * as React3 from "react";
4653
+ var useReactEffectEvent = React3[" useEffectEvent ".trim().toString()];
4654
+ var useReactInsertionEffect = React3[" useInsertionEffect ".trim().toString()];
4655
+
4656
+ // ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
4657
+ var useInsertionEffect = React4[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
4658
+ function useControllableState({
4659
+ prop,
4660
+ defaultProp,
4661
+ onChange = () => {},
4662
+ caller
4663
+ }) {
4664
+ const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
4665
+ defaultProp,
4666
+ onChange
4667
+ });
4668
+ const isControlled = prop !== undefined;
4669
+ const value = isControlled ? prop : uncontrolledProp;
4670
+ if (true) {
4671
+ const isControlledRef = React4.useRef(prop !== undefined);
4672
+ React4.useEffect(() => {
4673
+ const wasControlled = isControlledRef.current;
4674
+ if (wasControlled !== isControlled) {
4675
+ const from = wasControlled ? "controlled" : "uncontrolled";
4676
+ const to = isControlled ? "controlled" : "uncontrolled";
4677
+ console.warn(`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);
4678
+ }
4679
+ isControlledRef.current = isControlled;
4680
+ }, [isControlled, caller]);
4681
+ }
4682
+ const setValue = React4.useCallback((nextValue) => {
4683
+ if (isControlled) {
4684
+ const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
4685
+ if (value2 !== prop) {
4686
+ onChangeRef.current?.(value2);
4687
+ }
4688
+ } else {
4689
+ setUncontrolledProp(nextValue);
4690
+ }
4691
+ }, [isControlled, prop, setUncontrolledProp, onChangeRef]);
4692
+ return [value, setValue];
4693
+ }
4694
+ function useUncontrolledState({
4695
+ defaultProp,
4696
+ onChange
4697
+ }) {
4698
+ const [value, setValue] = React4.useState(defaultProp);
4699
+ const prevValueRef = React4.useRef(value);
4700
+ const onChangeRef = React4.useRef(onChange);
4701
+ useInsertionEffect(() => {
4702
+ onChangeRef.current = onChange;
4703
+ }, [onChange]);
4704
+ React4.useEffect(() => {
4705
+ if (prevValueRef.current !== value) {
4706
+ onChangeRef.current?.(value);
4707
+ prevValueRef.current = value;
4708
+ }
4709
+ }, [value, prevValueRef]);
4710
+ return [value, setValue, onChangeRef];
4711
+ }
4712
+ function isFunction(value) {
4713
+ return typeof value === "function";
4714
+ }
4715
+ var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
4716
+
4717
+ // ../../node_modules/@radix-ui/react-compose-refs/dist/index.mjs
4718
+ import * as React5 from "react";
4719
+ function setRef(ref, value) {
4720
+ if (typeof ref === "function") {
4721
+ return ref(value);
4722
+ } else if (ref !== null && ref !== undefined) {
4723
+ ref.current = value;
4724
+ }
4725
+ }
4726
+ function composeRefs(...refs) {
4727
+ return (node) => {
4728
+ let hasCleanup = false;
4729
+ const cleanups = refs.map((ref) => {
4730
+ const cleanup = setRef(ref, node);
4731
+ if (!hasCleanup && typeof cleanup == "function") {
4732
+ hasCleanup = true;
4733
+ }
4734
+ return cleanup;
4735
+ });
4736
+ if (hasCleanup) {
4737
+ return () => {
4738
+ for (let i = 0;i < cleanups.length; i++) {
4739
+ const cleanup = cleanups[i];
4740
+ if (typeof cleanup == "function") {
4741
+ cleanup();
4742
+ } else {
4743
+ setRef(refs[i], null);
4744
+ }
4745
+ }
4746
+ };
4747
+ }
4748
+ };
4749
+ }
4750
+ function useComposedRefs(...refs) {
4751
+ return React5.useCallback(composeRefs(...refs), refs);
4752
+ }
4753
+
4754
+ // ../../node_modules/@radix-ui/react-primitive/dist/index.mjs
4755
+ import * as React7 from "react";
4756
+ import * as ReactDOM from "react-dom";
4757
+
4758
+ // ../../node_modules/@radix-ui/react-primitive/node_modules/@radix-ui/react-slot/dist/index.mjs
4759
+ import * as React6 from "react";
4760
+ import { Fragment as Fragment2, jsx as jsx18 } from "react/jsx-runtime";
4761
+ function createSlot(ownerName) {
4762
+ const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
4763
+ const Slot2 = React6.forwardRef((props, forwardedRef) => {
4764
+ const { children, ...slotProps } = props;
4765
+ const childrenArray = React6.Children.toArray(children);
4766
+ const slottable = childrenArray.find(isSlottable);
4767
+ if (slottable) {
4768
+ const newElement = slottable.props.children;
4769
+ const newChildren = childrenArray.map((child) => {
4770
+ if (child === slottable) {
4771
+ if (React6.Children.count(newElement) > 1)
4772
+ return React6.Children.only(null);
4773
+ return React6.isValidElement(newElement) ? newElement.props.children : null;
4774
+ } else {
4775
+ return child;
4776
+ }
4777
+ });
4778
+ return /* @__PURE__ */ jsx18(SlotClone, { ...slotProps, ref: forwardedRef, children: React6.isValidElement(newElement) ? React6.cloneElement(newElement, undefined, newChildren) : null });
4779
+ }
4780
+ return /* @__PURE__ */ jsx18(SlotClone, { ...slotProps, ref: forwardedRef, children });
4781
+ });
4782
+ Slot2.displayName = `${ownerName}.Slot`;
4783
+ return Slot2;
4784
+ }
4785
+ function createSlotClone(ownerName) {
4786
+ const SlotClone = React6.forwardRef((props, forwardedRef) => {
4787
+ const { children, ...slotProps } = props;
4788
+ if (React6.isValidElement(children)) {
4789
+ const childrenRef = getElementRef(children);
4790
+ const props2 = mergeProps(slotProps, children.props);
4791
+ if (children.type !== React6.Fragment) {
4792
+ props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
4793
+ }
4794
+ return React6.cloneElement(children, props2);
4795
+ }
4796
+ return React6.Children.count(children) > 1 ? React6.Children.only(null) : null;
4797
+ });
4798
+ SlotClone.displayName = `${ownerName}.SlotClone`;
4799
+ return SlotClone;
4800
+ }
4801
+ var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
4802
+ function isSlottable(child) {
4803
+ return React6.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
4804
+ }
4805
+ function mergeProps(slotProps, childProps) {
4806
+ const overrideProps = { ...childProps };
4807
+ for (const propName in childProps) {
4808
+ const slotPropValue = slotProps[propName];
4809
+ const childPropValue = childProps[propName];
4810
+ const isHandler = /^on[A-Z]/.test(propName);
4811
+ if (isHandler) {
4812
+ if (slotPropValue && childPropValue) {
4813
+ overrideProps[propName] = (...args) => {
4814
+ const result = childPropValue(...args);
4815
+ slotPropValue(...args);
4816
+ return result;
4817
+ };
4818
+ } else if (slotPropValue) {
4819
+ overrideProps[propName] = slotPropValue;
4820
+ }
4821
+ } else if (propName === "style") {
4822
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
4823
+ } else if (propName === "className") {
4824
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
4825
+ }
4826
+ }
4827
+ return { ...slotProps, ...overrideProps };
4828
+ }
4829
+ function getElementRef(element) {
4830
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
4831
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
4832
+ if (mayWarn) {
4833
+ return element.ref;
4834
+ }
4835
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
4836
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
4837
+ if (mayWarn) {
4838
+ return element.props.ref;
4839
+ }
4840
+ return element.props.ref || element.ref;
4841
+ }
4842
+
4843
+ // ../../node_modules/@radix-ui/react-primitive/dist/index.mjs
4844
+ import { jsx as jsx19 } from "react/jsx-runtime";
4845
+ var NODES = [
4846
+ "a",
4847
+ "button",
4848
+ "div",
4849
+ "form",
4850
+ "h2",
4851
+ "h3",
4852
+ "img",
4853
+ "input",
4854
+ "label",
4855
+ "li",
4856
+ "nav",
4857
+ "ol",
4858
+ "p",
4859
+ "select",
4860
+ "span",
4861
+ "svg",
4862
+ "ul"
4863
+ ];
4864
+ var Primitive = NODES.reduce((primitive, node) => {
4865
+ const Slot = createSlot(`Primitive.${node}`);
4866
+ const Node = React7.forwardRef((props, forwardedRef) => {
4867
+ const { asChild, ...primitiveProps } = props;
4868
+ const Comp = asChild ? Slot : node;
4869
+ if (typeof window !== "undefined") {
4870
+ window[Symbol.for("radix-ui")] = true;
4871
+ }
4872
+ return /* @__PURE__ */ jsx19(Comp, { ...primitiveProps, ref: forwardedRef });
4873
+ });
4874
+ Node.displayName = `Primitive.${node}`;
4875
+ return { ...primitive, [node]: Node };
4876
+ }, {});
4877
+
4878
+ // ../../node_modules/@radix-ui/react-presence/dist/index.mjs
4879
+ import * as React23 from "react";
4880
+ import * as React8 from "react";
4881
+
4882
+ function useStateMachine(initialState, machine) {
4883
+ return React8.useReducer((state, event) => {
4884
+ const nextState = machine[state][event];
4885
+ return nextState ?? state;
4886
+ }, initialState);
4887
+ }
4888
+ var Presence = (props) => {
4889
+ const { present, children } = props;
4890
+ const presence = usePresence(present);
4891
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React23.Children.only(children);
4892
+ const ref = useComposedRefs(presence.ref, getElementRef2(child));
4893
+ const forceMount = typeof children === "function";
4894
+ return forceMount || presence.isPresent ? React23.cloneElement(child, { ref }) : null;
4895
+ };
4896
+ Presence.displayName = "Presence";
4897
+ function usePresence(present) {
4898
+ const [node, setNode] = React23.useState();
4899
+ const stylesRef = React23.useRef(null);
4900
+ const prevPresentRef = React23.useRef(present);
4901
+ const prevAnimationNameRef = React23.useRef("none");
4902
+ const initialState = present ? "mounted" : "unmounted";
4903
+ const [state, send] = useStateMachine(initialState, {
4904
+ mounted: {
4905
+ UNMOUNT: "unmounted",
4906
+ ANIMATION_OUT: "unmountSuspended"
4907
+ },
4908
+ unmountSuspended: {
4909
+ MOUNT: "mounted",
4910
+ ANIMATION_END: "unmounted"
4911
+ },
4912
+ unmounted: {
4913
+ MOUNT: "mounted"
4914
+ }
4915
+ });
4916
+ React23.useEffect(() => {
4917
+ const currentAnimationName = getAnimationName(stylesRef.current);
4918
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
4919
+ }, [state]);
4920
+ useLayoutEffect2(() => {
4921
+ const styles = stylesRef.current;
4922
+ const wasPresent = prevPresentRef.current;
4923
+ const hasPresentChanged = wasPresent !== present;
4924
+ if (hasPresentChanged) {
4925
+ const prevAnimationName = prevAnimationNameRef.current;
4926
+ const currentAnimationName = getAnimationName(styles);
4927
+ if (present) {
4928
+ send("MOUNT");
4929
+ } else if (currentAnimationName === "none" || styles?.display === "none") {
4930
+ send("UNMOUNT");
4931
+ } else {
4932
+ const isAnimating = prevAnimationName !== currentAnimationName;
4933
+ if (wasPresent && isAnimating) {
4934
+ send("ANIMATION_OUT");
4935
+ } else {
4936
+ send("UNMOUNT");
4937
+ }
4938
+ }
4939
+ prevPresentRef.current = present;
4940
+ }
4941
+ }, [present, send]);
4942
+ useLayoutEffect2(() => {
4943
+ if (node) {
4944
+ let timeoutId;
4945
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
4946
+ const handleAnimationEnd = (event) => {
4947
+ const currentAnimationName = getAnimationName(stylesRef.current);
4948
+ const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
4949
+ if (event.target === node && isCurrentAnimation) {
4950
+ send("ANIMATION_END");
4951
+ if (!prevPresentRef.current) {
4952
+ const currentFillMode = node.style.animationFillMode;
4953
+ node.style.animationFillMode = "forwards";
4954
+ timeoutId = ownerWindow.setTimeout(() => {
4955
+ if (node.style.animationFillMode === "forwards") {
4956
+ node.style.animationFillMode = currentFillMode;
4957
+ }
4958
+ });
4959
+ }
4960
+ }
4961
+ };
4962
+ const handleAnimationStart = (event) => {
4963
+ if (event.target === node) {
4964
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
4965
+ }
4966
+ };
4967
+ node.addEventListener("animationstart", handleAnimationStart);
4968
+ node.addEventListener("animationcancel", handleAnimationEnd);
4969
+ node.addEventListener("animationend", handleAnimationEnd);
4970
+ return () => {
4971
+ ownerWindow.clearTimeout(timeoutId);
4972
+ node.removeEventListener("animationstart", handleAnimationStart);
4973
+ node.removeEventListener("animationcancel", handleAnimationEnd);
4974
+ node.removeEventListener("animationend", handleAnimationEnd);
4975
+ };
4976
+ } else {
4977
+ send("ANIMATION_END");
4978
+ }
4979
+ }, [node, send]);
4980
+ return {
4981
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
4982
+ ref: React23.useCallback((node2) => {
4983
+ stylesRef.current = node2 ? getComputedStyle(node2) : null;
4984
+ setNode(node2);
4985
+ }, [])
4986
+ };
4987
+ }
4988
+ function getAnimationName(styles) {
4989
+ return styles?.animationName || "none";
4990
+ }
4991
+ function getElementRef2(element) {
4992
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
4993
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
4994
+ if (mayWarn) {
4995
+ return element.ref;
4996
+ }
4997
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
4998
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
4999
+ if (mayWarn) {
5000
+ return element.props.ref;
5001
+ }
5002
+ return element.props.ref || element.ref;
5003
+ }
5004
+
5005
+ // ../../node_modules/@radix-ui/react-id/dist/index.mjs
5006
+ import * as React9 from "react";
5007
+ var useReactId = React9[" useId ".trim().toString()] || (() => {
5008
+ return;
5009
+ });
5010
+ var count = 0;
5011
+ function useId(deterministicId) {
5012
+ const [id, setId] = React9.useState(useReactId());
5013
+ useLayoutEffect2(() => {
5014
+ if (!deterministicId)
5015
+ setId((reactId) => reactId ?? String(count++));
5016
+ }, [deterministicId]);
5017
+ return deterministicId || (id ? `radix-${id}` : "");
5018
+ }
5019
+
5020
+ // ../../node_modules/@radix-ui/react-collapsible/dist/index.mjs
5021
+ import { jsx as jsx20 } from "react/jsx-runtime";
5022
+
5023
+ var COLLAPSIBLE_NAME = "Collapsible";
5024
+ var [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);
5025
+ var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
5026
+ var Collapsible = React10.forwardRef((props, forwardedRef) => {
5027
+ const {
5028
+ __scopeCollapsible,
5029
+ open: openProp,
5030
+ defaultOpen,
5031
+ disabled,
5032
+ onOpenChange,
5033
+ ...collapsibleProps
5034
+ } = props;
5035
+ const [open, setOpen] = useControllableState({
5036
+ prop: openProp,
5037
+ defaultProp: defaultOpen ?? false,
5038
+ onChange: onOpenChange,
5039
+ caller: COLLAPSIBLE_NAME
5040
+ });
5041
+ return /* @__PURE__ */ jsx20(CollapsibleProvider, {
5042
+ scope: __scopeCollapsible,
5043
+ disabled,
5044
+ contentId: useId(),
5045
+ open,
5046
+ onOpenToggle: React10.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
5047
+ children: /* @__PURE__ */ jsx20(Primitive.div, {
5048
+ "data-state": getState(open),
5049
+ "data-disabled": disabled ? "" : undefined,
5050
+ ...collapsibleProps,
5051
+ ref: forwardedRef
5052
+ })
5053
+ });
5054
+ });
5055
+ Collapsible.displayName = COLLAPSIBLE_NAME;
5056
+ var TRIGGER_NAME = "CollapsibleTrigger";
5057
+ var CollapsibleTrigger = React10.forwardRef((props, forwardedRef) => {
5058
+ const { __scopeCollapsible, ...triggerProps } = props;
5059
+ const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
5060
+ return /* @__PURE__ */ jsx20(Primitive.button, {
5061
+ type: "button",
5062
+ "aria-controls": context.contentId,
5063
+ "aria-expanded": context.open || false,
5064
+ "data-state": getState(context.open),
5065
+ "data-disabled": context.disabled ? "" : undefined,
5066
+ disabled: context.disabled,
5067
+ ...triggerProps,
5068
+ ref: forwardedRef,
5069
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
5070
+ });
5071
+ });
5072
+ CollapsibleTrigger.displayName = TRIGGER_NAME;
5073
+ var CONTENT_NAME = "CollapsibleContent";
5074
+ var CollapsibleContent = React10.forwardRef((props, forwardedRef) => {
5075
+ const { forceMount, ...contentProps } = props;
5076
+ const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
5077
+ return /* @__PURE__ */ jsx20(Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ jsx20(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
5078
+ });
5079
+ CollapsibleContent.displayName = CONTENT_NAME;
5080
+ var CollapsibleContentImpl = React10.forwardRef((props, forwardedRef) => {
5081
+ const { __scopeCollapsible, present, children, ...contentProps } = props;
5082
+ const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
5083
+ const [isPresent, setIsPresent] = React10.useState(present);
5084
+ const ref = React10.useRef(null);
5085
+ const composedRefs = useComposedRefs(forwardedRef, ref);
5086
+ const heightRef = React10.useRef(0);
5087
+ const height = heightRef.current;
5088
+ const widthRef = React10.useRef(0);
5089
+ const width = widthRef.current;
5090
+ const isOpen = context.open || isPresent;
5091
+ const isMountAnimationPreventedRef = React10.useRef(isOpen);
5092
+ const originalStylesRef = React10.useRef(undefined);
5093
+ React10.useEffect(() => {
5094
+ const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
5095
+ return () => cancelAnimationFrame(rAF);
5096
+ }, []);
5097
+ useLayoutEffect2(() => {
5098
+ const node = ref.current;
5099
+ if (node) {
5100
+ originalStylesRef.current = originalStylesRef.current || {
5101
+ transitionDuration: node.style.transitionDuration,
5102
+ animationName: node.style.animationName
5103
+ };
5104
+ node.style.transitionDuration = "0s";
5105
+ node.style.animationName = "none";
5106
+ const rect = node.getBoundingClientRect();
5107
+ heightRef.current = rect.height;
5108
+ widthRef.current = rect.width;
5109
+ if (!isMountAnimationPreventedRef.current) {
5110
+ node.style.transitionDuration = originalStylesRef.current.transitionDuration;
5111
+ node.style.animationName = originalStylesRef.current.animationName;
5112
+ }
5113
+ setIsPresent(present);
5114
+ }
5115
+ }, [context.open, present]);
5116
+ return /* @__PURE__ */ jsx20(Primitive.div, {
5117
+ "data-state": getState(context.open),
5118
+ "data-disabled": context.disabled ? "" : undefined,
5119
+ id: context.contentId,
5120
+ hidden: !isOpen,
5121
+ ...contentProps,
5122
+ ref: composedRefs,
5123
+ style: {
5124
+ [`--radix-collapsible-content-height`]: height ? `${height}px` : undefined,
5125
+ [`--radix-collapsible-content-width`]: width ? `${width}px` : undefined,
5126
+ ...props.style
5127
+ },
5128
+ children: isOpen && children
5129
+ });
5130
+ });
5131
+ function getState(open) {
5132
+ return open ? "open" : "closed";
5133
+ }
5134
+ var Root = Collapsible;
5135
+ var Trigger = CollapsibleTrigger;
5136
+ var Content = CollapsibleContent;
5137
+
5138
+ // src/components/styled/CollapsiblePanel.tsx
5139
+ import { ChevronRight } from "lucide-react";
5140
+ import { useState as useState6 } from "react";
5141
+ import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
5142
+
5143
+ function CollapsiblePanel({
5144
+ title,
5145
+ children,
5146
+ defaultExpanded = false,
5147
+ expanded: controlledExpanded,
5148
+ onExpandedChange,
5149
+ className
5150
+ }) {
5151
+ const [internalExpanded, setInternalExpanded] = useState6(defaultExpanded);
5152
+ const isControlled = controlledExpanded !== undefined;
5153
+ const expanded = isControlled ? controlledExpanded : internalExpanded;
5154
+ const handleOpenChange = (open) => {
5155
+ if (isControlled) {
5156
+ onExpandedChange?.(open);
5157
+ } else {
5158
+ setInternalExpanded(open);
5159
+ }
5160
+ };
5161
+ return /* @__PURE__ */ jsxs12(Root, {
5162
+ open: expanded,
5163
+ onOpenChange: handleOpenChange,
5164
+ className: cn6("openpkg-collapsible-panel", className),
5165
+ children: [
5166
+ /* @__PURE__ */ jsxs12(Trigger, {
5167
+ className: cn6("openpkg-collapsible-trigger", "flex items-center gap-2.5 w-full", "px-4 py-3", "bg-[var(--openpkg-bg-collapsible,#161616)]", "border border-[var(--openpkg-border-subtle,#262626)]", "rounded-md", "cursor-pointer", "transition-all duration-150", "hover:bg-[var(--openpkg-bg-tertiary,#1c1c1c)]", expanded && "rounded-b-none border-b-transparent mb-0", !expanded && "mb-2"),
5168
+ children: [
5169
+ /* @__PURE__ */ jsx21(ChevronRight, {
5170
+ size: 14,
5171
+ className: cn6("text-[var(--openpkg-text-muted,#666666)]", "transition-transform duration-200", expanded && "rotate-90")
5172
+ }),
5173
+ /* @__PURE__ */ jsx21("span", {
5174
+ className: "text-[13px] font-medium text-[var(--openpkg-text-secondary,#a0a0a0)]",
5175
+ children: title
5176
+ })
5177
+ ]
5178
+ }),
5179
+ /* @__PURE__ */ jsx21(Content, {
5180
+ className: cn6("openpkg-collapsible-content", "bg-[var(--openpkg-bg-code,#0f0f18)]", "border border-[var(--openpkg-border-subtle,#262626)]", "border-t-0", "rounded-b-md", "mb-2", "overflow-hidden", "data-[state=open]:animate-[openpkg-expand_200ms_ease-out]", "data-[state=closed]:animate-[openpkg-collapse_200ms_ease-out]"),
5181
+ children
5182
+ })
5183
+ ]
5184
+ });
5185
+ }
5186
+ // src/components/styled/EnumValuesSection.tsx
5187
+ import { cn as cn7 } from "@openpkg-ts/ui/lib/utils";
5188
+ import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
5189
+
5190
+ function EnumValuesSection({
5191
+ values,
5192
+ header = "Possible values",
5193
+ className
5194
+ }) {
5195
+ if (values.length === 0)
5196
+ return null;
5197
+ return /* @__PURE__ */ jsxs13("div", {
5198
+ className: cn7("openpkg-enum-section", "mt-3", className),
5199
+ children: [
5200
+ /* @__PURE__ */ jsx22("div", {
5201
+ className: cn7("openpkg-enum-header", "text-[11px] font-medium", "text-[var(--openpkg-text-muted,#666666)]", "mb-2.5 pb-2", "border-b border-[var(--openpkg-border-subtle,#262626)]"),
5202
+ children: header
5203
+ }),
5204
+ /* @__PURE__ */ jsx22("div", {
5205
+ className: "openpkg-enum-values flex flex-col gap-0.5",
5206
+ children: values.map((item) => /* @__PURE__ */ jsxs13("div", {
5207
+ className: cn7("openpkg-enum-value", "py-2.5 px-3", "bg-[rgba(255,255,255,0.015)]", "rounded"),
5208
+ children: [
5209
+ /* @__PURE__ */ jsx22("span", {
5210
+ className: cn7("openpkg-enum-value-name", "font-mono text-xs font-medium", "text-[var(--openpkg-syn-string,#9ccfd8)]", "bg-[rgba(156,207,216,0.1)]", "px-1.5 py-0.5 rounded", "inline-block mb-1"),
5211
+ children: item.value
5212
+ }),
5213
+ item.description && /* @__PURE__ */ jsx22("p", {
5214
+ className: cn7("openpkg-enum-value-description", "text-xs text-[var(--openpkg-text-secondary,#a0a0a0)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-[11px] [&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded"),
5215
+ children: item.description
5216
+ })
5217
+ ]
5218
+ }, item.value))
5219
+ })
5220
+ ]
5221
+ });
5222
+ }
5223
+ // src/components/styled/ExampleChips.tsx
5224
+ import { cn as cn8 } from "@openpkg-ts/ui/lib/utils";
5225
+ import { jsx as jsx23 } from "react/jsx-runtime";
5226
+
5227
+ function ExampleChips({
5228
+ examples,
5229
+ activeId,
5230
+ onSelect,
5231
+ className
5232
+ }) {
5233
+ return /* @__PURE__ */ jsx23("div", {
5234
+ className: cn8("openpkg-example-chips", "flex flex-wrap gap-2 mb-5", className),
5235
+ children: examples.map((example) => {
5236
+ const isActive = example.id === activeId;
5237
+ return /* @__PURE__ */ jsx23("button", {
5238
+ type: "button",
5239
+ onClick: () => onSelect(example.id),
5240
+ className: cn8("openpkg-example-chip", "text-xs font-medium", "px-3 py-1.5", "border rounded-md", "cursor-pointer", "transition-all duration-150", isActive ? [
5241
+ "border-[var(--openpkg-border-chip-active,#666666)]",
5242
+ "text-[var(--openpkg-text-primary,#ededed)]",
5243
+ "bg-[var(--openpkg-bg-tertiary,#1c1c1c)]"
5244
+ ] : [
5245
+ "border-[var(--openpkg-border-chip,#333333)]",
5246
+ "text-[var(--openpkg-text-secondary,#a0a0a0)]",
5247
+ "bg-transparent",
5248
+ "hover:border-[var(--openpkg-text-muted,#666666)]",
5249
+ "hover:text-[var(--openpkg-text-primary,#ededed)]"
5250
+ ]),
5251
+ "aria-pressed": isActive,
5252
+ children: example.label
5253
+ }, example.id);
5254
+ })
5255
+ });
5256
+ }
5257
+ // src/components/styled/ExampleSection.tsx
5258
+ import { cn as cn9 } from "@openpkg-ts/ui/lib/utils";
5259
+ import { useEffect as useEffect6, useRef as useRef7, useState as useState8 } from "react";
5260
+
5261
+ // src/components/styled/SyncScrollProvider.tsx
5262
+ import {
5263
+ createContext as createContext2,
5264
+ useCallback as useCallback5,
5265
+ useContext as useContext2,
5266
+ useEffect as useEffect5,
5267
+ useMemo as useMemo7,
5268
+ useRef as useRef6,
5269
+ useState as useState7
5270
+ } from "react";
5271
+ import { jsx as jsx24 } from "react/jsx-runtime";
5272
+
5273
+ var SyncScrollContext = createContext2(null);
5274
+ function SyncScrollProvider({
5275
+ children,
5276
+ rootMargin = "-20% 0px -60% 0px",
5277
+ scrollBehavior = "smooth"
5278
+ }) {
5279
+ const [activeSection, setActiveSection] = useState7(null);
5280
+ const sectionsRef = useRef6(new Map);
5281
+ const rightColumnRef = useRef6(null);
5282
+ const isScrollingRef = useRef6(false);
5283
+ const registerSection = useCallback5((id, ref) => {
5284
+ sectionsRef.current.set(id, ref);
5285
+ }, []);
5286
+ const unregisterSection = useCallback5((id) => {
5287
+ sectionsRef.current.delete(id);
5288
+ }, []);
5289
+ const registerRightColumn = useCallback5((ref) => {
5290
+ rightColumnRef.current = ref;
5291
+ }, []);
5292
+ const scrollToSection = useCallback5((id) => {
5293
+ const rightColumn = rightColumnRef.current?.current;
5294
+ if (!rightColumn)
5295
+ return;
5296
+ const targetExample = rightColumn.querySelector(`[data-section="${id}"]`);
5297
+ if (targetExample instanceof HTMLElement) {
5298
+ const targetTop = targetExample.offsetTop - 48;
5299
+ rightColumn.scrollTo({ top: targetTop, behavior: scrollBehavior });
5300
+ }
5301
+ }, [scrollBehavior]);
5302
+ useEffect5(() => {
5303
+ if (typeof window === "undefined")
5304
+ return;
5305
+ const handleIntersect = (entries) => {
5306
+ if (isScrollingRef.current)
5307
+ return;
5308
+ for (const entry of entries) {
5309
+ if (entry.isIntersecting) {
5310
+ const sectionId = entry.target.getAttribute("data-section");
5311
+ if (sectionId) {
5312
+ setActiveSection(sectionId);
5313
+ scrollToSection(sectionId);
5314
+ }
5315
+ break;
5316
+ }
5317
+ }
5318
+ };
5319
+ const observer = new IntersectionObserver(handleIntersect, {
5320
+ rootMargin,
5321
+ threshold: 0
5322
+ });
5323
+ for (const [_id, ref] of sectionsRef.current) {
5324
+ if (ref.current) {
5325
+ observer.observe(ref.current);
5326
+ }
5327
+ }
5328
+ return () => {
5329
+ observer.disconnect();
5330
+ };
5331
+ }, [rootMargin, scrollToSection]);
5332
+ const value = useMemo7(() => ({
5333
+ activeSection,
5334
+ registerSection,
5335
+ unregisterSection,
5336
+ scrollToSection,
5337
+ registerRightColumn
5338
+ }), [activeSection, registerSection, unregisterSection, scrollToSection, registerRightColumn]);
5339
+ return /* @__PURE__ */ jsx24(SyncScrollContext.Provider, {
5340
+ value,
5341
+ children
5342
+ });
5343
+ }
5344
+ function useSyncScroll() {
5345
+ const context = useContext2(SyncScrollContext);
5346
+ if (!context) {
5347
+ throw new Error("useSyncScroll must be used within SyncScrollProvider");
5348
+ }
5349
+ return context;
5350
+ }
5351
+ function useSyncSection(id) {
5352
+ const { registerSection, unregisterSection } = useSyncScroll();
5353
+ const ref = useRef6(null);
5354
+ useEffect5(() => {
5355
+ registerSection(id, ref);
5356
+ return () => unregisterSection(id);
5357
+ }, [id, registerSection, unregisterSection]);
5358
+ return ref;
5359
+ }
5360
+
5361
+ // src/components/styled/ExampleSection.tsx
5362
+ import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
5363
+
5364
+ function ExampleSection({
5365
+ id,
5366
+ examples,
5367
+ dataSource,
5368
+ response,
5369
+ notes,
5370
+ className
5371
+ }) {
5372
+ const [activeExampleId, setActiveExampleId] = useState8(examples[0]?.id ?? "");
5373
+ const ref = useRef7(null);
5374
+ const syncScroll = useSyncScrollSafe();
5375
+ const activeExample = examples.find((e) => e.id === activeExampleId) ?? examples[0];
5376
+ const isActive = syncScroll?.activeSection === id;
5377
+ useEffect6(() => {
5378
+ if (ref.current) {
5379
+ ref.current.setAttribute("data-section", id);
5380
+ }
5381
+ }, [id]);
5382
+ return /* @__PURE__ */ jsxs14("div", {
5383
+ ref,
5384
+ "data-section": id,
5385
+ className: cn9("openpkg-example-section", "mb-12 last:mb-0", "transition-opacity duration-300", isActive ? "opacity-100" : "opacity-40", className),
5386
+ children: [
5387
+ examples.length > 1 && /* @__PURE__ */ jsx25(ExampleChips, {
5388
+ examples: examples.map((e) => ({ id: e.id, label: e.label })),
5389
+ activeId: activeExampleId,
5390
+ onSelect: setActiveExampleId
5391
+ }),
5392
+ activeExample && /* @__PURE__ */ jsx25(CodePanel, {
5393
+ code: activeExample.code,
5394
+ language: activeExample.language ?? "typescript",
5395
+ showLineNumbers: true
5396
+ }),
5397
+ dataSource && /* @__PURE__ */ jsx25(CollapsiblePanel, {
5398
+ title: "Data source",
5399
+ children: /* @__PURE__ */ jsx25("div", {
5400
+ className: "p-4",
5401
+ children: /* @__PURE__ */ jsx25(CodePanel, {
5402
+ code: dataSource,
5403
+ language: "sql"
5404
+ })
5405
+ })
5406
+ }),
5407
+ response && /* @__PURE__ */ jsx25(CollapsiblePanel, {
5408
+ title: "Response",
5409
+ children: /* @__PURE__ */ jsx25("div", {
5410
+ className: "p-4",
5411
+ children: /* @__PURE__ */ jsx25(CodePanel, {
5412
+ code: response,
5413
+ language: "json"
5414
+ })
5415
+ })
5416
+ }),
5417
+ notes && /* @__PURE__ */ jsx25(CollapsiblePanel, {
5418
+ title: "Notes",
5419
+ children: /* @__PURE__ */ jsx25("div", {
5420
+ className: cn9("openpkg-panel-note", "p-4", "text-[13px] text-[var(--openpkg-text-secondary,#a0a0a0)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-xs [&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded"),
5421
+ children: typeof notes === "string" ? /* @__PURE__ */ jsx25("p", {
5422
+ children: notes
5423
+ }) : notes
5424
+ })
5425
+ })
5426
+ ]
5427
+ });
5428
+ }
5429
+ function useSyncScrollSafe() {
5430
+ try {
5431
+ return useSyncScroll();
5432
+ } catch {
5433
+ return null;
5434
+ }
5435
+ }
5436
+ // src/components/styled/ExpandableParameter.tsx
5437
+ import { formatSchema as formatSchema8 } from "@openpkg-ts/sdk/browser";
5438
+ import { cn as cn12 } from "@openpkg-ts/ui/lib/utils";
5439
+ import { useState as useState9 } from "react";
5440
+
5441
+ // src/components/styled/NestedParameterContainer.tsx
5442
+ import { cn as cn10 } from "@openpkg-ts/ui/lib/utils";
5443
+ import { jsx as jsx26 } from "react/jsx-runtime";
5444
+
5445
+ function NestedParameterContainer({
5446
+ children,
5447
+ level = 0,
5448
+ className
5449
+ }) {
5450
+ return /* @__PURE__ */ jsx26("div", {
5451
+ className: cn10("openpkg-nested-container", "border border-t-0", level === 0 ? "border-[var(--openpkg-border-medium,#333333)]" : "border-[var(--openpkg-border-subtle,#262626)]", "rounded-b-lg", "px-5", "mb-2", "[&>.openpkg-param]:py-5", "[&>.openpkg-param]:border-b", "[&>.openpkg-param]:border-[var(--openpkg-border-subtle,#262626)]", "[&>.openpkg-param:last-child]:border-b-0", className),
5452
+ "data-level": level,
5453
+ children
5454
+ });
5455
+ }
5456
+
5457
+ // src/components/styled/NestedParameterToggle.tsx
5458
+ import { cn as cn11 } from "@openpkg-ts/ui/lib/utils";
5459
+ import { Plus } from "lucide-react";
5460
+ import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
5461
+
5462
+ function NestedParameterToggle({
5463
+ expanded,
5464
+ onToggle,
5465
+ count: count2,
5466
+ className
5467
+ }) {
5468
+ return /* @__PURE__ */ jsxs15("button", {
5469
+ type: "button",
5470
+ onClick: onToggle,
5471
+ className: cn11("openpkg-nested-toggle", "inline-flex items-center gap-2", "font-sans text-[13px] font-medium", "text-[var(--openpkg-text-secondary,#a0a0a0)]", "bg-transparent", "border border-[var(--openpkg-border-medium,#333333)]", "rounded-lg", "px-4 py-2.5", "mt-3", "cursor-pointer", "transition-all duration-150", "hover:border-[var(--openpkg-text-muted,#666666)]", "hover:text-[var(--openpkg-text-primary,#ededed)]", expanded && "rounded-b-none border-b-transparent mb-0", className),
5472
+ "aria-expanded": expanded,
5473
+ children: [
5474
+ /* @__PURE__ */ jsx27(Plus, {
5475
+ size: 12,
5476
+ className: cn11("transition-transform duration-200", expanded && "rotate-45")
5477
+ }),
5478
+ /* @__PURE__ */ jsxs15("span", {
5479
+ children: [
5480
+ expanded ? "Hide" : "Show",
5481
+ " child parameters",
5482
+ count2 !== undefined && ` (${count2})`
5483
+ ]
5484
+ })
5485
+ ]
5486
+ });
5487
+ }
5488
+
5489
+ // src/components/styled/ExpandableParameter.tsx
5490
+ import { jsx as jsx28, jsxs as jsxs16, Fragment as Fragment3 } from "react/jsx-runtime";
5491
+
5492
+ function ExpandableParameter({
5493
+ parameter,
5494
+ parentPath,
5495
+ defaultExpanded = false,
5496
+ expanded: controlledExpanded,
5497
+ onExpandedChange,
5498
+ level = 0,
5499
+ className
5500
+ }) {
5501
+ const [internalExpanded, setInternalExpanded] = useState9(defaultExpanded);
5502
+ const isControlled = controlledExpanded !== undefined;
5503
+ const expanded = isControlled ? controlledExpanded : internalExpanded;
5504
+ const handleToggle = () => {
5505
+ const newValue = !expanded;
5506
+ if (isControlled) {
5507
+ onExpandedChange?.(newValue);
5508
+ } else {
5509
+ setInternalExpanded(newValue);
5510
+ }
5511
+ };
5512
+ const { nestedParams, enumValues, hasChildren } = extractSchemaInfo(parameter.schema);
5513
+ const type = formatSchema8(parameter.schema);
5514
+ const isRequired = parameter.required !== false;
5515
+ return /* @__PURE__ */ jsx28("div", {
5516
+ className: cn12("openpkg-expandable-param", className),
5517
+ children: /* @__PURE__ */ jsxs16(APIParameterItem6, {
5518
+ name: parameter.name,
5519
+ parentPath,
5520
+ type: hasChildren ? "object" : type,
5521
+ required: isRequired,
5522
+ expandable: hasChildren,
5523
+ description: parameter.description,
5524
+ anchorId: parentPath ? `${parentPath}${parameter.name}` : parameter.name,
5525
+ showAnchor: level > 0,
5526
+ children: [
5527
+ enumValues.length > 0 && !nestedParams.length && /* @__PURE__ */ jsx28(EnumValuesSection, {
5528
+ values: enumValues
5529
+ }),
5530
+ nestedParams.length > 0 && /* @__PURE__ */ jsxs16(Fragment3, {
5531
+ children: [
5532
+ /* @__PURE__ */ jsx28(NestedParameterToggle, {
5533
+ expanded,
5534
+ onToggle: handleToggle,
5535
+ count: nestedParams.length
5536
+ }),
5537
+ expanded && /* @__PURE__ */ jsx28(NestedParameterContainer, {
5538
+ level,
5539
+ children: nestedParams.map((nested) => /* @__PURE__ */ jsx28(ExpandableParameter, {
5540
+ parameter: nested,
5541
+ parentPath: `${parameter.name}.`,
5542
+ level: level + 1
5543
+ }, nested.name))
5544
+ })
5545
+ ]
5546
+ })
5547
+ ]
5548
+ })
5549
+ });
5550
+ }
5551
+ function extractSchemaInfo(schema) {
5552
+ const result = {
5553
+ nestedParams: [],
5554
+ enumValues: [],
5555
+ hasChildren: false
5556
+ };
5557
+ if (!schema || typeof schema !== "object")
5558
+ return result;
5559
+ const s = schema;
5560
+ if (s.type === "object" && s.properties && typeof s.properties === "object") {
5561
+ const props = s.properties;
5562
+ const required = Array.isArray(s.required) ? s.required : [];
5563
+ for (const [name, propSchema] of Object.entries(props)) {
5564
+ result.nestedParams.push({
5565
+ name,
5566
+ schema: propSchema,
5567
+ required: required.includes(name),
5568
+ description: propSchema?.description
5569
+ });
5570
+ }
5571
+ }
5572
+ if (Array.isArray(s.enum)) {
5573
+ result.enumValues = s.enum.map((value) => ({
5574
+ value: String(value),
5575
+ description: undefined
5576
+ }));
5577
+ }
5578
+ result.hasChildren = result.nestedParams.length > 0 || result.enumValues.length > 0;
5579
+ return result;
5580
+ }
4194
5581
  // src/components/styled/FullAPIReferencePage.tsx
4195
5582
  import { APIReferencePage } from "@openpkg-ts/ui/docskit";
4196
- import { cn as cn3 } from "@openpkg-ts/ui/lib/utils";
4197
- import { useCallback, useEffect, useMemo as useMemo2, useRef, useState as useState2 } from "react";
5583
+ import { cn as cn13 } from "@openpkg-ts/ui/lib/utils";
5584
+ import { useCallback as useCallback6, useEffect as useEffect7, useMemo as useMemo8, useRef as useRef8, useState as useState10 } from "react";
4198
5585
 
4199
5586
  // src/components/styled/sections/ExportSection.tsx
4200
- import { jsx as jsx14 } from "react/jsx-runtime";
5587
+ import { jsx as jsx29 } from "react/jsx-runtime";
4201
5588
 
4202
5589
  function ExportSection({ export: exp, spec }) {
4203
5590
  const props = { export: exp, spec };
4204
5591
  switch (exp.kind) {
4205
5592
  case "function":
4206
- return /* @__PURE__ */ jsx14(FunctionSection, {
5593
+ return /* @__PURE__ */ jsx29(FunctionSection, {
4207
5594
  ...props
4208
5595
  });
4209
5596
  case "class":
4210
- return /* @__PURE__ */ jsx14(ClassSection, {
5597
+ return /* @__PURE__ */ jsx29(ClassSection, {
4211
5598
  ...props
4212
5599
  });
4213
5600
  case "interface":
4214
5601
  case "type":
4215
- return /* @__PURE__ */ jsx14(InterfaceSection, {
5602
+ return /* @__PURE__ */ jsx29(InterfaceSection, {
4216
5603
  ...props
4217
5604
  });
4218
5605
  case "enum":
4219
- return /* @__PURE__ */ jsx14(EnumSection, {
5606
+ return /* @__PURE__ */ jsx29(EnumSection, {
4220
5607
  ...props
4221
5608
  });
4222
5609
  default:
4223
- return /* @__PURE__ */ jsx14(VariableSection, {
5610
+ return /* @__PURE__ */ jsx29(VariableSection, {
4224
5611
  ...props
4225
5612
  });
4226
5613
  }
4227
5614
  }
4228
5615
 
4229
5616
  // src/components/styled/FullAPIReferencePage.tsx
4230
- import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
5617
+ import { jsx as jsx30, jsxs as jsxs17 } from "react/jsx-runtime";
4231
5618
 
4232
5619
  var KIND_ORDER2 = ["function", "class", "interface", "type", "enum", "variable"];
4233
5620
  var KIND_LABELS2 = {
@@ -4262,10 +5649,10 @@ function FullAPIReferencePage({
4262
5649
  description,
4263
5650
  className
4264
5651
  }) {
4265
- const [activeFilter, setActiveFilter] = useState2("all");
4266
- const [activeSection, setActiveSection] = useState2(null);
4267
- const isScrollingRef = useRef(false);
4268
- const availableKinds = useMemo2(() => {
5652
+ const [activeFilter, setActiveFilter] = useState10("all");
5653
+ const [activeSection, setActiveSection] = useState10(null);
5654
+ const isScrollingRef = useRef8(false);
5655
+ const availableKinds = useMemo8(() => {
4269
5656
  const kindSet = new Set;
4270
5657
  for (const exp of spec.exports) {
4271
5658
  const kind = exp.kind;
@@ -4275,7 +5662,7 @@ function FullAPIReferencePage({
4275
5662
  }
4276
5663
  return KIND_ORDER2.filter((k) => kindSet.has(k));
4277
5664
  }, [spec.exports]);
4278
- const filteredExports = useMemo2(() => {
5665
+ const filteredExports = useMemo8(() => {
4279
5666
  let exports = spec.exports;
4280
5667
  if (kinds?.length) {
4281
5668
  exports = exports.filter((e) => kinds.includes(e.kind));
@@ -4292,7 +5679,7 @@ function FullAPIReferencePage({
4292
5679
  return a.name.localeCompare(b.name);
4293
5680
  });
4294
5681
  }, [spec.exports, kinds, activeFilter]);
4295
- const groupedExports = useMemo2(() => {
5682
+ const groupedExports = useMemo8(() => {
4296
5683
  const groups = new Map;
4297
5684
  for (const exp of filteredExports) {
4298
5685
  const kind = exp.kind;
@@ -4303,7 +5690,7 @@ function FullAPIReferencePage({
4303
5690
  }
4304
5691
  return groups;
4305
5692
  }, [filteredExports]);
4306
- useEffect(() => {
5693
+ useEffect7(() => {
4307
5694
  if (typeof window === "undefined")
4308
5695
  return;
4309
5696
  const hash = window.location.hash.slice(1);
@@ -4322,7 +5709,7 @@ function FullAPIReferencePage({
4322
5709
  return () => clearTimeout(timer);
4323
5710
  }
4324
5711
  }, []);
4325
- useEffect(() => {
5712
+ useEffect7(() => {
4326
5713
  if (!showTOC || typeof window === "undefined")
4327
5714
  return;
4328
5715
  const sectionIds = filteredExports.map((exp) => exp.id || exp.name);
@@ -4355,7 +5742,7 @@ function FullAPIReferencePage({
4355
5742
  observer.disconnect();
4356
5743
  };
4357
5744
  }, [showTOC, filteredExports]);
4358
- const handleTOCClick = useCallback((id) => {
5745
+ const handleTOCClick = useCallback6((id) => {
4359
5746
  const element = document.getElementById(id);
4360
5747
  if (element) {
4361
5748
  isScrollingRef.current = true;
@@ -4367,12 +5754,12 @@ function FullAPIReferencePage({
4367
5754
  }, 1000);
4368
5755
  }
4369
5756
  }, []);
4370
- const defaultDescription = /* @__PURE__ */ jsxs9("div", {
5757
+ const defaultDescription = /* @__PURE__ */ jsxs17("div", {
4371
5758
  children: [
4372
- spec.meta.description && /* @__PURE__ */ jsx15("p", {
5759
+ spec.meta.description && /* @__PURE__ */ jsx30("p", {
4373
5760
  children: spec.meta.description
4374
5761
  }),
4375
- spec.meta.version && /* @__PURE__ */ jsxs9("p", {
5762
+ spec.meta.version && /* @__PURE__ */ jsxs17("p", {
4376
5763
  className: "text-sm text-muted-foreground mt-2",
4377
5764
  children: [
4378
5765
  "Version ",
@@ -4382,40 +5769,40 @@ function FullAPIReferencePage({
4382
5769
  ]
4383
5770
  });
4384
5771
  const shouldShowFilters = showFilters && !kinds?.length && availableKinds.length > 1;
4385
- return /* @__PURE__ */ jsxs9("div", {
4386
- className: cn3("doccov-full-reference-page not-prose", showTOC && "lg:grid lg:grid-cols-[220px_1fr] lg:gap-8", className),
5772
+ return /* @__PURE__ */ jsxs17("div", {
5773
+ className: cn13("doccov-full-reference-page not-prose", showTOC && "lg:grid lg:grid-cols-[220px_1fr] lg:gap-8", className),
4387
5774
  children: [
4388
- showTOC && /* @__PURE__ */ jsx15("aside", {
5775
+ showTOC && /* @__PURE__ */ jsx30("aside", {
4389
5776
  className: "hidden lg:block",
4390
- children: /* @__PURE__ */ jsxs9("nav", {
5777
+ children: /* @__PURE__ */ jsxs17("nav", {
4391
5778
  className: "sticky top-20 max-h-[calc(100vh-6rem)] overflow-y-auto pr-4",
4392
5779
  children: [
4393
- /* @__PURE__ */ jsx15("h4", {
5780
+ /* @__PURE__ */ jsx30("h4", {
4394
5781
  className: "text-sm font-semibold text-foreground mb-3",
4395
5782
  children: "On this page"
4396
5783
  }),
4397
- /* @__PURE__ */ jsx15("div", {
5784
+ /* @__PURE__ */ jsx30("div", {
4398
5785
  className: "space-y-4",
4399
5786
  children: KIND_ORDER2.map((kind) => {
4400
5787
  const exports = groupedExports.get(kind);
4401
5788
  if (!exports?.length)
4402
5789
  return null;
4403
- return /* @__PURE__ */ jsxs9("div", {
5790
+ return /* @__PURE__ */ jsxs17("div", {
4404
5791
  children: [
4405
- /* @__PURE__ */ jsx15("h5", {
5792
+ /* @__PURE__ */ jsx30("h5", {
4406
5793
  className: "text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2",
4407
5794
  children: KIND_LABELS2[kind]
4408
5795
  }),
4409
- /* @__PURE__ */ jsx15("ul", {
5796
+ /* @__PURE__ */ jsx30("ul", {
4410
5797
  className: "space-y-1",
4411
5798
  children: exports.map((exp) => {
4412
5799
  const id = exp.id || exp.name;
4413
5800
  const isActive = activeSection === id;
4414
- return /* @__PURE__ */ jsx15("li", {
4415
- children: /* @__PURE__ */ jsx15("button", {
5801
+ return /* @__PURE__ */ jsx30("li", {
5802
+ children: /* @__PURE__ */ jsx30("button", {
4416
5803
  type: "button",
4417
5804
  onClick: () => handleTOCClick(id),
4418
- className: cn3("block w-full text-left text-sm py-1 px-2 rounded-md transition-colors cursor-pointer truncate", isActive ? "bg-primary/10 text-primary font-medium" : "text-muted-foreground hover:text-foreground hover:bg-muted/50"),
5805
+ className: cn13("block w-full text-left text-sm py-1 px-2 rounded-md transition-colors cursor-pointer truncate", isActive ? "bg-primary/10 text-primary font-medium" : "text-muted-foreground hover:text-foreground hover:bg-muted/50"),
4419
5806
  title: getExportTitle(exp),
4420
5807
  children: getExportTitle(exp)
4421
5808
  })
@@ -4429,40 +5816,40 @@ function FullAPIReferencePage({
4429
5816
  ]
4430
5817
  })
4431
5818
  }),
4432
- /* @__PURE__ */ jsx15("div", {
4433
- children: /* @__PURE__ */ jsxs9(APIReferencePage, {
5819
+ /* @__PURE__ */ jsx30("div", {
5820
+ children: /* @__PURE__ */ jsxs17(APIReferencePage, {
4434
5821
  title: title || spec.meta.name || "API Reference",
4435
5822
  description: description || defaultDescription,
4436
5823
  children: [
4437
- shouldShowFilters && /* @__PURE__ */ jsxs9("div", {
5824
+ shouldShowFilters && /* @__PURE__ */ jsxs17("div", {
4438
5825
  className: "flex flex-wrap gap-2 mb-8 -mt-4",
4439
5826
  children: [
4440
- /* @__PURE__ */ jsx15("button", {
5827
+ /* @__PURE__ */ jsx30("button", {
4441
5828
  type: "button",
4442
5829
  onClick: () => setActiveFilter("all"),
4443
- className: cn3("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === "all" ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
5830
+ className: cn13("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === "all" ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
4444
5831
  children: "All"
4445
5832
  }),
4446
- availableKinds.map((kind) => /* @__PURE__ */ jsx15("button", {
5833
+ availableKinds.map((kind) => /* @__PURE__ */ jsx30("button", {
4447
5834
  type: "button",
4448
5835
  onClick: () => setActiveFilter(kind),
4449
- className: cn3("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === kind ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
5836
+ className: cn13("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === kind ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
4450
5837
  children: KIND_LABELS2[kind]
4451
5838
  }, kind))
4452
5839
  ]
4453
5840
  }),
4454
- filteredExports.map((exp) => /* @__PURE__ */ jsx15(ExportSection, {
5841
+ filteredExports.map((exp) => /* @__PURE__ */ jsx30(ExportSection, {
4455
5842
  export: exp,
4456
5843
  spec
4457
5844
  }, exp.id || exp.name)),
4458
- filteredExports.length === 0 && /* @__PURE__ */ jsxs9("div", {
5845
+ filteredExports.length === 0 && /* @__PURE__ */ jsxs17("div", {
4459
5846
  className: "rounded-lg border border-border bg-card/50 p-8 text-center",
4460
5847
  children: [
4461
- /* @__PURE__ */ jsx15("p", {
5848
+ /* @__PURE__ */ jsx30("p", {
4462
5849
  className: "text-muted-foreground",
4463
5850
  children: activeFilter !== "all" ? `No ${KIND_LABELS2[activeFilter].toLowerCase()} found.` : "No exports found in this package."
4464
5851
  }),
4465
- activeFilter !== "all" && /* @__PURE__ */ jsx15("button", {
5852
+ activeFilter !== "all" && /* @__PURE__ */ jsx30("button", {
4466
5853
  type: "button",
4467
5854
  onClick: () => setActiveFilter("all"),
4468
5855
  className: "mt-3 text-sm text-primary hover:underline cursor-pointer",
@@ -4476,12 +5863,126 @@ function FullAPIReferencePage({
4476
5863
  ]
4477
5864
  });
4478
5865
  }
5866
+ // src/components/styled/MethodSection.tsx
5867
+ import { cn as cn14 } from "@openpkg-ts/ui/lib/utils";
5868
+ import { useEffect as useEffect8, useRef as useRef9 } from "react";
5869
+ import { jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
5870
+
5871
+ function MethodSection({
5872
+ id,
5873
+ title,
5874
+ signature,
5875
+ description,
5876
+ notes,
5877
+ children,
5878
+ className
5879
+ }) {
5880
+ const ref = useRef9(null);
5881
+ const syncScroll = useSyncScrollSafe2();
5882
+ useEffect8(() => {
5883
+ if (syncScroll && ref.current) {
5884
+ syncScroll.registerSection(id, ref);
5885
+ return () => syncScroll.unregisterSection(id);
5886
+ }
5887
+ }, [id, syncScroll]);
5888
+ return /* @__PURE__ */ jsxs18("section", {
5889
+ ref,
5890
+ id,
5891
+ "data-section": id,
5892
+ className: cn14("openpkg-method-section", "mb-20 last:mb-0", className),
5893
+ children: [
5894
+ /* @__PURE__ */ jsx31("h2", {
5895
+ className: cn14("text-2xl font-semibold tracking-tight", "text-[var(--openpkg-text-primary,#ededed)]", "mb-4"),
5896
+ children: title
5897
+ }),
5898
+ signature && /* @__PURE__ */ jsx31("code", {
5899
+ className: cn14("block font-mono text-sm", "text-[var(--openpkg-text-muted,#666666)]", "mb-6"),
5900
+ children: signature
5901
+ }),
5902
+ description && /* @__PURE__ */ jsx31("div", {
5903
+ className: cn14("openpkg-method-description", "text-[15px] leading-relaxed", "text-[var(--openpkg-text-secondary,#a0a0a0)]", "mb-6", "[&_a]:text-[var(--openpkg-accent-link,#6cb6ff)] [&_a]:no-underline [&_a]:font-medium hover:[&_a]:underline", "[&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:font-mono [&_code]:text-[13px]"),
5904
+ children: typeof description === "string" ? /* @__PURE__ */ jsx31("p", {
5905
+ children: description
5906
+ }) : description
5907
+ }),
5908
+ notes && notes.length > 0 && /* @__PURE__ */ jsx31("ul", {
5909
+ className: cn14("openpkg-method-notes", "list-disc list-inside", "text-[15px] leading-relaxed", "text-[var(--openpkg-text-secondary,#a0a0a0)]", "mb-8 space-y-2"),
5910
+ children: notes.map((note, i) => /* @__PURE__ */ jsx31("li", {
5911
+ children: note
5912
+ }, i))
5913
+ }),
5914
+ children && /* @__PURE__ */ jsxs18("div", {
5915
+ className: "openpkg-method-params",
5916
+ children: [
5917
+ /* @__PURE__ */ jsx31("h3", {
5918
+ className: cn14("text-xs font-semibold uppercase tracking-wider", "text-[var(--openpkg-text-muted,#666666)]", "mb-4 pb-2", "border-b border-[var(--openpkg-border-subtle,#262626)]"),
5919
+ children: "Parameters"
5920
+ }),
5921
+ children
5922
+ ]
5923
+ })
5924
+ ]
5925
+ });
5926
+ }
5927
+ function useSyncScrollSafe2() {
5928
+ try {
5929
+ return useSyncScroll();
5930
+ } catch {
5931
+ return null;
5932
+ }
5933
+ }
5934
+ // src/components/styled/MethodSectionFromSpec.tsx
5935
+ import { cn as cn15 } from "@openpkg-ts/ui/lib/utils";
5936
+ import { jsx as jsx32 } from "react/jsx-runtime";
5937
+
5938
+ function MethodSectionFromSpec({
5939
+ spec,
5940
+ export: exportProp,
5941
+ className
5942
+ }) {
5943
+ const exp = typeof exportProp === "string" ? spec.exports.find((e) => e.name === exportProp) : exportProp;
5944
+ if (!exp) {
5945
+ return null;
5946
+ }
5947
+ const method = extractMethodData(exp, spec);
5948
+ const notes = buildNotes(exp);
5949
+ return /* @__PURE__ */ jsx32(MethodSection, {
5950
+ id: exp.id || exp.name,
5951
+ title: method.title,
5952
+ signature: method.signature,
5953
+ description: method.description,
5954
+ notes,
5955
+ className: cn15("openpkg-method-from-spec", className),
5956
+ children: method.parameters.map((param) => /* @__PURE__ */ jsx32(ExpandableParameter, {
5957
+ parameter: param
5958
+ }, param.name))
5959
+ });
5960
+ }
5961
+ function buildNotes(exp) {
5962
+ const notes = [];
5963
+ if (exp.deprecated) {
5964
+ notes.push(exp.deprecationReason ? `⚠️ Deprecated: ${exp.deprecationReason}` : "⚠️ This function is deprecated.");
5965
+ }
5966
+ const sig = exp.signatures?.[0];
5967
+ if (sig?.tags) {
5968
+ for (const tag of sig.tags) {
5969
+ if (tag.name === "note" || tag.name === "remarks") {
5970
+ notes.push(tag.text);
5971
+ }
5972
+ }
5973
+ }
5974
+ const flags = exp.flags;
5975
+ if (flags?.async) {
5976
+ notes.push("This function is async and returns a Promise.");
5977
+ }
5978
+ return notes;
5979
+ }
4479
5980
  // src/components/styled/ParameterItem.tsx
4480
- import { formatSchema as formatSchema6 } from "@openpkg-ts/sdk";
4481
- import { cn as cn4 } from "@openpkg-ts/ui/lib/utils";
4482
- import { ChevronRight } from "lucide-react";
4483
- import { useState as useState3 } from "react";
4484
- import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
5981
+ import { formatSchema as formatSchema9 } from "@openpkg-ts/sdk/browser";
5982
+ import { cn as cn16 } from "@openpkg-ts/ui/lib/utils";
5983
+ import { ChevronRight as ChevronRight2 } from "lucide-react";
5984
+ import { useState as useState11 } from "react";
5985
+ import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
4485
5986
 
4486
5987
  function getNestedProperties(schema) {
4487
5988
  if (!schema || typeof schema !== "object")
@@ -4511,55 +6012,55 @@ function NestedPropertyItem({
4511
6012
  required = false,
4512
6013
  depth = 0
4513
6014
  }) {
4514
- const [expanded, setExpanded] = useState3(false);
4515
- const type = formatSchema6(schema);
6015
+ const [expanded, setExpanded] = useState11(false);
6016
+ const type = formatSchema9(schema);
4516
6017
  const nestedProps = getNestedProperties(schema);
4517
6018
  const nestedCount = countProperties(schema);
4518
6019
  const hasNested = nestedCount > 0;
4519
6020
  const schemaObj = schema;
4520
6021
  const description = schemaObj?.description;
4521
- return /* @__PURE__ */ jsxs10("div", {
4522
- className: cn4("border-t border-border first:border-t-0", depth > 0 && "ml-4"),
6022
+ return /* @__PURE__ */ jsxs19("div", {
6023
+ className: cn16("border-t border-border first:border-t-0", depth > 0 && "ml-4"),
4523
6024
  children: [
4524
- /* @__PURE__ */ jsx16("div", {
6025
+ /* @__PURE__ */ jsx33("div", {
4525
6026
  className: "py-3",
4526
- children: /* @__PURE__ */ jsxs10("div", {
6027
+ children: /* @__PURE__ */ jsxs19("div", {
4527
6028
  className: "flex items-start gap-2",
4528
6029
  children: [
4529
- hasNested && /* @__PURE__ */ jsx16("button", {
6030
+ hasNested && /* @__PURE__ */ jsx33("button", {
4530
6031
  type: "button",
4531
6032
  onClick: () => setExpanded(!expanded),
4532
6033
  className: "mt-0.5 p-0.5 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",
4533
6034
  "aria-label": expanded ? "Collapse" : "Expand",
4534
- children: /* @__PURE__ */ jsx16(ChevronRight, {
6035
+ children: /* @__PURE__ */ jsx33(ChevronRight2, {
4535
6036
  size: 14,
4536
- className: cn4("transition-transform duration-200", expanded && "rotate-90")
6037
+ className: cn16("transition-transform duration-200", expanded && "rotate-90")
4537
6038
  })
4538
6039
  }),
4539
- !hasNested && /* @__PURE__ */ jsx16("div", {
6040
+ !hasNested && /* @__PURE__ */ jsx33("div", {
4540
6041
  className: "w-5"
4541
6042
  }),
4542
- /* @__PURE__ */ jsxs10("div", {
6043
+ /* @__PURE__ */ jsxs19("div", {
4543
6044
  className: "flex-1 min-w-0",
4544
6045
  children: [
4545
- /* @__PURE__ */ jsxs10("div", {
6046
+ /* @__PURE__ */ jsxs19("div", {
4546
6047
  className: "flex items-baseline gap-2 flex-wrap",
4547
6048
  children: [
4548
- /* @__PURE__ */ jsxs10("span", {
6049
+ /* @__PURE__ */ jsxs19("span", {
4549
6050
  className: "font-mono text-sm text-foreground",
4550
6051
  children: [
4551
6052
  name,
4552
- !required && /* @__PURE__ */ jsx16("span", {
6053
+ !required && /* @__PURE__ */ jsx33("span", {
4553
6054
  className: "text-muted-foreground",
4554
6055
  children: "?"
4555
6056
  })
4556
6057
  ]
4557
6058
  }),
4558
- /* @__PURE__ */ jsx16("span", {
6059
+ /* @__PURE__ */ jsx33("span", {
4559
6060
  className: "font-mono text-sm text-muted-foreground",
4560
6061
  children: hasNested ? "object" : type
4561
6062
  }),
4562
- hasNested && /* @__PURE__ */ jsxs10("button", {
6063
+ hasNested && /* @__PURE__ */ jsxs19("button", {
4563
6064
  type: "button",
4564
6065
  onClick: () => setExpanded(!expanded),
4565
6066
  className: "text-xs text-primary hover:underline cursor-pointer",
@@ -4571,7 +6072,7 @@ function NestedPropertyItem({
4571
6072
  })
4572
6073
  ]
4573
6074
  }),
4574
- description && /* @__PURE__ */ jsx16("p", {
6075
+ description && /* @__PURE__ */ jsx33("p", {
4575
6076
  className: "text-sm text-muted-foreground mt-1",
4576
6077
  children: description
4577
6078
  })
@@ -4580,9 +6081,9 @@ function NestedPropertyItem({
4580
6081
  ]
4581
6082
  })
4582
6083
  }),
4583
- hasNested && expanded && nestedProps && /* @__PURE__ */ jsx16("div", {
6084
+ hasNested && expanded && nestedProps && /* @__PURE__ */ jsx33("div", {
4584
6085
  className: "border-l border-border ml-2",
4585
- children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsx16(NestedPropertyItem, {
6086
+ children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsx33(NestedPropertyItem, {
4586
6087
  name: propName,
4587
6088
  schema: propSchema,
4588
6089
  required: getRequiredFields(schema).includes(propName),
@@ -4597,52 +6098,52 @@ function ParameterItem({
4597
6098
  depth = 0,
4598
6099
  className
4599
6100
  }) {
4600
- const [expanded, setExpanded] = useState3(false);
4601
- const type = formatSchema6(param.schema);
6101
+ const [expanded, setExpanded] = useState11(false);
6102
+ const type = formatSchema9(param.schema);
4602
6103
  const isRequired = param.required !== false;
4603
6104
  const nestedProps = getNestedProperties(param.schema);
4604
6105
  const nestedCount = countProperties(param.schema);
4605
6106
  const hasNested = nestedCount > 0;
4606
- return /* @__PURE__ */ jsxs10("div", {
4607
- className: cn4("border-b border-border last:border-b-0", className),
6107
+ return /* @__PURE__ */ jsxs19("div", {
6108
+ className: cn16("border-b border-border last:border-b-0", className),
4608
6109
  children: [
4609
- /* @__PURE__ */ jsx16("div", {
6110
+ /* @__PURE__ */ jsx33("div", {
4610
6111
  className: "py-3",
4611
- children: /* @__PURE__ */ jsxs10("div", {
6112
+ children: /* @__PURE__ */ jsxs19("div", {
4612
6113
  className: "flex items-start gap-2",
4613
6114
  children: [
4614
- hasNested && /* @__PURE__ */ jsx16("button", {
6115
+ hasNested && /* @__PURE__ */ jsx33("button", {
4615
6116
  type: "button",
4616
6117
  onClick: () => setExpanded(!expanded),
4617
6118
  className: "mt-0.5 p-0.5 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",
4618
6119
  "aria-label": expanded ? "Collapse" : "Expand",
4619
- children: /* @__PURE__ */ jsx16(ChevronRight, {
6120
+ children: /* @__PURE__ */ jsx33(ChevronRight2, {
4620
6121
  size: 14,
4621
- className: cn4("transition-transform duration-200", expanded && "rotate-90")
6122
+ className: cn16("transition-transform duration-200", expanded && "rotate-90")
4622
6123
  })
4623
6124
  }),
4624
- !hasNested && /* @__PURE__ */ jsx16("div", {
6125
+ !hasNested && /* @__PURE__ */ jsx33("div", {
4625
6126
  className: "w-5"
4626
6127
  }),
4627
- /* @__PURE__ */ jsxs10("div", {
6128
+ /* @__PURE__ */ jsxs19("div", {
4628
6129
  className: "flex-1 min-w-0",
4629
6130
  children: [
4630
- /* @__PURE__ */ jsxs10("div", {
6131
+ /* @__PURE__ */ jsxs19("div", {
4631
6132
  className: "flex items-baseline gap-2 flex-wrap",
4632
6133
  children: [
4633
- /* @__PURE__ */ jsx16("span", {
6134
+ /* @__PURE__ */ jsx33("span", {
4634
6135
  className: "font-mono text-sm font-medium text-foreground",
4635
6136
  children: param.name
4636
6137
  }),
4637
- isRequired && /* @__PURE__ */ jsx16("span", {
6138
+ isRequired && /* @__PURE__ */ jsx33("span", {
4638
6139
  className: "text-[10px] font-semibold px-1.5 py-0.5 rounded border border-border bg-muted text-muted-foreground uppercase tracking-wide",
4639
6140
  children: "Required"
4640
6141
  }),
4641
- /* @__PURE__ */ jsx16("span", {
6142
+ /* @__PURE__ */ jsx33("span", {
4642
6143
  className: "font-mono text-sm text-muted-foreground",
4643
6144
  children: hasNested ? "object" : type
4644
6145
  }),
4645
- hasNested && /* @__PURE__ */ jsxs10("button", {
6146
+ hasNested && /* @__PURE__ */ jsxs19("button", {
4646
6147
  type: "button",
4647
6148
  onClick: () => setExpanded(!expanded),
4648
6149
  className: "text-xs text-primary hover:underline cursor-pointer",
@@ -4654,7 +6155,7 @@ function ParameterItem({
4654
6155
  })
4655
6156
  ]
4656
6157
  }),
4657
- param.description && /* @__PURE__ */ jsx16("p", {
6158
+ param.description && /* @__PURE__ */ jsx33("p", {
4658
6159
  className: "text-sm text-muted-foreground mt-1",
4659
6160
  children: param.description
4660
6161
  })
@@ -4663,9 +6164,9 @@ function ParameterItem({
4663
6164
  ]
4664
6165
  })
4665
6166
  }),
4666
- hasNested && expanded && nestedProps && /* @__PURE__ */ jsx16("div", {
6167
+ hasNested && expanded && nestedProps && /* @__PURE__ */ jsx33("div", {
4667
6168
  className: "border-l border-border ml-2 mb-3",
4668
- children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsx16(NestedPropertyItem, {
6169
+ children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsx33(NestedPropertyItem, {
4669
6170
  name: propName,
4670
6171
  schema: propSchema,
4671
6172
  required: getRequiredFields(param.schema).includes(propName),
@@ -4675,25 +6176,144 @@ function ParameterItem({
4675
6176
  ]
4676
6177
  });
4677
6178
  }
6179
+ // src/components/styled/StripeAPIReferencePage.tsx
6180
+ import { cn as cn17 } from "@openpkg-ts/ui/lib/utils";
6181
+ import { jsx as jsx34, Fragment as Fragment5 } from "react/jsx-runtime";
6182
+
6183
+ function StripeAPIReferencePage({
6184
+ spec,
6185
+ filter,
6186
+ showAllKinds = false,
6187
+ className
6188
+ }) {
6189
+ const defaultFilter = (exp) => showAllKinds ? true : exp.kind === "function";
6190
+ const activeFilter = filter ?? defaultFilter;
6191
+ const exports = spec.exports.filter(activeFilter);
6192
+ const sortedExports = [...exports].sort((a, b) => a.name.localeCompare(b.name));
6193
+ return /* @__PURE__ */ jsx34(SyncScrollProvider, {
6194
+ children: /* @__PURE__ */ jsx34("div", {
6195
+ className: cn17("openpkg-stripe-api-page", "bg-[var(--openpkg-bg-root,#0c0c0c)]", "text-[var(--openpkg-text-primary,#ededed)]", "font-[var(--openpkg-font-sans)]", "min-h-screen", className),
6196
+ children: /* @__PURE__ */ jsx34(APIReferenceLayout, {
6197
+ examples: /* @__PURE__ */ jsx34(ExamplesColumn, {
6198
+ exports: sortedExports,
6199
+ spec
6200
+ }),
6201
+ children: /* @__PURE__ */ jsx34(DocsColumn, {
6202
+ exports: sortedExports,
6203
+ spec
6204
+ })
6205
+ })
6206
+ })
6207
+ });
6208
+ }
6209
+ function DocsColumn({ exports, spec }) {
6210
+ return /* @__PURE__ */ jsx34(Fragment5, {
6211
+ children: exports.map((exp) => /* @__PURE__ */ jsx34(MethodSectionFromSpec, {
6212
+ spec,
6213
+ export: exp
6214
+ }, exp.id || exp.name))
6215
+ });
6216
+ }
6217
+ function ExamplesColumn({ exports, spec }) {
6218
+ return /* @__PURE__ */ jsx34(Fragment5, {
6219
+ children: exports.map((exp) => {
6220
+ const method = extractMethodData(exp, spec);
6221
+ const examples = getExamplesForExport(exp, spec);
6222
+ return /* @__PURE__ */ jsx34(ExampleSection, {
6223
+ id: exp.id || exp.name,
6224
+ examples,
6225
+ response: generateMockResponse(exp),
6226
+ notes: method.returnDescription
6227
+ }, exp.id || exp.name);
6228
+ })
6229
+ });
6230
+ }
6231
+ function getExamplesForExport(exp, spec) {
6232
+ const method = extractMethodData(exp, spec);
6233
+ if (method.examples.length > 0) {
6234
+ return specExamplesToCodeExamples2(method.examples);
6235
+ }
6236
+ const paramNames = method.parameters.map((p) => p.name);
6237
+ return [generateDefaultExample(spec.meta.name, exp.name, paramNames)];
6238
+ }
6239
+ function generateMockResponse(exp) {
6240
+ const sig = exp.signatures?.[0];
6241
+ if (!sig?.returns?.schema)
6242
+ return;
6243
+ const schema = sig.returns.schema;
6244
+ if (typeof schema === "object") {
6245
+ const s = schema;
6246
+ if (s.type === "void" || s.type === "undefined") {
6247
+ return;
6248
+ }
6249
+ if (s.type === "object" && s.properties) {
6250
+ const props = s.properties;
6251
+ const mock = {};
6252
+ for (const [key, propSchema] of Object.entries(props)) {
6253
+ mock[key] = getMockValue(propSchema);
6254
+ }
6255
+ return JSON.stringify(mock, null, 2);
6256
+ }
6257
+ if (s.type === "array") {
6258
+ return JSON.stringify([getMockValue(s.items)], null, 2);
6259
+ }
6260
+ }
6261
+ return;
6262
+ }
6263
+ function getMockValue(schema) {
6264
+ if (!schema)
6265
+ return null;
6266
+ switch (schema.type) {
6267
+ case "string":
6268
+ return "example";
6269
+ case "number":
6270
+ case "integer":
6271
+ return 42;
6272
+ case "boolean":
6273
+ return true;
6274
+ case "array":
6275
+ return [];
6276
+ case "object":
6277
+ return {};
6278
+ default:
6279
+ return null;
6280
+ }
6281
+ }
4678
6282
  export {
6283
+ useSyncSection,
6284
+ useSyncScroll,
6285
+ useMethodsFromSpec,
6286
+ useMethodFromSpec,
4679
6287
  specSchemaToAPISchema,
6288
+ specParamsToNestedParams,
6289
+ specParamToNestedParam,
4680
6290
  specParamToAPIParam,
4681
6291
  specExamplesToCodeExamples,
6292
+ specExampleToCodeExample,
6293
+ resolveSchemaRef,
4682
6294
  groupMembersByKind,
4683
6295
  getLanguagesFromExamples,
4684
6296
  getExampleTitle,
4685
6297
  getExampleLanguage,
4686
6298
  getExampleCode,
6299
+ generateDefaultExample,
6300
+ extractMethodData,
4687
6301
  cleanCode,
4688
6302
  buildImportStatement,
4689
6303
  VariableSection,
4690
6304
  VariablePage,
4691
6305
  TypeTable,
6306
+ SyncScrollProvider,
6307
+ StripeAPIReferencePage,
4692
6308
  Signature,
4693
6309
  ParameterItem,
4694
6310
  ParamTable,
4695
6311
  ParamRow,
4696
6312
  NestedProperty,
6313
+ NestedParameterToggle,
6314
+ NestedParameterContainer,
6315
+ MethodSectionFromSpec,
6316
+ MethodSection,
4697
6317
  MembersTable,
4698
6318
  MemberRow,
4699
6319
  InterfaceSection,
@@ -4706,12 +6326,20 @@ export {
4706
6326
  ExportIndexPage,
4707
6327
  ExportCard,
4708
6328
  ExpandableProperty,
6329
+ ExpandableParameter,
6330
+ ExampleSection,
6331
+ ExampleChips,
4709
6332
  ExampleBlock,
6333
+ EnumValuesSection,
4710
6334
  EnumSection,
4711
6335
  EnumPage,
6336
+ CollapsiblePanel,
4712
6337
  CollapsibleMethod,
4713
6338
  CodeTabs,
6339
+ CodePanel,
4714
6340
  ClassSection,
4715
6341
  ClassPage,
6342
+ APIReferenceLayout,
6343
+ APIParameterItem6 as APIParameterItem,
4716
6344
  APIPage
4717
6345
  };