text: const { Plugin } = require('@uppy/core')
  const { Provider } = require('@uppy/companion-client')
  const { ProviderViews } = require('@uppy/provider-views')
  const { h } = require('preact')
  
  module.exports = class Dropbox extends Plugin {
    static VERSION = require('../package.json').version
  
    constructor (uppy, opts) {
      super(uppy, opts)
      this.id = this.opts.id || 'Dropbox'
      Provider.initPlugin(this, opts)
      this.title = this.opts.title || 'Dropbox'
      this.icon = () => (
        <svg aria-hidden="true" focusable="false" width="32" height="32" viewBox="0 0 32 32">
          <g fill="none" fill-rule="evenodd">
            <rect class="uppy-ProviderIconBg" fill="#0D2481" width="32" height="32" rx="16" />
            <path d="M11 8l5 3.185-5 3.186-5-3.186L11 8zm10 0l5 3.185-5 3.186-5-3.186L21 8zM6 17.556l5-3.185 5 3.185-5 3.186-5-3.186zm15-3.185l5 3.185-5 3.186-5-3.186 5-3.185zm-10 7.432l5-3.185 5 3.185-5 3.186-5-3.186z" fill="#FFF" fill-rule="nonzero" />
          </g>
        </svg>
      )
  
      this.provider = new Provider(uppy, {
        companionUrl: this.opts.companionUrl,
        companionHeaders: this.opts.companionHeaders || this.opts.serverHeaders,
        companionKeysParams: this.opts.companionKeysParams,
        companionCookiesRule: this.opts.companionCookiesRule,
        provider: 'dropbox',
        pluginId: this.id
      })
  
      this.onFirstRender = this.onFirstRender.bind(this)
      this.render = this.render.bind(this)
    }
  
    install () {
      this.view = new ProviderViews(this, {
        provider: this.provider
      })
  
      const target = this.opts.target
      if (target) {
        this.mount(target, this)
      }
    }
  
    uninstall () {
      this.view.tearDown()
      this.unmount()
    }
  
    onFirstRender () {
      return Promise.all([
        this.provider.fetchPreAuthToken(),
        this.view.getFolder()
      ])
    }
  
    render (state) {
      return this.view.render(state)
    }
  }
  