$.widget("ui.objects-property",$.ui.SceneResourceProperty,{options:{category:"object",sizeOrScale:"scale"},_createSourceProperty:function(){this._super();var e=this,i=this.$sourceProperty,r=this.randomNumber;i.find("legend").css("padding-left","1em");i.css("padding","10px 0px 0px 0px").append("<label for = 'h-mirror-"+r+"'>"+i18n("h_mirror")+"</label><input type = 'checkbox' id = 'h-mirror-"+r+"' class = 'h-mirror'/><label for = 'v-mirror-"+r+"'>"+i18n("v_mirror")+"</label><input type = 'checkbox' id = 'v-mirror-"+r+"' class = 'v-mirror'/>");i.find(".h-mirror, .v-mirror").customInput().click(function(){e.onchange("mirror",{mirror:e.mirror()})});i.find(".custom-checkbox:first").css("margin","0px 40px 0px 1em");i.append("<div class = 'tab-title ui-layout-north' style = 'padding: 0px;overflow:hidden;'><button class = 'open-extend'>"+i18n("extend")+"</button><button class = 'open-behavior'>"+i18n("behavior")+"</button></div><div class = 'tab-content ui-layout-center' style = 'padding: 0px;'><div class = 'extend'></div><div class = 'behavior'></div></div>");var t=["extend","behavior"];t.forEach(function(e){i.find(".open-"+e).button().css("width","50%").click(function(){i.find(".open-"+t.join(",.open-")).removeClass("selected");$(this).addClass("selected");i.find("."+t.join(",.")).hide();i.find("."+e).show()})});i.find(".extend").variables({addHistory:function(){e.onchange("extend",{extend:e.extend()})}});i.find(".behavior").objectBehaviorPane({addHistory:function(i,r){var t=e.currentInfo.data,n=e.behavior();$.utils.allBehaviors.forEach(function(i){if(JSON.stringify(t[i])!==JSON.stringify(n[i])){var r={};r[i]=n[i];e.onchange(i,r)}})}});i.find(".open-extend").click()},value:function(e){if(e){this._super(e);this.mirror(e.mirror);var i={};$.utils.allBehaviors.forEach(function(r){i[r]=e[r]});this.behavior(i);this.extend(e.extend)}},mirror:function(e){var i=this.element.find(".h-mirror"),r=this.element.find(".v-mirror");if(void 0===e)return{horizontal:i.customInput("checked")?-1:1,vertical:r.customInput("checked")?-1:1};i.customInput("checked",-1===e.horizontal);r.customInput("checked",-1===e.vertical)},behavior:function(e){var i=this.currentInfo&&this.currentInfo.data&&this.currentInfo.data.type;if(!i)return null;var r=this.objectBehavior(i)||{};if(void 0===e){e=this.element.find(".behavior").objectBehaviorPane("behaviors");$.utils.allBehaviors.forEach(function(i){JSON.stringify(e[i])===JSON.stringify(r[i])&&delete e[i]});return e}$.utils.allBehaviors.forEach(function(i){e[i]&&!Object.keys(e[i]).length&&(e[i]=null);var t=void 0!==r[i]?JSON.parse(JSON.stringify(r[i])):void 0;void 0===e[i]&&(e[i]=t)});var t=$.utils.getResourceData("objects",i)||{},n={name:i,parent:t.parent};$.utils.allBehaviors.forEach(function(i){n[i]=e[i]});this.element.find(".behavior").objectBehaviorPane("refresh",n)},extend:function(e){var i=this.element.find(".extend");if(void 0===e)return i.variables("value");i.variables("value",e);return void 0},objectBehavior:function(e){var i=$.utils.getAllJson(),r=i&&i.objects&&i.objects[e];if(r){var t={};$.utils.allBehaviors.forEach(function(e){t[e]=r[e]||void 0});return t}}});