func (_this *ConnectionCloseEvent) Reason() ConnectionCloseReason {
	var ret ConnectionCloseReason
	value := _this.Value_JS.Get("reason")
	ret = ConnectionCloseReasonFromJS(value)
	return ret
}
Reason returning attribute 'reason' with
type ConnectionCloseReason (idl: PresentationConnectionCloseReason).
package presentation
import "syscall/js"
import (
	"github.com/gowebapi/webapi/dom/domcore"
	"github.com/gowebapi/webapi/file"
	"github.com/gowebapi/webapi/html/channel"
	"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 ConnectionCloseReason int
const (
	ReasonError ConnectionCloseReason = iota
	ReasonClosed
	ReasonWentaway
)
var presentationConnectionCloseReasonToWasmTable = []string{
	"error", "closed", "wentaway",
}
var presentationConnectionCloseReasonFromWasmTable = map[string]ConnectionCloseReason{
	"error": ReasonError, "closed": ReasonClosed, "wentaway": ReasonWentaway,
}
func (this *ConnectionCloseReason) JSValue() js.Value {
	return js.ValueOf(this.Value())
}
func (this ConnectionCloseReason) Value() string {
	idx := int(this)
	if idx >= 0 && idx < len(presentationConnectionCloseReasonToWasmTable) {
		return presentationConnectionCloseReasonToWasmTable[idx]
	}
	panic("unknown input value")
}
func ConnectionCloseReasonFromJS(value js.Value) ConnectionCloseReason {
	key := value.String()
	conv, ok := presentationConnectionCloseReasonFromWasmTable[key]
	if !ok {
		panic("unable to convert '" + key + "'")
	}
	return conv
}
type ConnectionState int
const (
	StateConnecting ConnectionState = iota
	StateConnected
	StateClosed
	StateTerminated
)
var presentationConnectionStateToWasmTable = []string{
	"connecting", "connected", "closed", "terminated",
}
var presentationConnectionStateFromWasmTable = map[string]ConnectionState{
	"connecting": StateConnecting, "connected": StateConnected, "closed": StateClosed, "terminated": StateTerminated,
}
func (this *ConnectionState) JSValue() js.Value {
	return js.ValueOf(this.Value())
}
func (this ConnectionState) Value() string {
	idx := int(this)
	if idx >= 0 && idx < len(presentationConnectionStateToWasmTable) {
		return presentationConnectionStateToWasmTable[idx]
	}
	panic("unknown input value")
}
func ConnectionStateFromJS(value js.Value) ConnectionState {
	key := value.String()
	conv, ok := presentationConnectionStateFromWasmTable[key]
	if !ok {
		panic("unable to convert '" + key + "'")
	}
	return conv
}
type PromiseAvailabilityOnFulfilledFunc func(value *Availability)
type PromiseAvailabilityOnFulfilled js.Func
func PromiseAvailabilityOnFulfilledToJS(callback PromiseAvailabilityOnFulfilledFunc) *PromiseAvailabilityOnFulfilled {
	if callback == nil {
		return nil
	}
	ret := PromiseAvailabilityOnFulfilled(js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		var (
			_p0 *Availability  
		)
		_p0 = AvailabilityFromJS(args[0])
		callback(_p0)
		return nil
	}))
	return &ret
}
func PromiseAvailabilityOnFulfilledFromJS(_value js.Value) PromiseAvailabilityOnFulfilledFunc {
	return func(value *Availability) {
		var (
			_args [1]interface{}
			_end  int
		)
		_p0 := value.JSValue()
		_args[0] = _p0
		_end++
		_value.Invoke(_args[0:_end]...)
		return
	}
}
type PromiseAvailabilityOnRejectedFunc func(reason js.Value)
type PromiseAvailabilityOnRejected js.Func
func PromiseAvailabilityOnRejectedToJS(callback PromiseAvailabilityOnRejectedFunc) *PromiseAvailabilityOnRejected {
	if callback == nil {
		return nil
	}
	ret := PromiseAvailabilityOnRejected(js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		var (
			_p0 js.Value  
		)
		_p0 = args[0]
		callback(_p0)
		return nil
	}))
	return &ret
}
func PromiseAvailabilityOnRejectedFromJS(_value js.Value) PromiseAvailabilityOnRejectedFunc {
	return func(reason js.Value) {
		var (
			_args [1]interface{}
			_end  int
		)
		_p0 := reason
		_args[0] = _p0
		_end++
		_value.Invoke(_args[0:_end]...)
		return
	}
}
type PromiseConnectionOnFulfilledFunc func(value *Connection)
type PromiseConnectionOnFulfilled js.Func
func PromiseConnectionOnFulfilledToJS(callback PromiseConnectionOnFulfilledFunc) *PromiseConnectionOnFulfilled {
	if callback == nil {
		return nil
	}
	ret := PromiseConnectionOnFulfilled(js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		var (
			_p0 *Connection  
		)
		_p0 = ConnectionFromJS(args[0])
		callback(_p0)
		return nil
	}))
	return &ret
}
func PromiseConnectionOnFulfilledFromJS(_value js.Value) PromiseConnectionOnFulfilledFunc {
	return func(value *Connection) {
		var (
			_args [1]interface{}
			_end  int
		)
		_p0 := value.JSValue()
		_args[0] = _p0
		_end++
		_value.Invoke(_args[0:_end]...)
		return
	}
}
type PromiseConnectionOnRejectedFunc func(reason js.Value)
type PromiseConnectionOnRejected js.Func
func PromiseConnectionOnRejectedToJS(callback PromiseConnectionOnRejectedFunc) *PromiseConnectionOnRejected {
	if callback == nil {
		return nil
	}
	ret := PromiseConnectionOnRejected(js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		var (
			_p0 js.Value  
		)
		_p0 = args[0]
		callback(_p0)
		return nil
	}))
	return &ret
}
func PromiseConnectionOnRejectedFromJS(_value js.Value) PromiseConnectionOnRejectedFunc {
	return func(reason js.Value) {
		var (
			_args [1]interface{}
			_end  int
		)
		_p0 := reason
		_args[0] = _p0
		_end++
		_value.Invoke(_args[0:_end]...)
		return
	}
}
type ConnectionAvailableEventInit struct {
	Bubbles    bool
	Cancelable bool
	Composed   bool
	Connection *Connection
}
func (_this *ConnectionAvailableEventInit) JSValue() js.Value {
	out := js.Global().Get("Object").New()
	value0 := _this.Bubbles
	out.Set("bubbles", value0)
	value1 := _this.Cancelable
	out.Set("cancelable", value1)
	value2 := _this.Composed
	out.Set("composed", value2)
	value3 := _this.Connection.JSValue()
	out.Set("connection", value3)
	return out
}
func ConnectionAvailableEventInitFromJS(value js.Wrapper) *ConnectionAvailableEventInit {
	input := value.JSValue()
	var out ConnectionAvailableEventInit
	var (
		value0 bool         
		value1 bool         
		value2 bool         
		value3 *Connection  
	)
	value0 = (input.Get("bubbles")).Bool()
	out.Bubbles = value0
	value1 = (input.Get("cancelable")).Bool()
	out.Cancelable = value1
	value2 = (input.Get("composed")).Bool()
	out.Composed = value2
	value3 = ConnectionFromJS(input.Get("connection"))
	out.Connection = value3
	return &out
}
type ConnectionCloseEventInit struct {
	Bubbles    bool
	Cancelable bool
	Composed   bool
	Reason     ConnectionCloseReason
	Message    string
}
func (_this *ConnectionCloseEventInit) JSValue() js.Value {
	out := js.Global().Get("Object").New()
	value0 := _this.Bubbles
	out.Set("bubbles", value0)
	value1 := _this.Cancelable
	out.Set("cancelable", value1)
	value2 := _this.Composed
	out.Set("composed", value2)
	value3 := _this.Reason.JSValue()
	out.Set("reason", value3)
	value4 := _this.Message
	out.Set("message", value4)
	return out
}
func ConnectionCloseEventInitFromJS(value js.Wrapper) *ConnectionCloseEventInit {
	input := value.JSValue()
	var out ConnectionCloseEventInit
	var (
		value0 bool                   
		value1 bool                   
		value2 bool                   
		value3 ConnectionCloseReason  
		value4 string                 
	)
	value0 = (input.Get("bubbles")).Bool()
	out.Bubbles = value0
	value1 = (input.Get("cancelable")).Bool()
	out.Cancelable = value1
	value2 = (input.Get("composed")).Bool()
	out.Composed = value2
	value3 = ConnectionCloseReasonFromJS(input.Get("reason"))
	out.Reason = value3
	value4 = (input.Get("message")).String()
	out.Message = value4
	return &out
}
type Availability struct {
	domcore.EventTarget
}
func AvailabilityFromJS(value js.Wrapper) *Availability {
	input := value.JSValue()
	if typ := input.Type(); typ == js.TypeNull || typ == js.TypeUndefined {
		return nil
	}
	ret := &Availability{}
	ret.Value_JS = input
	return ret
}
func (_this *Availability) Value() bool {
	var ret bool
	value := _this.Value_JS.Get("value")
	ret = (value).Bool()
	return ret
}
func (_this *Availability) 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 eventFuncAvailability_domcore_Event(listener func(event *domcore.Event, target *Availability)) 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 := AvailabilityFromJS(incoming)
		listener(ret, src)
		return js.Undefined()
	}
	return js.FuncOf(fn)
}
func (_this *Availability) AddEventChange(listener func(event *domcore.Event, currentTarget *Availability)) js.Func {
	cb := eventFuncAvailability_domcore_Event(listener)
	_this.Value_JS.Call("addEventListener", "change", cb)
	return cb
}
func (_this *Availability) SetOnChange(listener func(event *domcore.Event, currentTarget *Availability)) js.Func {
	cb := eventFuncAvailability_domcore_Event(listener)
	_this.Value_JS.Set("onchange", cb)
	return cb
}
type Connection struct {
	domcore.EventTarget
}
func ConnectionFromJS(value js.Wrapper) *Connection {
	input := value.JSValue()
	if typ := input.Type(); typ == js.TypeNull || typ == js.TypeUndefined {
		return nil
	}
	ret := &Connection{}
	ret.Value_JS = input
	return ret
}
func (_this *Connection) Id() string {
	var ret string
	value := _this.Value_JS.Get("id")
	ret = (value).String()
	return ret
}
func (_this *Connection) Url() string {
	var ret string
	value := _this.Value_JS.Get("url")
	ret = (value).String()
	return ret
}
func (_this *Connection) State() ConnectionState {
	var ret ConnectionState
	value := _this.Value_JS.Get("state")
	ret = ConnectionStateFromJS(value)
	return ret
}
func (_this *Connection) OnConnect() domcore.EventHandlerFunc {
	var ret domcore.EventHandlerFunc
	value := _this.Value_JS.Get("onconnect")
	if value.Type() != js.TypeNull && value.Type() != js.TypeUndefined {
		ret = domcore.EventHandlerFromJS(value)
	}
	return ret
}
func (_this *Connection) OnClose() domcore.EventHandlerFunc {
	var ret domcore.EventHandlerFunc
	value := _this.Value_JS.Get("onclose")
	if value.Type() != js.TypeNull && value.Type() != js.TypeUndefined {
		ret = domcore.EventHandlerFromJS(value)
	}
	return ret
}
func (_this *Connection) OnTerminate() domcore.EventHandlerFunc {
	var ret domcore.EventHandlerFunc
	value := _this.Value_JS.Get("onterminate")
	if value.Type() != js.TypeNull && value.Type() != js.TypeUndefined {
		ret = domcore.EventHandlerFromJS(value)
	}
	return ret
}
func (_this *Connection) BinaryType() channel.BinaryType {
	var ret channel.BinaryType
	value := _this.Value_JS.Get("binaryType")
	ret = channel.BinaryTypeFromJS(value)
	return ret
}
func (_this *Connection) SetBinaryType(value channel.BinaryType) {
	input := value.JSValue()
	_this.Value_JS.Set("binaryType", input)
}
func (_this *Connection) OnMessage() domcore.EventHandlerFunc {
	var ret domcore.EventHandlerFunc
	value := _this.Value_JS.Get("onmessage")
	if value.Type() != js.TypeNull && value.Type() != js.TypeUndefined {
		ret = domcore.EventHandlerFromJS(value)
	}
	return ret
}
func eventFuncConnection_ConnectionCloseEvent(listener func(event *ConnectionCloseEvent, target *Connection)) js.Func {
	fn := func(this js.Value, args []js.Value) interface{} {
		var ret *ConnectionCloseEvent
		value := args[0]
		incoming := value.Get("target")
		ret = ConnectionCloseEventFromJS(value)
		src := ConnectionFromJS(incoming)
		listener(ret, src)
		return js.Undefined()
	}
	return js.FuncOf(fn)
}
func (_this *Connection) AddEventClose(listener func(event *ConnectionCloseEvent, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_ConnectionCloseEvent(listener)
	_this.Value_JS.Call("addEventListener", "close", cb)
	return cb
}
func (_this *Connection) SetOnClose(listener func(event *ConnectionCloseEvent, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_ConnectionCloseEvent(listener)
	_this.Value_JS.Set("onclose", cb)
	return cb
}
func eventFuncConnection_domcore_Event(listener func(event *domcore.Event, target *Connection)) 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 := ConnectionFromJS(incoming)
		listener(ret, src)
		return js.Undefined()
	}
	return js.FuncOf(fn)
}
func (_this *Connection) AddEventConnect(listener func(event *domcore.Event, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_domcore_Event(listener)
	_this.Value_JS.Call("addEventListener", "connect", cb)
	return cb
}
func (_this *Connection) SetOnConnect(listener func(event *domcore.Event, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_domcore_Event(listener)
	_this.Value_JS.Set("onconnect", cb)
	return cb
}
func eventFuncConnection_channel_MessageEvent(listener func(event *channel.MessageEvent, target *Connection)) js.Func {
	fn := func(this js.Value, args []js.Value) interface{} {
		var ret *channel.MessageEvent
		value := args[0]
		incoming := value.Get("target")
		ret = channel.MessageEventFromJS(value)
		src := ConnectionFromJS(incoming)
		listener(ret, src)
		return js.Undefined()
	}
	return js.FuncOf(fn)
}
func (_this *Connection) AddEventMessage(listener func(event *channel.MessageEvent, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_channel_MessageEvent(listener)
	_this.Value_JS.Call("addEventListener", "message", cb)
	return cb
}
func (_this *Connection) SetOnMessage(listener func(event *channel.MessageEvent, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_channel_MessageEvent(listener)
	_this.Value_JS.Set("onmessage", cb)
	return cb
}
func (_this *Connection) AddEventTerminate(listener func(event *domcore.Event, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_domcore_Event(listener)
	_this.Value_JS.Call("addEventListener", "terminate", cb)
	return cb
}
func (_this *Connection) SetOnTerminate(listener func(event *domcore.Event, currentTarget *Connection)) js.Func {
	cb := eventFuncConnection_domcore_Event(listener)
	_this.Value_JS.Set("onterminate", cb)
	return cb
}
func (_this *Connection) Close() {
	var (
		_args [0]interface{}
		_end  int
	)
	_this.Value_JS.Call("close", _args[0:_end]...)
	return
}
func (_this *Connection) Terminate() {
	var (
		_args [0]interface{}
		_end  int
	)
	_this.Value_JS.Call("terminate", _args[0:_end]...)
	return
}
func (_this *Connection) Send(message string) {
	var (
		_args [1]interface{}
		_end  int
	)
	_p0 := message
	_args[0] = _p0
	_end++
	_this.Value_JS.Call("send", _args[0:_end]...)
	return
}
func (_this *Connection) Send2(data *file.Blob) {
	var (
		_args [1]interface{}
		_end  int
	)
	_p0 := data.JSValue()
	_args[0] = _p0
	_end++
	_this.Value_JS.Call("send", _args[0:_end]...)
	return
}
func (_this *Connection) Send3(data *javascript.ArrayBuffer) {
	var (
		_args [1]interface{}
		_end  int
	)
	_p0 := data.JSValue()
	_args[0] = _p0
	_end++
	_this.Value_JS.Call("send", _args[0:_end]...)
	return
}
func (_this *Connection) Send4(data *Union) {
	var (
		_args [1]interface{}
		_end  int
	)
	_p0 := data.JSValue()
	_args[0] = _p0
	_end++
	_this.Value_JS.Call("send", _args[0:_end]...)
	return
}
type ConnectionAvailableEvent struct {
	domcore.Event
}
func ConnectionAvailableEventFromJS(value js.Wrapper) *ConnectionAvailableEvent {
	input := value.JSValue()
	if typ := input.Type(); typ == js.TypeNull || typ == js.TypeUndefined {
		return nil
	}
	ret := &ConnectionAvailableEvent{}
	ret.Value_JS = input
	return ret
}
func NewPresentationConnectionAvailableEvent(_type string, eventInitDict *ConnectionAvailableEventInit) (_result *ConnectionAvailableEvent) {
	_klass := js.Global().Get("PresentationConnectionAvailableEvent")
	var (
		_args [2]interface{}
		_end  int
	)
	_p0 := _type
	_args[0] = _p0
	_end++
	_p1 := eventInitDict.JSValue()
	_args[1] = _p1
	_end++
	_returned := _klass.New(_args[0:_end]...)
	var (
		_converted *ConnectionAvailableEvent  
	)
	_converted = ConnectionAvailableEventFromJS(_returned)
	_result = _converted
	return
}
func (_this *ConnectionAvailableEvent) Connection() *Connection {
	var ret *Connection
	value := _this.Value_JS.Get("connection")
	ret = ConnectionFromJS(value)
	return ret
}
type ConnectionCloseEvent struct {
	domcore.Event
}
func ConnectionCloseEventFromJS(value js.Wrapper) *ConnectionCloseEvent {
	input := value.JSValue()
	if typ := input.Type(); typ == js.TypeNull || typ == js.TypeUndefined {
		return nil
	}
	ret := &ConnectionCloseEvent{}
	ret.Value_JS = input
	return ret
}
func NewPresentationConnectionCloseEvent(_type string, eventInitDict *ConnectionCloseEventInit) (_result *ConnectionCloseEvent) {
	_klass := js.Global().Get("PresentationConnectionCloseEvent")
	var (
		_args [2]interface{}
		_end  int
	)
	_p0 := _type
	_args[0] = _p0
	_end++
	_p1 := eventInitDict.JSValue()
	_args[1] = _p1
	_end++
	_returned := _klass.New(_args[0:_end]...)
	var (
		_converted *ConnectionCloseEvent  
	)
	_converted = ConnectionCloseEventFromJS(_returned)
	_result = _converted
	return
}