Spaces:
Runtime error
Runtime error
{"version":3,"file":"Empty.svelte_svelte_type_style_lang.d7a3af78.js","sources":["../../../../ui/packages/utils/src/styles.ts","../../../../ui/packages/button/src/Button.svelte","../../../../ui/packages/atoms/src/Block.svelte"],"sourcesContent":["export interface Styles {\n\tcontainer?: boolean;\n\tgrid?: number | Array<number>;\n\theight?: \"auto\" | string | number;\n\twidth?: \"auto\" | string | number;\n\tfull_width?: boolean;\n\tequal_height?: boolean;\n\tvisible?: boolean;\n\titem_container?: boolean;\n\tcolor_map?: Record<string, string>;\n\tlabel_container?: boolean;\n\tgap?: boolean;\n\tsize?: \"sm\" | \"lg\";\n\tpreview?: boolean;\n\tshow_copy_button?: boolean;\n}\n\ntype PartialRecord<K extends keyof any, T> = {\n\t[P in K]?: T;\n};\n\ntype ProcessedStyles = PartialRecord<keyof Styles, string> & {\n\tstyles: string;\n};\n\nconst get_style = <T extends keyof Styles>(styles: Styles, key: T) => {\n\treturn style_handlers[key](styles[key]!);\n};\n\nexport function get_styles(\n\tstyles: Styles,\n\tallowed_styles: Array<keyof Styles>\n): ProcessedStyles {\n\tconst processed_styles = allowed_styles.reduce((acc, next) => {\n\t\tif (styles[next] === undefined || !style_handlers[next]) acc[next] = \" \";\n\t\telse {\n\t\t\tacc[next] = ` ${get_style(styles, next)} `;\n\t\t}\n\t\treturn acc;\n\t}, {} as ProcessedStyles);\n\n\tprocessed_styles.styles = ` ${Object.values(processed_styles)\n\t\t.join(\" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim()} `;\n\n\treturn processed_styles;\n}\n\ntype StyleHandlers = {\n\t[K in keyof Styles]: (style: Exclude<Styles[K], null | undefined>) => string;\n};\n\nconst style_handlers: StyleHandlers = {\n\tcontainer(container_visible) {\n\t\treturn container_visible\n\t\t\t? \"\"\n\t\t\t: `padding: 0; margin: 0; border-width: 0; box-shadow: none; overflow: visible; background: transparent;`;\n\t},\n\tlabel_container(visible) {\n\t\treturn visible\n\t\t\t? \"\"\n\t\t\t: `border-width: 0; box-shadow: none; overflow: visible; background: transparent;`;\n\t},\n\tgrid(grid) {\n\t\tlet grid_map = [\"\", \"sm-\", \"md-\", \"lg-\", \"xl-\", \"2xl-\"];\n\t\tlet _grid = Array.isArray(grid) ? grid : [grid];\n\n\t\treturn [0, 0, 0, 0, 0, 0]\n\t\t\t.map(\n\t\t\t\t(_, i) =>\n\t\t\t\t\t`--${grid_map[i]}grid-cols: var(--grid-${\n\t\t\t\t\t\t_grid?.[i] || _grid?.[_grid?.length - 1]\n\t\t\t\t\t});`\n\t\t\t)\n\t\t\t.join(\" \");\n\t},\n\theight(height) {\n\t\treturn height === \"auto\" ? \"height: auto;\" : \"\";\n\t},\n\tfull_width(full_width) {\n\t\treturn full_width\n\t\t\t? \"width: var(--size-full); flex-grow: 1;\"\n\t\t\t: \"flex-grow: 0; width: fit-content;\";\n\t},\n\tequal_height(equal_height) {\n\t\treturn equal_height ? \"align-items: stretch;\" : \"align-items: flex-start;\";\n\t},\n\tvisible(visible) {\n\t\treturn visible ? \"\" : \"display:hidden;\";\n\t},\n\titem_container(visible) {\n\t\treturn visible ? \"\" : \"border-width:0;\";\n\t}\n} as const;\n\nexport const create_classes = (\n\tstyles: Record<string, any>,\n\tprefix: string = \"\"\n): string => {\n\tlet classes: Array<string> = [];\n\tlet target_styles: Record<string, any> = {};\n\tif (prefix === \"\") {\n\t\ttarget_styles = styles;\n\t} else {\n\t\tfor (const prop in styles) {\n\t\t\tif (prop.startsWith(prefix + \"_\")) {\n\t\t\t\tconst propname = prop.substring(prop.indexOf(\"_\") + 1);\n\t\t\t\ttarget_styles[propname] = styles[prop];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (target_styles.hasOwnProperty(\"margin\")) {\n\t\tif (!Array.isArray(target_styles.margin)) {\n\t\t\ttarget_styles.margin = !!target_styles.margin\n\t\t\t\t? [true, true, true, true]\n\t\t\t\t: [false, false, false, false];\n\t\t}\n\n\t\tlet margin_map = [\"t\", \"r\", \"b\", \"l\"];\n\n\t\t(target_styles.margin as boolean[]).forEach((margin, i) => {\n\t\t\tif (!margin) {\n\t\t\t\tclasses.push(`!m${margin_map[i]}-0`);\n\t\t\t}\n\t\t});\n\t}\n\n\tif (target_styles.hasOwnProperty(\"border\")) {\n\t\tif (!Array.isArray(target_styles.border)) {\n\t\t\ttarget_styles.border = !!target_styles.border\n\t\t\t\t? [true, true, true, true]\n\t\t\t\t: [false, false, false, false];\n\t\t}\n\n\t\tlet border_map = [\"t\", \"r\", \"b\", \"l\"];\n\n\t\t(target_styles.border as boolean[]).forEach((border, i) => {\n\t\t\tif (!border) {\n\t\t\t\tclasses.push(`!border-${border_map[i]}-0`);\n\t\t\t}\n\t\t});\n\t}\n\n\tswitch (target_styles.rounded) {\n\t\tcase true:\n\t\t\tclasses.push(\"!rounded-lg\");\n\t\t\tbreak;\n\t\tcase false:\n\t\t\tclasses.push(\"!rounded-none\");\n\t\t\tbreak;\n\t}\n\n\tswitch (target_styles.full_width) {\n\t\tcase true:\n\t\t\tclasses.push(\"w-full\");\n\t\t\tbreak;\n\t\tcase false:\n\t\t\tclasses.push(\"!grow-0\");\n\t\t\tbreak;\n\t}\n\n\tswitch (target_styles.text_color) {\n\t\tcase \"red\":\n\t\t\tclasses.push(\"!text-red-500\", \"dark:text-red-100\");\n\t\t\tbreak;\n\t\tcase \"yellow\":\n\t\t\tclasses.push(\"!text-yellow-500\", \"dark:text-yellow-100\");\n\t\t\tbreak;\n\t\tcase \"green\":\n\t\t\tclasses.push(\"!text-green-500\", \"dark:text-green-100\");\n\t\t\tbreak;\n\t\tcase \"blue\":\n\t\t\tclasses.push(\"!text-blue-500\", \"dark:text-blue-100\");\n\t\t\tbreak;\n\t\tcase \"purple\":\n\t\t\tclasses.push(\"!text-purple-500\", \"dark:text-purple-100\");\n\t\t\tbreak;\n\t\tcase \"black\":\n\t\t\tclasses.push(\"!text-gray-700\", \"dark:text-gray-50\");\n\t\t\tbreak;\n\t}\n\tswitch (target_styles.bg_color) {\n\t\tcase \"red\":\n\t\t\tclasses.push(\n\t\t\t\t\"!bg-red-100 !from-red-100 !to-red-200 !border-red-300\",\n\t\t\t\t\"dark:!bg-red-700 dark:!from-red-700 dark:!to-red-800 dark:!border-red-900\"\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"yellow\":\n\t\t\tclasses.push(\n\t\t\t\t\"!bg-yellow-100 !from-yellow-100 !to-yellow-200 !border-yellow-300\",\n\t\t\t\t\"dark:!bg-yellow-700 dark:!from-yellow-700 dark:!to-yellow-800 dark:!border-yellow-900\"\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"green\":\n\t\t\tclasses.push(\n\t\t\t\t\"!bg-green-100 !from-green-100 !to-green-200 !border-green-300\",\n\t\t\t\t\"dark:!bg-green-700 dark:!from-green-700 dark:!to-green-800 dark:!border-green-900 !text-gray-800\"\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"blue\":\n\t\t\tclasses.push(\n\t\t\t\t\"!bg-blue-100 !from-blue-100 !to-blue-200 !border-blue-300\",\n\t\t\t\t\"dark:!bg-blue-700 dark:!from-blue-700 dark:!to-blue-800 dark:!border-blue-900\"\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"purple\":\n\t\t\tclasses.push(\n\t\t\t\t\"!bg-purple-100 !from-purple-100 !to-purple-200 !border-purple-300\",\n\t\t\t\t\"dark:!bg-purple-700 dark:!from-purple-700 dark:!to-purple-800 dark:!border-purple-900\"\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"black\":\n\t\t\tclasses.push(\n\t\t\t\t\"!bg-gray-100 !from-gray-100 !to-gray-200 !border-gray-300\",\n\t\t\t\t\"dark:!bg-gray-700 dark:!from-gray-700 dark:!to-gray-800 dark:!border-gray-900\"\n\t\t\t);\n\t\tcase \"pink\":\n\t\t\tclasses.push(\n\t\t\t\t\"!bg-pink-100 !from-pink-100 !to-pink-200 !border-pink-300\",\n\t\t\t\t\"dark:!bg-pink-700 dark:!from-pink-700 dark:!to-pink-800 dark:!border-pink-900 !text-gray-800\"\n\t\t\t);\n\t\t\tbreak;\n\t}\n\treturn \" \" + classes.join(\" \");\n};\n","<script lang=\"ts\">\n\timport { get_styles } from \"../../utils\";\n\timport type { Styles } from \"@gradio/utils\";\n\n\texport let style: Styles = {};\n\texport let elem_id: string = \"\";\n\texport let elem_classes: Array<string> = [];\n\texport let visible: boolean = true;\n\texport let variant: \"primary\" | \"secondary\" | \"stop\" = \"secondary\";\n\texport let size: \"sm\" | \"lg\" = style.size || \"lg\";\n\texport let disabled: boolean = false;\n\n\t$: ({ styles } = get_styles(style, [\"full_width\"]));\n</script>\n\n<button\n\ton:click\n\tclass:hide={!visible}\n\tclass=\"{size} {variant} {elem_classes.join(' ')}\"\n\tstyle={styles}\n\tid={elem_id}\n\t{disabled}\n>\n\t<slot />\n</button>\n\n<style>\n\tbutton {\n\t\tdisplay: inline-flex;\n\t\tjustify-content: center;\n\t\talign-items: center;\n\t\ttransition: var(--button-transition);\n\t\tbox-shadow: var(--button-shadow);\n\t\tpadding: var(--size-0-5) var(--size-2);\n\t\ttext-align: center;\n\t}\n\n\tbutton:hover,\n\tbutton[disabled] {\n\t\tbox-shadow: var(--button-shadow-hover);\n\t}\n\tbutton:active {\n\t\tbox-shadow: var(--button-shadow-active);\n\t}\n\n\tbutton[disabled] {\n\t\topacity: 0.5;\n\t\tfilter: grayscale(30%);\n\t\tcursor: not-allowed;\n\t}\n\n\t.hide {\n\t\tdisplay: none;\n\t}\n\n\t.primary {\n\t\tborder: var(--button-border-width) solid var(--button-primary-border-color);\n\t\tbackground: var(--button-primary-background-fill);\n\t\tcolor: var(--button-primary-text-color);\n\t}\n\t.primary:hover,\n\t.primary[disabled] {\n\t\tborder-color: var(--button-primary-border-color-hover);\n\t\tbackground: var(--button-primary-background-fill-hover);\n\t\tcolor: var(--button-primary-text-color-hover);\n\t}\n\n\t.secondary {\n\t\tborder: var(--button-border-width) solid\n\t\t\tvar(--button-secondary-border-color);\n\t\tbackground: var(--button-secondary-background-fill);\n\t\tcolor: var(--button-secondary-text-color);\n\t}\n\n\t.secondary:hover,\n\t.secondary[disabled] {\n\t\tborder-color: var(--button-secondary-border-color-hover);\n\t\tbackground: var(--button-secondary-background-fill-hover);\n\t\tcolor: var(--button-secondary-text-color-hover);\n\t}\n\n\t.stop {\n\t\tborder: var(--button-border-width) solid var(--button-cancel-border-color);\n\t\tbackground: var(--button-cancel-background-fill);\n\t\tcolor: var(--button-cancel-text-color);\n\t}\n\n\t.stop:hover,\n\t.stop[disabled] {\n\t\tborder-color: var(--button-cancel-border-color-hover);\n\t\tbackground: var(--button-cancel-background-fill-hover);\n\t\tcolor: var(--button-cancel-text-color-hover);\n\t}\n\n\t.sm {\n\t\tborder-radius: var(--button-small-radius);\n\t\tpadding: var(--button-small-padding);\n\t\tfont-weight: var(--button-small-text-weight);\n\t\tfont-size: var(--button-small-text-size);\n\t}\n\n\t.lg {\n\t\tborder-radius: var(--button-large-radius);\n\t\tpadding: var(--button-large-padding);\n\t\tfont-weight: var(--button-large-text-weight);\n\t\tfont-size: var(--button-large-text-size);\n\t}\n</style>\n","<script lang=\"ts\">\n\timport { get_styles } from \"../../utils\";\n\timport type { Styles } from \"@gradio/utils\";\n\n\timport { getContext } from \"svelte\";\n\n\texport let style: Styles = {};\n\texport let elem_id: string = \"\";\n\texport let elem_classes: Array<string> = [];\n\texport let variant: \"solid\" | \"dashed\" | \"none\" = \"solid\";\n\texport let border_mode: \"base\" | \"focus\" = \"base\";\n\texport let padding: boolean = true;\n\texport let type: \"normal\" | \"fieldset\" = \"normal\";\n\texport let test_id: string | undefined = undefined;\n\texport let disable: boolean = false;\n\texport let explicit_call: boolean = false;\n\texport let visible = true;\n\texport let allow_overflow = true;\n\n\tlet tag = type === \"fieldset\" ? \"fieldset\" : \"div\";\n\n\tconst parent = getContext<string | null>(\"BLOCK_KEY\");\n\n\t$: _parent = parent === \"column\" || parent == \"row\" ? parent : \"column\";\n\n\t$: ({ styles } = explicit_call\n\t\t? get_styles(style, [])\n\t\t: disable\n\t\t? get_styles({ container: false }, [\"container\"])\n\t\t: { styles: \"\" });\n\t$: size_style =\n\t\t\"\" +\n\t\t(typeof style.height === \"number\" ? `height: ${style.height}px; ` : \"\") +\n\t\t(typeof style.width === \"number\" ? `width: ${style.width}px;` : \"\");\n</script>\n\n<svelte:element\n\tthis={tag}\n\tdata-testid={test_id}\n\tid={elem_id}\n\tclass:hidden={visible === false}\n\tclass=\"block {elem_classes.join(' ')}\"\n\tclass:padded={padding}\n\tclass:border_focus={border_mode === \"focus\"}\n\tstyle=\"{styles} {size_style || null}\"\n\tstyle:border-style={variant}\n\tstyle:overflow={allow_overflow ? \"visible\" : \"hidden\"}\n>\n\t<slot />\n</svelte:element>\n\n<style>\n\t.block {\n\t\tposition: relative;\n\t\tmargin: 0;\n\t\tbox-shadow: var(--block-shadow);\n\t\tborder-width: var(--block-border-width);\n\t\tborder-color: var(--block-border-color);\n\t\tborder-radius: var(--block-radius);\n\t\tbackground: var(--block-background-fill);\n\t\twidth: 100%;\n\t\tline-height: var(--line-sm);\n\t}\n\n\t.block.border_focus {\n\t\tborder-color: var(--color-accent);\n\t}\n\n\t.padded {\n\t\tpadding: var(--block-padding);\n\t}\n\n\t.hidden {\n\t\tdisplay: none;\n\t}\n</style>\n"],"names":[],"mappings":"4LAyBA,KAAM,GAAY,CAAyB,EAAgB,IACnD,EAAe,GAAK,EAAO,EAAK,aAIvC,EACA,EACkB,MACZ,GAAmB,EAAe,OAAO,CAAC,EAAK,KAChD,EAAO,KAAU,QAAa,CAAC,EAAe,KAAW,GAAQ,MAEhE,GAAQ,IAAI,EAAU,EAAQ,CAAI,KAEhC,GACL,EAAqB,WAEP,OAAS,IAAI,OAAO,OAAO,CAAgB,EAC1D,KAAK,GAAG,EACR,QAAQ,OAAQ,GAAG,EACnB,UAEK,CACR,CAMA,KAAM,GAAgC,CACrC,UAAU,EAAmB,OACrB,GACJ,GACA,yGAEJ,gBAAgB,EAAS,OACjB,GACJ,GACA,kFAEJ,K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