func PromisePermissionStatusFromJS(value js.Wrapper) *PromisePermissionStatus {
	input := value.JSValue()
	if typ := input.Type(); typ == js.TypeNull || typ == js.TypeUndefined {
		return nil
	}
	ret := &PromisePermissionStatus{}
	ret.Value_JS = input
	return ret
}
PromisePermissionStatusFromJS is casting a js.Wrapper into PromisePermissionStatus.
package permissions
import "syscall/js"
import (
	"github.com/gowebapi/webapi/dom/domcore"
	"github.com/gowebapi/webapi/javascript"
)
func unused(value interface{}) {
}
type Union struct {
	Value js.Value
}
func (u *Union) JSValue() js.Value {
	return u.Value
}
func UnionFromJS(value js.Value) *Union {
	return &Union{Value: value}
}
type PermissionState int
const (
	GrantedPermissionState PermissionState = iota
	DeniedPermissionState
	PromptPermissionState
)
var permissionStateToWasmTable = []string{
	"granted", "denied", "prompt",
}
var permissionStateFromWasmTable = map[string]PermissionState{
	"granted": GrantedPermissionState, "denied": DeniedPermissionState, "prompt": PromptPermissionState,
}
func (this *PermissionState) JSValue() js.Value {
	return js.ValueOf(this.Value())
}
func (this PermissionState) Value() string {
	idx := int(this)
	if idx >= 0 && idx < len(permissionStateToWasmTable) {
		return permissionStateToWasmTable[idx]
	}
	panic("unknown input value")
}
func PermissionStateFromJS(value js.Value) PermissionState {
	key := value.String()
	conv, ok := permissionStateFromWasmTable[key]
	if !ok {
		panic("unable to convert '" + key + "'")
	}
	return conv
}
type PromisePermissionStatusOnFulfilledFunc func(value *PermissionStatus)
type PromisePermissionStatusOnFulfilled js.Func
func PromisePermissionStatusOnFulfilledToJS(callback PromisePermissionStatusOnFulfilledFunc) *PromisePermissionStatusOnFulfilled {
	if callback == nil {
		return nil
	}
	ret := PromisePermissionStatusOnFulfilled(js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		var (
			_p0 *PermissionStatus  
		)
		_p0 = PermissionStatusFromJS(args[0])
		callback(_p0)
		return nil
	}))
	return &ret
}
func PromisePermissionStatusOnFulfilledFromJS(_value js.Value) PromisePermissionStatusOnFulfilledFunc {
	return func(value *PermissionStatus) {
		var (
			_args [1]interface{}
			_end  int
		)
		_p0 := value.JSValue()
		_args[0] = _p0
		_end++
		_value.Invoke(_args[0:_end]...)
		return
	}
}
type PromisePermissionStatusOnRejectedFunc func(reason js.Value)
type PromisePermissionStatusOnRejected js.Func
func PromisePermissionStatusOnRejectedToJS(callback PromisePermissionStatusOnRejectedFunc) *PromisePermissionStatusOnRejected {
	if callback == nil {
		return nil
	}
	ret := PromisePermissionStatusOnRejected(js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		var (
			_p0 js.Value  
		)
		_p0 = args[0]
		callback(_p0)
		return nil
	}))
	return &ret
}
func PromisePermissionStatusOnRejectedFromJS(_value js.Value) PromisePermissionStatusOnRejectedFunc {
	return func(reason js.Value) {
		var (
			_args [1]interface{}
			_end  int
		)
		_p0 := reason
		_args[0] = _p0
		_end++
		_value.Invoke(_args[0:_end]...)
		return
	}
}
type DevicePermissionDescriptor struct {
	Name     string
	DeviceId string
}
func (_this *DevicePermissionDescriptor) JSValue() js.Value {
	out := js.Global().Get("Object").New()
	value0 := _this.Name
	out.Set("name", value0)
	value1 := _this.DeviceId
	out.Set("deviceId", value1)
	return out
}
func DevicePermissionDescriptorFromJS(value js.Wrapper) *DevicePermissionDescriptor {
	input := value.JSValue()
	var out DevicePermissionDescriptor
	var (
		value0 string  
		value1 string  
	)
	value0 = (input.Get("name")).String()
	out.Name = value0
	value1 = (input.Get("deviceId")).String()
	out.DeviceId = value1
	return &out
}
type MidiPermissionDescriptor struct {
	Name  string
	Sysex bool
}
func (_this *MidiPermissionDescriptor) JSValue() js.Value {
	out := js.Global().Get("Object").New()
	value0 := _this.Name
	out.Set("name", value0)
	value1 := _this.Sysex
	out.Set("sysex", value1)
	return out
}
func MidiPermissionDescriptorFromJS(value js.Wrapper) *MidiPermissionDescriptor {
	input := value.JSValue()
	var out MidiPermissionDescriptor
	var (
		value0 string  
		value1 bool    
	)
	value0 = (input.Get("name")).String()
	out.Name = value0
	value1 = (input.Get("sysex")).Bool()
	out.Sysex = value1
	return &out
}
type PermissionDescriptor struct {
	Name string
}
func (_this *PermissionDescriptor) JSValue() js.Value {
	out := js.Global().Get("Object").New()
	value0 := _this.Name
	out.Set("name", value0)
	return out
}
func PermissionDescriptorFromJS(value js.Wrapper) *PermissionDescriptor {
	input := value.JSValue()
	var out PermissionDescriptor
	var (
		value0 string  
	)
	value0 = (input.Get("name")).String()
	out.Name = value0
	return &out
}
type PermissionSetParameters struct {
	Descriptor *PermissionDescriptor
	State      PermissionState
	OneRealm   bool
}
func (_this *PermissionSetParameters) JSValue() js.Value {
	out := js.Global().Get("Object").New()
	value0 := _this.Descriptor.JSValue()
	out.Set("descriptor", value0)
	value1 := _this.State.JSValue()
	out.Set("state", value1)
	value2 := _this.OneRealm
	out.Set("oneRealm", value2)
	return out
}
func PermissionSetParametersFromJS(value js.Wrapper) *PermissionSetParameters {
	input := value.JSValue()
	var out PermissionSetParameters
	var (
		value0 *PermissionDescriptor  
		value1 PermissionState        
		value2 bool                   
	)
	value0 = PermissionDescriptorFromJS(input.Get("descriptor"))
	out.Descriptor = value0
	value1 = PermissionStateFromJS(input.Get("state"))
	out.State = value1
	value2 = (input.Get("oneRealm")).Bool()
	out.OneRealm = value2
	return &out
}
type PushPermissionDescriptor struct {
	Name            string
	UserVisibleOnly bool
}
func (_this *PushPermissionDescriptor) JSValue() js.Value {
	out := js.Global().Get("Object").New()
	value0 := _this.Name
	out.Set("name", value0)
	value1 := _this.UserVisibleOnly
	out.Set("userVisibleOnly", value1)
	return out
}
func PushPermissionDescriptorFromJS(value js.Wrapper) *PushPermissionDescriptor {
	input := value.JSValue()
	var out PushPermissionDescriptor
	var (
		value0 string  
		value1 bool    
	)
	value0 = (input.Get("name")).String()
	out.Name = value0
	value1 = (input.Get("userVisibleOnly")).Bool()
	out.UserVisibleOnly = value1
	return &out
}
type PermissionStatus struct {
	domcore.EventTarget
}
func PermissionStatusFromJS(value js.Wrapper) *PermissionStatus {
	input := value.JSValue()
	if typ := input.Type(); typ == js.TypeNull || typ == js.TypeUndefined {
		return nil
	}
	ret := &PermissionStatus{}
	ret.Value_JS = input
	return ret
}
func (_this *PermissionStatus) State() PermissionState {
	var ret PermissionState
	value := _this.Value_JS.Get("state")
	ret = PermissionStateFromJS(value)
	return ret
}
func (_this *PermissionStatus) OnChange() domcore.EventHandlerFunc {
	var ret domcore.EventHandlerFunc
	value := _this.Value_JS.Get("onchange")
	if value.Type() != js.TypeNull && value.Type() != js.TypeUndefined {
		ret = domcore.EventHandlerFromJS(value)
	}
	return ret
}
func eventFuncPermissionStatus_domcore_Event(listener func(event *domcore.Event, target *PermissionStatus)) js.Func {
	fn := func(this js.Value, args []js.Value) interface{} {
		var ret *domcore.Event
		value := args[0]
		incoming := value.Get("target")
		ret = domcore.EventFromJS(value)
		src := PermissionStatusFromJS(incoming)
		listener(ret, src)
		return js.Undefined()
	}
	return js.FuncOf(fn)
}
func (_this *PermissionStatus) AddEventChange(listener func(event *domcore.Event, currentTarget *PermissionStatus)) js.Func {
	cb := eventFuncPermissionStatus_domcore_Event(listener)
	_this.Value_JS.Call("addEventListener", "change", cb)
	return cb
}
func (_this *PermissionStatus) SetOnChange(listener func(event *domcore.Event, currentTarget *PermissionStatus)) js.Func {
	cb := eventFuncPermissionStatus_domcore_Event(listener)
	_this.Value_JS.Set("onchange", cb)
	return cb
}
type Permissions struct {
	Value_JS js.Value
}
func (_this *Permissions) JSValue() js.Value {
	return _this.Value_JS
}
func PermissionsFromJS(value js.Wrapper) *Permissions {
	input := value.JSValue()
	if typ := input.Type(); typ == js.TypeNull || typ == js.TypeUndefined {
		return nil
	}
	ret := &Permissions{}
	ret.Value_JS = input
	return ret
}
func (_this *Permissions) Query(permissionDesc *javascript.Object) (_result *PromisePermissionStatus) {
	var (
		_args [1]interface{}
		_end  int
	)
	_p0 := permissionDesc.JSValue()
	_args[0] = _p0
	_end++
	_returned := _this.Value_JS.Call("query", _args[0:_end]...)
	var (
		_converted *PromisePermissionStatus  
	)
	_converted = PromisePermissionStatusFromJS(_returned)
	_result = _converted
	return
}
type PromisePermissionStatus struct {
	Value_JS js.Value
}
func (_this *PromisePermissionStatus) JSValue() js.Value {
	return _this.Value_JS
}