define(["ember","./shape","./style","../fixture-data"],function(a,b,c,d){var e=a.Object.extend(a.Evented,{id:null,title:null,items:null,mode:"preview",sortedItems:function(){return this.get("items").toArray().sort(function(a,b){return a.get("zIndex")-b.get("zIndex")})}.property("items.@each.zIndex"),createShape:function(a,b){var c;if("background"==a&&(c=this.get("items").findBy("type",a)),c)c.setProperties(b);else{var d="";if("topic"==a&&(d=b.properties.get("TopictypeCode")),c=this._buildShape(a,d),"background"==a)c.set("style.zIndex",0);else{var e=this.get("sortedItems").get("lastObject")&&"background"!=this.get("sortedItems").get("lastObject").get("type")?this.get("sortedItems").get("lastObject").get("style.zIndex")+100:1e5;c.set("style.zIndex",e)}c.setProperties(b),this.get("items").addObject(c)}return"edit"==this.get("mode")&&"topic"==c.get("type")&&this._populateFixtureData(c),c.set("page",this),c.set("mode",this.get("mode")),c},deleteShape:function(a){this.get("items").removeObject(a)},layerUp:function(a){var b=this.get("sortedItems"),c=b.get("length"),d=b.indexOf(a);if(0!=c&&d!=c-1){var e=0;e=c-2==d?b.objectAt(d+1).get("style.zIndex")+100:(b.objectAt(d+1).get("style.zIndex")+b.objectAt(d+2).get("style.zIndex"))/2,a.set("style.zIndex",e),0!==e%10&&this._resetZIndex()}}.on("layerUp"),layerDown:function(a){var b=this.get("sortedItems"),c=b.get("length"),d=b.indexOf(a);if(0!=c&&0!=d&&(1!=d||"background"!=b.objectAt(0).get("type"))){var e=0;1==d||2==d&&"background"==b.objectAt(0).get("type")?(e=b.objectAt(d-1).get("style.zIndex")-100,10>=e&&(e=b.objectAt(d-1).get("style.zIndex")-.1)):e=(b.objectAt(d-1).get("style.zIndex")+b.objectAt(d-2).get("style.zIndex"))/2,a.set("style.zIndex",e),0!==e%10&&this._resetZIndex()}}.on("layerDown"),_resetZIndex:function(){this.get("sortedItems").forEach(function(a,b){(0!=b||"background"!=a.get("type"))&&a.set("style.zIndex",1e5+100*b)})},_populateFixtureData:function(a){a.get("properties.TopictypeCode")&&d[a.get("properties.TopictypeCode")]&&a.set("data",d[a.get("properties.TopictypeCode")])},_buildShape:function(d,e){var f=b.create({type:d,style:c.create()});e&&(d+="-"+e);var g=a.$.extend({},this.defaultConfigs[d]);return f.setProperties(g),f.setProperties({style:{fontFamily:"宋体",fontSize:14,fontWeight:"normal",lineHeight:30}}),f},defaultConfigs:{background:{title:"背景图",style:{width:60,height:60}},icon:{title:"图标",style:{width:100.618,height:100.618}},text:{title:"文本框",style:{width:250,height:30,fontFamily:"宋体",fontSize:14,fontWeight:"normal",lineHeight:30}},"topic-Text":{title:"主题",style:{width:400,height:200}},"topic-Image":{title:"主题",style:{width:400,height:300}},"topic-MultImage":{title:"主题",style:{width:400,height:300}},"topic-Aideo":{title:"主题",style:{width:130,height:45}},"topic-Video":{title:"主题",style:{width:400,height:300}},"topic-TableScore":{title:"主题",style:{width:600,height:300}},"topic-TableAssess":{title:"主题",style:{width:600,height:300}},"topic-TableMultiple":{title:"主题",style:{width:600,height:300}}}});return e.reopenClass({create:function(a){return a=a||{},a.items=[],this._super(a)}}),e});