').appendTo(b),P=C.find(".name"),D=S.find(".name");C.click(m.bind(this,"year")),C.find(".back-button").click(y.bind(this,"year","left",!0)),C.find(".forward-button").click(y.bind(this,"year","right",!0)),S.click(m.bind(this,"month")),S.find(".back-button").click(y.bind(this,"month","left",!0)),S.find(".forward-button").click(y.bind(this,"month","right",!0));var _=t('
').append('
12 3 6 9 ?? ').append('
'),F=_.find(".hourhand"),M=_.find(".minutehand"),q=_.find(".am-pm-text"),k=_.find(".digital-time-display .hour-wrapper"),j=_.find(".digital-time-display .hour");k.click(m.bind(this,"hour")),k.find(".up-button").click(y.bind(this,"hour","up",!0)),k.find(".down-button").click(y.bind(this,"hour","down",!0));var L=_.find(".digital-time-display .minute-wrapper"),N=_.find(".digital-time-display .minute");L.click(m.bind(this,"minute")),L.find(".up-button").click(y.bind(this,"minute","up",!0)),L.find(".down-button").click(y.bind(this,"minute","down",!0)),"date"!=v.mode&&"datetime"!=v.mode||b.appendTo(T),"time"!=v.mode&&"datetime"!==v.mode||_.appendTo(T),E?(a(E),o(E)):(a(moment()),o(moment()));var B=function(){a(E),o(E)};this.$=T,this.setSelectedDate=l,this.getSelectedDate=function(){return E},this.setYear=s,this.setMonth=d,this.setDayOfMonth=c,this.setHour=p,this.setMinute=h,this.setKeyboardNavigationState=m,this.navigate=function(e){y(x,e)}}return e.registerJqueryPlugin(r,"TrivialCalendarBox","tr-calendarbox"),t.fn.TrivialCalendarBox}),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-calendarcombobox",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.trivialcalendarcombobox&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(n,r){function a(t,n){var r=D.get().indexOf(document.activeElement),i=r+t;if(i>=0&&i
').insertAfter(v);if(h.showTrigger){var w=t('
').appendTo(x);w.mousedown(function(){return f?c():(D.get().indexOf(document.activeElement)==-1&&D.first().focus(),d()),!1})}var E=t('
').appendTo("body"),T=t('
'),b=t('
').appendTo(T);T.append('
. ');var C=t('
').appendTo(T);T.append('
. ');var S=t('
').appendTo(T);T.append('
');var O=t('
').appendTo(T);T.append('
: ');var P=t('
').appendTo(T),D=T.find("[contenteditable='true']");v.addClass("tr-original-input"),D.focus(function(e){e.target==S[0]?u.setKeyboardNavigationState("year"):e.target==C[0]?u.setKeyboardNavigationState("month"):e.target==b[0]?u.setKeyboardNavigationState("day"):e.target==O[0]?u.setKeyboardNavigationState("hour"):e.target==P[0]?u.setKeyboardNavigationState("minute"):e.target==$timeZoneInput[0]&&u.setKeyboardNavigationState("timeZone"),x.addClass("focus")}).blur(function(e){g||(y?t(e.target).focus():(x.removeClass("focus"),c()))}).keydown(function(n){if(p=t(this).text(),!(e.isModifierKey(n)||n.altKey|n.ctrlKey|n.metaKey)){if(n.which==i.tab)return!a(n.shiftKey?-1:1,!0);if(!i.isSpecialKey(n.which)&&!i.isDigitKey(n.which))return a(1,!0),!1;if(n.which==i.up_arrow)return d(),n.target==b[0]?u.navigate("right"):u.navigate("up"),e.selectElementContents(n.target,0,t(n.target).text().length),!1;if(n.which==i.down_arrow)return d(),n.target==b[0]?u.navigate("left"):u.navigate("down"),e.selectElementContents(n.target,0,t(n.target).text().length),!1;if(n.which==i.left_arrow){if(0==window.getSelection().anchorOffset&&0==window.getSelection().focusOffset)return!a(-1)}else if(n.which==i.right_arrow){if(window.getSelection().anchorOffset==t(n.target).text().length&&window.getSelection().focusOffset==t(n.target).text().length)return!a(1)}else if(f&&n.which==i.enter)c(),T.select();else if(n.which==i.escape)c(),clearEditorIfNotContainsFreeText();else{var r=t(this),o=i.isSpecialKey(n.which),l=r.text().length>=parseInt(r.attr("data-maxlength")),s=window.getSelection().anchorOffset===window.getSelection().focusOffset;!o&&l&&s?n.preventDefault():d()}}}).keyup(function(e){e.keyCode!==i.up_arrow&&e.keyCodes!==i.down_arrow&&e.keyCode!==i.left_arrow&&e.keyCodes!==i.right_arrow&&o()}),T.prependTo(x).mousedown(function(e){if(d(),D.get().indexOf(e.target)==-1)return D.get().indexOf(document.activeElement)==-1&&(D.first().focus(),!1)}),v.attr("placeholder")&&T.attr("placeholder",v.attr("placeholder")),v.attr("tabindex")&&D.first().attr("tabindex",v.attr("tabindex")),v.attr("autofocus")&&D.first().focus(),x.add(E).add(w).mousedown(function(e){x.is(".focus")&&(D.get().indexOf(document.activeElement)!=-1?g=!0:y=!0)}).on("mouseout mouseup",function(){(y||g)&&(y=!1,g=!1)}),u=E.TrivialCalendarBox(h),u.$.change(function(){var e=u.getSelectedDate();e&&(m=e,l())}),m=h.selectedDate,u.setSelectedDate(h.selectedDate||null),l(),this.$=x,x[0].trivialCalendarComboBox=this,this.destroy=function(){v.removeClass("tr-original-input").insertBefore(x),x.remove(),E.remove()}}var i=e.keyCodes;return e.registerJqueryPlugin(r,"TrivialCalendarComboBox","tr-calendarcombobox"),t.fn.TrivialCalendarComboBox}),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-combobox",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.trivialcombobox&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(r,a){function o(e){setTimeout(function(){var n=f(),r=R.val();if(C!==n||S!==r){if(0===k.length){var i=t(w.spinnerTemplate).appendTo(I);k=k.add(i)}w.queryFunction(n,{completeInputString:r,currentlySelectedEntry:P},function(t){g(t,e),w.showDropDownOnResultsOnly&&t&&t.length>0&&R.is(":focus")&&p()}),C=n,S=r}},0)}function l(e){j.trigger("change"),v.onSelectedEntryChanged.fire(e)}function s(e,r,i){if(null==e){w.valueProperty&&j.val(""),P=null;var a=t(n.render(w.emptyEntry[w.selectedEntryTemplateProperty]||w.emptyEntryTemplate,w.emptyEntry)).addClass("tr-combobox-entry").addClass("empty");N.empty().append(a)}else{w.valueProperty&&j.val(e[w.valueProperty]),P=e;var a=t(n.render(P[w.selectedEntryTemplateProperty]||w.selectedEntryTemplate,e)).addClass("tr-combobox-entry");N.empty().append(a),R.val(w.entryToEditorTextFunction(e))}r&&(D=e,i||l(e)),B&&B.toggle(null!=e),b&&c(),T&&$()}function d(){return null!=P&&P!==w.emptyEntry}function c(){var e=N.find(".tr-editor-area");0===e.length&&(e=N),R.css({width:Math.min(e[0].offsetWidth,Q?Q[0].offsetLeft-e[0].offsetLeft:99999999)+"px",height:e[0].offsetHeight+"px"}).position({my:"left top",at:"left top",of:e}),b=!0}function u(){R.width(0).height(0),b=!1}function p(){H&&(q&&y(),L.addClass("open"),$(),T=!0)}function h(){L.removeClass("open"),I.hide(),T=!1}function f(){return R.val().substring(0,R[0].selectionStart)}function m(e){if(w.autoComplete){clearTimeout(F);var t=E.getHighlightedEntry();t&&!M&&(F=setTimeout(function(){var e=f(),n=w.autoCompleteFunction(e,t)||e;R.val(e+n.substr(e.length)),R.is(":focus")&&R[0].setSelectionRange(e.length,n.length)},e||0)),M=!1}}function y(){E.updateEntries(O),q=!1}function g(e,n){O=e,k.remove(),k=t(),T?y():q=!0;var r=f();E.highlightTextMatches(e.length<=w.textHighlightingEntryLimit?r:null),n?E.highlightNextEntry(n):E.setHighlightedEntry(null),m(w.autoCompleteDelay),T&&p()}var v=this;a=a||{};var x=a.selectedEntryTemplate||a.template||e.image2LinesTemplate,w=t.extend({valueProperty:null,template:e.image2LinesTemplate,selectedEntryTemplate:x,templateProperty:"template",selectedEntryTemplateProperty:"selectedEntryTemplate",selectedEntry:void 0,spinnerTemplate:e.defaultSpinnerTemplate,noEntriesTemplate:e.defaultNoEntriesTemplate,textHighlightingEntryLimit:100,entries:null,emptyEntryTemplate:a.emptyEntryTemplate||x,emptyEntry:{},queryFunction:null,autoComplete:!0,autoCompleteDelay:0,entryToEditorTextFunction:function(e){return e.displayValue},autoCompleteFunction:function(e,t){if(e){for(propertyName in t){var n=t[propertyName];if(n&&0===n.toString().toLowerCase().indexOf(e.toLowerCase()))return n.toString()}return null}return w.entryToEditorTextFunction(t)},allowFreeText:!1,freeTextEntryFactory:function(e){return{displayValue:e,_isFreeTextEntry:!0}},showClearButton:!1,showTrigger:!0,matchingOptions:{matchingMode:"contains",ignoreCase:!0,maxLevenshteinDistance:2},editingMode:"editable",showDropDownOnResultsOnly:!1},a);w.queryFunction=w.queryFunction||e.defaultListQueryFunctionFactory(w.entries||[],w.matchingOptions),this.onSelectedEntryChanged=new e.Event;var E,T=!1,b=!1,C=null,S=null,O=w.entries,P=null,D=null,_=!1,F=-1,M=!1,q=!0,k=t(),j=t(r),L=t('
').addClass(w.editingMode).insertAfter(j),N=t('
').appendTo(L);if(w.showClearButton){var B=t('
').appendTo(L);B.mousedown(function(){s(null)})}if(w.showTrigger){var Q=t('
').appendTo(L);Q.mousedown(function(){T?(c(),h()):setTimeout(function(){c(),R.select(),p(),o()})})}var I=t('
').scroll(function(e){return!1}),H="editable"==w.editingMode&&(w.entries&&w.entries.length>0||a.queryFunction||w.showTrigger);H&&I.appendTo("body");var R;j.addClass("tr-original-input"),R=t('
'),R.prependTo(L).addClass("tr-combobox-editor tr-editor").focus(function(){_||(L.addClass("focus"),c())}).blur(function(){_?R.focus():(L.removeClass("focus"),K()?e.objectEquals(v.getSelectedEntry(),D)||s(v.getSelectedEntry(),!0):(R.val(""),s(D)),u(),h())}).keydown(function(t){if(!e.isModifierKey(t)){if(t.which==i.tab){var n=E.getHighlightedEntry();return void(T&&n?s(n,!0):R.val()?w.allowFreeText&&s(v.getSelectedEntry(),!0):s(null,!0))}if(t.which==i.left_arrow||t.which==i.right_arrow)return void c();if(t.which!=i.backspace&&t.which!=i["delete"]||(M=!0),t.which==i.up_arrow||t.which==i.down_arrow){b||(R.select(),c());var r=t.which==i.up_arrow?-1:1;return T?(E.highlightNextEntry(r),m(w.autoCompleteDelay)):(o(r),w.showDropDownOnResultsOnly||p()),!1}if(t.which==i.enter){if(b||K()){t.preventDefault();var n=E.getHighlightedEntry();T&&n?s(n,!0):R.val()?w.allowFreeText&&s(v.getSelectedEntry(),!0):s(null,!0),h(),u()}}else t.which==i.escape?(t.preventDefault(),K()&&T||(u(),R.val(""),O=null,s(D,!1)),h()):(b||(c(),R.select()),w.showDropDownOnResultsOnly||p(),setTimeout(function(){R.val()?o(1):(o(0),E.setHighlightedEntry(null))}))}}).keyup(function(t){!e.isModifierKey(t)&&[i.enter,i.escape,i.tab].indexOf(t.which)===-1&&d()&&R.val()!==w.entryToEditorTextFunction(P)&&s(null,!1)}).mousedown(function(){w.showDropDownOnResultsOnly||p(),o()}),j.attr("tabindex")&&R.attr("tabindex",j.attr("tabindex")),j.attr("autofocus")&&R.focus(),L.add(I).mousedown(function(){R.is(":focus")&&(_=!0)}).mouseup(function(){_&&(R.focus(),_=!1)}).mouseout(function(){_&&(R.focus(),_=!1)});var V=t.extend({},w);V.entries=[],E=I.TrivialListBox(V),E.onSelectedEntryChanged.addListener(function(t){t&&(s(t,!0,e.objectEquals(t,D)),E.selectEntry(null),h()),u()}),s(w.selectedEntry,!0,!0),N.click(function(){c(),R.select(),w.showDropDownOnResultsOnly||p(),o()});var K=function(){return w.allowFreeText&&R.val().length>0&&!d()},$=function(){I.show().position({my:"left top",at:"left bottom",of:L,collision:"flip",using:function(e,n){"top"===n.vertical?(L.removeClass("dropdown-flipped"),t(this).removeClass("flipped")):(L.addClass("dropdown-flipped"),t(this).addClass("flipped")),t(this).css({left:e.left+"px",top:e.top+"px"})}}).width(L.width())};this.$=L,L[0].trivialComboBox=this,this.updateEntries=g,this.getSelectedEntry=function(){if(null!=P||w.allowFreeText&&R.val()){if(null==P&&w.allowFreeText)return w.freeTextEntryFactory(R.val());var e=jQuery.extend({},P);return e._trEntryElement=void 0,e}return null},this.selectEntry=function(e,t){s(e,!0,t)},this.focus=function(){c(),R.select()},this.getDropDown=function(){return I},this.destroy=function(){j.removeClass("tr-original-input").insertBefore(L),L.remove(),I.remove()}}var i=e.keyCodes;return e.registerJqueryPlugin(r,"TrivialComboBox","tr-combobox"),t.fn.TrivialComboBox}),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-dateTimeField",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.trivialdatetimefield&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(r,d){function c(t){ee=t,U||t!==X||(V=pe.TrivialCalendarBox({firstDayOfWeek:1,mode:"date"}),V.setKeyboardNavigationState("month"),V.onChange.addListener(function(t,n){y(O(n,I.dateFormat)),"day"===t&&(E(),ue=le,e.selectElementContents(le[0],0,le.text().length),m())}),U=!0),U&&V.$.toggle(t===X),H.$.toggle(t===Z),R.$.toggle(t===G)}function u(){return ee===X?V:ee===Z?H:R}function p(){return ue}function h(){if(ee===Z||ee===G){var e=u().getHighlightedEntry();K&&e&&(p()===ae?y(e,!0):g(e,!0))}}function f(e){setTimeout(function(){var t=T();p()===ae?S(t,{completeInputString:ae.text()},function(t){C(t,e)}):M(t,{completeInputString:le.text()},function(t){C(t,e)})},0)}function m(){te.trigger("change"),Q.onChange.fire(he())}function y(e,t){$=e,v(),t&&m()}function g(e,t){A=e,v(),t&&m()}function v(){$?(ae.text(moment([$.year,$.month-1,$.day]).format(I.dateFormat)),ie.empty().append(n.render(i,$))):(ae.text(""),ie.empty().append(n.render(i,{}))),A?(le.text(moment([1970,0,1,A.hour,A.minute]).format(I.timeFormat)),oe.empty().append(n.render(o,A))):(le.text(""),oe.empty().append(n.render(o,{})))}function x(e){y(e&&O(e,I.dateFormat)),g(e&&j(e.hour(),e.minute(),I.timeFormat))}function w(){ce&&(ne.addClass("open"),fe(),K=!0)}function E(){ne.removeClass("open"),de.hide(),K=!1}function T(){var e=p().text().replace(String.fromCharCode(160)," "),t=window.getSelection();return t.anchorOffset!=t.focusOffset?e.substring(0,Math.min(t.anchorOffset,t.focusOffset)):e}function b(t){if(I.autoComplete&&(ee===Z||ee===G)){clearTimeout(W);var n=u(),r=n.getHighlightedEntry();if(r&&!J){var i=r.displayString;i&&(W=setTimeout(function(){var t,n=T();t=0===i.toLowerCase().indexOf(n.toLowerCase())?n+i.substr(n.length):T(),p().text(t),p().is(":focus")&&e.selectElementContents(p()[0],n.length,t.length)},t||0))}J=!1}}function C(e,t){var n=u();t=void 0===t?1:t,n.updateEntries(e);var r=T();n.highlightTextMatches(e.length<=I.textHighlightingEntryLimit?r:null),n.highlightNextEntry(t),b(I.autoCompleteDelay),K&&w()}function S(e,t,n){""===e&&t.completeInputString.length>0&&(e=t.completeInputString);var r;if(e.match(/[^\d]/)){var i=e.split(/[^\d]/).filter(function(e){return!!e});r=F(i,moment())}else r=_(e,moment());var a=[];r=r.filter(function(e){return!(a.filter(function(t){return e.moment.isSame(t,"day")}).length>0)&&(a.push(e.moment),!0)});var o=P(I.dateFormat);r.sort(function(e,t){if(o.indexOf(e.ymdOrder)===-1&&o.indexOf(t.ymdOrder)!==-1)return 1;if(o.indexOf(e.ymdOrder)!==-1&&o.indexOf(t.ymdOrder)===-1)return-1;if(e.ymdOrder.length!=t.ymdOrder.length)return e.ymdOrder.length-t.ymdOrder.length;if(e.ymdOrder!==t.ymdOrder)return new Levenshtein(e.ymdOrder,o).distance-new Levenshtein(t.ymdOrder,o).distance;var n=moment();return e.moment.diff(n,"days")-t.moment.diff(n,"days")}),n(r.map(function(e){return O(e.moment,I.dateFormat)}))}function O(e,t){return{moment:e,day:e.date(),weekDay:e.format("dd"),month:e.month()+1,year:e.year(),displayString:e.format(t)}}function P(e){var t={D:e.indexOf("D"),M:e.indexOf("M"),Y:e.indexOf("Y")};return["D","M","Y"].sort(function(e,n){return t[e]-t[n]}).join("")}function D(e,t){return{moment:e,ymdOrder:t}}function _(e,t){if(!e){for(var n=[],r=0;r<7;r++)n.push(D(moment(t).add(r,"day"),""));return n}if(e.length>8)return[];for(var i=[],r=1;r<=e.length;r++)for(var a=Math.min(e.length,r+1);a<=e.length;a-r===2?a+=2:a++)i=i.concat(F([e.substring(0,r),e.substring(r,a),e.substring(a,e.length)],t));return i}function F(e,t){function n(e){return t.isBefore(e,"day")||t.isSame(e,"day")}function r(e){var n=t.year()%100,r=(n+20)%100,i=100*Math.floor(t.year()/100);return e
t.year()-100&&e0&&(e=t.completeInputString);var r=[],i=e.match(/[^\d]/),a=null!=i?i.index:null;if(null!==a){var o=e.substring(0,a),l=e.substring(a+1);r=r.concat(L(B(o),N(l),I.timeFormat))}else if(e.length>0){if(e.length>=2){var o=e.substr(0,2),l=e.substring(2,e.length);r=r.concat(L(B(o),N(l),I.timeFormat))}var o=e.substr(0,1),l=e.substring(1,e.length);l.length<=2&&(r=r.concat(L(B(o),N(l),I.timeFormat)))}else r=r.concat(L(q(6,24).concat(q(1,5)),[0],I.timeFormat));n(r)}function q(e,t){for(var n=[],r=e;r<=t;r++)n.push(r);return n}function k(e,t){for(var n=e+"";n.length=20}}function L(e,t,n){for(var r=[],i=0;i1?[t%60]:t<6?[10*t]:[t%60];
}function B(e){var t=parseInt(e);return isNaN(t)?q(1,24):t<12?[t,(t+12)%24]:t<=24?[t%24]:[]}var Q=this;d=d||{};var I=t.extend({dateFormat:"MM/DD/YYYY",timeFormat:"HH:mm",autoComplete:!0,autoCompleteDelay:0,showTrigger:!0,editingMode:"editable"},d);this.onChange=new e.Event;var H,R,V,K=!1,$=null,A=null,Y=!1,z=!1,W=-1,J=!1,U=!1,X="calendar",Z="dateList",G="timeList",ee=X,te=t(r).addClass("tr-original-input"),ne=t('
').addClass(I.editingMode).insertAfter(te),re=t('').appendTo(ne),ie=t('
').appendTo(re),ae=t('
').appendTo(re),oe=t('
').appendTo(re),le=t('
').appendTo(re);if(ie.click(function(){ue=ae,c(X),w(),e.selectElementContents(ae[0],0,ae.text().length)}),oe.click(function(){ue=le,c(X),e.selectElementContents(le[0],0,le.text().length)}),ae.focus(function(){ue=ae,Y&&!z||e.selectElementContents(ae[0],0,ae.text().length)}),le.focus(function(){ue=le,Y&&!z||e.selectElementContents(le[0],0,le.text().length)}),I.showTrigger){var se=t('
').appendTo(ne);se.mousedown(function(){K?E():setTimeout(function(){c(X),V.setSelectedDate($?$.moment:moment()),ue=ae,e.selectElementContents(ae[0],0,ae.text().length),w()})})}var de=t('
').scroll(function(e){return!1}),ce="editable"==I.editingMode;ce&&de.appendTo("body"),H=t('
').appendTo(de).TrivialListBox({template:a}),H.onSelectedEntryChanged.addListener(function(e){e&&(y(e,e.displayString!=($&&$.displayString)),H.selectEntry(null),E())}),R=t('
').appendTo(de).TrivialListBox({template:l}),R.onSelectedEntryChanged.addListener(function(e){e&&(g(e,e.displayString!=(A&&A.displayString)),H.selectEntry(null),E())});var ue,pe=t('
').appendTo(de);ue=ae,ae.add(le).focus(function(){ne.addClass("focus")}).blur(function(){Y||(ne.removeClass("focus"),v(),E())}).keydown(function(t){if(!e.isModifierKey(t)){if(t.which==s.tab)return void h();if(t.which==s.left_arrow||t.which==s.right_arrow)return void(p()===le&&t.which==s.left_arrow&&0===window.getSelection().focusOffset?(t.preventDefault(),e.selectElementContents(ae[0],0,ae.text().length)):p()===ae&&t.which==s.right_arrow&&window.getSelection().focusOffset===ae.text().length&&(t.preventDefault(),e.selectElementContents(le[0],0,le.text().length)));if(t.which!=s.backspace&&t.which!=s["delete"]||(J=!0),t.which==s.up_arrow||t.which==s.down_arrow){p().select();var n=t.which==s.up_arrow?-1:1;return K?ee!==X&&(u().navigate(1===n?"down":"up"),b(I.autoCompleteDelay)):(c(this===ae[0]?Z:G),f(n),w()),!1}t.which==s.enter?K&&(t.preventDefault(),h(),e.selectElementContents(p()[0],0,p().text().length),E()):t.which==s.escape?(t.preventDefault(),K||(v(),e.selectElementContents(p()[0],0,p().text().length)),E()):(c(this===ae[0]?Z:G),f(1),w())}}),x(te.val()?moment(te.val()):null),te.attr("tabindex")&&ae.add(le).attr("tabindex",te.attr("tabindex")),te.attr("autofocus")&&ae.focus(),ne.add(de).mousedown(function(e){(ae.is(":focus")||le.is(":focus"))&&(Y=!0),e.target!==ae[0]&&e.target!==le[0]&&e.target!==ie[0]&&e.target!==oe[0]||(z=!0)}).on("mouseup mouseout",function(){Y&&!z&&p().focus(),Y=!1,z=!1});var he=function(){return null==$&&null==A?null:null==$?null:null==A?moment([$.year,$.month-1,$.day]).startOf("day"):moment([$.year,$.month-1,$.day,A.hour,A.minute])},fe=function(){de.show().position({my:"left top",at:"left bottom",of:ne,collision:"flip",using:function(e,n){"top"===n.vertical?(ne.removeClass("dropdown-flipped"),t(this).removeClass("flipped")):(ne.addClass("dropdown-flipped"),t(this).addClass("flipped")),t(this).css({left:e.left+"px",top:e.top+"px"})}}).width(ne.width())};this.$=ne,ne[0].trivialDateTimeField=this,this.setValue=x,this.getValue=he,this.focus=function(){e.selectElementContents(p()[0],0,p().text().length)},this.destroy=function(){te.removeClass("tr-original-input").insertBefore(ne),ne.remove(),de.remove()}}var i='
{{weekDay}} ',a='
',o='
',l='
',s=e.keyCodes;return e.registerJqueryPlugin(r,"TrivialDateTimeField","tr-datetimefield"),t.fn.TrivialDateTimeField}),function(e){e.expr[":"].containsIgnoreCase=e.expr.createPseudo(function(t){return function(n){return e(n).text().toUpperCase().indexOf(t.toUpperCase())>=0}})}(jQuery),function(e){e.trivialMatch=function(t,n,r){function i(e){for(var n,r=[];n=e.exec(t);)r.push({start:n.index,length:n[0].length});return r}function a(e,t){var n=new Levenshtein(e,t);return n.distance<=r.maxLevenshteinDistance?[{start:0,length:t.length,distance:n.distance}]:[]}if(!n)throw"searchString may not be empty!";var r=e.extend({matchingMode:"contains",ignoreCase:!0,maxLevenshteinDistance:3},r||null);if(r.ignoreCase&&(t=t.toLowerCase(),n=n.toLowerCase()),"contains"==r.matchingMode)return n=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i(new RegExp(n,"g"));if("prefix"==r.matchingMode)return n=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i(new RegExp("^"+n,"g"));if("prefix-word"==r.matchingMode)return n=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i(n.charAt(0).match(/^\w/)?new RegExp("\\b"+n,"g"):new RegExp(n,"g"));if("prefix-levenshtein"==r.matchingMode)return a(t.substr(0,Math.min(n.length,t.length)),n);if("levenshtein"==r.matchingMode)return a(t,n);throw"unknown matchingMode: "+r.matchingMode}}(jQuery),function(e){function t(e){if(e){if(3==e.nodeType)for(;e.nextSibling&&3==e.nextSibling.nodeType;)e.nodeValue+=e.nextSibling.nodeValue,e.parentNode.removeChild(e.nextSibling);else t(e.firstChild);t(e.nextSibling)}}var n=!window.ActiveXObject&&"ActiveXObject"in window;e.fn.trivialHighlight=function(r,i){return i=e.extend({highlightClassName:"tr-highlighted-text",matchingMode:"contains",ignoreCase:!0,maxLevenshteinDistance:3},i),this.find("*").each(function(){var a=e(this);a.find("."+i.highlightClassName).contents().unwrap(),n?t(this):this.normalize(),r&&""!==r&&a.contents().filter(function(){return 3==this.nodeType&&e.trivialMatch(this.nodeValue,r,i).length>0}).replaceWith(function(){for(var t=this.nodeValue||"",n="",a=e.trivialMatch(this.nodeValue,r,i),o=0,l=0;l
'+t.substr(s.start,s.length)+"",o=s.start+s.length}return n+=t.substring(o,t.length)})})}}(jQuery),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-list",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.triviallist&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(r,a){function o(e){var t=g.filter(function(t){return t[m.valueProperty]==e});return t&&t.length>0?t[0]:null}function l(e){if(T.empty(),e.length>0)for(var r=0;r0?(f(),"undefined"!=typeof t&&p(t)):c(null)}function d(e){T.append(m.spinnerTemplate),setTimeout(function(){m.queryFunction(b.val(),{completeInputString:b.val(),currentlySelectedEntry:y},function(t){s(t,e)})})}function c(e){v=e,T.find(".tr-list-entry").removeClass("tr-highlighted-entry"),null!=e&&(e._trEntryElement.addClass("tr-highlighted-entry"),T.minimallyScrollTo(e._trEntryElement))}function u(e){T.find(".tr-selected-entry").removeClass("tr-selected-entry"),null==e?w.val(""):(w.val(e[m.valueProperty]),y=e,y._trEntryElement.addClass("tr-selected-entry"))}function p(e){var t=h(e);null!=t&&c(t)}function h(e){var t;if(null==g||0==g.length)return null;if(null==v&&e>0)t=-1+e;else if(null==v&&e<0)t=g.length+e;else{var n=g.indexOf(v);t=(n+g.length+e)%g.length}return g[t]}function f(){for(var e=0;e ').insertAfter(w),T=t('
').appendTo(E),b=t(' ').prependTo(E).focus(function(){E.addClass("focus")}).blur(function(){x?b.focus():(E.removeClass("focus"),c(null))}).keydown(function(t){if(t.which!=i.tab&&!e.isModifierKey(t)&&t.which!=i.left_arrow&&t.which!=i.right_arrow)if(t.which==i.up_arrow||t.which==i.down_arrow){var n=t.which==i.up_arrow?-1:1;if(null!=g)return p(n),!1;d(n)}else t.which==i.enter?(u(v),b.select()):t.which==i.escape?c(null):d(1)}).keyup(function(e){}).mousedown(function(){null==g&&d()});E.add(T).mousedown(function(){b.is(":focus")&&(x=!0)}).mouseup(function(){x&&(b.focus(),x=!1)}).mouseout(function(){x&&(b.focus(),x=!1)}),T.mouseout(function(){c(null)}),g&&l(g),u(m.selectedEntryId?o(m.selectedEntryId):null),this.$=E,E[0].trivialList=this,this.updateEntries=s,this.getSelectedEntry=function(){return y},this.destroy=function(){w.removeClass("tr-original-input").insertBefore(E),E.remove()}}var i=e.keyCodes;return e.registerJqueryPlugin(r,"TrivialList","tr-list"),t.fn.TrivialList}),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-listbox",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.triviallistbox&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(r,i){function a(e){if(w.detach(),w.empty(),e.length>0)for(var r=0;r0)t=-1+e;else if(null==v&&e<0)t=g.length+e;else{var n=g.indexOf(v);t=(n+g.length+e)%g.length}return g[t]}function h(e){for(var t=0;t ').appendTo(r);x.on("mousedown",".tr-listbox-entry",function(e){c(t(this).data("entry"),e)}).on("mouseup",".tr-listbox-entry",function(e){x.trigger("mouseup",e)}).on("mouseenter",".tr-listbox-entry",function(e){s(t(this).data("entry"))}).on("mouseleave",".tr-listbox-entry",function(e){t(e.toElement).is(".tr-listbox-entry")||s(null)});var w=t('
').appendTo(x);g&&a(g),this.$=x,x[0].trivialListBox=this,this.updateEntries=o,this.getSelectedEntry=function(){if(y){var e=jQuery.extend({},y);return e._trEntryElement=void 0,e}return null},this.selectEntry=function(e,t){c(e,t,!0)},this.setHighlightedEntry=s,this.highlightNextEntry=u,this.highlightNextMatchingEntry=u,this.getHighlightedEntry=function(){return v},this.highlightTextMatches=h,this.navigate=function(e){"up"===e?u(-1):"down"===e&&u(1)}}return e.registerJqueryPlugin(r,"TrivialListBox","tr-listbox"),t.fn.TrivialListBox}),$.fn.minimallyScrollTo=function(e){return this.each(function(){var t=$(this),n=t.scrollTop(),r=n+t.innerHeight(),i=$(e).offset().top-$(this).offset().top+t.scrollTop(),a=i+e.height();ir&&t.scrollTop(Math.min(i,a-t.innerHeight()));var o=t.scrollLeft(),l=o+t.innerWidth(),s=$(e).offset().left-$(this).offset().left+t.scrollLeft(),d=s+e.width();sl&&t.scrollLeft(Math.min(s,d-t.innerWidth()))})},function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-tagbox",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.trivialtagbox&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(r,a){function o(){w.updateEntries(C),_=!1}function l(e,n){C=e,F.remove(),F=t(),E?o():_=!0;var r=y();w.highlightTextMatches(e.length<=x.textHighlightingEntryLimit?r:null),n?w.highlightNextEntry(n):w.setHighlightedEntry(null),g(x.autoCompleteDelay),E&&f()}function s(e){var t=S.indexOf(e);t>-1&&S.splice(t,1),e._trEntryElement.remove(),M.val(u()),c(v.getSelectedEntries())}function d(e){setTimeout(function(){var n=y(),r=B.text().replace(String.fromCharCode(160)," ");if(T!==n||b!==r){if(0===F.length){var i=t(x.spinnerTemplate).appendTo(L);F=F.add(i)}x.queryFunction(n,{},function(t){l(t,e),x.showDropDownOnResultsOnly&&t&&t.length>0&&B.is(":focus")&&f()}),T=n,b=r}},0)}function c(e){M.trigger("change"),v.onSelectedEntryChanged.fire(e)}function u(){return S.map(function(e){return e[x.valueProperty]}).join(x.valueSeparator)}function p(e,r){if(null!=e&&!(x.maxSelectedEntries&&S.length>=x.maxSelectedEntries||x.distinct&&S.map(function(e){return e[x.valueProperty]}).indexOf(e[x.valueProperty])!=-1)){var i=t.extend({},e);S.splice(B.index(),0,i),M.val(u());var a=t(n.render(i[x.selectedEntryTemplateProperty]||x.selectedEntryTemplate,i)),o=t('
');o.append(a).insertBefore(B),i._trEntryElement=o,"editable"==x.editingMode&&a.find(".tr-remove-button").click(function(e){return s(i),!1}),B.text(""),r||c(v.getSelectedEntries())}}function h(){L.position({my:"left top",at:"left bottom",of:q,collision:"flip",using:function(e,n){"top"===n.vertical?(q.removeClass("dropdown-flipped"),t(this).removeClass("flipped")):(q.addClass("dropdown-flipped"),t(this).addClass("flipped")),t(this).css({left:e.left+"px",top:e.top+"px"})}}).width(q.width())}function f(){N&&(_&&o(),q.addClass("open"),L.show(),h(),E=!0),null==H&&(H=setInterval(h,1e3))}function m(){q.removeClass("open"),L.hide(),E=!1,null!=H&&clearInterval(H)}function y(){var e=B.text().replace(String.fromCharCode(160)," "),t=window.getSelection();return t.anchorOffset!=t.focusOffset?e.substring(0,Math.min(window.getSelection().baseOffset,window.getSelection().focusOffset)):e}function g(t){if(x.autoComplete){clearTimeout(P);var n=w.getHighlightedEntry();n&&!D&&(P=setTimeout(function(){var t=y(),r=x.autoCompleteFunction(t,n)||t;B.text(t+r.replace(" ",String.fromCharCode(160)).substr(t.length)),h(),B.is(":focus")&&e.selectElementContents(B[0],t.length,r.length)},t||0)),D=!1}}var v=this;a=a||{};var x=t.extend({valueProperty:"displayValue",valueSeparator:",",template:e.image2LinesTemplate,selectedEntryTemplate:a.template?e.wrapEntryTemplateWithDefaultTagWrapperTemplate(a.template):e.wrapEntryTemplateWithDefaultTagWrapperTemplate(e.image2LinesTemplate),spinnerTemplate:e.defaultSpinnerTemplate,noEntriesTemplate:e.defaultNoEntriesTemplate,textHighlightingEntryLimit:100,templateProperty:"template",selectedEntryTemplateProperty:"selectedEntryTemplate",finalEntryProperty:"finalEntry",entries:null,selectedEntries:[],maxSelectedEntries:null,queryFunction:null,autoComplete:!0,autoCompleteDelay:0,autoCompleteFunction:function(e,t){if(e){for(propertyName in t){var n=t[propertyName];if(n&&0===n.toString().toLowerCase().indexOf(e.toLowerCase()))return n.toString()}return null}return null},allowFreeText:!1,freeTextSeparators:[",",";"],freeTextEntryFactory:function(e){return{displayValue:e,_isFreeTextEntry:!0}},showTrigger:!0,distinct:!0,matchingOptions:{matchingMode:"contains",ignoreCase:!0,maxLevenshteinDistance:2},editingMode:"editable",showDropDownOnResultsOnly:!1},a);x.queryFunction=x.queryFunction||e.defaultListQueryFunctionFactory(x.entries||[],x.matchingOptions),this.onSelectedEntryChanged=new e.Event;var w,E=!1,T=null,b=null,C=x.entries,S=[],O=!1,P=-1,D=!1,_=!0,F=t(),M=t(r).addClass("tr-original-input"),q=t('
').addClass(x.editingMode).insertAfter(M);M.appendTo(q);var k=t('
').appendTo(q);if(x.showTrigger){var j=t('
').appendTo(q);j.mousedown(function(){B.focus(),E?m():setTimeout(function(){B.select(),f(),d()})})}var L=t('
').scroll(function(e){return!1}),N="editable"==x.editingMode&&(x.entries&&x.entries.length>0||a.queryFunction||x.showTrigger);N&&L.appendTo("body");var B=t(' ');B.appendTo(k).addClass("tr-tagbox-editor tr-editor").focus(function(){O||q.addClass("focus"),setTimeout(function(){k.minimallyScrollTo(B)})}).blur(function(){O?B.focus():(q.removeClass("focus"),C=null,m(),x.allowFreeText&&B.text().trim().length>0&&p(x.freeTextEntryFactory(B.text())),B.text(""))}).keydown(function(t){if(!e.isModifierKey(t)){if(t.which==i.tab){var n=w.getHighlightedEntry();return void(E&&n&&p(n))}if(t.which==i.left_arrow||t.which==i.right_arrow)return void(t.which==i.left_arrow&&0===B.text().length&&0===window.getSelection().anchorOffset?B.prev()&&(B.insertBefore(B.prev()),B.focus()):t.which==i.right_arrow&&0===B.text().length&&0===window.getSelection().anchorOffset&&B.next()&&(B.insertAfter(B.next()),B.focus()));if(t.which!=i.backspace&&t.which!=i["delete"]){if(t.which==i.up_arrow||t.which==i.down_arrow){f();var r=t.which==i.up_arrow?-1:1;return E?(w.highlightNextEntry(r),g(x.autoCompleteDelay)):(d(r),x.showDropDownOnResultsOnly||f()),!1}if(t.which==i.enter){var n=w.getHighlightedEntry();E&&null!=n?(p(n),C=null):x.allowFreeText&&B.text().trim().length>0&&p(x.freeTextEntryFactory(B.text())),m()}else t.which==i.escape?(m(),B.text("")):(x.showDropDownOnResultsOnly||f(),d(1))}else if(""==B.text()){var a=S[B.index()+(t.which==i.backspace?-1:0)];a&&(s(a),m())}else D=!0,d(1)}}).keyup(function(t){function n(t,n){return t.split(new RegExp("["+e.escapeSpecialRegexCharacter(n.join())+"]"))}if(B.find("*").length>0&&B.text(B.text()),x.allowFreeText){var r=y();if(r.length>0)for(var i=n(r,x.freeTextSeparators),a=0;a0&&p(x.freeTextEntryFactory(o)),B.text(i[i.length-1]),e.selectElementContents(B[0],B.text().length,B.text().length),C=null,m()}}}).mousedown(function(){x.showDropDownOnResultsOnly||f(),d()}),M.attr("placeholder")&&B.attr("placeholder",M.attr("placeholder")),M.attr("tabindex")&&B.attr("tabindex",M.attr("tabindex")),M.attr("autofocus")&&B.focus(),q.add(L).mousedown(function(e){B.is(":focus")&&(O=!0)}).mouseup(function(){O&&(B.focus(),O=!1)}).mouseout(function(){O&&(B.focus(),O=!1)});var Q=t.extend({},x);Q.entries=[],w=L.TrivialListBox(Q),w.onSelectedEntryChanged.addListener(function(e){e&&(p(e),w.selectEntry(null),m())}),p(x.selectedEntry,!0,!0),k.click(function(e){x.showDropDownOnResultsOnly||f(),d();for(var t=null,n=1e6,r=0;r=o.top&&e.clientY=o.left&&e.clientX(o.left+o.right)/2;u?B.insertAfter(t):B.insertBefore(t)}B.focus()});for(var I=0;I0&&(m.highlightTextMatches(T.val()),f.directSelectionViaArrowKeys||m.highlightNextMatchingEntry(e)),m.revealSelectedEntry()}clearTimeout(b),l(t) ').insertAfter(x);"always-visible"!==f.searchBarMode&&w.addClass(f.showSearchField?"":"hide-searchfield"),w.keydown(function(t){if(t.which!=i.tab&&!e.isModifierKey(t))if(T.is(":visible")&&i.specialKeys.indexOf(t.which)===-1&&T.focus(),t.which==i.up_arrow||t.which==i.down_arrow){var n=t.which==i.up_arrow?-1:1;if(null!=g)return f.directSelectionViaArrowKeys?m.selectNextEntry(n):m.highlightNextEntry(n),!1}else t.which==i.left_arrow||t.which==i.right_arrow?m.setHighlightedNodeExpanded(t.which==i.right_arrow):t.which==i.enter?m.setSelectedEntry(m.getHighlightedEntry()[f.valueProperty]):t.which==i.escape?(T.val(""),o(),w.focus()):o(1)});var E=t('
').appendTo(w),T=t(' ').prependTo(w).attr("tabindex",x.attr("-1")).focus(function(){w.addClass("focus")}).blur(function(){w.removeClass("focus")}).keydown(function(e){if(e.which==i.left_arrow||e.which==i.right_arrow){var t=m.setHighlightedNodeExpanded(e.which==i.right_arrow);return!t&&void 0}}).on("keyup change",function(){"show-if-filled"===f.searchBarMode&&(T.val()?w.removeClass("hide-searchfield"):w.addClass("hide-searchfield"))});"none"===f.searchBarMode&&T.css("display","none"),x.attr("placeholder")&&T.attr("placeholder",x.attr("placeholder")),x.attr("tabindex")&&w.attr("tabindex",x.attr("tabindex")),x.attr("autofocus")&&w.focus(),m=E.TrivialTreeBox(f),m.onNodeExpansionStateChanged.addListener(function(e){p.onNodeExpansionStateChanged.fire(e)}),m.$.change(function(){var e=m.getSelectedEntry();e&&c(e)}),c(void 0!==f.selectedEntryId&&null!==f.selectedEntryId?d(f.selectedEntryId):null);var b;this.$=w,w[0].trivialTree=this,this.updateEntries=a,this.getSelectedEntry=m.getSelectedEntry,this.updateChildren=m.updateChildren,this.updateNode=m.updateNode,this.removeNode=m.removeNode,this.addNode=m.addNode,this.selectNode=function(e){m.setSelectedEntry(e)},this.destroy=function(){x.removeClass("tr-original-input").insertBefore(w),w.remove()}}var i=e.keyCodes;return e.registerJqueryPlugin(r,"TrivialTree","tr-tree"),t.fn.TrivialTree}),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-treebox",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.TrivialTreeBox&&(window.TrivialTreeBox=e(TrivialComponents,jQuery,Mustache))}(function(e,t,n){function r(r,i){function a(e){return(null==e[_.childrenProperty]||0==e[_.childrenProperty].length)&&!e[_.lazyChildrenFlagProperty]}function o(e,r){return t(n.render(e[_.templateProperty]||_.templates[Math.min(_.templates.length-1,r)],e))}function l(e,n){var r=a(e),i=t('
');e._trEntryElement=i;for(var s=t('
').appendTo(i),c=0;c ');var u=t('
').appendTo(s),p=o(e,n);if(p.addClass("tr-tree-entry filterable-item").appendTo(s),e[_.valueProperty]===F&&s.addClass("tr-selected-entry"),s.mousedown(function(t){k.trigger("mousedown",t),v(e)}).mouseup(function(e){k.trigger("mouseup",e)}).mouseenter(function(){b(e)}).mouseleave(function(e){t(e.toElement).is(".tr-tree-entry-outer-wrapper")||b(null)}),!r){var h=t('
').appendTo(i);if(u.mousedown(function(e){return!1}).click(function(t){d(e,!e[_.expandedProperty],!0)}),e[_.childrenProperty]){if(e[_.expandedProperty])for(var f=0;f '),e.length>0)for(var n=0;n
.tr-tree-entry-children-wrapper");t?n?c.slideDown(_.animationDuration):c.show():n?c.slideUp(_.animationDuration):c.hide(),!!i!=!!t&&P.onNodeExpansionStateChanged.fire(e)}function c(e){return e?parseInt(e._trEntryElement.attr("data-depth")):0}function u(e,t){e[_.childrenProperty]=t,e[_.lazyChildrenFlagProperty]=!1,p(e,t)}function p(e){var t=e._trEntryElement.find("> .tr-tree-entry-children-wrapper");t.empty();var n=e[_.childrenProperty];if(n&&n.length>0)for(var r=c(e),i=0;i.tr-tree-entry-and-expander-wrapper");t.addClass("tr-selected-entry")}}function E(e){k.trigger("change"),P.onSelectedEntryChanged.fire(e)}function T(e){var t=C(O(),e);null!=t&&v(t)}function b(e){if(e!==q)if(q=e,j.find(".tr-highlighted-entry").removeClass("tr-highlighted-entry"),null!=e&&e._trEntryElement){var t=e._trEntryElement.find(">.tr-tree-entry-and-expander-wrapper");t.addClass("tr-highlighted-entry"),x(t)}else{var n=O();n&&(q=n)}}function C(e,t,n){var r,i=f(function(t){return!!t._trEntryElement&&(n?t._trEntryElement.is(":visible")&&t._trEntryElement.has(">.tr-tree-entry-and-expander-wrapper .tr-highlighted-text").length>0:t._trEntryElement.is(":visible")||t===e);
});if(null==i||0==i.length)return null;if(null==e&&t>0)r=-1+t;else if(null==e&&t<0)r=i.length+t;else{var a=i.indexOf(e);r=(a+i.length+t)%i.length}return i[r]}function S(e){j.detach();for(var t=0;t ').appendTo(r);k.toggleClass("hide-expanders",!_.showExpanders);var j=t('
').appendTo(k);M&&h(M),v(void 0!==_.selectedEntryId&&null!==_.selectedEntryId?y(_.selectedEntryId):null),this.$=k,k[0].trivialTreeBox=this,this.updateEntries=h,this.getSelectedEntry=O,this.setSelectedEntry=function(e){v(y(e))},this.selectNextEntry=T,this.revealSelectedEntry=function(e){var t=O();if(t){for(var n=t;n=g(n);)d(n,!0,e);x(t._trEntryElement)}},this.setHighlightedEntry=b,this.highlightNextEntry=function(e){var t=C(q||O(),e);null!=t&&b(t)},this.highlightNextMatchingEntry=function(e){var t=C(q||O(),e,!0);null!=t&&b(t)},this.selectNextMatchingEntry=function(e){var t=C(q,e,!0);null!=t&&v(t)},this.getHighlightedEntry=function(){return q},this.highlightTextMatches=S,this.setHighlightedNodeExpanded=function(e){if(!q||a(q))return!1;var t=q[_.expandedProperty];return d(q,e,!0),!t!=!e},this.updateChildren=function(e,t){var n=y(e);n&&u(n,t)},this.updateNode=function(e){var t=y(e.id),n=g(t);n?n[_.childrenProperty][n[_.childrenProperty].indexOf(t)]=e:M[M.indexOf(t)]=e,l(e,c(t)).insertAfter(t._trEntryElement),t._trEntryElement.remove()},this.removeNode=function(e){var t=y(e);if(t){var n=g(t);n?n[_.childrenProperty].splice(n[_.childrenProperty].indexOf(t),1):M.splice(M.indexOf(t),1),t._trEntryElement.remove()}},this.addNode=function(e,t){var n=y(e);a(n),n[_.childrenProperty]||(n[_.childrenProperty]=[]),n[_.childrenProperty].push(t);var r=l(t,c(n)+1);r.appendTo(n._trEntryElement.find(">.tr-tree-entry-children-wrapper")),n._trEntryElement.addClass("has-children")}}return e.registerJqueryPlugin(r,"TrivialTreeBox","tr-treebox"),t.fn.TrivialTreeBox}),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-treecombobox",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.trivialtreecombobox&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(r,a){function o(e){setTimeout(function(){var n=f(),r=I.val();if(b!==n||C!==r){if(0===M.length){var i=t(x.spinnerTemplate).appendTo(B);M=M.add(i)}x.queryFunction(n,{completeInputString:r,currentlySelectedEntry:O},function(t){y(t,e),x.showDropDownOnResultsOnly&&t&&t.length>0&&I.is(":focus")&&p()}),b=n,C=r}else p()},0)}function l(e){q.trigger("change"),g.onSelectedEntryChanged.fire(e)}function s(e,r,i){if(null==e){x.valueProperty&&q.val(""),O=null;var a=t(n.render(x.emptyEntry[x.selectedEntryTemplateProperty]||x.emptyEntryTemplate,x.emptyEntry)).addClass("tr-combobox-entry").addClass("empty");j.empty().append(a)}else{x.valueProperty&&q.val(e[x.valueProperty]),O=e;var a=t(n.render(O[x.selectedEntryTemplateProperty]||x.selectedEntryTemplate,e)).addClass("tr-combobox-entry");j.empty().append(a),I.val(x.entryToEditorTextFunction(e))}r&&(P=e,i||l(e)),L&&L.toggle(null!=e),T&&c(),E&&R()}function d(){return null!=O&&O!==x.emptyEntry}function c(){var e=j.find(".tr-editor-area");0===e.length&&(e=j),I.css({width:Math.min(e[0].offsetWidth,N?N[0].offsetLeft-e[0].offsetLeft:99999999)+"px",height:e[0].offsetHeight+"px"}).position({my:"left top",at:"left top",of:e}),T=!0}function u(){I.width(0).height(0),T=!1}function p(){Q&&(k.addClass("open"),R(),E=!0)}function h(){k.removeClass("open"),B.hide(),E=!1}function f(){return I.val().substring(0,I[0].selectionStart)}function m(e){if(x.autoComplete){clearTimeout(_);var t=w.getHighlightedEntry();t&&!F&&(_=setTimeout(function(){var e=f(),n=x.autoCompleteFunction(e,t)||e;I.val(e+n.substr(e.length)),I.is(":focus")&&I[0].setSelectionRange(e.length,n.length)},e||0)),F=!1}}function y(e,n){S=e,M.remove(),M=t(),w.updateEntries(e);var r=f();r.length>0?(w.highlightTextMatches(e.length<=x.textHighlightingEntryLimit?r:null),n&&w.highlightNextMatchingEntry(n)):n&&w.highlightNextEntry(n),m(x.autoCompleteDelay),E&&p()}var g=this;a=a||{};var v=a.selectedEntryTemplate||a.templates&&a.templates.length>0&&a.templates[0]||e.icon2LinesTemplate,x=t.extend({valueProperty:"id",templates:[e.iconSingleLineTemplate],selectedEntryTemplate:v,templateProperty:"template",selectedEntryTemplateProperty:"selectedEntryTemplate",selectedEntry:null,spinnerTemplate:e.defaultSpinnerTemplate,noEntriesTemplate:e.defaultNoEntriesTemplate,textHighlightingEntryLimit:100,entries:null,emptyEntryTemplate:a.emptyEntryTemplate||v,emptyEntry:{},queryFunction:null,autoComplete:!0,autoCompleteDelay:0,entryToEditorTextFunction:function(e){return e.displayValue},autoCompleteFunction:function(e,t){if(e){for(propertyName in t){var n=t[propertyName];if(n&&0===n.toString().toLowerCase().indexOf(e.toLowerCase()))return n.toString()}return null}return x.entryToEditorTextFunction(t)},allowFreeText:!1,freeTextEntryFactory:function(e){return{displayValue:e,_isFreeTextEntry:!0}},showClearButton:!1,showTrigger:!0,matchingOptions:{matchingMode:"contains",ignoreCase:!0,maxLevenshteinDistance:2},childrenProperty:"children",lazyChildrenFlagProperty:"hasLazyChildren",expandedProperty:"expanded",editingMode:"editable",showDropDownOnResultsOnly:!1},a);x.queryFunction=x.queryFunction||e.defaultTreeQueryFunctionFactory(x.entries||[],x.templates,x.matchingOptions,x.childrenProperty,x.expandedProperty),this.onSelectedEntryChanged=new e.Event;var w,E=!1,T=!1,b=null,C=null,S=x.entries,O=null,P=null,D=!1,_=-1,F=!1,M=t(),q=t(r),k=t('
').addClass(x.editingMode).insertAfter(q),j=t('
').appendTo(k);if(x.showClearButton){var L=t('').appendTo(k);L.mousedown(function(){s(null)})}if(x.showTrigger){var N=t('
').appendTo(k);N.mousedown(function(){E?(c(),h()):setTimeout(function(){c(),I.select(),p(),o()})})}var B=t('
').scroll(function(e){return!1}),Q="editable"==x.editingMode&&(x.entries&&x.entries.length>0||a.queryFunction||x.showTrigger);Q&&B.appendTo("body");var I;q.addClass("tr-original-input"),I=t('
'),I.prependTo(k).addClass("tr-combobox-editor tr-editor").focus(function(){D||(k.addClass("focus"),c())}).blur(function(){D?I.focus():(k.removeClass("focus"),H()?e.objectEquals(g.getSelectedEntry(),P)||s(g.getSelectedEntry(),!0):(I.val(""),s(P)),u(),h())}).keydown(function(t){if(!e.isModifierKey(t)){if(t.which==i.tab){var n=w.getHighlightedEntry();return void(E&&n?s(n,!0):I.val()?x.allowFreeText&&s(g.getSelectedEntry(),!0):s(null,!0))}if(t.which==i.left_arrow||t.which==i.right_arrow){if(E){var r=w.setHighlightedNodeExpanded(t.which==i.right_arrow);if(r)return!1}return void c()}if(t.which!=i.backspace&&t.which!=i["delete"]||(F=!0),t.which==i.up_arrow||t.which==i.down_arrow){T||(I.select(),c());var a=t.which==i.up_arrow?-1:1;return E?(w.highlightNextEntry(a),m(x.autoCompleteDelay)):(o(a),x.showDropDownOnResultsOnly||p()),!1}if(t.which==i.enter){if(T||H()){t.preventDefault();var n=w.getHighlightedEntry();E&&n?s(n,!0):I.val()?x.allowFreeText&&s(g.getSelectedEntry(),!0):s(null,!0),h(),u()}}else t.which==i.escape?(t.preventDefault(),H()&&E||(u(),I.val(""),S=null,s(P,!1)),h()):(T||(c(),I.select()),x.showDropDownOnResultsOnly||p(),setTimeout(function(){I.val()?o(1):(o(0),w.setHighlightedEntry(null))}))}}).keyup(function(t){!e.isModifierKey(t)&&[i.enter,i.escape,i.tab].indexOf(t.which)===-1&&d()&&I.val()!==x.entryToEditorTextFunction(O)&&s(null,!1)}).mousedown(function(){x.showDropDownOnResultsOnly||p(),o()}),q.attr("tabindex")&&I.attr("tabindex",q.attr("tabindex")),q.attr("autofocus")&&I.focus(),k.add(B).mousedown(function(){I.is(":focus")&&(D=!0)}).mouseup(function(){D&&(I.focus(),D=!1)}).mouseout(function(){D&&(I.focus(),D=!1)}),w=B.TrivialTreeBox(x),w.onSelectedEntryChanged.addListener(function(t){t&&(s(t,!0,e.objectEquals(t,P)),w.setSelectedEntry(null),h()),u()}),s(x.selectedEntry,!0,!0),j.click(function(){c(),I.select(),x.showDropDownOnResultsOnly||p(),o()});var H=function(){return x.allowFreeText&&I.val().length>0&&!d()},R=function(){B.show().position({my:"left top",at:"left bottom",of:k,collision:"flip",using:function(e,n){"top"===n.vertical?(k.removeClass("dropdown-flipped"),t(this).removeClass("flipped")):(k.addClass("dropdown-flipped"),t(this).addClass("flipped")),t(this).css({left:e.left+"px",top:e.top+"px"})}}).width(k.width())};this.$=k,k[0].trivialTreeComboBox=this,this.updateEntries=y,this.getSelectedEntry=function(){if(null!=O||x.allowFreeText&&I.val()){if(null==O&&x.allowFreeText)return x.freeTextEntryFactory(I.val());var e=jQuery.extend({},O);return e._trEntryElement=void 0,e}return null},this.selectEntry=function(e,t){s(e,!0,t)},this.updateChildren=w.updateChildren,this.updateNode=w.updateNode,this.removeNode=w.removeNode,this.focus=function(){c(),I.select()},this.getDropDown=function(){return B},this.destroy=function(){q.removeClass("tr-original-input").insertBefore(k),k.remove(),B.remove()}}var i=e.keyCodes;return e.registerJqueryPlugin(r,"TrivialTreeComboBox","tr-combobox"),t.fn.TrivialTreeComboBox}),function(e){"use strict";"function"==typeof define&&define.amd?define("trivial-unitbox",["trivial-core","jquery","mustache"],e):"object"==typeof exports?module.exports=e(require("trivial-core"),require("jquery"),require("mustache")):jQuery&&!jQuery.fn.trivialunitbox&&e(TrivialComponents,jQuery,Mustache)}(function(e,t,n){function r(r,a){function o(e){var t,n,r=F.val().match(P).join(""),i=r.indexOf(E.decimalSeparator);return i!==-1?(t=r.substring(0,i),n=r.substring(i+1,r.length).replace(/\D/g,"")):(t=r,n=""),0==t.length&&0==n?"":(e&&(n=(n+new Array(E.decimalPrecision+1).join("0")).substr(0,E.decimalPrecision)),t+E.decimalSeparator+n)}function l(e){var n=t(E.spinnerTemplate).appendTo(j);D=D.add(n),setTimeout(function(){E.queryFunction(L(),{completeInputString:F.val(),currentlySelectedEntry:S},function(t){x(t);var n=L();n.length>0&&T.highlightTextMatches(n),T.highlightNextEntry(e),b&&f()})})}function s(){w.onSelectedEntryChanged.fire(S)}function d(){_.trigger("change"),w.onChange.fire({unit:null!=S?S[E.unitValueProperty]:null,unitEntry:S,amount:g(),amountAsFloatingPointNumber:parseFloat(h(g(),E.decimalPrecision,E.decimalSeparator,E.thousandsSeparator))})}function c(e,r){if(null==e){S=null;var i=t(n.render(E.selectedEntryTemplate,E.emptyEntry)).addClass("tr-combobox-entry").addClass("empty");k.empty().append(i)}else{S=e;var i=t(n.render(E.selectedEntryTemplate,e)).addClass("tr-combobox-entry");k.empty().append(i)}p(),y(),r||s()}function u(){F.val(h(g(),E.decimalPrecision,E.decimalSeparator,E.thousandsSeparator))}function p(){F.val()&&F.val(o(!0))}function h(e,t,n,r){if(null==e||isNaN(e))return"";var i=""+e;if(i.length<=t)return 0+n+new Array(t-i.length+1).join("0")+i;var a=i.substring(0,i.length-t),o=a.replace(/\B(?=(\d{3})+(?!\d))/g,r),l=i.substr(i.length-t,t);return o+n+l}function f(){M.addClass("open"),N(),b=!0}function m(){M.removeClass("open"),j.hide(),b=!1}function y(){"left"===E.unitDisplayPosition?_.val((S?S[E.unitValueProperty]:"")+h(g(),E.decimalPrecision,E.decimalSeparator,"")):_.val(h(g(),E.decimalPrecision,E.decimalSeparator,"")+(S?S[E.unitValueProperty]:""))}function g(){var e=o(!1);return 0===e.length&&E.allowNullAmount?null:parseInt(o(!0).replace(/\D/g,""))}function v(e){c(C.filter(function(t){return t[E.unitIdProperty]===e})[0],!0)}function x(e){C=e,D.remove(),D=t(),T.updateEntries(e)}var w=this;a=a||{};var E=t.extend({unitValueProperty:"code",unitIdProperty:"code",decimalPrecision:2,decimalSeparator:".",thousandsSeparator:",",unitDisplayPosition:"right",allowNullAmount:!0,template:e.currency2LineTemplate,selectedEntryTemplate:e.currencySingleLineShortTemplate,amount:null,selectedEntry:void 0,spinnerTemplate:e.defaultSpinnerTemplate,noEntriesTemplate:e.defaultNoEntriesTemplate,entries:null,emptyEntry:{code:"..."},queryFunction:null,queryOnNonNumberCharacters:!0,openDropdownOnEditorClick:!1,showTrigger:!0,matchingOptions:{matchingMode:"prefix-word",ignoreCase:!0,maxLevenshteinDistance:2}},a);E.queryFunction=E.queryFunction||e.defaultListQueryFunctionFactory(E.entries||[],E.matchingOptions),this.onChange=new e.Event,this.onSelectedEntryChanged=new e.Event;var T,b=!1,C=E.entries,S=null,O=!1,P=new RegExp("\\d*\\"+E.decimalSeparator+"?\\d*","g"),D=t(),_=t(r).addClass("tr-original-input"),F=t('
'),M=t('
').insertAfter(_).addClass("left"===E.unitDisplayPosition?"unit-display-left":"unit-display-right");_.appendTo(M);var q=t('
').appendTo(M),k=t('
').appendTo(q);E.showTrigger&&t('
').appendTo(q),q.mousedown(function(){b?m():setTimeout(function(){f(),l()}),F.focus()});var j=t('
').appendTo("body");F.prependTo(M).addClass("tr-unitbox-editor tr-editor").focus(function(){O||(M.addClass("focus"),p())}).blur(function(){O?F.focus():(M.removeClass("focus"),u(),m())}).keydown(function(t){if(!e.isModifierKey(t)){if(t.which==i.tab){var n=T.getHighlightedEntry();b&&n&&c(n)}else if(t.which==i.left_arrow||t.which==i.right_arrow)return;if(t.which==i.up_arrow||t.which==i.down_arrow){var r=t.which==i.up_arrow?-1:1;return b?T.highlightNextEntry(r):(f(),l(r)),!1}if(b&&t.which==i.enter)t.preventDefault(),c(T.getHighlightedEntry()),m();else if(t.which==i.escape)m(),p();else if(!t.shiftKey&&i.numberKeys.indexOf(t.which)!=-1){var a=o(),s=a.indexOf(E.decimalSeparator),d=s!=-1&&a.length-(s+1)>=E.decimalPrecision,u=F.val(),h=u.indexOf(E.decimalSeparator),y=F[0].selectionStart,g=F[0].selectionEnd,v=h!==-1&&g>h&&y===g;if(d&&v){if(!/^\d$/.test(u[g]))return!1;F.val(u.substring(0,g)+u.substring(g+1)),F[0].setSelectionRange(g,g)}}}}).keyup(function(e){if(i.specialKeys.indexOf(e.which)==-1||e.which==i.backspace||e.which==i["delete"]){var t=new RegExp("(?:\\"+E.decimalSeparator+".*)\\"+E.decimalSeparator,"g").test(F.val());t&&(p(),F[0].setSelectionRange(F.val().length-E.decimalPrecision,F.val().length-E.decimalPrecision)),E.queryOnNonNumberCharacters&&(L().length>0?(f(),l(1)):m())}}).mousedown(function(){E.openDropdownOnEditorClick&&(f(),null==C&&l())}).change(function(){y(),d()}),M.add(j).mousedown(function(){F.is(":focus")&&(O=!0)}).mouseup(function(){O&&(F.focus(),O=!1)}).mouseout(function(){O&&(F.focus(),O=!1)}),T=j.TrivialListBox(E),T.onSelectedEntryChanged.addListener(function(e){e&&(c(e,!1),T.selectEntry(null),m())}),F.val(E.amount||_.val()),u(),c(E.selectedEntry||null,!0);var L=function(){return F.val().replace(P,"")},N=function(){j.show().position({my:"left top",at:"left bottom",of:M,collision:"flip",using:function(e,n){"top"===n.vertical?(M.removeClass("dropdown-flipped"),t(this).removeClass("flipped")):(M.addClass("dropdown-flipped"),t(this).addClass("flipped")),t(this).css({left:e.left+"px",top:e.top+"px"})}}).width(M.width())};this.$=M,M[0].trivialUnitBox=this,this.updateEntries=x,this.getSelectedUnit=function(){if(null==S)return null;var e=jQuery.extend({},S);return e._trEntryElement=void 0,e},this.getAmount=g,this.setAmount=function(e){if(null!=e&&e!==parseInt(e))throw"TrivialUnitBox: You must specify an integer amount!";null==e?E.allowNullAmount?F.val(""):F.val(h(0,E.decimalPrecision,E.decimalSeparator,"")):F.is(":focus")?F.val(h(e,E.decimalPrecision,E.decimalSeparator,"")):F.val(h(e,E.decimalPrecision,E.decimalSeparator,E.thousandsSeparator))},this.selectEntry=c,this.selectUnit=v,this.focus=function(){F.select()},this.destroy=function(){_.removeClass("tr-original-input").insertBefore(M),M.remove(),j.remove()}}var i=e.keyCodes;return e.registerJqueryPlugin(r,"TrivialUnitBox","tr-unitbox"),t.fn.TrivialUnitBox});