UNPKG

fictoan-react

Version:

A full-featured, designer-friendly, yet performant framework with plain-English props and focus on rapid iteration.

1,143 lines (1,142 loc) 244 kB
"use client"; "use client;"; import React, { useState, useRef, useEffect, useCallback, useMemo, createRef, useImperativeHandle, useContext, createContext } from "react"; var createClassName = function createClassName2(classNames) { return classNames.filter(function(item) { return !!item; }).join(" "); }; var _excluded$Q = ["as", "role", "ariaLabel", "tabIndex", "onKeyDown"], _excluded2$8 = ["classNames", "bgColor", "bgColour", "borderColor", "borderColour", "className", "columns", "fillColor", "fillColour", "gap", "hideOnDesktop", "hideOnMobile", "hideOnTabletLandscape", "hideOnTabletPortrait", "horizontalMargin", "horizontalPadding", "horizontallyCenterThis", "horizontallyCentreThis", "isFullHeight", "isFullWidth", "layoutAsFlexbox", "layoutAsGrid", "marginLeft", "marginBottom", "margin", "marginRight", "marginTop", "opacity", "paddingBottom", "paddingLeft", "padding", "paddingRight", "paddingTop", "pushItemsToEnds", "shadow", "shape", "showOnlyOnDesktop", "showOnlyOnMobile", "showOnlyOnTabletLandscape", "showOnlyOnTabletPortrait", "size", "strokeColor", "strokeColour", "textColor", "textColour", "verticalMargin", "verticalPadding", "verticallyCenterItems", "verticallyCentreItems", "weight"], _excluded3$1 = ["className", "classNames"]; function _extends$R() { return _extends$R = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$R.apply(null, arguments); } function _objectWithoutProperties$Q(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$Q(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$Q(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Element = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var _ref$as = _ref.as, Component = _ref$as === void 0 ? "div" : _ref$as, role = _ref.role, ariaLabel = _ref.ariaLabel, tabIndex = _ref.tabIndex, onKeyDown = _ref.onKeyDown, props = _objectWithoutProperties$Q(_ref, _excluded$Q); var _props$classNames = props.classNames, classNames = _props$classNames === void 0 ? [] : _props$classNames, bgColor = props.bgColor, bgColour = props.bgColour, borderColor = props.borderColor, borderColour = props.borderColour, className = props.className; props.columns; var fillColor = props.fillColor, fillColour = props.fillColour; props.gap; var hideOnDesktop = props.hideOnDesktop, hideOnMobile = props.hideOnMobile, hideOnTabletLandscape = props.hideOnTabletLandscape, hideOnTabletPortrait = props.hideOnTabletPortrait, horizontalMargin = props.horizontalMargin, horizontalPadding = props.horizontalPadding, horizontallyCenterThis = props.horizontallyCenterThis, horizontallyCentreThis = props.horizontallyCentreThis, isFullHeight = props.isFullHeight, isFullWidth = props.isFullWidth, layoutAsFlexbox = props.layoutAsFlexbox, layoutAsGrid = props.layoutAsGrid, marginLeft = props.marginLeft, marginBottom = props.marginBottom, margin = props.margin, marginRight = props.marginRight, marginTop = props.marginTop, opacity = props.opacity, paddingBottom = props.paddingBottom, paddingLeft = props.paddingLeft, padding = props.padding, paddingRight = props.paddingRight, paddingTop = props.paddingTop, pushItemsToEnds = props.pushItemsToEnds, shadow = props.shadow, shape = props.shape, showOnlyOnDesktop = props.showOnlyOnDesktop, showOnlyOnMobile = props.showOnlyOnMobile, showOnlyOnTabletLandscape = props.showOnlyOnTabletLandscape, showOnlyOnTabletPortrait = props.showOnlyOnTabletPortrait, size = props.size, strokeColor = props.strokeColor, strokeColour = props.strokeColour, textColor = props.textColor, textColour = props.textColour, verticalMargin = props.verticalMargin, verticalPadding = props.verticalPadding, verticallyCenterItems = props.verticallyCenterItems, verticallyCentreItems = props.verticallyCentreItems, weight = props.weight, minimalProps = _objectWithoutProperties$Q(props, _excluded2$8); props.className; props.classNames; _objectWithoutProperties$Q(props, _excluded3$1); return /* @__PURE__ */ React.createElement(Component, _extends$R({ ref, role, "aria-label": ariaLabel, tabIndex, onKeyDown }, minimalProps, { className: createClassName([className, bgColor && "bg-".concat(bgColor), bgColour && "bg-".concat(bgColour), borderColor && "border-".concat(borderColor), borderColour && "border-".concat(borderColour), fillColor && "fill-".concat(fillColor), fillColour && "fill-".concat(fillColour), hideOnDesktop && "hide-on-desktop", hideOnMobile && "hide-on-mobile", hideOnTabletLandscape && "hide-on-tablet-landscape", hideOnTabletPortrait && "hide-on-tablet-portrait", horizontalMargin && "margin-right-".concat(horizontalMargin, " margin-left-").concat(horizontalMargin), horizontalPadding && "padding-right-".concat(horizontalPadding, " padding-left-").concat(horizontalPadding), horizontallyCenterThis && "horizontally-centre-this", horizontallyCentreThis && "horizontally-centre-this", isFullHeight && "full-height", isFullWidth && "full-width", layoutAsFlexbox && "layout-flexbox", layoutAsGrid && "layout-grid", marginLeft && "margin-left-".concat(marginLeft), marginBottom && "margin-bottom-".concat(marginBottom), margin && "margin-all-".concat(margin), marginRight && "margin-right-".concat(marginRight), marginTop && "margin-top-".concat(marginTop), opacity && "opacity-".concat(opacity), paddingBottom && "padding-bottom-".concat(paddingBottom), paddingLeft && "padding-left-".concat(paddingLeft), padding && "padding-all-".concat(padding), paddingRight && "padding-right-".concat(paddingRight), paddingTop && "padding-top-".concat(paddingTop), pushItemsToEnds && "push-to-ends", shadow && "shadow-".concat(shadow), shape && "shape-".concat(shape), showOnlyOnDesktop && "show-only-on-desktop", showOnlyOnMobile && "show-only-on-mobile", showOnlyOnTabletLandscape && "show-only-on-tablet-landscape", showOnlyOnTabletPortrait && "show-only-on-tablet-portrait", size && "size-".concat(size), strokeColor && "stroke-".concat(strokeColor), strokeColour && "stroke-".concat(strokeColour), textColor && "text-".concat(textColor), textColour && "text-".concat(textColour), verticalMargin && "margin-top-".concat(verticalMargin, " margin-bottom-").concat(verticalMargin), verticalPadding && "padding-top-".concat(verticalPadding, " padding-bottom-").concat(verticalPadding), verticallyCenterItems && "vertically-centre-items", verticallyCentreItems && "vertically-centre-items", weight && "weight-".concat(weight)].concat(classNames)) })); }); var _excluded$P = ["external"]; function _typeof$7(o) { "@babel/helpers - typeof"; return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) { return typeof o2; } : function(o2) { return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2; }, _typeof$7(o); } function _extends$Q() { return _extends$Q = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$Q.apply(null, arguments); } function _objectWithoutProperties$P(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$P(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$P(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function(r2) { return Object.getOwnPropertyDescriptor(e, r2).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function(r2) { _defineProperty$5(e, r2, t[r2]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function(r2) { Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2)); }); } return e; } function _defineProperty$5(e, r, t) { return (r = _toPropertyKey$5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _toPropertyKey$5(t) { var i = _toPrimitive$5(t, "string"); return "symbol" == _typeof$7(i) ? i : i + ""; } function _toPrimitive$5(t, r) { if ("object" != _typeof$7(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof$7(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var createComponentWithElement = function createComponentWithElement2(tagName, defaultProps) { return /* @__PURE__ */ React.forwardRef(function(props, ref) { var finalProps = _objectSpread$4(_objectSpread$4({}, defaultProps), props); if (tagName === "a" && "external" in finalProps) { var external = finalProps.external; _objectWithoutProperties$P(finalProps, _excluded$P); if (external) { finalProps.target = "_blank"; finalProps.rel = "noopener noreferrer"; } } return /* @__PURE__ */ React.createElement(Element, _extends$Q({ as: tagName, ref }, finalProps)); }); }; var Article = createComponentWithElement("article"); var Aside = createComponentWithElement("aside"); var Body = createComponentWithElement("body"); var Div = createComponentWithElement("div"); var Footer = createComponentWithElement("footer"); var Header = createComponentWithElement("header"); var Main = createComponentWithElement("main"); var Nav = createComponentWithElement("nav"); var Section = createComponentWithElement("section"); var Span = createComponentWithElement("span"); var Hyperlink = createComponentWithElement("a", { rel: "noopener noreferrer" // Default props for Hyperlink }); var _excluded$O = ["weight", "size", "fontStyle", "align", "isSubtext"]; function _extends$P() { return _extends$P = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$P.apply(null, arguments); } function _objectWithoutProperties$O(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$O(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$O(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Text = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var weight = _ref.weight, size = _ref.size, _ref$fontStyle = _ref.fontStyle, fontStyle = _ref$fontStyle === void 0 ? "sans-serif" : _ref$fontStyle, align = _ref.align, isSubtext = _ref.isSubtext, props = _objectWithoutProperties$O(_ref, _excluded$O); var classNames = []; if (weight) { classNames.push("weight-".concat(weight)); } if (size) { classNames.push("text-".concat(size)); } if (fontStyle) { classNames.push("font-".concat(fontStyle)); } if (isSubtext) { classNames.push("sub-text"); } if (align) { classNames.push("text-".concat(align)); } return /* @__PURE__ */ React.createElement(Element, _extends$P({ as: "p", ref, classNames }, props)); }); var _excluded$N = ["summary", "children", "open"]; function _extends$O() { return _extends$O = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$O.apply(null, arguments); } function _objectWithoutProperties$N(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$N(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$N(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Accordion = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var summary = _ref.summary, children = _ref.children, _ref$open = _ref.open, open = _ref$open === void 0 ? false : _ref$open, props = _objectWithoutProperties$N(_ref, _excluded$N); return /* @__PURE__ */ React.createElement(Element, _extends$O({ as: "details", "data-expandable-content": true, ref }, props, { open, role: "region", "aria-labelledby": "accordion-summary" }), /* @__PURE__ */ React.createElement("summary", { role: "button", tabIndex: 0, "aria-controls": "accordion-content", "aria-expanded": open }, typeof summary === "string" ? /* @__PURE__ */ React.createElement(Text, { margin: "none" }, summary) : summary), children); }); var _excluded$M = ["children", "size", "shape", "withDelete", "onDelete", "label"]; function _extends$N() { return _extends$N = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$N.apply(null, arguments); } function _objectWithoutProperties$M(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$M(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$M(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Badge = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var children = _ref.children, _ref$size = _ref.size, size = _ref$size === void 0 ? "medium" : _ref$size, shape = _ref.shape, withDelete = _ref.withDelete, onDelete = _ref.onDelete, label = _ref.label, props = _objectWithoutProperties$M(_ref, _excluded$M); var classNames = []; if (size) { classNames.push("size-".concat(size)); } if (shape) { classNames.push("shape-".concat(shape)); } var handleDelete = function handleDelete2(e) { e.stopPropagation(); onDelete === null || onDelete === void 0 || onDelete(e); }; var handleKeyPress = function handleKeyPress2(e) { if (withDelete && (e.key === "Enter" || e.key === " ")) { e.preventDefault(); onDelete === null || onDelete === void 0 || onDelete(e); } }; return /* @__PURE__ */ React.createElement(Element, _extends$N({ "data-badge": true, ref, classNames, role: "status", "aria-label": label || (typeof children === "string" ? children : void 0) }, props), children, withDelete && /* @__PURE__ */ React.createElement(Text, { className: "badge-dismiss-button", onClick: handleDelete, onKeyDown: handleKeyPress, role: "button", tabIndex: 0, "aria-label": "Remove badge" }, "×")); }); function _typeof$6(o) { "@babel/helpers - typeof"; return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) { return typeof o2; } : function(o2) { return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2; }, _typeof$6(o); } var _excluded$L = ["children", "current"], _excluded2$7 = ["children", "separator", "spacing"]; function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function(r2) { return Object.getOwnPropertyDescriptor(e, r2).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function(r2) { _defineProperty$4(e, r2, t[r2]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r2) { Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2)); }); } return e; } function _defineProperty$4(e, r, t) { return (r = _toPropertyKey$4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _toPropertyKey$4(t) { var i = _toPrimitive$4(t, "string"); return "symbol" == _typeof$6(i) ? i : i + ""; } function _toPrimitive$4(t, r) { if ("object" != _typeof$6(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != _typeof$6(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _extends$M() { return _extends$M = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$M.apply(null, arguments); } function _objectWithoutProperties$L(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$L(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$L(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var BreadcrumbItem = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var children = _ref.children, current = _ref.current, props = _objectWithoutProperties$L(_ref, _excluded$L); return /* @__PURE__ */ React.createElement(Element, _extends$M({ as: "li", "data-breadcrumb-item": true, ref }, props, { "aria-current": current ? "page" : void 0, className: current ? "current" : void 0, role: "listitem" }), /* @__PURE__ */ React.createElement("span", { className: "breadcrumb-content" }, children)); }); var Separator = function Separator2(_ref2) { var separator = _ref2.separator; return /* @__PURE__ */ React.createElement(Text, { className: "breadcrumb-separator", "aria-hidden": "true", role: "presentation", margin: "none" }, separator); }; var Breadcrumbs = /* @__PURE__ */ React.forwardRef(function(_ref3, ref) { var children = _ref3.children, _ref3$separator = _ref3.separator, separator = _ref3$separator === void 0 ? "/" : _ref3$separator, spacing = _ref3.spacing, props = _objectWithoutProperties$L(_ref3, _excluded2$7); var classNames = []; if (spacing) { classNames.push("spacing-".concat(spacing)); } var childrenArray = React.Children.toArray(children).filter(Boolean); var processedChildren = childrenArray.reduce(function(acc, child, index) { if (!/* @__PURE__ */ React.isValidElement(child)) return acc; var isLast = index === childrenArray.length - 1; var breadcrumbItem; if (child.type === BreadcrumbItem) { breadcrumbItem = /* @__PURE__ */ React.cloneElement(child, _objectSpread$3(_objectSpread$3({}, child.props), {}, { current: isLast })); } else { breadcrumbItem = /* @__PURE__ */ React.createElement(BreadcrumbItem, { key: "item-".concat(index), current: isLast }, child); } acc.push(breadcrumbItem); if (!isLast) { acc.push(/* @__PURE__ */ React.createElement(Separator, { key: "sep-".concat(index), separator })); } return acc; }, []); return /* @__PURE__ */ React.createElement("nav", _extends$M({ "aria-label": "Breadcrumb", ref }, props), /* @__PURE__ */ React.createElement(Element, { as: "ul", "data-breadcrumbs-wrapper": true, role: "list", classNames }, processedChildren)); }); var _excluded$K = ["size", "shape", "kind", "isLoading", "hasDelete", "label"]; function _extends$L() { return _extends$L = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$L.apply(null, arguments); } function _objectWithoutProperties$K(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$K(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$K(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Button = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var _ref$size = _ref.size, size = _ref$size === void 0 ? "medium" : _ref$size, shape = _ref.shape, kind = _ref.kind, isLoading = _ref.isLoading, hasDelete = _ref.hasDelete, label = _ref.label, props = _objectWithoutProperties$K(_ref, _excluded$K); var classNames = []; if (kind) { classNames.push(kind); } if (size) { classNames.push("size-".concat(size)); } if (shape) { classNames.push("shape-".concat(shape)); } if (isLoading) { classNames.push("is-loading"); } if (hasDelete) { classNames.push("has-delete"); } return /* @__PURE__ */ React.createElement(Element, _extends$L({ as: "button", "data-button": true, ref, classNames, "aria-label": label, "aria-disabled": props.disabled || isLoading, "aria-busy": isLoading }, props)); }); var _excluded$J = ["kind", "children", "title"]; function _extends$K() { return _extends$K = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$K.apply(null, arguments); } function _objectWithoutProperties$J(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$J(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$J(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Callout = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var kind = _ref.kind, children = _ref.children, title = _ref.title, props = _objectWithoutProperties$J(_ref, _excluded$J); var roleMap = { info: "status", success: "status", warning: "alert", error: "alert" }; return /* @__PURE__ */ React.createElement(Element, _extends$K({ as: "div", "data-callout": true, ref, className: kind, role: roleMap[kind], "aria-live": kind === "error" || kind === "warning" ? "assertive" : "polite", "aria-label": title }, props), children); }); var _excluded$I = ["shape", "heading", "children"]; function _extends$J() { return _extends$J = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$J.apply(null, arguments); } function _objectWithoutProperties$I(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$I(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$I(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var Card = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var shape = _ref.shape, heading = _ref.heading, children = _ref.children, props = _objectWithoutProperties$I(_ref, _excluded$I); var classNames = []; if (shape) { classNames.push("shape-".concat(shape)); } return /* @__PURE__ */ React.createElement(Element, _extends$J({ as: "div", "data-card": true, ref, classNames, role: "region", "aria-label": heading, tabIndex: 0 }, props), children); }); var _excluded$H = ["children", "source", "language", "showCopyButton", "showLineNumbers", "description", "withSyntaxHighlighting", "makeEditable", "onChange"]; function _extends$I() { return _extends$I = Object.assign ? Object.assign.bind() : function(n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$I.apply(null, arguments); } function _regeneratorRuntime() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime2() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r2) { t2[e2] = r2.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t2, e2, r2) { return Object.defineProperty(t2, e2, { value: r2, enumerable: true, configurable: true, writable: true }), t2[e2]; } try { define({}, ""); } catch (t2) { define = function define2(t3, e2, r2) { return t3[e2] = r2; }; } function wrap(t2, e2, r2, n2) { var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c2 = new Context(n2 || []); return o(a2, "_invoke", { value: makeInvokeMethod(t2, r2, c2) }), a2; } function tryCatch(t2, e2, r2) { try { return { type: "normal", arg: t2.call(e2, r2) }; } catch (t3) { return { type: "throw", arg: t3 }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() { } function GeneratorFunction() { } function GeneratorFunctionPrototype() { } var p = {}; define(p, a, function() { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t2) { ["next", "throw", "return"].forEach(function(e2) { define(t2, e2, function(t3) { return this._invoke(e2, t3); }); }); } function AsyncIterator(t2, e2) { function invoke(r3, o2, i2, a2) { var c2 = tryCatch(t2[r3], t2, o2); if ("throw" !== c2.type) { var u2 = c2.arg, h2 = u2.value; return h2 && "object" == _typeof$5(h2) && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) { invoke("next", t3, i2, a2); }, function(t3) { invoke("throw", t3, i2, a2); }) : e2.resolve(h2).then(function(t3) { u2.value = t3, i2(u2); }, function(t3) { return invoke("throw", t3, i2, a2); }); } a2(c2.arg); } var r2; o(this, "_invoke", { value: function value(t3, n2) { function callInvokeWithMethodAndArg() { return new e2(function(e3, r3) { invoke(t3, n2, e3, r3); }); } return r2 = r2 ? r2.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e2, r2, n2) { var o2 = h; return function(i2, a2) { if (o2 === f) throw Error("Generator is already running"); if (o2 === s) { if ("throw" === i2) throw a2; return { value: t, done: true }; } for (n2.method = i2, n2.arg = a2; ; ) { var c2 = n2.delegate; if (c2) { var u2 = maybeInvokeDelegate(c2, n2); if (u2) { if (u2 === y) continue; return u2; } } if ("next" === n2.method) n2.sent = n2._sent = n2.arg; else if ("throw" === n2.method) { if (o2 === h) throw o2 = s, n2.arg; n2.dispatchException(n2.arg); } else "return" === n2.method && n2.abrupt("return", n2.arg); o2 = f; var p2 = tryCatch(e2, r2, n2); if ("normal" === p2.type) { if (o2 = n2.done ? s : l, p2.arg === y) continue; return { value: p2.arg, done: n2.done }; } "throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg); } }; } function maybeInvokeDelegate(e2, r2) { var n2 = r2.method, o2 = e2.iterator[n2]; if (o2 === t) return r2.delegate = null, "throw" === n2 && e2.iterator["return"] && (r2.method = "return", r2.arg = t, maybeInvokeDelegate(e2, r2), "throw" === r2.method) || "return" !== n2 && (r2.method = "throw", r2.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y; var i2 = tryCatch(o2, e2.iterator, r2.arg); if ("throw" === i2.type) return r2.method = "throw", r2.arg = i2.arg, r2.delegate = null, y; var a2 = i2.arg; return a2 ? a2.done ? (r2[e2.resultName] = a2.value, r2.next = e2.nextLoc, "return" !== r2.method && (r2.method = "next", r2.arg = t), r2.delegate = null, y) : a2 : (r2.method = "throw", r2.arg = new TypeError("iterator result is not an object"), r2.delegate = null, y); } function pushTryEntry(t2) { var e2 = { tryLoc: t2[0] }; 1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2); } function resetTryEntry(t2) { var e2 = t2.completion || {}; e2.type = "normal", delete e2.arg, t2.completion = e2; } function Context(t2) { this.tryEntries = [{ tryLoc: "root" }], t2.forEach(pushTryEntry, this), this.reset(true); } function values(e2) { if (e2 || "" === e2) { var r2 = e2[a]; if (r2) return r2.call(e2); if ("function" == typeof e2.next) return e2; if (!isNaN(e2.length)) { var o2 = -1, i2 = function next() { for (; ++o2 < e2.length; ) if (n.call(e2, o2)) return next.value = e2[o2], next.done = false, next; return next.value = t, next.done = true, next; }; return i2.next = i2; } } throw new TypeError(_typeof$5(e2) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) { var e2 = "function" == typeof t2 && t2.constructor; return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name)); }, e.mark = function(t2) { return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2; }, e.awrap = function(t2) { return { __await: t2 }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function() { return this; }), e.AsyncIterator = AsyncIterator, e.async = function(t2, r2, n2, o2, i2) { void 0 === i2 && (i2 = Promise); var a2 = new AsyncIterator(wrap(t2, r2, n2, o2), i2); return e.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) { return t3.done ? t3.value : a2.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() { return this; }), define(g, "toString", function() { return "[object Generator]"; }), e.keys = function(t2) { var e2 = Object(t2), r2 = []; for (var n2 in e2) r2.push(n2); return r2.reverse(), function next() { for (; r2.length; ) { var t3 = r2.pop(); if (t3 in e2) return next.value = t3, next.done = false, next; } return next.done = true, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e2) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2) for (var r2 in this) "t" === r2.charAt(0) && n.call(this, r2) && !isNaN(+r2.slice(1)) && (this[r2] = t); }, stop: function stop() { this.done = true; var t2 = this.tryEntries[0].completion; if ("throw" === t2.type) throw t2.arg; return this.rval; }, dispatchException: function dispatchException(e2) { if (this.done) throw e2; var r2 = this; function handle(n2, o3) { return a2.type = "throw", a2.arg = e2, r2.next = n2, o3 && (r2.method = "next", r2.arg = t), !!o3; } for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) { var i2 = this.tryEntries[o2], a2 = i2.completion; if ("root" === i2.tryLoc) return handle("end"); if (i2.tryLoc <= this.prev) { var c2 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc"); if (c2 && u2) { if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true); if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc); } else if (c2) { if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true); } else { if (!u2) throw Error("try statement without catch or finally"); if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc); } } } }, abrupt: function abrupt(t2, e2) { for (var r2 = this.tryEntries.length - 1; r2 >= 0; --r2) { var o2 = this.tryEntries[r2]; if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) { var i2 = o2; break; } } i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null); var a2 = i2 ? i2.completion : {}; return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2); }, complete: function complete(t2, e2) { if ("throw" === t2.type) throw t2.arg; return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y; }, finish: function finish(t2) { for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) { var r2 = this.tryEntries[e2]; if (r2.finallyLoc === t2) return this.complete(r2.completion, r2.afterLoc), resetTryEntry(r2), y; } }, "catch": function _catch(t2) { for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) { var r2 = this.tryEntries[e2]; if (r2.tryLoc === t2) { var n2 = r2.completion; if ("throw" === n2.type) { var o2 = n2.arg; resetTryEntry(r2); } return o2; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e2, r2, n2) { return this.delegate = { iterator: values(e2), resultName: r2, nextLoc: n2 }, "next" === this.method && (this.arg = t), y; } }, e; } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n2) { return void e(n2); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function() { var t = this, e = arguments; return new Promise(function(r, o) { var a = n.apply(t, e); function _next(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n2); } function _throw(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2); } _next(void 0); }); }; } function _typeof$5(o) { "@babel/helpers - typeof"; return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) { return typeof o2; } : function(o2) { return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2; }, _typeof$5(o); } function _slicedToArray$c(r, e) { return _arrayWithHoles$c(r) || _iterableToArrayLimit$c(r, e) || _unsupportedIterableToArray$f(r, e) || _nonIterableRest$c(); } function _nonIterableRest$c() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$f(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$f(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$f(r, a) : void 0; } } function _arrayLikeToArray$f(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _iterableToArrayLimit$c(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = true, o = false; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = false; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ; } catch (r2) { o = true, n = r2; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles$c(r) { if (Array.isArray(r)) return r; } function _objectWithoutProperties$H(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose$H(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose$H(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } var CodeBlock = /* @__PURE__ */ React.forwardRef(function(_ref, ref) { var children = _ref.children, source = _ref.source, _ref$language = _ref.language, language = _ref$language === void 0 ? "json" : _ref$language, showCopyButton = _ref.showCopyButton, showLineNumbers = _ref.showLineNumbers, description = _ref.description, _ref$withSyntaxHighli = _ref.withSyntaxHighlighting, withSyntaxHighlighting = _ref$withSyntaxHighli === void 0 ? false : _ref$withSyntaxHighli, _ref$makeEditable = _ref.makeEditable, makeEditable = _ref$makeEditable === void 0 ? false : _ref$makeEditable, onChange = _ref.onChange, props = _objectWithoutProperties$H(_ref, _excluded$H); var _useState = useState(false), _useState2 = _slicedToArray$c(_useState, 2), isCodeCopied = _useState2[0], setIsCodeCopied = _useState2[1]; var _useState3 = useState(null), _useState4 = _slicedToArray$c(_useState3, 2), prismModule = _useState4[0], setPrismModule = _useState4[1]; var _useState5 = useState(withSyntaxHighlighting), _useState6 = _slicedToArray$c(_useState5, 2), isLoading = _useState6[0], setIsLoading = _useState6[1]; var _useState7 = useState(null), _useState8 = _slicedToArray$c(_useState7, 2), codeElement = _useState8[0], setCodeElement = _useState8[1]; var preRef = useRef(null); var initialCode = typeof children === "string" ? children : React.Children.toArray(children).join(""); if (!children) { initialCode = _typeof$5(source) === "object" ? JSON.stringify(source, null, 2) : source !== null && source !== void 0 ? source : ""; } useEffect(function() { if (!withSyntaxHighlighting) return; var loadPrismWithLanguage = /* @__PURE__ */ function() { var _ref2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() { var _yield$Promise$all, _yield$Promise$all2, prism; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: setIsLoading(true); _context.prev = 1; _context.next = 4; return Promise.all([import("prismjs"), language !== "plain" ? import("prismjs/components/prism-".concat(language)) : Promise.resolve()]); case 4: _yield$Promise$all = _context.sent; _yield$Promise$all2 = _slicedToArray$c(_yield$Promise$all, 1); prism = _yield$Promise$all2[0]; setPrismModule(prism["default"]); _context.next = 13; break; case 10: _context.prev = 10; _context.t0 = _context["catch"](1); console.warn("Failed to load syntax highlighting for ".concat(language, ":"), _context.t0); case 13: _context.prev = 13; setIsLoading(false); return _context.finish(13); case 16: case "end": return _context.stop(); } }, _callee, null, [[1, 10, 13, 16]]); })); return function loadPrismWithLanguage2() { return _ref2.apply(this, arguments); }; }(); loadPrismWithLanguage(); }, [withSyntaxHighlighting, language]); var getCursorPosition = useCallback(function() { var selection = window.getSelection(); if (!selection || selection.rangeCount === 0) return null; var range3 = selection.getRangeAt(0); var currentNode = range3.startContainer; var cursorOffset = range3.startOffset; var absoluteOffset = cursorOffset; if (currentNode && currentNode !== codeElement && codeElement) { var treeWalker = document.createTreeWalker(codeElement, NodeFilter.SHOW_TEXT, null); var node; while (node = treeWalker.nextNode()) { var _node$textContent; if (node === currentNode) break; absoluteOffset += ((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.length) || 0; } } return absoluteOffset; }, [codeElement]); var highlightCode = useCallback(function(content) { if (!codeElement || !withSyntaxHighlighting || !prismModule) return; try { var cursorPosition = makeEditable ? getCursorPosition() : null; var highlighted = prismModule.highlight(content, prismModule.languages[language] || prismModule.languages.plain, language); codeElement.innerHTML = highlighted; if (makeEditable && cursorPosition !== null) { var selection = window.getSelection(); var newRange = document.createRange(); var treeWalker = document.createTreeWalker(codeElement, NodeFilter.SHOW_TEXT, null); var currentOffset = 0; var node; while (node = treeWalker.nextNode()) { var _node$textContent2; var length = ((_node$textContent2 = node.textContent) === null || _node$textContent2 === void 0 ? void 0 : _node$textContent2.length) || 0; if (currentOffset + length >= cursorPosition) { newRange.setStart(node, cursorPosition - currentOffset); newRange.setEnd(node, cursorPosition - currentOffset); selection === null || selection === void 0 || selection.removeAllRanges(); selection === null || selection === void 0 || selection.addRange(newRange); break; } currentOffset += length; } } } catch (error) { console.warn("Error highlighting code:", error); if (codeElement) { codeElement.textContent = content; } } }, [language, withSyntaxHighlighting, makeEditable, prismModule, getCursorPosition, codeElement]); var handleInput = useCallback(function(event) { if (!codeElement) return; var content = codeElement.textContent || ""; onChange === null || onChange === void 0 || onChange(content); requestAnimationFrame(function() { highlightCode(content); }); }, [highlightCode, onChange, codeElement]); useEffect(function() { var element = codeElement; if (!element || !makeEditable) return; element.addEventListener("input", handleInput); return function() { element.removeEventListener("input", handleInput); }; }, [makeEditable, handleInput, codeElement]); useEffect(function() { if (!codeElement || !prismModule) return; highlightCode(initialCode); }, [highlightCode, initialCode, prismModule, codeElement]); var copyToClipboard = /* @__PURE__ */ function() { var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2() { var textToCopy; return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: _context2.prev = 0; textToCopy = codeElement ? codeElement.textContent || "" : initialCode; _context2.next = 4; return navigator.clipboard.writeText(textToCopy); case 4: setIsCodeCopied(true); setTimeout(function() { return setIsCodeCopied(false); }, 3e3); _context2.next = 11; break; case 8: _context2.prev = 8; _context2.t0 = _context2["catch"](0); console.error("Could not copy text: ", _context2.t0); case 11: case "end": return _context2.stop(); } }, _callee2, null, [[0, 8]]); })); return function copyToClipboard2() { return _ref3.apply(this, arguments); }; }(); var handleKeyDown = /* @__PURE__ */ function() { var _ref4 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(e) { return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: if (!((e.key === "Enter" || e.key === " ") && e.target === preRef.current)) { _context3.next = 4; break; } e.preventDefault(); _context3.next = 4; return copyToClipboard(); case 4: case "end": return _context3.stop(); } }, _callee3); })); return function handleKeyDown2(_x) { return _ref4.apply(this, arguments); }; }(); var classNames = []; if (showLineNumbers) { classNames.push("show-line-numbers"); } var lines = initialCode.split(/\r\n|\r|\n/gm); return /* @__PURE__ */ React.createElement(Element, _extends$I({ "data-code-block": true, as: "div", classNames, role: "region", "aria-label": description || "Code block in ".concat(language) }, props), showCopyButton ? isCodeCopied ? /* @__PURE__ */ React.createElement(Badge, { className: "code-block-copied-badge", size: "tiny", shape: "rounded", "aria-live": "polite" }, "Copied!") : /* @__PURE__ */ React.createElement(Button, { type: "button", className: "code-block-copy-button", size: "tiny", shape: "rounded", onClick: copyToClipboard, onKeyDown: handleKeyDown, "aria-label": "Copy code to clipboard" }, "Copy") : null, /* @__PURE__ */ React.createElement("pre", {