//>>built
define("dojox/calendar/StoreManager","dojo/_base/declare dojo/_base/array dojo/_base/html dojo/_base/lang dojo/dom-class dojo/Stateful dojo/Evented dojo/when".split(" "),function(h,k,p,g,q,l,m,n){return h("dojox.calendar.StoreManager",[l,m],{owner:null,store:null,_ownerItemsProperty:null,_getParentStoreManager:function(){return this.owner&&this.owner.owner?this.owner.owner.get("storeManager"):null},_initItems:function(a){this.set("items",a);return a},_itemsSetter:function(a){this.items=a;this.emit("dataLoaded",
a)},_computeVisibleItems:function(a){var b=a.startTime,c=a.endTime,e=null,f=this.owner[this._ownerItemsProperty];f&&(e=k.filter(f,function(d){return this.owner.isOverlapping(a,d.startTime,d.endTime,b,c)},this));return e},_updateItems:function(a,b,c){var e=!0,f=null,d=this.owner.itemToRenderItem(a,this.store);d._item=a;this.items=this.owner[this._ownerItemsProperty];if(-1!==b)c!==b?(this.items.splice(b,1),this.owner.setItemSelected&&this.owner.isItemSelected(d)&&(this.owner.setItemSelected(d,!1),this.owner.dispatchChange(d,
this.get("selectedItem"),null,null))):(f=this.items[b],c=this.owner.dateModule,e=0!==c.compare(d.startTime,f.startTime)||0!==c.compare(d.endTime,f.endTime),g.mixin(f,d));else if(-1!==c){if(a=a.temporaryId){b=this.items?this.items.length:0;for(--b;0<=b;b--)if(this.items[b].id===a){this.items[b]=d;break}b=this._getItemStoreStateObj({id:a});this._cleanItemStoreState(a);this._setItemStoreState(d,b?b.state:null)}if((a=this._getItemStoreStateObj(d))&&"storing"===a.state){if(this.items&&this.items[c]&&this.items[c].id!==
d.id){b=this.items.length;for(--b;0<=b;b--)if(this.items[b].id===d.id){this.items.splice(b,1);break}this.items.splice(c,0,d)}g.mixin(a.renderItem,d)}else this.items.splice(c,0,d);this.set("items",this.items)}this._setItemStoreState(d,"stored");this.owner._isEditing||(e?this.emit("layoutInvalidated"):this.emit("renderersInvalidated",f))},_storeSetter:function(a){var b=this.owner;this._observeHandler&&(this._observeHandler.remove(),this._observeHandler=null);if(a){var c=a.query(b.query,b.queryOptions);
c.observe&&(this._observeHandler=c.observe(g.hitch(this,this._updateItems),!0));c=c.map(g.hitch(this,function(e){var f=b.itemToRenderItem(e,a);null==f.id&&console.err("The data item "+e.summary+" must have an unique identifier from the store.getIdentity(). The calendar will NOT work properly.");f._item=e;return f}));c=n(c,g.hitch(this,this._initItems))}else c=this._initItems([]);this.store=a;return c},_getItemStoreStateObj:function(a){var b=this._getParentStoreManager();if(b)return b._getItemStoreStateObj(a);
b=this.get("store");return null!=b&&null!=this._itemStoreState?(a=void 0===a.id?b.getIdentity(a):a.id,this._itemStoreState[a]):null},getItemStoreState:function(a){var b=this._getParentStoreManager();if(b)return b.getItemStoreState(a);if(null==this._itemStoreState)return"stored";b=this.get("store");a=void 0===a.id?b.getIdentity(a):a.id;a=this._itemStoreState[a];return null!=b&&void 0!==a?a.state:"stored"},_cleanItemStoreState:function(a){var b=this._getParentStoreManager();if(b)return b._cleanItemStoreState(a);
if(this._itemStoreState)return this._itemStoreState[a]?(delete this._itemStoreState[a],!0):!1},_setItemStoreState:function(a,b){var c=this._getParentStoreManager();if(c)c._setItemStoreState(a,b);else{void 0===this._itemStoreState&&(this._itemStoreState={});c=this.get("store");var e=void 0===a.id?c.getIdentity(a):a.id,f=this._itemStoreState[e];"stored"===b||null==b?void 0!==f&&delete this._itemStoreState[e]:c&&(this._itemStoreState[e]={id:e,item:a,renderItem:this.owner.itemToRenderItem(a,c),state:b})}}})});