/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/angular-ui-calendar@1.0.2/src/calendar.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
angular.module("ui.calendar",[]).constant("uiCalendarConfig",{calendars:{}}).controller("uiCalendarCtrl",["$scope","$locale",function(n,e){var a=n.eventSources,r=n.calendarWatchEvent?n.calendarWatchEvent:angular.noop,t=1;this.eventFingerprint=function(n){n._id||(n._id=t++);var e=r({event:n})||"",a=moment.isMoment(n.start)?n.start.unix():n.start?moment(n.start).unix():"",l=moment.isMoment(n.end)?n.end.unix():n.end?moment(n.end).unix():"";return""+n._id+(n.id||"")+(n.title||"")+(n.url||"")+a+l+(n.allDay||"")+(n.className||"")+e};var l=1,o=1;this.sourceFingerprint=function(n){var e=""+(n.__id||(n.__id=l++)),a=angular.isObject(n)&&n.events;return a&&(e=e+"-"+(a.__id||(a.__id=o++))),e},this.allEvents=function(){for(var n=[],e=0,r=a.length;e<r;e++){var t=a[e];if(angular.isArray(t))n.push(t);else if(angular.isObject(t)&&angular.isArray(t.events)){var l={};for(var o in t)"_id"!==o&&"events"!==o&&(l[o]=t[o]);for(var u=0;u<t.events.length;u++)angular.extend(t.events[u],l);n.push(t.events)}}return Array.prototype.concat.apply([],n)},this.changeWatcher=function(n,e){var a,r=function(){for(var a,r,t=angular.isFunction(n)?n():n,o=[],u=0,i=t.length;u<i;u++)r=t[u],a=e(r),l[a]=r,o.push(a);return o},t=function(n,e){var a,r,t=[],l={};for(a=0,r=e.length;a<r;a++)l[e[a]]=!0;for(a=0,r=n.length;a<r;a++)l[n[a]]||t.push(n[a]);return t},l={};return a={subscribe:function(n,o){n.$watch(r,(function(n,r){!(o&&!1===o(n,r))&&function(n,r){var o,u,i,d,c={},f=t(r,n);for(o=0,u=f.length;o<u;o++){var s=f[o];i=l[s],delete l[s];var v=e(i);v===s?a.onRemoved(i):(c[v]=s,a.onChanged(i))}var g=t(n,r);for(o=0,u=g.length;o<u;o++)d=g[o],i=l[d],c[d]||a.onAdded(i)}(n,r)}),!0)},onAdded:angular.noop,onChanged:angular.noop,onRemoved:angular.noop}},this.getFullCalendarConfig=function(e,a){var r={};return angular.extend(r,a),angular.extend(r,e),angular.forEach(r,(function(e,a){var t;"function"==typeof e&&(r[a]=(t=r[a],function(){if(n.$root.$$phase)return t.apply(this,arguments);var e=arguments,a=this;return n.$root.$apply((function(){return t.apply(a,e)}))}))})),r},this.getLocaleConfig=function(n){if(!n.lang||n.useNgLocale){var a=function(n){var e,a;for(a in e=[],n)e[a]=n[a];return e},r=e.DATETIME_FORMATS;return{monthNames:a(r.MONTH),monthNamesShort:a(r.SHORTMONTH),dayNames:a(r.DAY),dayNamesShort:a(r.SHORTDAY)}}return{}}}]).directive("uiCalendar",["uiCalendarConfig",function(n){return{restrict:"A",scope:{eventSources:"=ngModel",calendarWatchEvent:"&"},controller:"uiCalendarCtrl",link:function(e,a,r,t){var l,o=e.eventSources,u=!1,i=t.changeWatcher(o,t.sourceFingerprint),d=t.changeWatcher(t.allEvents,t.eventFingerprint),c=null;e.destroyCalendar=function(){l&&l.fullCalendar&&l.fullCalendar("destroy"),l=r.calendar?n.calendars[r.calendar]=$(a).html(""):$(a).html("")},e.initCalendar=function(){l||(l=angular.element(a).html("")),l.fullCalendar(c),r.calendar&&(n.calendars[r.calendar]=l)},e.$on("$destroy",(function(){e.destroyCalendar()})),i.onAdded=function(e){l&&l.fullCalendar&&(l.fullCalendar(c),r.calendar&&(n.calendars[r.calendar]=l),l.fullCalendar("addEventSource",e),u=!0)},i.onRemoved=function(n){l&&l.fullCalendar&&(l.fullCalendar("removeEventSource",n),u=!0)},i.onChanged=function(){l&&l.fullCalendar&&(l.fullCalendar("refetchEvents"),u=!0)},d.onAdded=function(n){l&&l.fullCalendar&&l.fullCalendar("renderEvent",n,!!n.stick)},d.onRemoved=function(n){l&&l.fullCalendar&&l.fullCalendar("removeEvents",n._id)},d.onChanged=function(n){if(l&&l.fullCalendar)for(var e=l.fullCalendar("clientEvents",n._id),a=0;a<e.length;a++){var r=e[a];r=angular.extend(r,n),l.fullCalendar("updateEvent",r)}},i.subscribe(e),d.subscribe(e,(function(){if(!0===u)return u=!1,!1})),e.$watch((function(){var a,l=r.uiCalendar?e.$parent.$eval(r.uiCalendar):{};a=t.getFullCalendarConfig(l,n);var u=t.getLocaleConfig(a);angular.extend(u,a),c={eventSources:o},angular.extend(c,u),c.calendars=null;var i={};for(var d in c)"eventSources"!==d&&(i[d]=c[d]);return JSON.stringify(i)}),(function(n,a){n!==a?(e.destroyCalendar(),e.initCalendar()):n&&angular.isUndefined(l)&&e.initCalendar()}))}}}]);
//# sourceMappingURL=/sm/8339ec195e10293cf3052c57e23e8ed27454cf9f312d0fcadebc930197d5cf9e.map