define(['knockout', 'underscore', 'viewmodels/widget'], function (ko, _, WidgetViewModel) {
    /**
    * knockout components namespace used in arches
    * @external "ko.components"
    * @see http://knockoutjs.com/documentation/component-binding.html
    */

    /**
    * registers a switch-widget component for use in forms
    * @function external:"ko.components".switch-widget
    * @param {object} params
    * @param {boolean} params.value - the value being managed
    * @param {object} params.config -
    * @param {string} params.config.label - label to use alongside the select input
    * @param {string} params.config.subtitle - subtitle to use alongside the select input
    * @param {string|true} [params.config.on=true] - the value to use for the "on" state of the switch
    * @param {string|false} [params.config.off=false] - the value to use for the "off" state of the switch
    */
    return ko.components.register('switch-widget', {
        viewModel: function(params) {
            params.configKeys = ['subtitle', 'defaultValue'];
            WidgetViewModel.apply(this, [params]);
            this.on = this.config().on || true;
            this.off = this.config().off || false;
            this.null = this.config().null || null;
            this.setvalue = this.config().setvalue || function(self, evt){
                if (ko.unwrap(self.disabled) === false) {
                    if(self.value() === self.on){
                        self.value(self.null);
                    }else if (self.value() === self.null) {
                        self.value(self.off);
                    }else if (self.value() === self.off) {
                        self.value(self.on);
                    }
                }
            }
            this.getvalue = this.config().getvalue || ko.computed(function(){
                var result = null;
                if (this.value() === this.on) {
                    result = true;
                } else if (this.value() === false) {
                    result = false;
                };
                return result;
            }, this);

            this.setdefault = this.config().setdefault || function(self, evt){
                if(self.defaultValue() === self.on){
                    self.defaultValue(self.null)
                }else if(self.defaultValue() === self.null){
                    self.defaultValue(self.off)
                }else if(self.defaultValue() === self.off){
                    self.defaultValue(self.on)
                }
            }

            this.getdefault = this.config().getdefault || ko.computed(function(){
                var result = null;
                if (this.defaultValue() === this.on) {
                    result = true;
                } else if (this.defaultValue() === false) {
                    result = false;
                };
                return result;
            }, this);

            var defaultValue = ko.unwrap(this.defaultValue)
            if (this.value() === null && this.defaultValue() !== null) {
                this.value(this.defaultValue());
            }
            if (this.tile && this.tile.tileid() == "" && defaultValue != null && defaultValue != "") {
                this.value(defaultValue);
            }

        },
        template: { require: 'text!widget-templates/switch' }
    });
});

@@ -57,17 +57,16 @@
 function
- 
 (ko, _, 
@@ -1735,33 +1735,34 @@
  %7D%0A            %7D
+;
 %0A
-
             this
@@ -2039,33 +2039,32 @@
                %7D
-;
 %0A               
@@ -2282,16 +2282,17 @@
 lf.null)
+;
 %0A       
@@ -2392,16 +2392,17 @@
 elf.off)
+;
 %0A       
@@ -2500,16 +2500,17 @@
 self.on)
+;
 %0A       
@@ -2525,32 +2525,33 @@
  %7D%0A            %7D
+;
 %0A%0A            th
@@ -2848,33 +2848,32 @@
                %7D
-;
 %0A               
@@ -2970,16 +2970,17 @@
 ltValue)
+;
 %0A       
@@ -3100,32 +3100,32 @@
 ;%0A            %7D%0A
+
             if (
@@ -3153,18 +3153,16 @@
 e.tileid
-()
  == %22%22 &

Fix issue where boolean widget was displaying config form when editing a resource instance, re #3816