@mintlify/msft-sdk 1.1.35 → 1.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,14 @@
1
1
  import "react/jsx-runtime";
2
- import $ from "@sindresorhus/slugify";
3
- const c = (r, e, t, i) => $(
4
- `${r ? `${r}-` : ""}${t ? `${t}-` : ""}${e || ""}-`,
2
+ import i from "@sindresorhus/slugify";
3
+ import "../../../contexts/EndpointLocationContext.js";
4
+ const s = (r, t, e, $) => i(
5
+ `${r ? `${r}-` : ""}${e ? `${e}-` : ""}${t || ""}-`,
5
6
  {
6
7
  decamelize: !0
7
8
  }
8
- ), s = (r, e) => r ? `${e ? `${e}` : ""}${r}.` : "";
9
+ ), m = (r, t) => r ? `${t ? `${t}` : ""}${r}.` : "";
9
10
  export {
10
- c as buildRecursiveParamFieldId,
11
- s as getRecursiveParentName
11
+ s as buildRecursiveParamFieldId,
12
+ m as getRecursiveParentName
12
13
  };
13
14
  //# sourceMappingURL=RecursiveParamField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RecursiveParamField.js","sources":["../../../../src/api-playground/EndpointFields/ParamFields/RecursiveParamField.tsx"],"sourcesContent":["\nimport { DataSchema, DataSchemaArray, IncrementalDataSchemaArray } from '@mintlify/validation';\nimport slugify from '@sindresorhus/slugify';\n\nimport { useEndpointLocation } from '@/contexts/EndpointLocationContext';\nimport { getConstFilteredSchemaArray } from '@/openapi/filterEnums';\nimport {\n getAuthFilteredSchemaArray,\n isDataSchemaArrayOrIncrementalDataSchemaArray,\n} from '@/openapi/getAuthFilteredSchemaArray';\nimport { getNextPropertiesByType } from '@/utils/api-reference/getNextPropertiesByType';\n\nimport { RecursiveParamFieldWithChildrenObserver } from './RecursiveParamFieldWithChildrenObserver';\nimport { RecursiveParamFieldWithObserver } from './RecursiveParamFieldWithObserver';\nimport { FieldType, RenderedRefs } from '@/api-playground-2/types/api';\n\nexport type RecursiveParamFieldParams = {\n fieldType: FieldType;\n schemaArray: DataSchemaArray | IncrementalDataSchemaArray;\n renderedRefs?: RenderedRefs;\n name?: string | null;\n location?: string;\n parentName?: string;\n depth?: number;\n hideDescription?: boolean;\n circularRefs?: string[];\n paramId?: string;\n style?: string;\n explode?: boolean;\n};\n\nexport const RecursiveParamField = ({\n fieldType,\n schemaArray,\n name,\n location,\n parentName,\n depth = 0,\n hideDescription = false,\n renderedRefs = new Set(),\n circularRefs,\n paramId,\n style,\n explode,\n}: RecursiveParamFieldParams) => {\n const { anchor } = useEndpointLocation();\n let filteredSchemaArray: DataSchemaArray | IncrementalDataSchemaArray | null = schemaArray;\n filteredSchemaArray = getAuthFilteredSchemaArray({ schemaArray, userGroups: undefined });\n\n if (\n filteredSchemaArray &&\n filteredSchemaArray.some((schema) => 'enum' in schema && 'const' in schema)\n ) {\n filteredSchemaArray = getConstFilteredSchemaArray({ schemaArray });\n }\n\n if (!isDataSchemaArrayOrIncrementalDataSchemaArray(filteredSchemaArray)) {\n return null;\n }\n\n const RecursiveParamFieldType = anchor\n ? RecursiveParamFieldWithChildrenObserver\n : RecursiveParamFieldWithObserver;\n\n return (\n <RecursiveParamFieldType\n fieldType={fieldType}\n schemaArray={filteredSchemaArray}\n name={name}\n location={location}\n parentName={parentName}\n depth={depth}\n style={style}\n explode={explode}\n hideDescription={hideDescription}\n renderedRefs={renderedRefs}\n circularRefs={circularRefs}\n paramId={paramId}\n />\n );\n};\n\ntype RenderNextPropertiesRecursivelyParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n depth: number;\n refs: Set<string>;\n parentName?: string;\n name?: string | null;\n currentSchemaRef: string | undefined;\n style?: string;\n explode?: boolean;\n hideParentName?: boolean;\n};\n\nexport const renderNextPropertiesRecursively = ({\n currentSchemaRef,\n properties,\n fieldType,\n parentName,\n name,\n depth,\n refs,\n style,\n explode,\n hideParentName,\n}: RenderNextPropertiesRecursivelyParams) => {\n // Create a new set with the current refs for this level\n const currentLevelRefs = new Set(refs);\n\n if (currentSchemaRef) {\n currentLevelRefs.add(currentSchemaRef);\n }\n\n if (currentLevelRefs.size > 0) {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const nextSchemaArrayProperties = getNextPropertiesByType(nextSchemaArray);\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n let circularReferences: string[] = [];\n if (\n Object.values(nextSchemaArrayProperties).some(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n )\n ) {\n circularReferences = Object.values(nextSchemaArrayProperties).filter(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n );\n }\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set(currentLevelRefs)}\n circularRefs={circularReferences}\n style={style}\n explode={explode}\n />\n );\n });\n } else {\n return properties.map(([propertyName, schemaArray]) => {\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set()}\n style={style}\n explode={explode}\n />\n );\n });\n }\n};\n\ntype RenderTruncatedNextPropertiesParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n parentName?: string;\n name?: string | null;\n depth: number;\n};\n\nexport const renderTruncatedNextProperties = ({\n properties,\n fieldType,\n parentName,\n name,\n depth,\n}: RenderTruncatedNextPropertiesParams) => {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const baseSchema: DataSchema = nextSchemaArray as DataSchema;\n if (baseSchema.type === 'array') {\n baseSchema.items = [{ type: 'any' }];\n } else if (baseSchema.type === 'object') {\n baseSchema.properties = {};\n }\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName);\n const id = `${paramId}-${propertyName}`;\n return (\n <RecursiveParamField\n fieldType={fieldType}\n key={propertyName}\n schemaArray={[baseSchema]}\n name={propertyName}\n paramId={id}\n depth={depth + 1}\n renderedRefs={new Set()}\n />\n );\n });\n};\n\nexport const buildRecursiveParamFieldId = (\n fieldType: FieldType | undefined,\n name: string | undefined | null,\n parentName: string | undefined,\n propertyName?: string | undefined\n) => {\n return slugify(\n `${fieldType ? `${fieldType}-` : ''}${parentName ? `${parentName}-` : ''}${name ? name : ''}-${propertyName ? propertyName : ''}`,\n {\n decamelize: true,\n }\n );\n};\n\nexport const getRecursiveParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return `${parentName ? `${parentName}` : ''}${name}.`;\n};\n\nexport const getDeepObjectParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return parentName ? `${parentName}${name}][` : `${name}[`;\n};\n"],"names":["buildRecursiveParamFieldId","fieldType","name","parentName","propertyName","slugify","getRecursiveParentName"],"mappings":";;AAyNO,MAAMA,IAA6B,CACxCC,GACAC,GACAC,GACAC,MAEOC;AAAA,EACL,GAAGJ,IAAY,GAAGA,CAAS,MAAM,EAAE,GAAGE,IAAa,GAAGA,CAAU,MAAM,EAAE,GAAGD,KAAc,EAAE;AAAA,EAC3F;AAAA,IACE,YAAY;AAAA,EAAA;AACd,GAISI,IAAyB,CAACJ,GAAsBC,MACtDD,IAIE,GAAGC,IAAa,GAAGA,CAAU,KAAK,EAAE,GAAGD,CAAI,MAHzC;"}
1
+ {"version":3,"file":"RecursiveParamField.js","sources":["../../../../src/api-playground/EndpointFields/ParamFields/RecursiveParamField.tsx"],"sourcesContent":["\nimport { DataSchema, DataSchemaArray, IncrementalDataSchemaArray } from '@mintlify/validation';\nimport slugify from '@sindresorhus/slugify';\n\nimport { useEndpointLocation } from '@/contexts/EndpointLocationContext';\nimport { getConstFilteredSchemaArray } from '@/openapi/filterEnums';\nimport {\n getAuthFilteredSchemaArray,\n isDataSchemaArrayOrIncrementalDataSchemaArray,\n} from '@/openapi/getAuthFilteredSchemaArray';\nimport { getNextPropertiesByType } from '@/utils/api-reference/getNextPropertiesByType';\n\nimport { RecursiveParamFieldWithChildrenObserver } from './RecursiveParamFieldWithChildrenObserver';\nimport { RecursiveParamFieldWithObserver } from './RecursiveParamFieldWithObserver';\nimport { FieldType, RenderedRefs } from '@/api-playground-2/types/api';\n\nexport type RecursiveParamFieldParams = {\n fieldType: FieldType;\n schemaArray: DataSchemaArray | IncrementalDataSchemaArray;\n renderedRefs?: RenderedRefs;\n name?: string | null;\n location?: string;\n parentName?: string;\n depth?: number;\n hideDescription?: boolean;\n circularRefs?: string[];\n paramId?: string;\n style?: string;\n explode?: boolean;\n};\n\nexport const RecursiveParamField = ({\n fieldType,\n schemaArray,\n name,\n location,\n parentName,\n depth = 0,\n hideDescription = false,\n renderedRefs = new Set(),\n circularRefs,\n paramId,\n style,\n explode,\n}: RecursiveParamFieldParams) => {\n const { anchor } = useEndpointLocation();\n let filteredSchemaArray: DataSchemaArray | IncrementalDataSchemaArray | null = schemaArray;\n filteredSchemaArray = getAuthFilteredSchemaArray({ schemaArray, userGroups: undefined });\n\n if (\n filteredSchemaArray &&\n filteredSchemaArray.some((schema) => 'enum' in schema && 'const' in schema)\n ) {\n filteredSchemaArray = getConstFilteredSchemaArray({ schemaArray });\n }\n\n if (!isDataSchemaArrayOrIncrementalDataSchemaArray(filteredSchemaArray)) {\n return null;\n }\n\n const RecursiveParamFieldType = anchor\n ? RecursiveParamFieldWithChildrenObserver\n : RecursiveParamFieldWithObserver;\n\n return (\n <RecursiveParamFieldType\n fieldType={fieldType}\n schemaArray={filteredSchemaArray}\n name={name}\n location={location}\n parentName={parentName}\n depth={depth}\n style={style}\n explode={explode}\n hideDescription={hideDescription}\n renderedRefs={renderedRefs}\n circularRefs={circularRefs}\n paramId={paramId}\n />\n );\n};\n\ntype RenderNextPropertiesRecursivelyParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n depth: number;\n refs: Set<string>;\n parentName?: string;\n name?: string | null;\n currentSchemaRef: string | undefined;\n style?: string;\n explode?: boolean;\n hideParentName?: boolean;\n};\n\nexport const renderNextPropertiesRecursively = ({\n currentSchemaRef,\n properties,\n fieldType,\n parentName,\n name,\n depth,\n refs,\n style,\n explode,\n hideParentName,\n}: RenderNextPropertiesRecursivelyParams) => {\n // Create a new set with the current refs for this level\n const currentLevelRefs = new Set(refs);\n\n if (currentSchemaRef) {\n currentLevelRefs.add(currentSchemaRef);\n }\n\n if (currentLevelRefs.size > 0) {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const nextSchemaArrayProperties = getNextPropertiesByType(nextSchemaArray);\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n let circularReferences: string[] = [];\n if (\n Object.values(nextSchemaArrayProperties).some(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n )\n ) {\n circularReferences = Object.values(nextSchemaArrayProperties).filter(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n );\n }\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set(currentLevelRefs)}\n circularRefs={circularReferences}\n style={style}\n explode={explode}\n />\n );\n });\n } else {\n return properties.map(([propertyName, schemaArray]) => {\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set()}\n style={style}\n explode={explode}\n />\n );\n });\n }\n};\n\ntype RenderTruncatedNextPropertiesParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n parentName?: string;\n name?: string | null;\n depth: number;\n};\n\nexport const renderTruncatedNextProperties = ({\n properties,\n fieldType,\n parentName,\n name,\n depth,\n}: RenderTruncatedNextPropertiesParams) => {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const baseSchema: DataSchema = nextSchemaArray as DataSchema;\n if (baseSchema.type === 'array') {\n baseSchema.items = [{ type: 'any' }];\n } else if (baseSchema.type === 'object') {\n baseSchema.properties = {};\n }\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName);\n const id = `${paramId}-${propertyName}`;\n return (\n <RecursiveParamField\n fieldType={fieldType}\n key={propertyName}\n schemaArray={[baseSchema]}\n name={propertyName}\n paramId={id}\n depth={depth + 1}\n renderedRefs={new Set()}\n />\n );\n });\n};\n\nexport const buildRecursiveParamFieldId = (\n fieldType: FieldType | undefined,\n name: string | undefined | null,\n parentName: string | undefined,\n propertyName?: string | undefined\n) => {\n return slugify(\n `${fieldType ? `${fieldType}-` : ''}${parentName ? `${parentName}-` : ''}${name ? name : ''}-${propertyName ? propertyName : ''}`,\n {\n decamelize: true,\n }\n );\n};\n\nexport const getRecursiveParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return `${parentName ? `${parentName}` : ''}${name}.`;\n};\n\nexport const getDeepObjectParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return parentName ? `${parentName}${name}][` : `${name}[`;\n};\n"],"names":["buildRecursiveParamFieldId","fieldType","name","parentName","propertyName","slugify","getRecursiveParentName"],"mappings":";;;AAyNO,MAAMA,IAA6B,CACxCC,GACAC,GACAC,GACAC,MAEOC;AAAA,EACL,GAAGJ,IAAY,GAAGA,CAAS,MAAM,EAAE,GAAGE,IAAa,GAAGA,CAAU,MAAM,EAAE,GAAGD,KAAc,EAAE;AAAA,EAC3F;AAAA,IACE,YAAY;AAAA,EAAA;AACd,GAISI,IAAyB,CAACJ,GAAsBC,MACtDD,IAIE,GAAGC,IAAa,GAAGA,CAAU,KAAK,EAAE,GAAGD,CAAI,MAHzC;"}
@@ -1,7 +1,8 @@
1
1
  import "react/jsx-runtime";
2
- import { useOpenApiEndpoint as n } from "../../hooks/useEndpoint.js";
3
- const p = () => (n(), null);
2
+ import "../../contexts/EndpointLocationContext.js";
3
+ import { useOpenApiEndpoint as t } from "../../hooks/useEndpoint.js";
4
+ const i = () => (t(), null);
4
5
  export {
5
- p as default
6
+ i as default
6
7
  };
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/api-playground/EndpointFields/index.tsx"],"sourcesContent":["\nimport { EndpointLocationProvider } from '@/contexts/EndpointLocationContext';\nimport { useOpenApiEndpoint } from '@/hooks/useEndpoint';\nimport { getFilteredSecurityOptions } from '@/utils/api-reference/getFilteredSecurityOptions';\n\nimport { EndpointBody } from './EndpointBody';\nimport { EndpointParameters } from './EndpointParameters';\nimport { EndpointResponse } from './EndpointResponse';\nimport { EndpointSecurity } from './EndpointSecurity';\n\nconst EndpointFields = () => {\n const endpoint = useOpenApiEndpoint();\n const newApiReferencePage = true;\n\n if (endpoint === undefined || newApiReferencePage) {\n return null;\n }\n\n // TODO(ronan): remove when all security options are handled (none should be empty)\n const filteredSecurityOptions = getFilteredSecurityOptions(endpoint);\n\n return (\n <>\n {filteredSecurityOptions.length > 0 && (\n <EndpointSecurity securityOptions={filteredSecurityOptions} />\n )}\n <EndpointParameters parameters={endpoint.request.parameters} />\n <EndpointLocationProvider location=\"request\">\n <EndpointBody body={endpoint.request.body} />\n </EndpointLocationProvider>\n <EndpointLocationProvider location=\"response\">\n {Object.entries(endpoint.response)[0] && <EndpointResponse response={endpoint.response} />}\n </EndpointLocationProvider>\n </>\n );\n};\n\nexport default EndpointFields;\n"],"names":["EndpointFields","useOpenApiEndpoint"],"mappings":";;AAUA,MAAMA,IAAiB,OACJC,EAAA,GAIR;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/api-playground/EndpointFields/index.tsx"],"sourcesContent":["\nimport { EndpointLocationProvider } from '@/contexts/EndpointLocationContext';\nimport { useOpenApiEndpoint } from '@/hooks/useEndpoint';\nimport { getFilteredSecurityOptions } from '@/utils/api-reference/getFilteredSecurityOptions';\n\nimport { EndpointBody } from './EndpointBody';\nimport { EndpointParameters } from './EndpointParameters';\nimport { EndpointResponse } from './EndpointResponse';\nimport { EndpointSecurity } from './EndpointSecurity';\n\nconst EndpointFields = () => {\n const endpoint = useOpenApiEndpoint();\n const newApiReferencePage = true;\n\n if (endpoint === undefined || newApiReferencePage) {\n return null;\n }\n\n // TODO(ronan): remove when all security options are handled (none should be empty)\n const filteredSecurityOptions = getFilteredSecurityOptions(endpoint);\n\n return (\n <>\n {filteredSecurityOptions.length > 0 && (\n <EndpointSecurity securityOptions={filteredSecurityOptions} />\n )}\n <EndpointParameters parameters={endpoint.request.parameters} />\n <EndpointLocationProvider location=\"request\">\n <EndpointBody body={endpoint.request.body} />\n </EndpointLocationProvider>\n <EndpointLocationProvider location=\"response\">\n {Object.entries(endpoint.response)[0] && <EndpointResponse response={endpoint.response} />}\n </EndpointLocationProvider>\n </>\n );\n};\n\nexport default EndpointFields;\n"],"names":["EndpointFields","useOpenApiEndpoint"],"mappings":";;;AAUA,MAAMA,IAAiB,OACJC,EAAA,GAIR;"}
@@ -34,8 +34,8 @@ const f = {
34
34
  warning: "Warning",
35
35
  nextstepaction: "Next step action"
36
36
  };
37
- function h({ type: n, children: e }) {
38
- const i = f[n], a = b[n];
37
+ function h({ type: i, children: e }) {
38
+ const n = f[i], a = b[i];
39
39
  return /* @__PURE__ */ r(
40
40
  "aside",
41
41
  {
@@ -43,17 +43,10 @@ function h({ type: n, children: e }) {
43
43
  "aria-label": a,
44
44
  className: l(
45
45
  "mint:my-4 mint:flex mint:gap-2 mint:px-3 mint:py-2.5 mint:rounded-lg mint:border mint:overflow-hidden",
46
- i.className
46
+ n.className
47
47
  ),
48
48
  children: [
49
- i.icon && /* @__PURE__ */ t(
50
- "div",
51
- {
52
- className: "mint:flex mint:items-start mint:justify-center",
53
- "aria-hidden": "true",
54
- children: i.icon
55
- }
56
- ),
49
+ n.icon && /* @__PURE__ */ t("div", { className: "mint:flex mint:items-center mint:justify-center", "aria-hidden": "true", children: n.icon }),
57
50
  /* @__PURE__ */ t("div", { className: "mint:text-sm mint:min-w-0 mint:w-full mint:max-w-none mint:prose mint:dark:prose-invert mint:[&>p:first-child]:font-semibold", children: e })
58
51
  ]
59
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"callouts.js","sources":["../../../src/components/content-components/callouts.tsx"],"sourcesContent":["import {\n Lightbulb20Regular,\n InfoFilled,\n Warning20Regular,\n DismissCircle20Regular,\n Info20Regular,\n} from \"@fluentui/react-icons\";\nimport { cn } from \"../../utils/cn\";\n\nexport type CalloutType =\n | \"note\"\n | \"tip\"\n | \"important\"\n | \"caution\"\n | \"warning\"\n | \"nextstepaction\";\n\ninterface CalloutProps {\n type: CalloutType;\n children: React.ReactNode;\n}\n\nconst calloutConfig: Record<\n CalloutType,\n {\n icon?: React.ReactNode;\n className: string;\n }\n> = {\n tip: {\n icon: <Lightbulb20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n \"mint:bg-[#f1faf1] mint:border-[#9fd89f] mint:text-[#0c5e0c] mint:dark:bg-[#052505] mint:dark:border-[#54b054] mint:dark:text-[#54b054]\",\n },\n note: {\n icon: <Info20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n \"mint:bg-[#f5f5f5] mint:border-[#d1d1d1] mint:text-[#242424] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white\",\n },\n warning: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n \"mint:bg-[#fff9f5] mint:border-[#fdcfb4] mint:text-[#8a3707] mint:dark:bg-[#4a1e04] mint:dark:border-[#de590b] mint:dark:text-[#faa06b]\",\n },\n caution: {\n icon: (\n <DismissCircle20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />\n ),\n className:\n \"mint:bg-[#fdf3f4] mint:border-[#eeacb2] mint:text-[#960b18] mint:dark:bg-[#3b0509] mint:dark:border-[#c50f1f] mint:dark:text-[#dc626d]\",\n },\n important: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n \"mint:bg-[#e1cefc] mint:border-[#8251ee] mint:text-[#643fb2] mint:dark:bg-[#1a1326] mint:dark:border-[#9263f1] mint:dark:text-[#9263f1]\",\n },\n nextstepaction: {\n icon: (\n <InfoFilled className=\"mint:w-5 mint:h-5 mint:shrink-0 mint:text-[#616161] mint:dark:text-white\" />\n ),\n className:\n \"mint:bg-[#f9fafb] mint:border-[#d1d1d1] mint:text-[#141414] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white\",\n },\n};\n\nconst calloutLabels: Record<CalloutType, string> = {\n note: \"Note\",\n tip: \"Tip\",\n important: \"Important\",\n caution: \"Caution\",\n warning: \"Warning\",\n nextstepaction: \"Next step action\",\n};\n\nexport function Callout({ type, children }: CalloutProps) {\n const config = calloutConfig[type];\n const label = calloutLabels[type];\n\n return (\n <aside\n role=\"note\"\n aria-label={label}\n className={cn(\n \"mint:my-4 mint:flex mint:gap-2 mint:px-3 mint:py-2.5 mint:rounded-lg mint:border mint:overflow-hidden\",\n config.className\n )}\n >\n {config.icon && (\n <div\n className=\"mint:flex mint:items-start mint:justify-center\"\n aria-hidden=\"true\"\n >\n {config.icon}\n </div>\n )}\n <div className=\"mint:text-sm mint:min-w-0 mint:w-full mint:max-w-none mint:prose mint:dark:prose-invert mint:[&>p:first-child]:font-semibold\">\n {children}\n </div>\n </aside>\n );\n}\n"],"names":["calloutConfig","jsx","Lightbulb20Regular","Info20Regular","Warning20Regular","DismissCircle20Regular","InfoFilled","calloutLabels","Callout","type","children","config","label","jsxs","cn"],"mappings":";;;AAsBA,MAAMA,IAMF;AAAA,EACF,KAAK;AAAA,IACH,MAAM,gBAAAC,EAACC,GAAA,EAAmB,WAAU,kCAAA,CAAkC;AAAA,IACtE,WACE;AAAA,EAAA;AAAA,EAEJ,MAAM;AAAA,IACJ,MAAM,gBAAAD,EAACE,GAAA,EAAc,WAAU,kCAAA,CAAkC;AAAA,IACjE,WACE;AAAA,EAAA;AAAA,EAEJ,SAAS;AAAA,IACP,MAAM,gBAAAF,EAACG,GAAA,EAAiB,WAAU,kCAAA,CAAkC;AAAA,IACpE,WACE;AAAA,EAAA;AAAA,EAEJ,SAAS;AAAA,IACP,MACE,gBAAAH,EAACI,GAAA,EAAuB,WAAU,kCAAA,CAAkC;AAAA,IAEtE,WACE;AAAA,EAAA;AAAA,EAEJ,WAAW;AAAA,IACT,MAAM,gBAAAJ,EAACG,GAAA,EAAiB,WAAU,kCAAA,CAAkC;AAAA,IACpE,WACE;AAAA,EAAA;AAAA,EAEJ,gBAAgB;AAAA,IACd,MACE,gBAAAH,EAACK,GAAA,EAAW,WAAU,2EAAA,CAA2E;AAAA,IAEnG,WACE;AAAA,EAAA;AAEN,GAEMC,IAA6C;AAAA,EACjD,MAAM;AAAA,EACN,KAAK;AAAA,EACL,WAAW;AAAA,EACX,SAAS;AAAA,EACT,SAAS;AAAA,EACT,gBAAgB;AAClB;AAEO,SAASC,EAAQ,EAAE,MAAAC,GAAM,UAAAC,KAA0B;AACxD,QAAMC,IAASX,EAAcS,CAAI,GAC3BG,IAAQL,EAAcE,CAAI;AAEhC,SACE,gBAAAI;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAYD;AAAA,MACZ,WAAWE;AAAA,QACT;AAAA,QACAH,EAAO;AAAA,MAAA;AAAA,MAGR,UAAA;AAAA,QAAAA,EAAO,QACN,gBAAAV;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA,YAEX,UAAAU,EAAO;AAAA,UAAA;AAAA,QAAA;AAAA,QAGZ,gBAAAV,EAAC,OAAA,EAAI,WAAU,gIACZ,UAAAS,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"callouts.js","sources":["../../../src/components/content-components/callouts.tsx"],"sourcesContent":["import {\n Lightbulb20Regular,\n InfoFilled,\n Warning20Regular,\n DismissCircle20Regular,\n Info20Regular,\n} from '@fluentui/react-icons';\n\nimport { cn } from '../../utils/cn';\n\nexport type CalloutType = 'note' | 'tip' | 'important' | 'caution' | 'warning' | 'nextstepaction';\n\ninterface CalloutProps {\n type: CalloutType;\n children: React.ReactNode;\n}\n\nconst calloutConfig: Record<\n CalloutType,\n {\n icon?: React.ReactNode;\n className: string;\n }\n> = {\n tip: {\n icon: <Lightbulb20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#f1faf1] mint:border-[#9fd89f] mint:text-[#0c5e0c] mint:dark:bg-[#052505] mint:dark:border-[#54b054] mint:dark:text-[#54b054]',\n },\n note: {\n icon: <Info20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#f5f5f5] mint:border-[#d1d1d1] mint:text-[#242424] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white',\n },\n warning: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#fff9f5] mint:border-[#fdcfb4] mint:text-[#8a3707] mint:dark:bg-[#4a1e04] mint:dark:border-[#de590b] mint:dark:text-[#faa06b]',\n },\n caution: {\n icon: <DismissCircle20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#fdf3f4] mint:border-[#eeacb2] mint:text-[#960b18] mint:dark:bg-[#3b0509] mint:dark:border-[#c50f1f] mint:dark:text-[#dc626d]',\n },\n important: {\n icon: <Warning20Regular className=\"mint:w-5 mint:h-5 mint:shrink-0\" />,\n className:\n 'mint:bg-[#e1cefc] mint:border-[#8251ee] mint:text-[#643fb2] mint:dark:bg-[#1a1326] mint:dark:border-[#9263f1] mint:dark:text-[#9263f1]',\n },\n nextstepaction: {\n icon: (\n <InfoFilled className=\"mint:w-5 mint:h-5 mint:shrink-0 mint:text-[#616161] mint:dark:text-white\" />\n ),\n className:\n 'mint:bg-[#f9fafb] mint:border-[#d1d1d1] mint:text-[#141414] mint:dark:bg-[#141414] mint:dark:border-[#666666] mint:dark:text-white',\n },\n};\n\nconst calloutLabels: Record<CalloutType, string> = {\n note: 'Note',\n tip: 'Tip',\n important: 'Important',\n caution: 'Caution',\n warning: 'Warning',\n nextstepaction: 'Next step action',\n};\n\nexport function Callout({ type, children }: CalloutProps) {\n const config = calloutConfig[type];\n const label = calloutLabels[type];\n\n return (\n <aside\n role=\"note\"\n aria-label={label}\n className={cn(\n 'mint:my-4 mint:flex mint:gap-2 mint:px-3 mint:py-2.5 mint:rounded-lg mint:border mint:overflow-hidden',\n config.className\n )}\n >\n {config.icon && (\n <div className=\"mint:flex mint:items-center mint:justify-center\" aria-hidden=\"true\">\n {config.icon}\n </div>\n )}\n <div className=\"mint:text-sm mint:min-w-0 mint:w-full mint:max-w-none mint:prose mint:dark:prose-invert mint:[&>p:first-child]:font-semibold\">\n {children}\n </div>\n </aside>\n );\n}\n"],"names":["calloutConfig","jsx","Lightbulb20Regular","Info20Regular","Warning20Regular","DismissCircle20Regular","InfoFilled","calloutL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EF,gBAAAV,EAAC,OAAA,EAAI,WAAU,gIACZ,UAAAS,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1,17 +1,17 @@
1
1
  import { jsx as o, jsxs as v } from "react/jsx-runtime";
2
- import N, { useState as C, useEffect as B } from "react";
2
+ import { ClipboardCheckmarkRegular as N, Copy20Regular as B } from "@fluentui/react-icons";
3
3
  import b from "prismjs";
4
- import "prismjs/components/prism-javascript.js";
5
- import "prismjs/components/prism-typescript.js";
6
- import "prismjs/components/prism-python.js";
7
4
  import "prismjs/components/prism-bash.js";
5
+ import "prismjs/components/prism-csharp.js";
6
+ import "prismjs/components/prism-javascript.js";
8
7
  import "prismjs/components/prism-json.js";
9
8
  import "prismjs/components/prism-markdown.js";
10
- import "prismjs/components/prism-csharp.js";
11
9
  import "prismjs/components/prism-powershell.js";
12
- import { getNodeText as I } from "../../utils/get-node-text.js";
10
+ import "prismjs/components/prism-python.js";
11
+ import "prismjs/components/prism-typescript.js";
12
+ import I, { useState as C, useEffect as A } from "react";
13
13
  import { cn as h } from "../../utils/cn.js";
14
- import { ClipboardCheckmarkRegular as A, Copy20Regular as R } from "@fluentui/react-icons";
14
+ import { getNodeText as R } from "../../utils/get-node-text.js";
15
15
  const w = ["image/png", "text/plain"];
16
16
  function g() {
17
17
  const [t, e] = C(!1), n = async (r) => {
@@ -52,18 +52,24 @@ function _({ onClick: t, isCopied: e, showTooltip: n = !0 }) {
52
52
  onClick: t,
53
53
  className: "mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]",
54
54
  "aria-label": e ? "Copied" : "Copy code",
55
- children: e ? /* @__PURE__ */ o(A, { className: "mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]" }) : /* @__PURE__ */ o(R, { className: "mint:w-5 mint:h-5" })
55
+ children: e ? /* @__PURE__ */ o(N, { className: "mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]" }) : /* @__PURE__ */ o(B, { className: "mint:w-5 mint:h-5" })
56
56
  }
57
57
  )
58
58
  ] });
59
59
  }
60
- function q({ textToCopy: t, showTooltip: e = !0 }) {
60
+ function q({
61
+ textToCopy: t,
62
+ showTooltip: e = !0
63
+ }) {
61
64
  const { isCopied: n, copy: p } = g();
62
65
  return /* @__PURE__ */ o(_, { onClick: () => {
63
66
  p(t);
64
67
  }, isCopied: n, showTooltip: e });
65
68
  }
66
- function G({ data: t, showTooltip: e = !0 }) {
69
+ function G({
70
+ data: t,
71
+ showTooltip: e = !0
72
+ }) {
67
73
  const { isCopied: n, copy: p, copyBlob: r } = g();
68
74
  return /* @__PURE__ */ o(_, { onClick: () => {
69
75
  t.contentType && w.includes(t.contentType) ? r(t.blob, t.contentType) : t.type === "other" && t.content ? p(t.content) : console.error("Unsupported content type for clipboard");
@@ -79,7 +85,7 @@ function J({
79
85
  }) {
80
86
  const [i, a] = C("");
81
87
  g();
82
- const m = p || (e == null ? void 0 : e.replace(/^language-/, "")) || "text", d = I(t), k = !!n, u = N.useMemo(() => {
88
+ const m = p || (e == null ? void 0 : e.replace(/^language-/, "")) || "text", d = R(t), k = !!n, u = I.useMemo(() => {
83
89
  var f, y;
84
90
  if (typeof t != "object" || t == null)
85
91
  return !1;
@@ -93,7 +99,7 @@ function J({
93
99
  }
94
100
  return !1;
95
101
  }, [t]);
96
- return B(() => {
102
+ return A(() => {
97
103
  if (!u)
98
104
  try {
99
105
  const s = b.languages[m] || b.languages.plaintext, f = b.highlight(d, s, m);
@@ -1 +1 @@
1
- {"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["\nimport React, { useEffect, useState } from \"react\";\nimport Prism from \"prismjs\";\nimport \"prismjs/components/prism-javascript.js\";\nimport \"prismjs/components/prism-typescript.js\";\nimport \"prismjs/components/prism-python.js\";\nimport \"prismjs/components/prism-bash.js\";\nimport \"prismjs/components/prism-json.js\";\nimport \"prismjs/components/prism-markdown.js\";\nimport \"prismjs/components/prism-csharp.js\";\nimport \"prismjs/components/prism-powershell.js\";\nimport { getNodeText } from \"../../utils/get-node-text\";\nimport { capitalize } from \"../../utils/string\";\nimport { cn } from \"../../utils/cn\";\nimport {\n Copy20Regular,\n ClipboardCheckmarkRegular,\n} from \"@fluentui/react-icons\";\n\nconst SUPPORTED_CLIPBOARD_CONTENT_TYPES = [\"image/png\", \"text/plain\"];\n\n// Hook for clipboard operations\nexport function useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error(\"Failed to copy to clipboard:\", error);\n }\n };\n\n const copyBlob = async (blob: Blob, contentType: string) => {\n try {\n // image/png, text/plain, and text/html are the only filetypes supported in the chromium\n // clipboard - however, text/html crashes chrome for some reason\n if (SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(contentType)) {\n const buffer = await blob.arrayBuffer();\n const newBlob = new Blob([buffer], { type: contentType });\n const clipboardItem = new ClipboardItem({\n [contentType]: newBlob,\n });\n await navigator.clipboard.write([clipboardItem]);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } else {\n // Fallback to text copy for unsupported types\n const text = await blob.text();\n await copy(text);\n }\n } catch (error) {\n console.error(\"Failed to copy blob to clipboard:\", error);\n // Fallback to text copy if blob copy fails\n try {\n const text = await blob.text();\n await copy(text);\n } catch (fallbackError) {\n console.error(\"Failed to copy as text fallback:\", fallbackError);\n }\n }\n };\n\n return { isCopied, copy, copyBlob };\n}\n\n// Base copy icon button component\ninterface CopyIconButtonProps {\n onClick: () => void;\n isCopied: boolean;\n showTooltip?: boolean;\n}\n\nexport function CopyIconButton({ onClick, isCopied, showTooltip = true }: CopyIconButtonProps) {\n return (\n <div className=\"mint:relative\">\n {showTooltip && isCopied && (\n <div className=\"mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]\">\n Copied!\n </div>\n )}\n <button\n onClick={onClick}\n className=\"mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]\"\n aria-label={isCopied ? \"Copied\" : \"Copy code\"}\n >\n {isCopied ? (\n <ClipboardCheckmarkRegular className=\"mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n ) : (\n <Copy20Regular className=\"mint:w-5 mint:h-5\" />\n )}\n </button>\n </div>\n );\n}\n\n// Convenience component that handles text copying\ninterface CopyToClipboardButtonProps {\n textToCopy: string;\n showTooltip?: boolean;\n}\n\nexport function CopyToClipboardButton({ textToCopy, showTooltip = true }: CopyToClipboardButtonProps) {\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = () => {\n copy(textToCopy);\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\n// Convenience component that handles blob/data copying\ninterface CopyDataToClipboardButtonProps {\n data: {\n type: 'image' | 'audio' | 'video' | 'other';\n blob: Blob;\n contentType?: string;\n content?: string;\n };\n showTooltip?: boolean;\n}\n\nexport function CopyDataToClipboardButton({ data, showTooltip = true }: CopyDataToClipboardButtonProps) {\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n\n const handleCopy = () => {\n // Check if we can copy as blob (for images, etc.)\n if (data.contentType && SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(data.contentType)) {\n copyBlob(data.blob, data.contentType);\n } else if (data.type === 'other' && data.content) {\n // For text content, copy as text\n copy(data.content);\n } else {\n console.error('Unsupported content type for clipboard');\n }\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n // Support for copying blobs (images, etc.)\n blob?: Blob;\n contentType?: string;\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n blob,\n contentType,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>(\"\");\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, \"\") || \"text\";\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== \"object\" || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (\n typeof child === \"object\" &&\n child != null &&\n \"props\" in child &&\n child.props?.children\n ) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === \"object\" &&\n codeChild != null &&\n \"props\" in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error(\"Failed to highlight code:\", error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n // If blob and contentType are provided, use blob copying\n if (blob && contentType) {\n copyBlob(blob, contentType);\n } else {\n // Otherwise, use text copying\n copy(codeText);\n }\n };\n\n return (\n <div\n className={\n showContainer\n ? \"mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden\"\n : undefined\n }\n >\n <div className=\"not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414]\">\n <div className=\"mint:code-scrollbar mint:overflow-x-scroll\">\n <pre className=\"mint:px-4 mint:py-2 mint:m-0 mint:whitespace-pre mint:text-sm\">\n {isSSRHighlighted ? (\n <code\n className={cn(\n `language-${lang}`,\n \"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]\"\n )}\n >\n {children}\n </code>\n ) : highlightedCode ? (\n <code\n className={cn(\n `language-${lang}`,\n \"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]\"\n )}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <code\n className={cn(\n `language-${lang}`,\n \"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]\"\n )}\n >\n {codeText}\n </code>\n )}\n </pre>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["SUPPORTED_CLIPBOARD_CONTENT_TYPES","useCopyToClipboard","isCopied","setIsCopied","useState","copy","text","error","blob","contentType","buffer","newBlob","clipboardItem","fallbackError","CopyIconButton","onClick","showTooltip","jsxs","jsx","ClipboardCheckmarkRegular","Copy20Regular","CopyToClipboardButton","textToCopy","CopyDataToClipboardButton","data","copyBlob","CodeBlock","children","className","fileName","language","highlightedCode","setHighlightedCode","lang","codeText","getNodeText","showContainer","isSSRHighlighted","React","childrenArray","child","_a","codeChildren","codeChild","_b","useEffect","grammar","Prism","html","cn"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAMA,IAAoC,CAAC,aAAa,YAAY;AAG7D,SAASC,IAAqB;AACnC,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAO,OAAOC,MAAiB;AACnC,QAAI;AACF,YAAM,UAAU,UAAU,UAAUA,CAAI,GACxCH,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,IAC3C,SAASI,GAAO;AACd,cAAQ,MAAM,gCAAgCA,CAAK;AAAA,IACrD;AAAA,EACF;AAgCA,SAAO,EAAE,UAAAL,GAAU,MAAAG,GAAM,UA9BR,OAAOG,GAAYC,MAAwB;AAC1D,QAAI;AAGF,UAAIT,EAAkC,SAASS,CAAW,GAAG;AAC3D,cAAMC,IAAS,MAAMF,EAAK,YAAA,GACpBG,IAAU,IAAI,KAAK,CAACD,CAAM,GAAG,EAAE,MAAMD,GAAa,GAClDG,IAAgB,IAAI,cAAc;AAAA,UACtC,CAACH,CAAW,GAAGE;AAAA,QAAA,CAChB;AACD,cAAM,UAAU,UAAU,MAAM,CAACC,CAAa,CAAC,GAC/CT,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,MAC3C,OAAO;AAEL,cAAMG,IAAO,MAAME,EAAK,KAAA;AACxB,cAAMH,EAAKC,CAAI;AAAA,MACjB;AAAA,IACF,SAASC,GAAO;AACd,cAAQ,MAAM,qCAAqCA,CAAK;AAExD,UAAI;AACF,cAAMD,IAAO,MAAME,EAAK,KAAA;AACxB,cAAMH,EAAKC,CAAI;AAAA,MACjB,SAASO,GAAe;AACtB,gBAAQ,MAAM,oCAAoCA,CAAa;AAAA,MACjE;AAAA,IACF;AAAA,EACF,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AA,MACC,WACEkB,IACI,oGACA;AAAA,MAGN,UAAA,gBAAAlB,EAAC,OAAA,EAAI,WAAU,oFACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,8CACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,iEACZ,UAAAmB,IACC,gBAAAnB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAGD,UAAAN;AAAA,QAAA;AAAA,MAAA,IAEDI,IACF,gBAAAb;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAEF,yBAAyB,EAAE,QAAQF,EAAA;AAAA,QAAgB;AAAA,MAAA,IAGrD,gBAAAb;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAGD,UAAAC;AAAA,QAAA;AAAA,MAAA,EACH,CAEJ,GACF,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["import { Copy20Regular, ClipboardCheckmarkRegular } from '@fluentui/react-icons';\nimport Prism from 'prismjs';\nimport 'prismjs/components/prism-bash.js';\nimport 'prismjs/components/prism-csharp.js';\nimport 'prismjs/components/prism-javascript.js';\nimport 'prismjs/components/prism-json.js';\nimport 'prismjs/components/prism-markdown.js';\nimport 'prismjs/components/prism-powershell.js';\nimport 'prismjs/components/prism-python.js';\nimport 'prismjs/components/prism-typescript.js';\nimport React, { useEffect, useState } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\n\nconst SUPPORTED_CLIPBOARD_CONTENT_TYPES = ['image/png', 'text/plain'];\n\n// Hook for clipboard operations\nexport function useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error('Failed to copy to clipboard:', error);\n }\n };\n\n const copyBlob = async (blob: Blob, contentType: string) => {\n try {\n // image/png, text/plain, and text/html are the only filetypes supported in the chromium\n // clipboard - however, text/html crashes chrome for some reason\n if (SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(contentType)) {\n const buffer = await blob.arrayBuffer();\n const newBlob = new Blob([buffer], { type: contentType });\n const clipboardItem = new ClipboardItem({\n [contentType]: newBlob,\n });\n await navigator.clipboard.write([clipboardItem]);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } else {\n // Fallback to text copy for unsupported types\n const text = await blob.text();\n await copy(text);\n }\n } catch (error) {\n console.error('Failed to copy blob to clipboard:', error);\n // Fallback to text copy if blob copy fails\n try {\n const text = await blob.text();\n await copy(text);\n } catch (fallbackError) {\n console.error('Failed to copy as text fallback:', fallbackError);\n }\n }\n };\n\n return { isCopied, copy, copyBlob };\n}\n\n// Base copy icon button component\ninterface CopyIconButtonProps {\n onClick: () => void;\n isCopied: boolean;\n showTooltip?: boolean;\n}\n\nexport function CopyIconButton({ onClick, isCopied, showTooltip = true }: CopyIconButtonProps) {\n return (\n <div className=\"mint:relative\">\n {showTooltip && isCopied && (\n <div className=\"mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]\">\n Copied!\n </div>\n )}\n <button\n onClick={onClick}\n className=\"mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]\"\n aria-label={isCopied ? 'Copied' : 'Copy code'}\n >\n {isCopied ? (\n <ClipboardCheckmarkRegular className=\"mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n ) : (\n <Copy20Regular className=\"mint:w-5 mint:h-5\" />\n )}\n </button>\n </div>\n );\n}\n\n// Convenience component that handles text copying\ninterface CopyToClipboardButtonProps {\n textToCopy: string;\n showTooltip?: boolean;\n}\n\nexport function CopyToClipboardButton({\n textToCopy,\n showTooltip = true,\n}: CopyToClipboardButtonProps) {\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = () => {\n copy(textToCopy);\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\n// Convenience component that handles blob/data copying\ninterface CopyDataToClipboardButtonProps {\n data: {\n type: 'image' | 'audio' | 'video' | 'other';\n blob: Blob;\n contentType?: string;\n content?: string;\n };\n showTooltip?: boolean;\n}\n\nexport function CopyDataToClipboardButton({\n data,\n showTooltip = true,\n}: CopyDataToClipboardButtonProps) {\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n\n const handleCopy = () => {\n // Check if we can copy as blob (for images, etc.)\n if (data.contentType && SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(data.contentType)) {\n copyBlob(data.blob, data.contentType);\n } else if (data.type === 'other' && data.content) {\n // For text content, copy as text\n copy(data.content);\n } else {\n console.error('Unsupported content type for clipboard');\n }\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n // Support for copying blobs (images, etc.)\n blob?: Blob;\n contentType?: string;\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n blob,\n contentType,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>('');\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, '') || 'text';\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== 'object' || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (typeof child === 'object' && child != null && 'props' in child && child.props?.children) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === 'object' &&\n codeChild != null &&\n 'props' in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error('Failed to highlight code:', error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n // If blob and contentType are provided, use blob copying\n if (blob && contentType) {\n copyBlob(blob, contentType);\n } else {\n // Otherwise, use text copying\n copy(codeText);\n }\n };\n\n return (\n <div\n className={\n showContainer\n ? 'mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden'\n : undefined\n }\n >\n <div className=\"not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414]\">\n <div className=\"mint:code-scrollbar mint:overflow-x-scroll\">\n <pre className=\"mint:px-4 mint:py-2 mint:m-0 mint:whitespace-pre mint:text-sm\">\n {isSSRHighlighted ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {children}\n </code>\n ) : highlightedCode ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {codeText}\n </code>\n )}\n </pre>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["SUPPORTED_CLIPBOARD_CONTENT_TYPES","useCopyToClipboard","isCopied","setIsCopied","useState","copy","text","error","blob","contentType","buffer","newBlob","clipboardItem","fallbackError","CopyIconButton","onClick","showTooltip","jsxs","jsx","ClipboardCheckmarkRegular","Copy20Regular","CopyToClipboardButton","textToCopy","CopyDataToClipboardButton","data","copyBlob","CodeBlock","children","className","fileName","language","highlightedCode","setHighlightedCode","lang","codeText","getNodeText","showContainer","isSSRHighlighted","React","childrenArray","child","_a","codeChildren","codeChild","_b","useEffect","grammar","Prism","html","cn"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAMA,IAAoC,CAAC,aAAa,YAAY;AAG7D,SAASC,IAAqB;AACnC,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAO,OAAOC,MAAiB;AACnC,QAAI;AACF,YAAM,UAAU,UAAU,UAAUA,CAAI,GACxCH,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,IAC3C,SAASI,GAA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;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAEF,yBAAyB,EAAE,QAAQF,EAAA;AAAA,QAAgB;AAAA,MAAA,IAGrD,gBAAAb;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAGD,UAAAC;AAAA,QAAA;AAAA,MAAA,EACH,CAEJ,GACF,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1,99 +1,117 @@
1
- import { jsx as a, jsxs as u } from "react/jsx-runtime";
2
- import m, { useState as k, useRef as w, useEffect as N } from "react";
1
+ import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
+ import o, { useState as v, useRef as $, useEffect as g } from "react";
3
3
  import { cn as p } from "../../../utils/cn.js";
4
- const x = m.createContext({
4
+ const A = o.createContext({
5
5
  activeTab: 0,
6
6
  setActiveTab: () => {
7
7
  }
8
8
  });
9
- function E({ children: h, defaultTab: v = 0, defaultTabIndex: y, className: g, onClickTab: o, onChange: c }) {
10
- const [s, b] = k(y ?? v), l = w([]), n = m.Children.toArray(h);
11
- N(() => {
12
- l.current = l.current.slice(0, n.length);
13
- }, [n.length]);
14
- const _ = (e, t) => {
15
- var i;
16
- let r = t;
9
+ function T({ children: y, defaultTab: w = 0, defaultTabIndex: x, className: _, onClickTab: f, onChange: c }) {
10
+ const [a, b] = v(x ?? w), l = $([]), [h, N] = v({ left: 0, width: 0 }), i = o.Children.toArray(y);
11
+ g(() => {
12
+ l.current = l.current.slice(0, i.length);
13
+ }, [i.length]), g(() => {
14
+ const e = l.current[a];
15
+ e && N({
16
+ left: e.offsetLeft,
17
+ width: e.offsetWidth
18
+ });
19
+ }, [a]);
20
+ const k = (e, t) => {
21
+ var s;
22
+ let n = t;
17
23
  switch (e.key) {
18
24
  case "ArrowRight":
19
- e.preventDefault(), r = (t + 1) % n.length;
25
+ e.preventDefault(), n = (t + 1) % i.length;
20
26
  break;
21
27
  case "ArrowLeft":
22
- e.preventDefault(), r = (t - 1 + n.length) % n.length;
28
+ e.preventDefault(), n = (t - 1 + i.length) % i.length;
23
29
  break;
24
30
  case "Home":
25
- e.preventDefault(), r = 0;
31
+ e.preventDefault(), n = 0;
26
32
  break;
27
33
  case "End":
28
- e.preventDefault(), r = n.length - 1;
34
+ e.preventDefault(), n = i.length - 1;
29
35
  break;
30
36
  default:
31
37
  return;
32
38
  }
33
- b(r), (i = l.current[r]) == null || i.focus();
39
+ b(n), (s = l.current[n]) == null || s.focus();
34
40
  };
35
- return /* @__PURE__ */ a(x.Provider, { value: { activeTab: s, setActiveTab: b }, children: /* @__PURE__ */ u("div", { className: p("mint:my-6", g), children: [
36
- /* @__PURE__ */ a(
41
+ return /* @__PURE__ */ r(A.Provider, { value: { activeTab: a, setActiveTab: b }, children: /* @__PURE__ */ m("div", { className: p("mint:my-6", _), children: [
42
+ /* @__PURE__ */ m(
37
43
  "div",
38
44
  {
39
45
  role: "tablist",
40
46
  "aria-label": "Content tabs",
41
- className: "mint:flex mint:gap-1 mint:border-b mint:border-gray-200 mint:mb-4 mint:overflow-x-auto mint:dark:border-b-gray-700",
42
- children: n.map((e, t) => {
43
- if (!m.isValidElement(e)) return null;
44
- const r = e.props.title || `Tab ${t + 1}`, i = e.props.icon, d = s === t;
45
- return /* @__PURE__ */ a(
46
- "button",
47
- {
48
- ref: (f) => {
49
- l.current[t] = f;
50
- },
51
- role: "tab",
52
- "aria-selected": d,
53
- "aria-controls": `tabpanel-${t}`,
54
- id: `tab-${t}`,
55
- tabIndex: d ? 0 : -1,
56
- onClick: () => {
57
- b(t), o == null || o(t), c == null || c(t);
58
- },
59
- onKeyDown: (f) => _(f, t),
60
- className: p(
61
- "mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:border-b-2 mint:rounded-t mint:bg-transparent mint:cursor-pointer mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2",
62
- d ? "mint:border-b-[#8251ee] mint:text-[#242424] mint:dark:border-b-[#9263f1] mint:dark:text-[#ffffff] mint:font-semibold" : "mint:border-b-transparent mint:text-gray-600 mint:hover:text-gray-900 mint:hover:border-b-gray-300 mint:dark:text-gray-400 mint:dark:hover:text-gray-200 mint:dark:hover:border-b-gray-600"
63
- ),
64
- children: /* @__PURE__ */ u("span", { className: "mint:flex mint:items-center mint:gap-2", children: [
65
- i && /* @__PURE__ */ a("span", { "aria-hidden": "true", children: i }),
66
- /* @__PURE__ */ u("span", { className: "mint:relative", children: [
67
- /* @__PURE__ */ a("span", { className: "mint:invisible mint:font-semibold", "aria-hidden": "true", children: r }),
68
- /* @__PURE__ */ a("span", { className: "mint:absolute mint:inset-0", children: r })
47
+ className: "mint:relative mint:flex mint:gap-1 mint:mb-4 mint:overflow-x-auto mint:pb-[3px] mint:before:content-[''] mint:before:absolute mint:before:left-0 mint:before:right-0 mint:before:bottom-0 mint:before:h-[2px] mint:before:bg-[#f2f3f3] mint:before:dark:bg-[#222223] mint:before:rounded-full",
48
+ children: [
49
+ i.map((e, t) => {
50
+ if (!o.isValidElement(e)) return null;
51
+ const n = e.props.title || `Tab ${t + 1}`, s = e.props.icon, d = a === t;
52
+ return /* @__PURE__ */ r(
53
+ "button",
54
+ {
55
+ ref: (u) => {
56
+ l.current[t] = u;
57
+ },
58
+ role: "tab",
59
+ "aria-selected": d,
60
+ "aria-controls": `tabpanel-${t}`,
61
+ id: `tab-${t}`,
62
+ tabIndex: d ? 0 : -1,
63
+ onClick: () => {
64
+ b(t), f == null || f(t), c == null || c(t);
65
+ },
66
+ onKeyDown: (u) => k(u, t),
67
+ className: p(
68
+ "mint:relative mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:bg-transparent mint:cursor-pointer mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2",
69
+ d ? "mint:text-[#242424] mint:dark:text-[#ffffff] mint:font-semibold" : "mint:text-gray-600 mint:hover:text-gray-900 mint:dark:text-gray-400 mint:dark:hover:text-gray-200"
70
+ ),
71
+ children: /* @__PURE__ */ m("span", { className: "mint:flex mint:items-center mint:gap-2", children: [
72
+ s && /* @__PURE__ */ r("span", { "aria-hidden": "true", children: s }),
73
+ /* @__PURE__ */ m("span", { className: "mint:relative", children: [
74
+ /* @__PURE__ */ r("span", { className: "mint:invisible mint:font-semibold", "aria-hidden": "true", children: n }),
75
+ /* @__PURE__ */ r("span", { className: "mint:absolute mint:inset-0", children: n })
76
+ ] })
69
77
  ] })
70
- ] })
71
- },
72
- t
73
- );
74
- })
78
+ },
79
+ t
80
+ );
81
+ }),
82
+ /* @__PURE__ */ r(
83
+ "div",
84
+ {
85
+ className: "mint:absolute mint:bottom-0 mint:h-[3px] mint:rounded-full mint:bg-[#8251ee] mint:dark:bg-[#9263f1] mint:transition-all mint:duration-300 mint:ease-out mint:z-10",
86
+ style: {
87
+ left: `${h.left}px`,
88
+ width: `${h.width}px`
89
+ }
90
+ }
91
+ )
92
+ ]
75
93
  }
76
94
  ),
77
- /* @__PURE__ */ a("div", { children: n.map((e, t) => /* @__PURE__ */ a(
95
+ /* @__PURE__ */ r("div", { children: i.map((e, t) => /* @__PURE__ */ r(
78
96
  "div",
79
97
  {
80
98
  role: "tabpanel",
81
99
  id: `tabpanel-${t}`,
82
100
  "aria-labelledby": `tab-${t}`,
83
101
  tabIndex: 0,
84
- hidden: s !== t,
102
+ hidden: a !== t,
85
103
  className: p(
86
104
  "mint:outline-none",
87
- s !== t && "mint:hidden"
105
+ a !== t && "mint:hidden"
88
106
  ),
89
- children: m.isValidElement(e) ? e.props.children : null
107
+ children: o.isValidElement(e) ? e.props.children : null
90
108
  },
91
109
  t
92
110
  )) })
93
111
  ] }) });
94
112
  }
95
113
  export {
96
- E as Tabs,
97
- x as TabsContext
114
+ T as Tabs,
115
+ A as TabsContext
98
116
  };
99
117
  //# sourceMappingURL=tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","sources":["../../../../src/components/content-components/tabs/tabs.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from \"react\";\nimport { cn } from \"../../../utils/cn\";\n\ninterface TabsProps {\n children: React.ReactNode;\n defaultTab?: number;\n defaultTabIndex?: number;\n className?: string;\n onClickTab?: (index: number) => void;\n onChange?: (index: number) => void;\n}\n\ninterface TabsContextValue {\n activeTab: number;\n setActiveTab: (index: number) => void;\n}\n\nexport const TabsContext = React.createContext<TabsContextValue>({\n activeTab: 0,\n setActiveTab: () => {},\n});\n\nexport function Tabs({ children, defaultTab = 0, defaultTabIndex, className, onClickTab, onChange }: TabsProps) {\n const [activeTab, setActiveTab] = useState(defaultTabIndex ?? defaultTab);\n const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n const tabs = React.Children.toArray(children);\n\n useEffect(() => {\n tabRefs.current = tabRefs.current.slice(0, tabs.length);\n }, [tabs.length]);\n\n const handleKeyDown = (event: React.KeyboardEvent, currentIndex: number) => {\n let newIndex = currentIndex;\n\n switch (event.key) {\n case \"ArrowRight\":\n event.preventDefault();\n newIndex = (currentIndex + 1) % tabs.length;\n break;\n case \"ArrowLeft\":\n event.preventDefault();\n newIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n break;\n case \"Home\":\n event.preventDefault();\n newIndex = 0;\n break;\n case \"End\":\n event.preventDefault();\n newIndex = tabs.length - 1;\n break;\n default:\n return;\n }\n\n setActiveTab(newIndex);\n tabRefs.current[newIndex]?.focus();\n };\n\n return (\n <TabsContext.Provider value={{ activeTab, setActiveTab }}>\n <div className={cn(\"mint:my-6\", className)}>\n <div\n role=\"tablist\"\n aria-label=\"Content tabs\"\n className=\"mint:flex mint:gap-1 mint:border-b mint:border-gray-200 mint:mb-4 mint:overflow-x-auto mint:dark:border-b-gray-700\"\n >\n {tabs.map((tab, index) => {\n if (!React.isValidElement(tab)) return null;\n const title = tab.props.title || `Tab ${index + 1}`;\n const icon = tab.props.icon;\n const isActive = activeTab === index;\n\n return (\n <button\n key={index}\n ref={(el) => {tabRefs.current[index] = el}}\n role=\"tab\"\n aria-selected={isActive}\n aria-controls={`tabpanel-${index}`}\n id={`tab-${index}`}\n tabIndex={isActive ? 0 : -1}\n onClick={() => {\n setActiveTab(index);\n onClickTab?.(index);\n onChange?.(index);\n }}\n onKeyDown={(e) => handleKeyDown(e, index)}\n className={cn(\n \"mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:border-b-2 mint:rounded-t mint:bg-transparent mint:cursor-pointer mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2\",\n isActive\n ? \"mint:border-b-[#8251ee] mint:text-[#242424] mint:dark:border-b-[#9263f1] mint:dark:text-[#ffffff] mint:font-semibold\"\n : \"mint:border-b-transparent mint:text-gray-600 mint:hover:text-gray-900 mint:hover:border-b-gray-300 mint:dark:text-gray-400 mint:dark:hover:text-gray-200 mint:dark:hover:border-b-gray-600\"\n )}\n >\n <span className=\"mint:flex mint:items-center mint:gap-2\">\n {icon && <span aria-hidden=\"true\">{icon}</span>}\n <span className=\"mint:relative\">\n <span className=\"mint:invisible mint:font-semibold\" aria-hidden=\"true\">\n {title}\n </span>\n <span className=\"mint:absolute mint:inset-0\">\n {title}\n </span>\n </span>\n </span>\n </button>\n );\n })}\n </div>\n\n <div>\n {tabs.map((tab, index) => (\n <div\n key={index}\n role=\"tabpanel\"\n id={`tabpanel-${index}`}\n aria-labelledby={`tab-${index}`}\n tabIndex={0}\n hidden={activeTab !== index}\n className={cn(\n \"mint:outline-none\",\n activeTab !== index && \"mint:hidden\"\n )}\n >\n {React.isValidElement(tab) ? tab.props.children : null}\n </div>\n ))}\n </div>\n </div>\n </TabsContext.Provider>\n );\n}\n"],"names":["TabsContext","React","Tabs","children","defaultTab","defaultTabIndex","className","onClickTab","onChange","activeTab","setActiveTab","useState","tabRefs","useRef","tabs","useEffect","handleKeyDown","event","currentIndex","newIndex","_a","jsx","cn","tab","index","title","icon","isActive","el","e","jsxs"],"mappings":";;;AAiBO,MAAMA,IAAcC,EAAM,cAAgC;AAAA,EAC/D,WAAW;AAAA,EACX,cAAc,MAAM;AAAA,EAAC;AACvB,CAAC;AAEM,SAASC,EAAK,EAAE,UAAAC,GAAU,YAAAC,IAAa,GAAG,iBAAAC,GAAiB,WAAAC,GAAW,YAAAC,GAAY,UAAAC,KAAuB;AAC9G,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAASN,KAAmBD,CAAU,GAClEQ,IAAUC,EAAqC,EAAE,GAEjDC,IAAOb,EAAM,SAAS,QAAQE,CAAQ;AAE5C,EAAAY,EAAU,MAAM;AACd,IAAAH,EAAQ,UAAUA,EAAQ,QAAQ,MAAM,GAAGE,EAAK,MAAM;AAAA,EACxD,GAAG,CAACA,EAAK,MAAM,CAAC;AAEhB,QAAME,IAAgB,CAACC,GAA4BC,MAAyB;;AAC1E,QAAIC,IAAWD;AAEf,YAAQD,EAAM,KAAA;AAAA,MACZ,KAAK;AACH,QAAAA,EAAM,eAAA,GACNE,KAAYD,IAAe,KAAKJ,EAAK;AACrC;AAAA,MACF,KAAK;AACH,QAAAG,EAAM,eAAA,GACNE,KAAYD,IAAe,IAAIJ,EAAK,UAAUA,EAAK;AACnD;AAAA,MACF,KAAK;AACH,QAAAG,EAAM,eAAA,GACNE,IAAW;AACX;AAAA,MACF,KAAK;AACH,QAAAF,EAAM,eAAA,GACNE,IAAWL,EAAK,SAAS;AACzB;AAAA,MACF;AACE;AAAA,IAAA;AAGJ,IAAAJ,EAAaS,CAAQ,IACrBC,IAAAR,EAAQ,QAAQO,CAAQ,MAAxB,QAAAC,EAA2B;AAAA,EAC7B;AAEA,SACE,gBAAAC,EAACrB,EAAY,UAAZ,EAAqB,OAAO,EAAE,WAAAS,GAAW,cAAAC,EAAA,GACxC,4BAAC,OAAA,EAAI,WAAWY,EAAG,aAAahB,CAAS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;AAAA,UAAA;AAAA,QAiCX,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGF,OAAA,EACE,UAAAV,EAAK,IAAI,CAACS,GAAKC,MACd,gBAAAH;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,MAAK;AAAA,QACL,IAAI,YAAYG,CAAK;AAAA,QACrB,mBAAiB,OAAOA,CAAK;AAAA,QAC7B,UAAU;AAAA,QACV,QAAQf,MAAce;AAAA,QACtB,WAAWF;AAAA,UACT;AAAA,UACAb,MAAce,KAAS;AAAA,QAAA;AAAA,QAGxB,YAAM,eAAeD,CAAG,IAAIA,EAAI,MAAM,WAAW;AAAA,MAAA;AAAA,MAX7CC;AAAA,IAAA,CAaR,EAAA,CACH;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"tabs.js","sources":["../../../../src/components/content-components/tabs/tabs.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from \"react\";\nimport { cn } from \"../../../utils/cn\";\n\ninterface TabsProps {\n children: React.ReactNode;\n defaultTab?: number;\n defaultTabIndex?: number;\n className?: string;\n onClickTab?: (index: number) => void;\n onChange?: (index: number) => void;\n}\n\ninterface TabsContextValue {\n activeTab: number;\n setActiveTab: (index: number) => void;\n}\n\nexport const TabsContext = React.createContext<TabsContextValue>({\n activeTab: 0,\n setActiveTab: () => {},\n});\n\nexport function Tabs({ children, defaultTab = 0, defaultTabIndex, className, onClickTab, onChange }: TabsProps) {\n const [activeTab, setActiveTab] = useState(defaultTabIndex ?? defaultTab);\n const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\n const [indicatorStyle, setIndicatorStyle] = useState({ left: 0, width: 0 });\n\n const tabs = React.Children.toArray(children);\n\n useEffect(() => {\n tabRefs.current = tabRefs.current.slice(0, tabs.length);\n }, [tabs.length]);\n\n useEffect(() => {\n const activeTabElement = tabRefs.current[activeTab];\n if (activeTabElement) {\n setIndicatorStyle({\n left: activeTabElement.offsetLeft,\n width: activeTabElement.offsetWidth,\n });\n }\n }, [activeTab]);\n\n const handleKeyDown = (event: React.KeyboardEvent, currentIndex: number) => {\n let newIndex = currentIndex;\n\n switch (event.key) {\n case \"ArrowRight\":\n event.preventDefault();\n newIndex = (currentIndex + 1) % tabs.length;\n break;\n case \"ArrowLeft\":\n event.preventDefault();\n newIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n break;\n case \"Home\":\n event.preventDefault();\n newIndex = 0;\n break;\n case \"End\":\n event.preventDefault();\n newIndex = tabs.length - 1;\n break;\n default:\n return;\n }\n\n setActiveTab(newIndex);\n tabRefs.current[newIndex]?.focus();\n };\n\n return (\n <TabsContext.Provider value={{ activeTab, setActiveTab }}>\n <div className={cn(\"mint:my-6\", className)}>\n <div\n role=\"tablist\"\n aria-label=\"Content tabs\"\n className=\"mint:relative mint:flex mint:gap-1 mint:mb-4 mint:overflow-x-auto mint:pb-[3px] mint:before:content-[''] mint:before:absolute mint:before:left-0 mint:before:right-0 mint:before:bottom-0 mint:before:h-[2px] mint:before:bg-[#f2f3f3] mint:before:dark:bg-[#222223] mint:before:rounded-full\"\n >\n {tabs.map((tab, index) => {\n if (!React.isValidElement(tab)) return null;\n const title = tab.props.title || `Tab ${index + 1}`;\n const icon = tab.props.icon;\n const isActive = activeTab === index;\n\n return (\n <button\n key={index}\n ref={(el) => {tabRefs.current[index] = el}}\n role=\"tab\"\n aria-selected={isActive}\n aria-controls={`tabpanel-${index}`}\n id={`tab-${index}`}\n tabIndex={isActive ? 0 : -1}\n onClick={() => {\n setActiveTab(index);\n onClickTab?.(index);\n onChange?.(index);\n }}\n onKeyDown={(e) => handleKeyDown(e, index)}\n className={cn(\n \"mint:relative mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:bg-transparent mint:cursor-pointer mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2\",\n isActive\n ? \"mint:text-[#242424] mint:dark:text-[#ffffff] mint:font-semibold\"\n : \"mint:text-gray-600 mint:hover:text-gray-900 mint:dark:text-gray-400 mint:dark:hover:text-gray-200\"\n )}\n >\n <span className=\"mint:flex mint:items-center mint:gap-2\">\n {icon && <span aria-hidden=\"true\">{icon}</span>}\n <span className=\"mint:relative\">\n <span className=\"mint:invisible mint:font-semibold\" aria-hidden=\"true\">\n {title}\n </span>\n <span className=\"mint:absolute mint:inset-0\">\n {title}\n </span>\n </span>\n </span>\n </button>\n );\n })}\n <div\n className=\"mint:absolute mint:bottom-0 mint:h-[3px] mint:rounded-full mint:bg-[#8251ee] mint:dark:bg-[#9263f1] mint:transition-all mint:duration-300 mint:ease-out mint:z-10\"\n style={{\n left: `${indicatorStyle.left}px`,\n width: `${indicatorStyle.width}px`,\n }}\n />\n </div>\n\n <div>\n {tabs.map((tab, index) => (\n <div\n key={index}\n role=\"tabpanel\"\n id={`tabpanel-${index}`}\n aria-labelledby={`tab-${index}`}\n tabIndex={0}\n hidden={activeTab !== index}\n className={cn(\n \"mint:outline-none\",\n activeTab !== index && \"mint:hidden\"\n )}\n >\n {React.isValidElement(tab) ? tab.props.children : null}\n </div>\n ))}\n </div>\n </div>\n </TabsContext.Provider>\n );\n}\n"],"names":["TabsContext","React","Tabs","children","defaultTab","defaultTabIndex","className","onClickTab","onChange","activeTab","setActiveTab","useState","tabRefs","useRef","indicatorStyle","setIndicatorStyle","tabs","useEffect","activeTabElement","handleKeyDown","event","currentIndex","newIndex","_a","jsx","cn","jsxs","tab","index","title","icon","isActive","el","e"],"mappings":";;;AAiBO,MAAMA,IAAcC,EAAM,cAAgC;AAAA,EAC/D,WAAW;AAAA,EACX,cAAc,MAAM;AAAA,EAAC;AACvB,CAAC;AAEM,SAASC,EAAK,EAAE,UAAAC,GAAU,YAAAC,IAAa,GAAG,iBAAAC,GAAiB,WAAAC,GAAW,YAAAC,GAAY,UAAAC,KAAuB;AAC9G,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAASN,KAAmBD,CAAU,GAClEQ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YAAA;AAAA,cACC,WAAU;AAAA,cACV,OAAO;AAAA,gBACL,MAAM,GAAGV,EAAe,IAAI;AAAA,gBAC5B,OAAO,GAAGA,EAAe,KAAK;AAAA,cAAA;AAAA,YAChC;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGD,OAAA,EACE,UAAAE,EAAK,IAAI,CAACW,GAAKC,MACd,gBAAAJ;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,MAAK;AAAA,QACL,IAAI,YAAYI,CAAK;AAAA,QACrB,mBAAiB,OAAOA,CAAK;AAAA,QAC7B,UAAU;AAAA,QACV,QAAQnB,MAAcmB;AAAA,QACtB,WAAWH;AAAA,UACT;AAAA,UACAhB,MAAcmB,KAAS;AAAA,QAAA;AAAA,QAGxB,YAAM,eAAeD,CAAG,IAAIA,EAAI,MAAM,WAAW;AAAA,MAAA;AAAA,MAX7CC;AAAA,IAAA,CAaR,EAAA,CACH;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ;"}
@@ -16,8 +16,8 @@ function at({
16
16
  toc: o,
17
17
  navTree: W,
18
18
  activeHref: X,
19
- theme: x,
20
- className: p = "",
19
+ theme: p,
20
+ className: x = "",
21
21
  pathname: s,
22
22
  markdownContent: w,
23
23
  allPages: v,
@@ -27,7 +27,7 @@ function at({
27
27
  localization: N,
28
28
  telemetry: J,
29
29
  contextMenu: n,
30
- apiReferenceData2: l
30
+ apiReferenceData2: r
31
31
  }) {
32
32
  var f, h;
33
33
  const T = i.serializedContent, a = ((f = i.mdxExtracts) == null ? void 0 : f.zonePivotGroups) || [], c = (h = i.mdxExtracts) == null ? void 0 : h.pivotTocItems, P = !i.title, C = { ...{
@@ -42,10 +42,10 @@ function at({
42
42
  const { hash: m } = window.location;
43
43
  if (!m) return;
44
44
  const y = setTimeout(() => {
45
- const E = m.substring(1), r = document.getElementById("main-content"), g = document.getElementById(E);
46
- if (r && g) {
47
- const b = window.getComputedStyle(document.documentElement), z = parseFloat(b.getPropertyValue("--scroll-mt") || "0"), F = parseFloat(b.fontSize), I = z * F, L = r.getBoundingClientRect(), O = g.getBoundingClientRect().top - L.top + r.scrollTop - I;
48
- r.scrollTo({
45
+ const E = m.substring(1), l = document.getElementById("main-content"), g = document.getElementById(E);
46
+ if (l && g) {
47
+ const b = window.getComputedStyle(document.documentElement), z = parseFloat(b.getPropertyValue("--scroll-mt") || "0"), F = parseFloat(b.fontSize), I = z * F, L = l.getBoundingClientRect(), O = g.getBoundingClientRect().top - L.top + l.scrollTop - I;
48
+ l.scrollTo({
49
49
  top: O,
50
50
  behavior: "instant"
51
51
  });
@@ -56,8 +56,8 @@ function at({
56
56
  "div",
57
57
  {
58
58
  className: d(
59
- x === "dark" && "dark",
60
- p,
59
+ p === "dark" && "dark",
60
+ x,
61
61
  "mint:flex mint:flex-col mint:flex-1 mint:min-h-0 mint:h-full mint:overflow-hidden"
62
62
  ),
63
63
  children: /* @__PURE__ */ t(
@@ -83,7 +83,7 @@ function at({
83
83
  className: "mint:flex mint:flex-row-reverse mint:gap-12 mint:justify-center mint:mx-auto mint:w-full",
84
84
  id: "content-layout-container",
85
85
  children: [
86
- l != null && l.operation ? /* @__PURE__ */ t("div", { className: "mint:hidden mint:xl:!flex mint:self-start mint:sticky mint:flex-col mint:max-w-[28rem] mint:top-0 mint:gap-6", children: /* @__PURE__ */ t(B, { apiReferenceData: l }) }) : o && o.length > 0 ? /* @__PURE__ */ t("aside", { className: "mint:w-64 mint:shrink-0 mint:ml-8 mint:max-xl:hidden mint:xl:block", children: /* @__PURE__ */ e("div", { className: "mint:sticky mint:top-2 mint:p-2 mint:pb-6 mint:max-h-[calc(100vh-3.5rem)] mint:overflow-y-auto", children: [
86
+ r != null && r.operation ? /* @__PURE__ */ t("div", { className: "mint:hidden mint:xl:!flex mint:self-start mint:sticky mint:flex-col mint:max-w-[28rem] mint:top-0 mint:gap-6", children: /* @__PURE__ */ t(B, { apiReferenceData: r }) }) : o && o.length > 0 ? /* @__PURE__ */ t("aside", { className: "mint:w-64 mint:shrink-0 mint:ml-8 mint:max-xl:hidden mint:xl:block", children: /* @__PURE__ */ e("div", { className: "mint:sticky mint:top-2 mint:p-2 mint:pb-6 mint:max-h-[calc(100vh-3.5rem)] mint:overflow-y-auto", children: [
87
87
  /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-2 mint:mb-4", children: [
88
88
  /* @__PURE__ */ t(S, { className: "mint:w-4 mint:h-4 mint:text-[#4b5563] mint:dark:text-[#9ca3af]" }),
89
89
  /* @__PURE__ */ t("h2", { className: "mint:text-sm mint:font-semibold mint:text-[#141414] mint:dark:text-white", children: C.onThisPage })
@@ -94,7 +94,7 @@ function at({
94
94
  "div",
95
95
  {
96
96
  className: d(
97
- "mint:w-full mint:overflow-x-visible mint:max-w-2xl",
97
+ "mint:w-full mint:overflow-x-visible mint:max-w-[730px]",
98
98
  P && "mint:max-w-none!"
99
99
  ),
100
100
  children: [