ronantakizawa/codereview-bench huggingface dataset:
Repository: grpc/grpc-go
File: experimental/stats/metricregistry_test.go (Go)

Code before:
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	r.floatValues[handle.Descriptor()] += incr
}

func (r *fakeMetricsRecorder) RecordInt64Gauge(handle *Int64GaugeHandle, incr int64, labels ...string) {
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	r.intValues[handle.Descriptor()] += incr
}

func (r *fakeMetricsRecorder) RecordInt64UpDownCount(handle *Int64UpDownCountHandle, incr int64, labels ...string) {
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	r.intValues[handle.Descriptor()] += incr
}

func (r *fakeMetricsRecorder) RecordInt64AsyncGauge(handle *Int64AsyncGaugeHandle, val int64, labels ...string) {
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	// Async gauges in OTel are "Observer" instruments; they report
	// the current state of the world every cycle, they do not accumulate deltas.
	r.intValues[handle.Descriptor()] = val
}

func (r *fakeMetricsRecorder) RegisterAsyncReporter(reporter AsyncMetricReporter, _ ...AsyncMetric) func() {
	// We execute the reporter immediately.
	// This allows the test to verify the metric value in r.intValues immediately
	// after the component under test calls RegisterAsyncReporter.
	err := reporter.Report(r)
	if err != nil {
		r.t.Logf("Async reporter returned error: %v", err)
	}

	// Return a no-op cleanup function
	return func() {}
}


Review comment (bug):
Calling the `reporter` in a blocking manner during registration  may cause deadlocks in the callers of `RegisterAsyncReporter`. For example the caller may be holding a mutex that also needs to be locked in the `Report` method. Can we call `reporter.Report` in a separate goroutine instead?

Code after:
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	r.floatValues[handle.Descriptor()] += incr
}

func (r *fakeMetricsRecorder) RecordInt64Gauge(handle *Int64GaugeHandle, incr int64, labels ...string) {
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	r.intValues[handle.Descriptor()] += incr
}

func (r *fakeMetricsRecorder) RecordInt64UpDownCount(handle *Int64UpDownCountHandle, incr int64, labels ...string) {
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	r.intValues[handle.Descriptor()] += incr
}

func (r *fakeMetricsRecorder) RecordInt64AsyncGauge(handle *Int64AsyncGaugeHandle, val int64, labels ...string) {
	verifyLabels(r.t, handle.Descriptor().Labels, handle.Descriptor().OptionalLabels, labels)
	// Async gauges in OTel are "Observer" instruments; they report
	// the current state of the world every cycle, they do not accumulate deltas.
	r.intValues[handle.Descriptor()] = val
}

// RegisterAsyncReporter is noop implementation, this might be changed at a
// later stage.
func (r *fakeMetricsRecorder) RegisterAsyncReporter(AsyncMetricReporter, ...AsyncMetric) func() {
	return func() {}
}
Repository: grpc/grpc-go
File: mem/buffers.go (Go)

Code before:
}

func (b *buffer) ReadOnlyData() []byte {
	if !b.refs.initialized {
		panic("Cannot read freed buffer")
	}
	return b.data
}

func (b *buffer) Ref() {
	if !b.refs.initialized {
		panic("Cannot ref freed buffer")
	}
	b.refs.Add(1)
}

func (b *buffer) Free() {
	if !b.refs.initialized {
		panic("Cannot free freed buffer")
	}

	refs := b.refs.Add(-1)
	switch {
	case refs > 0:
		return
	case refs == 0:
	default:
		panic("Cannot free freed buffer")
	}

	b.refs.initialized = false
	b.data = nil
	if b.rootBuf == b {
		// This buffer is the owner of the data slice and its ref count reached
		// 0, free the slice.
		if b.pool != nil {
			b.pool.Put(b.origData)
			b.pool = nil
		}
		b.origData = nil
	} else {
		// This buffer doesn't own the data slice, decrement a ref on the root
		// buffer.
		b.rootBuf.Free()
	}

	b.rootBuf = nil
	bufferObjectPool.Put(b)
}

func (b *buffer) Len() int {

Review comment (suggestion):
The fact that this case statement has no lines of code within it, but implicitly means that we break out of the switch to execute code that is defined outside of the switch makes this code harder to read. I would recommend making an unexported method on the `buffer` type that actually takes care of doing the freeing (the code which is now currently outside of this switch block) and invoke it from here.

Code after:
	if b.refs.Add(1) <= 1 {
		panic("Cannot ref freed buffer")
	}
}

func (b *buffer) Free() {
	refs := b.refs.Add(-1)
	if refs < 0 {
		panic("Cannot free freed buffer")
	}
	if refs > 0 {
		return
	}

	b.data = nil
	if b.rootBuf == b {
		// This buffer is the owner of the data slice and its ref count reached
		// 0, free the slice.
		if b.pool != nil {
			b.pool.Put(b.origData)
			b.pool = nil
		}
		b.origData = nil
	} else {
		// This buffer doesn't own the data slice, decrement a ref on the root
		// buffer.
		b.rootBuf.Free()
	}

	b.rootBuf = nil
	bufferObjectPool.Put(b)
}

func (b *buffer) Len() int {
	return len(b.ReadOnlyData())
}

func (b *buffer) split(n int) (Buffer, Buffer) {
	if b.rootBuf == nil || b.rootBuf.refs.Add(1) <= 1 {
		panic("Cannot split freed buffer")
	}

	split := newBuffer()
	split.data = b.data[n:]
	split.rootBuf = b.rootBuf
	split.refs.Store(1)

	b.data = b.data[:n]

	return b, split
}
Repository: grpc/grpc-go
File: internal/transport/transport.go (Go)

Code before:
		}
		if err != nil {
			if n > 0 && err == io.EOF {
				err = io.ErrUnexpectedEOF
			}
			return err
		}
	}
	return nil
}

// Read reads n bytes from the wire for this stream.
func (s *Stream) read(n int) (data mem.BufferSlice, err error) {
	// Don't request a read if there was an error earlier
	if er := s.trReader.er; er != nil {
		return nil, er
	}
	if n == 0 {
		return data, nil
	}
	// gRPC Go accepts data frames with a maximum length of 16KB. Larger
	// messages must be split into multiple frames. We pre-allocate the
	// buffer to avoid resizing during the read loop, but cap the initial
	// capacity to 128 frames (2MB) to prevent over-allocation or panics
	// when reading extremely large streams.
	allocCap := min((n-1)/http2MaxFrameLen+1, 2*1024*1024/http2MaxFrameLen)
	data = make(mem.BufferSlice, 0, allocCap)
	s.readRequester.requestRead(n)
	for n != 0 {
		buf, err := s.trReader.Read(n)
		var bufLen int
		if buf != nil {
			bufLen = buf.Len()
		}
		n -= bufLen
		if n == 0 {
			err = nil
		}
		if err != nil {
			if bufLen > 0 && err == io.EOF {
				err = io.ErrUnexpectedEOF
			}
			data.Free()
			return nil, err
		}
		data = append(data, buf)
	}
	return data, nil
}

// noCopy may be embedded into structs which must not be copied

Review comment (suggestion):
Does it make more sense to replace `2*1024*1024/http2MaxFrameLen` with `128` as the comment above already states that.

Code after:
		}
		if err != nil {
			if n > 0 && err == io.EOF {
				err = io.ErrUnexpectedEOF
			}
			return err
		}
	}
	return nil
}

// ceil returns the ceil after dividing the numerator and denominator while
// avoiding integer overflows.
func ceil(numerator, denominator int) int {
	if numerator == 0 {
		return 0
	}
	return (numerator-1)/denominator + 1
}

// Read reads n bytes from the wire for this stream.
func (s *Stream) read(n int) (data mem.BufferSlice, err error) {
	// Don't request a read if there was an error earlier
	if er := s.trReader.er; er != nil {
		return nil, er
	}
	// gRPC Go accepts data frames with a maximum length of 16KB. Larger
	// messages must be split into multiple frames. We pre-allocate the
	// buffer to avoid resizing during the read loop, but cap the initial
	// capacity to 128 frames (2MB) to prevent over-allocation or panics
	// when reading extremely large streams.
	allocCap := min(ceil(n, http2MaxFrameLen), 128)
	data = make(mem.BufferSlice, 0, allocCap)
	s.readRequester.requestRead(n)
	for n != 0 {
		buf, err := s.trReader.Read(n)
		var bufLen int
		if buf != nil {
			bufLen = buf.Len()
		}
		n -= bufLen
		if n == 0 {
			err = nil
		}
		if err != nil {
			if bufLen > 0 && err == io.EOF {
				err = io.ErrUnexpectedEOF
			}
			data.Free()
			return nil, err
		}
Repository: grpc/grpc-go
File: internal/xds/xdsclient/pool.go (Go)

Code before:
		if err != nil {
			return nil
		}
		r := &v3statuspb.ClientStatusResponse{}
		if err := proto.Unmarshal(b, r); err != nil {
			return nil
		}
		cfg := r.Config[0]
		cfg.ClientScope = key
		resp.Config = append(resp.Config, cfg)
	}
	return resp
}

// BootstrapConfigForTesting returns the bootstrap configuration used by the
// pool. The caller should not mutate the returned config.
//
// To be used only for testing purposes.
func (p *Pool) BootstrapConfigForTesting() *bootstrap.Config {
	p.mu.Lock()
	defer p.mu.Unlock()
	cfg, _ := p.getConfiguration()
	if cfg != nil {
		return cfg
	}
	return nil
}

// UnsetBootstrapConfigForTesting unsets the bootstrap configuration used by
// the pool.
//
// To be used only for testing purposes.
func (p *Pool) UnsetBootstrapConfigForTesting() {
	p.mu.Lock()
	defer p.mu.Unlock()
	p.getConfiguration = sync.OnceValues(bootstrap.GetConfiguration)
}

func (p *Pool) clientRefCountedClose(name string) {
	p.mu.Lock()
	client, ok := p.clients[name]
	if !ok {
		logger.Errorf("Attempt to close a non-existent xDS client with name %s", name)
		p.mu.Unlock()
		return
	}
	if client.decrRef() != 0 {
		p.mu.Unlock()
		return
	}
	delete(p.clients, name)

Review comment (suggestion):
Can this simply be:

```golang
	cfg, _ := p.getConfiguration()
    return cfg
```

Code after:
	}

	c, cancel, err := p.newRefCounted(opts.Name, opts.MetricsRecorder, opts.WatchExpiryTimeout, config)
	if err != nil {
		return nil, nil, err
	}
	return c, cancel, nil
}

// GetClientForTesting returns an xDS client created earlier using the given
// name from the pool. If the client with the given name doesn't already exist,
// it returns an error.
//
// The second return value represents a close function which the caller is
// expected to invoke once they are done using the client.  It is safe for the
// caller to invoke this close function multiple times.
//
// # Testing Only
//
// This function should ONLY be used for testing purposes.
func (p *Pool) GetClientForTesting(name string) (XDSClient, func(), error) {
	p.mu.Lock()
	defer p.mu.Unlock()

	c, ok := p.clients[name]
	if !ok {
		return nil, nil, fmt.Errorf("xds:: xDS client with name %q not found", name)
	}
	c.incrRef()
	return c, sync.OnceFunc(func() { p.clientRefCountedClose(name) }), nil
}

// DumpResources returns the status and contents of all xDS resources.
func (p *Pool) DumpResources() *v3statuspb.ClientStatusResponse {
	p.mu.Lock()
	defer p.mu.Unlock()

	resp := &v3statuspb.ClientStatusResponse{}
	for key, client := range p.clients {
		b, err := client.DumpResources()
		if err != nil {
			return nil
		}
		r := &v3statuspb.ClientStatusResponse{}
		if err := proto.Unmarshal(b, r); err != nil {
			return nil
		}
		cfg := r.Config[0]
		cfg.ClientScope = key
		resp.Config = append(resp.Config, cfg)
	}
Repository: grpc/grpc-go
File: internal/xds/bootstrap/bootstrap_test.go (Go)

Code before:
		}},
		certProviderConfigs: map[string]*certprovider.BuildableConfig{
			"fakeProviderInstance": wantCfg,
		},
		clientDefaultListenerResourceNameTemplate: "%s",
		node: v3Node,
	}
	tests := []struct {
		name       string
		wantConfig *Config
		wantErr    bool
	}{
		{
			name:    "badJSONCertProviderConfig",
			wantErr: true,
		},
		{

			name:    "badCertProviderConfig",
			wantErr: true,
		},
		{

			name:       "allUnknownCertProviders",
			wantConfig: configWithGoogleDefaultCredsAndV3,
			wantErr:    false,
		},
		{
			name:       "goodCertProviderConfig",
			wantConfig: goodConfig,
			wantErr:    false,
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			testGetConfigurationWithFileNameEnv(t, test.name, test.wantErr, test.wantConfig)
			testGetConfigurationWithFileContentEnv(t, test.name, test.wantErr, test.wantConfig)
		})
	}
}

func (s) TestGetConfiguration_ServerListenerResourceNameTemplate(t *testing.T) {
	cancel := setupBootstrapOverride(map[string]string{
		"badServerListenerResourceNameTemplate:": `
		{
			"node": {
				"id": "ENVOY_NODE_ID",
				"metadata": {
				    "TRAFFICDIRECTOR_GRPC_HOSTNAME": "trafficdirector"
			    }

Review comment (suggestion):
Any specific reason for adding `wantErr: false` here and in the next sub-test? The default value for `bool` is `false` and it is common practice to not specify fields that are to contain their zero values (unless it improves readability).

Code after:
		}},
		certProviderConfigs: map[string]*certprovider.BuildableConfig{
			"fakeProviderInstance": wantCfg,
		},
		clientDefaultListenerResourceNameTemplate: "%s",
		node: v3Node,
	}
	tests := []struct {
		name       string
		wantConfig *Config
		wantErr    bool
	}{
		{
			name:    "badJSONCertProviderConfig",
			wantErr: true,
		},
		{

			name:    "badCertProviderConfig",
			wantErr: true,
		},
		{

			name:       "allUnknownCertProviders",
			wantConfig: configWithGoogleDefaultCredsAndV3,
		},
		{
			name:       "goodCertProviderConfig",
			wantConfig: goodConfig,
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			testGetConfigurationWithFileNameEnv(t, test.name, test.wantErr, test.wantConfig)
			testGetConfigurationWithFileContentEnv(t, test.name, test.wantErr, test.wantConfig)
		})
	}
}

func (s) TestGetConfiguration_ServerListenerResourceNameTemplate(t *testing.T) {
	cancel := setupBootstrapOverride(map[string]string{
		"badServerListenerResourceNameTemplate:": `
		{
			"node": {
				"id": "ENVOY_NODE_ID",
				"metadata": {
				    "TRAFFICDIRECTOR_GRPC_HOSTNAME": "trafficdirector"
			    }
			},
			"xds_servers" : [{
Repository: grpc/grpc-go
File: internal/xds/clients/xdsclient/test/custom_resource_watch_test.go (Go)

Code before:
		return nil, fmt.Errorf("failed to unmarshal resource: %v", err)
	}

	// We expect the value to be "name|content". This allows us to extract the
	// name which is required by the xDS client to match the watch.
	str := val.GetValue()
	name, content, found := strings.Cut(str, "|")
	if !found {
		return nil, fmt.Errorf("invalid format: expected 'name|content', got %q", str)
	}

	return &xdsclient.DecodeResult{
		Name:     name,
		Resource: &customTestResourceData{val: content},
	}, nil
}

type customTestResourceData struct {
	val string
}

func (c *customTestResourceData) Equal(other xdsclient.ResourceData) bool {
	if c == nil && other == nil {
		return true
	}
	if (c == nil) != (other == nil) {
		return false
	}
	o, ok := other.(*customTestResourceData)
	if !ok {
		return false
	}
	return c.val == o.val
}

func (c *customTestResourceData) Bytes() []byte {
	return []byte(c.val)
}

func (c *customTestResourceData) Raw() *anypb.Any {
	a, _ := anypb.New(&wrapperspb.StringValue{Value: c.val})
	return a
}

// customTestWatcher is a watcher for the custom resource type.
type customTestWatcher struct {
	updateCh chan xdsclient.ResourceData
	errCh    chan error
}

func newCustomTestWatcher() *customTestWatcher {

Review comment (suggestion):
This can be simplified to `if c==nil || other==nil{return false}` since we already have a check above this that gaurantees that both are not nil. 

Code after:
		return nil, fmt.Errorf("failed to unmarshal resource: %v", err)
	}

	// We expect the value to be "name|content". This allows us to extract the
	// name which is required by the xDS client to match the watch.
	str := val.GetValue()
	name, content, found := strings.Cut(str, "|")
	if !found {
		return nil, fmt.Errorf("invalid format: expected 'name|content', got %q", str)
	}

	return &xdsclient.DecodeResult{
		Name:     name,
		Resource: &customTestResourceData{val: content},
	}, nil
}

type customTestResourceData struct {
	val string
}

func (c *customTestResourceData) Equal(other xdsclient.ResourceData) bool {
	if c == nil && other == nil {
		return true
	}
	if c == nil || other == nil {
		return false
	}
	o, ok := other.(*customTestResourceData)
	if !ok {
		return false
	}
	return c.val == o.val
}

func (c *customTestResourceData) Bytes() []byte {
	return []byte(c.val)
}

// customTestWatcher is a watcher for the custom resource type.
type customTestWatcher struct {
	updateCh chan xdsclient.ResourceData
	errCh    chan error
}

func newCustomTestWatcher() *customTestWatcher {
	return &customTestWatcher{
		updateCh: make(chan xdsclient.ResourceData, 1),
		errCh:    make(chan error, 1),
	}
}
Repository: h2oai/wave
File: ui/src/theme.ts (TypeScript)

Code before:
        text8: rgba(r, g, b, a += 0.1),
        text9: rgba(r, g, b, a += 0.1),
      }
    return { ...palette, ...tones }
  },
  defaultColors = {
    red: '#F44336',
    pink: '#E91E63',
    purple: '#9C27B0',
    violet: '#673AB7',
    indigo: '#3F51B5',
    blue: '#2196F3',
    azure: '#03A9F4',
    cyan: '#00BCD4',
    teal: '#009688',
    mint: '#4CAF50',
    green: '#8BC34A',
    lime: '#CDDC39',
    yellow: '#FFEB3B',
    amber: '#FFC107',
    orange: '#FF9800',
    tangerine: '#FF5722',
    brown: '#795548',
    gray: '#9E9E9E',
  },
  palettes: Dict<ColorTheme> = {
    light: {
      palette: toPalette({
        ...defaultColors,
        text: '#a529d6',
        card: '#ffffff',
        page: '#f5f5f5',
      }, 0.1),
      theme: {
        palette: {
          themePrimary: '#a529d6',
          themeLighterAlt: '#fbf5fd',
          themeLighter: '#efd8f8',
          themeLight: '#e2b8f3',
          themeTertiary: '#c776e7',
          themeSecondary: '#af3fdb',
          themeDarkAlt: '#9525c1',
          themeDark: '#7d1fa3',
          themeDarker: '#5c1778',
          neutralLighterAlt: '#f8f8f8',
          neutralLighter: '#f4f4f4',
          neutralLight: '#eaeaea',
          neutralQuaternaryAlt: '#dadada',
          neutralQuaternary: '#d0d0d0',
          neutralTertiaryAlt: '#c8c8c8',
          neutralTertiary: '#595959',

Review comment (suggestion):
This turns into `palettes[x].palette` at call sites. We need a good design to merge `palette` and `theme`.

Code after:
    red: '#F44336',
    pink: '#E91E63',
    purple: '#9C27B0',
    violet: '#673AB7',
    indigo: '#3F51B5',
    blue: '#2196F3',
    azure: '#03A9F4',
    cyan: '#00BCD4',
    teal: '#009688',
    mint: '#4CAF50',
    green: '#8BC34A',
    lime: '#CDDC39',
    yellow: '#FFEB3B',
    amber: '#FFC107',
    orange: '#FF9800',
    tangerine: '#FF5722',
    brown: '#795548',
    gray: '#9E9E9E',
  },
  palettes: Dict<Palette & Tones> = {
    light: toPalette({
      ...defaultColors,
      text: '#323130',
      card: '#ffffff',
      page: '#f5f5f5',
    }, 0.1),
    dark: toPalette({
      ...defaultColors,
      text: '#ffffff',
      card: '#21252b',
      page: '#282c34',
    }, 0),
    neon: toPalette({
      ...defaultColors,
      text: '#ffffff',
      card: '#0d0e0f',
      page: '#1b1d1f',
    }, 0),
  },
  // tracking = a + b * Math.exp(c * fontSize)
  // a = -0.0223, b = 0.185, c = -0.1745
  fontTrackings = [
    [6, 0.043],
    [7, 0.032],
    [8, 0.024],
    [9, 0.016],
    [10, 0.01],
    [11, 0.005],
    [12, 0],
    [13, -0.0025],
    [14, -0.006],
Repository: h2oai/wave
File: py/examples/file_upload.py (Python)

Code before:
# Form / File Upload
# No description available.
# ---
from telesync import site, ui

page = site['/demo']

page['hello'] = ui.form_card(
    box='1 1 4 10',
    items=[
      ui.file_upload(name='file_upload', label='Upload a file')
    ]
)

page.sync()


Review comment (suggestion):
```suggestion
page['example'] = ui.form_card(
```

Code after:
# Form / File Upload
# No description available.
# ---
from telesync import site, ui

page = site['/demo']

page['example'] = ui.form_card(
    box='1 1 4 10',
    items=[
      ui.file_upload(name='file_upload', label='Upload a file')
    ]
)

page.sync()
Repository: h2oai/wave
File: ui/src/file_upload.tsx (TypeScript)

Code before:
import * as Fluent from '@fluentui/react';
import React from 'react';
import { stylesheet } from 'typestyle';
import { B, bond, box, S, telesync, U, xid } from './telesync';
import { getTheme, centerMixin, dashed, clas } from './theme';

/**
 * Create a file upload component.
 * A file upload component allows a user to browse, select and upload one or more files.
 */
export interface FileUpload {
  /** An identifying name for this component. */
  name: S
  /** Text to be displayed alongside the component. */
  label?: S
  /** True if the component should allow multiple files to be uploaded. */
  multiple?: B
  /** An optional tooltip message displayed when a user clicks the help icon to the right of the component. */
  tooltip?: S
  /** An optional string array for defining allowed upload types. E.g. .pdf, .docx ... . Default value is empty - every file type is allowed. */
  allowedFileTypes?: S[]
  /** Maximum file size in Mb that none of the files uploaded can exceed. Default value is unlimited. */
  maxSizePerFile?: U
  /** Maximum file size in Mb for all uploaded files combined that cannot be excceeded. Default value is unlimited. */
  maxSizeTotal?: U
}

const
  { colors } = getTheme(),
  css = stylesheet({
    uploadInput: {
      opacity: 0
    },
    upload: {
      height: 300,
      ...centerMixin(),
      flexDirection: 'column',
      boxSizing: 'border-box',
      margin: 5,
    },
    uploadDragging: {
      border: dashed(2, colors.text),
    },
    uploadLabel: {
      ...centerMixin(),

Review comment (suggestion):
```suggestion
  /** List of allowed file extensions, e.g. `pdf`, `docx`, etc. */
```

Code after:
import * as Fluent from '@fluentui/react';
import React from 'react';
import { stylesheet } from 'typestyle';
import { B, bond, box, S, telesync, U, xid, F } from './telesync';
import { getTheme, centerMixin, dashed, clas } from './theme';

/**
 * Create a file upload component.
 * A file upload component allows a user to browse, select and upload one or more files.
 */
export interface FileUpload {
  /** An identifying name for this component. */
  name: S
  /** Text to be displayed alongside the component. */
  label?: S
  /** True if the component should allow multiple files to be uploaded. */
  multiple?: B
  /** List of allowed file extensions, e.g. `pdf`, `docx`, etc. */
  file_extensions?: S[]
  /** Maximum allowed size (Mb) per file. Defaults to no limit. */
  max_file_size?: F
  /** Maximum allowed size (Mb) for all files combined. Defaults to no limit. */
  max_size?: F
  /** An optional tooltip message displayed when a user clicks the help icon to the right of the component. */
  tooltip?: S
}

const
  { colors } = getTheme(),
  css = stylesheet({
    uploadInput: {
      opacity: 0
    },
    upload: {
      height: 300,
      ...centerMixin(),
      flexDirection: 'column',
      boxSizing: 'border-box',
      margin: 5,
    },
    uploadDragging: {
      border: dashed(2, colors.text),
    },
    uploadLabel: {
      ...centerMixin(),