@progress/kendo-dateinputs-common 0.3.3 → 0.3.4-dev.202407300720
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{tools → bin}/release-master +0 -0
- package/dist/cdn/js/kendo-dateinputs-common.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/dateobject.js +115 -20
- package/dist/es2015/common/dateobject.js +116 -22
- package/dist/npm/common/dateobject.d.ts +29 -0
- package/dist/npm/common/dateobject.js +115 -20
- package/dist/systemjs/kendo-dateinputs-common.js +1 -1
- package/package.json +9 -4
package/dist/cdn/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@progress/kendo-date-math"),require("tslib")):"function"==typeof define&&define.amd?define([,],e):"object"==typeof exports?exports.KendoDateinputsCommon=e(require("@progress/kendo-date-math"),require("tslib")):t.KendoDateinputsCommon=e(t.KendoDateMath,t.self)}(window,(function(t,e){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(e,i){e.exports=t},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Constants={formatSeparator:"_",twoDigitYearMax:68,defaultDateFormat:"d",defaultLocaleId:"en"}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=i(0),a=function(t){return t&&"object"==typeof t&&!Array.isArray(t)},r=function(t){return t instanceof HTMLElement};e.isPresent=function(t){return null!=t},e.isDocumentAvailable=function(){return!!document},e.isNumber=function(t){return e.isPresent(t)&&"number"==typeof t&&!Number.isNaN(t)},e.parseToInt=function(t){return parseInt(t,10)},e.clamp=function(t,e,i){return Math.min(i,Math.max(e,t))},e.extend=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Object.assign.apply(Object,t)},e.deepExtend=function(t){for(var i,n,s=[],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(!s.length)return t;var l=s.shift();if(a(t)&&a(l))for(var h in l)r(l[h])?t[h]=l[h]:!a(l[h])||l[h]instanceof Date?e.extend(t,((n={})[h]=l[h],n)):(t[h]&&a(t[h])||e.extend(t,((i={})[h]={},i)),e.deepExtend(t[h],l[h]));return e.deepExtend.apply(void 0,[t].concat(s))},e.noop=function(){},e.isFunction=function(t){return"function"==typeof t},e.cropTwoDigitYear=function(t){return!e.isPresent(t)||isNaN(t.getTime())?0:Number(t.getFullYear().toString().slice(-2))},e.setYears=(n="setFullYear",function(t,e){var i=s.cloneDate(t);return i[n](e),i}),e.millisecondDigitsInFormat=function(t){var e=t&&t.match(/S+(\1)/);return e?e[0].length:0},e.millisecondStepFor=function(t){return Math.pow(10,3-t)},e.areDatePartsEqualTo=function(t,e,i,n,s,a,r,o){return!(!t||t.getFullYear()!==e||t.getMonth()!==i||t.getDate()!==n||t.getHours()!==s||t.getMinutes()!==a||t.getSeconds()!==r||t.getMilliseconds()!==o)},e.isValidDate=function(t){return e.isPresent(t)&&t.getTime&&e.isNumber(t.getTime())}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(1),s=i(4);e.padZero=function(t){return new Array(Math.max(t,0)).fill("0").join("")},e.unpadZero=function(t){return t.replace(/^0*/,"")},e.approximateStringMatching=function(t){var e=t.oldText,i=t.newText,a=t.formatPattern,r=t.selectionStart,o=t.isInCaretMode,l=t.keyEvent,h=r+e.length-i.length,u=e[h],c=e.substring(0,h),d=i.substring(0,r),p=[];if(c===d&&r>0)return p.push([a[r-1],d[r-1]]),p;if(0===c.indexOf(d)&&o&&(l.key===s.Key.DELETE||l.key===s.Key.BACKSPACE)||0===c.indexOf(d)&&!o&&(0===d.length||a[d.length-1]!==a[d.length])){var m="";o||1!==d.length||p.push([a[0],d[0]]);for(var v=d.length;v<c.length;v++)a[v]!==m&&a[v]!==n.Constants.formatSeparator&&(m=a[v],p.push([m,""]));return p}if(o&&(0===d.indexOf(c)||a[r-1]===n.Constants.formatSeparator)||!o&&(0===d.indexOf(c)||a[r-1]===n.Constants.formatSeparator)){var f=a[0];for(v=Math.max(0,c.length-1);v<a.length;v++)if(a[v]!==n.Constants.formatSeparator){f=a[v];break}return[[f,d[r-1]]]}return" "===d[d.length-1]||d[d.length-1]===u&&"_"===a[h]?[[a[r-1],n.Constants.formatSeparator]]:[[a[r-1],d[r-1]]]},e.dateSymbolMap=function(t,e){return t[e.pattern[0]]=e.type,t},e.isInRange=function(t,e,i){return null===t||!(e&&e>t||i&&i<t)}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Key={DELETE:"Delete",BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",ARROW_LEFT:"ArrowLeft",ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown",SPACE:" ",END:"End",HOME:"Home",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown"}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(6);e.DateInput=n.DateInput},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=i(7),a=i(8),r=i(3),o=i(10),l=i(4),h=i(2),u=i(11),c=i(12),d=i(0),p=i(1),m={format:"d",hasPlaceholder:!1,placeholder:null,cycleTime:!0,locale:null,steps:{millisecond:1,second:1,minute:1,hour:1,day:1,month:1,year:1},formatPlaceholder:null,events:(n={},n.valueChange=null,n.input=null,n.inputEnd=null,n.focus=null,n.focusEnd=null,n.blur=null,n.blurEnd=null,n.keydown=null,n.mousewheel=null,n.change=null,n),selectNearestSegmentOnFocus:!1,selectPreviousSegmentOnBackspace:!1,enableMouseWheel:!1,allowCaretMode:!1,autoSwitchParts:!0,autoSwitchKeys:[],twoDigitYearMax:p.Constants.twoDigitYearMax,autoCorrectParts:!0,autoFill:!1},v=function(t){function e(e,i){var n=t.call(this,i)||this;return n.dateObject=null,n.currentText="",n.currentFormat="",n.interactionMode=c.DateInputInteractionMode.None,n.previousElementSelection={start:0,end:0},n.init(e,i),n}return s.__extends(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.dateObject&&this.dateObject.getValue()},enumerable:!0,configurable:!0}),e.prototype.init=function(t,e){var i=h.isValidDate(this.options.value)?d.cloneDate(this.options.value):new Date(e.formattedValue);h.isValidDate(i)||(i=null),this.element=t,this.options=h.extend({},m,e,{steps:s.__assign({},m.steps,e.steps)}),this.intl=this.options.intlService,this.dateObject=this.createDateObject(),this.dateObject.setValue(i),this.setTextAndFormat(),this.bindEvents(),this.resetSegmentValue=!0,this.interactionMode=c.DateInputInteractionMode.None,this.forceUpdate()},e.prototype.destroy=function(){this.unbindEvents(),this.dateObject=null,t.prototype.destroy.call(this)},e.prototype.bindEvents=function(){this.onElementDragStart=this.onElementDragStart.bind(this),this.element.addEventListener("dragStart",this.onElementDragStart),this.onElementDrop=this.onElementDrop.bind(this),this.element.addEventListener("drop",this.onElementDrop),this.onElementClick=this.onElementClick.bind(this),this.element.addEventListener("click",this.onElementClick),this.onElementMouseDown=this.onElementMouseDown.bind(this),this.element.addEventListener("mousedown",this.onElementMouseDown),this.element.addEventListener("touchstart",this.onElementMouseDown),this.onElementMouseUp=this.onElementMouseUp.bind(this),this.element.addEventListener("mouseup",this.onElementMouseUp),this.onElementInput=this.onElementInput.bind(this),this.element.addEventListener("input",this.onElementInput),this.onElementKeyDown=this.onElementKeyDown.bind(this),this.element.addEventListener("keydown",this.onElementKeyDown),this.onElementFocus=this.onElementFocus.bind(this),this.element.addEventListener("focus",this.onElementFocus),this.onElementBlur=this.onElementBlur.bind(this),this.element.addEventListener("blur",this.onElementBlur),this.onElementChange=this.onElementChange.bind(this),this.element.addEventListener("change",this.onElementChange),this.onElementPaste=this.onElementPaste.bind(this),this.element.addEventListener("paste",this.onElementPaste),this.onElementMouseWheel=this.onElementMouseWheel.bind(this),this.element.addEventListener("DOMMouseScroll",this.onElementMouseWheel),this.element.addEventListener("mousewheel",this.onElementMouseWheel)},e.prototype.unbindEvents=function(){this.element.removeEventListener("dragStart",this.onElementDragStart),this.element.removeEventListener("drop",this.onElementDrop),this.element.removeEventListener("touchstart",this.onElementMouseDown),this.element.removeEventListener("mousedown",this.onElementMouseDown),this.element.removeEventListener("mouseup",this.onElementMouseUp),this.element.removeEventListener("click",this.onElementClick),this.element.removeEventListener("input",this.onElementInput),this.element.removeEventListener("keydown",this.onElementKeyDown),this.element.removeEventListener("focus",this.onElementFocus),this.element.removeEventListener("blur",this.onElementBlur),this.element.removeEventListener("change",this.onElementChange),this.element.removeEventListener("paste",this.onElementPaste),this.element.removeEventListener("DOMMouseScroll",this.onElementMouseWheel),this.element.removeEventListener("mousewheel",this.onElementMouseWheel)},e.prototype.setOptions=function(t,e){void 0===e&&(e=!1),this.options=h.extend({},this.options,t,{steps:s.__assign({},m.steps,t.steps)}),this.setDateObjectOptions(),e&&(this.unbindEvents(),this.init(this.element,this.options))},e.prototype.setDateObjectOptions=function(){if(this.dateObject){var t=this.getDateObjectOptions();this.dateObject.setOptions(t)}},e.prototype.resetLocale=function(){this.unbindEvents(),this.init(this.element,this.options)},e.prototype.isInCaretMode=function(){return this.interactionMode===c.DateInputInteractionMode.Caret},e.prototype.focus=function(){this.element.focus(),this.options.selectNearestSegmentOnFocus&&this.selectNearestSegment(0)},e.prototype.onElementDragStart=function(t){t.preventDefault()},e.prototype.onElementDrop=function(t){t.preventDefault()},e.prototype.onElementMouseDown=function(){this.mouseDownStarted=!0,this.focusedPriorToMouseDown=this.isActive},e.prototype.onElementMouseUp=function(t){this.mouseDownStarted=!1,t.preventDefault()},e.prototype.onElementClick=function(t){this.mouseDownStarted=!1,this.switchedPartOnPreviousKeyAction=!1;var e=this.selection;if(this.isInCaretMode()&&this.forceUpdate(),3===t.detail);else if(this.isActive&&this.options.selectNearestSegmentOnFocus){var i=this.element.selectionStart!==this.element.selectionEnd,n=h.isPresent(this.options.placeholder)&&!this.dateObject.hasValue()&&!this.focusedPriorToMouseDown,s=!i&&n?0:this.caret()[0];this.selectNearestSegment(s)}else this.setSelection(this.selectionByIndex(e.start))},e.prototype.onElementInput=function(t){this.triggerInput({event:t});var e=this.elementValue;if(this.element&&this.dateObject){var i=this.switchedPartOnPreviousKeyAction;if(this.isPasteInProgress)return this.options.allowCaretMode&&(this.resetSegmentValue=!1),this.updateOnPaste(t),void(this.isPasteInProgress=!1);var n=this.keyDownEvent||{},s=n.keyCode===o.KeyCode.BACKSPACE||n.key===l.Key.BACKSPACE,a=n.keyCode===o.KeyCode.DELETE||n.key===l.Key.DELETE,u=this.interactionMode;!this.options.allowCaretMode||u===c.DateInputInteractionMode.Caret||a||s||(this.resetSegmentValue=!0),this.options.allowCaretMode?this.interactionMode=c.DateInputInteractionMode.Caret:this.interactionMode=c.DateInputInteractionMode.Selection;var m=this.isInCaretMode();if(m&&this.keyDownEvent.key===l.Key.SPACE)this.restorePreviousInputEventState();else{var v=this.dateObject&&this.dateObject.getValue(),f=this.dateObject?this.dateObject.value:null,g=this.dateObject.getTextAndFormat(),y=g.text,D=g.format;this.currentFormat=D;var E="";E=m&&(s||a||u===c.DateInputInteractionMode.Caret)?this.previousElementValue:y;var P=this.elementValue,b=r.approximateStringMatching({oldText:E,newText:P,formatPattern:this.currentFormat,selectionStart:this.selection.start,isInCaretMode:m,keyEvent:this.keyDownEvent});if(b&&b.length&&b[0]&&b[0][1]!==p.Constants.formatSeparator&&(this.switchedPartOnPreviousKeyAction=!1),!m||b&&0!==b.length){if(m&&1===b.length){if(!b[0]||!b[0][0])return void this.restorePreviousInputEventState();if(m&&b[0]&&(b[0][0]===p.Constants.formatSeparator||b[0][1]===p.Constants.formatSeparator))return void this.restorePreviousInputEventState()}var S=1===b.length&&b[0][1]===p.Constants.formatSeparator,M=[],I=!1,x=null;if(!S)for(var O=0;O<b.length;O++){var w=this.dateObject.parsePart({symbol:b[O][0],currentChar:b[O][1],resetSegmentValue:this.resetSegmentValue,cycleSegmentValue:!this.isInCaretMode(),rawTextValue:this.element.value,isDeleting:s||a,originalFormat:this.currentFormat});M.push(w),w.value||(x={type:"parse"}),I=w.switchToNext}this.options.autoSwitchParts||(I=!1),this.resetSegmentValue=!1;var C,F=this.options.format===this.currentFormat||h.isPresent(this.options.format)&&this.options.format.length>1,V=M[M.length-1],k=V&&!h.isPresent(V.value),_=m&&(s||a)&&k,T=!!V&&V.resetPart,j=this.dateObject.getValue(),A=!d.isEqual(v,j),N=this.dateObject.value,L=this.selection;if(m){var K=b&&b.length>0?b[0][0]:null,W=this.dateObject.getLeadingZero()[K];b.length&&b[0][0]!==p.Constants.formatSeparator?I?(this.forceUpdateWithSelection(),this.switchDateSegment(1)):T?(C=this.currentFormat[L.start])?(this.forceUpdate(),this.setSelection(this.selectionBySymbol(C))):this.restorePreviousInputEventState():_?(this.forceUpdate(),b.length&&b[0][0]!==p.Constants.formatSeparator&&this.setSelection(this.selectionBySymbol(b[0][0]))):k?"0"===t.data&&W||(h.isPresent(v)&&!h.isPresent(j)?this.restorePreviousInputEventState():!h.isPresent(v)&&h.isPresent(j)?this.forceUpdateWithSelection():h.isPresent(v)&&h.isPresent(j)?A?this.forceUpdateWithSelection():this.restorePreviousInputEventState():h.isPresent(v)||h.isPresent(j)?f!==N||this.restorePreviousInputEventState():this.forceUpdateWithSelection()):k||F||this.forceUpdateWithSelection():(this.options.autoSwitchParts||b[0][1]!==p.Constants.formatSeparator)&&this.setSelection(this.selectionBySymbol(b[0][0]))}else m||(this.forceUpdate(),b.length&&b[0][0]!==p.Constants.formatSeparator&&this.setSelection(this.selectionBySymbol(b[0][0])),this.options.autoSwitchParts?S?(this.resetSegmentValue=!0,i||this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0):I&&(this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0):V&&V.switchToNext?this.resetSegmentValue=!0:S&&(this.resetSegmentValue=!0,i||this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0),s&&this.options.selectPreviousSegmentOnBackspace&&this.switchDateSegment(-1));this.tryTriggerValueChange({oldValue:v,event:t}),this.triggerInputEnd({event:t,error:x,oldElementValue:e,newElementValue:this.elementValue}),m&&this.setTextAndFormat()}else this.restorePreviousInputEventState()}}},e.prototype.onElementFocus=function(t){this.triggerFocus({event:t})||(this.isActive=!0,this.interactionMode=c.DateInputInteractionMode.None,this.switchedPartOnPreviousKeyAction=!1,this.refreshElementValue(),this.mouseDownStarted||this.caret(0,this.elementValue.length),this.mouseDownStarted=!1,this.triggerFocusEnd({event:t}))},e.prototype.onElementBlur=function(t){this.resetSegmentValue=!0,this.isActive=!1,this.triggerBlur({event:t})||(this.options.autoFill&&this.autoFill(),this.interactionMode=c.DateInputInteractionMode.None,this.switchedPartOnPreviousKeyAction=!1,this.refreshElementValue(),this.triggerBlurEnd({event:t}))},e.prototype.onElementChange=function(t){this.triggerChange({event:t})},e.prototype.onElementKeyDown=function(t){if(!this.triggerKeyDown({event:t})){var e=this.selection,i=e.start,n=e.end,s=t;if(this.keyDownEvent=t,this.previousElementValue=this.element.value,this.previousElementSelection={start:i,end:n},this.keyEventMatchesAutoSwitchKeys(t)){var a=t.keyCode===o.KeyCode.TAB;if(!a)return t.preventDefault(),void this.switchDateSegment(1);var r=this.selection,l=r.start,h=r.end;if(t.shiftKey&&a?this.switchDateSegment(-1):this.switchDateSegment(1),l!==this.selection.start||h!==this.selection.end)return void t.preventDefault()}var u=this.currentFormat[this.selection.start],c=this.getStepFromSymbol(u),d=!1,p=this.elementValue;if(!(t.altKey||t.ctrlKey||t.metaKey||t.keyCode===o.KeyCode.TAB)){switch(t.keyCode){case o.KeyCode.ARROW_LEFT:this.switchDateSegment(-1),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ARROW_UP:this.modifyDateSegmentValue(c,u,s),p!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:p}),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ARROW_RIGHT:this.switchDateSegment(1),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ARROW_DOWN:this.modifyDateSegmentValue(-c,u,s),p!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:p}),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ENTER:break;case o.KeyCode.HOME:this.selectNearestSegment(0),d=!0,this.switchedPartOnPreviousKeyAction=!1,this.resetSegmentValue=!0;break;case o.KeyCode.END:this.selectNearestSegment(this.elementValue.length),d=!0,this.switchedPartOnPreviousKeyAction=!1,this.resetSegmentValue=!0;break;default:return}d&&t.preventDefault()}}},e.prototype.onElementPaste=function(){this.isPasteInProgress=!0},e.prototype.onElementMouseWheel=function(t){var e=this.elementValue;if(this.options.enableMouseWheel&&!this.triggerMouseWheel({event:t})&&this.isActive){var i=t;i.shiftKey?this.switchDateSegment((i.wheelDelta||-i.detail)>0?-1:1):this.modifyDateSegmentValue((i.wheelDelta||-i.detail)>0?1:-1),i.returnValue=!1,i.preventDefault&&i.preventDefault(),i.stopPropagation&&i.stopPropagation(),e!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:e})}},e.prototype.updateOnPaste=function(t){var e=this.intl.parseDate(this.elementValue,this.inputFormat)||this.value;h.isPresent(e)&&this.dateObject.shouldNormalizeCentury()&&(e=this.dateObject.normalizeCentury(e));var i=this.dateObject&&this.dateObject.getValue();this.writeValue(e),this.tryTriggerValueChange({oldValue:i,event:t})},Object.defineProperty(e.prototype,"elementValue",{get:function(){return(this.element||{}).value||""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputFormat",{get:function(){return this.options.format?"string"==typeof this.options.format?this.options.format:this.options.format.inputFormat:p.Constants.defaultDateFormat},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayFormat",{get:function(){return this.options.format?"string"==typeof this.options.format?this.options.format:this.options.format.displayFormat:p.Constants.defaultDateFormat},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){var t={start:0,end:0};return null!==this.element&&void 0!==this.element.selectionStart&&(t={start:this.element.selectionStart,end:this.element.selectionEnd}),t},enumerable:!0,configurable:!0}),e.prototype.setSelection=function(t){this.element&&document.activeElement===this.element&&(this.element.setSelectionRange(t.start,t.end),t.start!==t.end&&(this.interactionMode=c.DateInputInteractionMode.Selection))},e.prototype.selectionBySymbol=function(t){for(var e=-1,i=0,n=0;n<this.currentFormat.length;n++)this.currentFormat[n]===t&&(i=n+1,-1===e&&(e=n));return e<0&&(e=0),this.options.autoCorrectParts||this.currentFormat.length===this.currentText.length||(this.currentFormat.length<this.currentText.length?i+=this.currentText.length-this.currentFormat.length:i=Math.max(0,i-(this.currentFormat.length-this.currentText.length))),{start:e,end:i}},e.prototype.selectionByIndex=function(t){for(var e={start:t,end:t},i=t,n=t-1;i<this.currentFormat.length||n>=0;i++,n--){if(i<this.currentFormat.length&&this.currentFormat[i]!==p.Constants.formatSeparator){e=this.selectionBySymbol(this.currentFormat[i]);break}if(n>=0&&this.currentFormat[n]!==p.Constants.formatSeparator){e=this.selectionBySymbol(this.currentFormat[n]);break}}return e},e.prototype.switchDateSegment=function(t){var e=this.selection;if(this.isInCaretMode()){var i=e.start,n=this.currentFormat[i-1],s="",a="";if(t<0){for(var r=i+t;r>=0;r--)if((a=this.currentFormat[r])!==p.Constants.formatSeparator&&a!==n){i=r,s=a;break}}else for(r=i+t;r<this.currentFormat.length;r++)if((a=this.currentFormat[r])!==p.Constants.formatSeparator&&a!==n){i=r,s=a;break}if(s)return this.forceUpdate(),this.setSelection(this.selectionBySymbol(s)),void(this.interactionMode=c.DateInputInteractionMode.Selection)}this.interactionMode=c.DateInputInteractionMode.None;var o=this.selection,l=o.start,h=o.end;if(l<h&&this.currentFormat[l]!==this.currentFormat[h-1])return this.setSelection(this.selectionByIndex(t>0?l:h-1)),this.resetSegmentValue=!0,void(this.interactionMode=c.DateInputInteractionMode.None);for(var u=this.currentFormat[l],d=l+t;d>0&&d<this.currentFormat.length&&(this.currentFormat[d]===u||this.currentFormat[d]===p.Constants.formatSeparator);)d+=t;if(this.currentFormat[d]!==p.Constants.formatSeparator){for(var m=d;m>=0&&m<this.currentFormat.length&&this.currentFormat[m]===this.currentFormat[d];)m+=t;d>m&&(m+1!==l||d+1!==h)?(this.setSelection({start:m+1,end:d+1}),this.resetSegmentValue=!0):d<m&&(d!==l||m!==h)&&(this.setSelection({start:d,end:m}),this.resetSegmentValue=!0),this.interactionMode=c.DateInputInteractionMode.None}},e.prototype.modifyDateSegmentValue=function(t,e,i){if(void 0===e&&(e=""),void 0===i&&(i={}),this.dateObject&&!this.options.readonly){var n=this.value,s=1,a=this.caret();if("S"===(e=e||this.currentFormat[a[0]])&&(!this.options.steps.millisecond||1===this.options.steps.millisecond)){var r=h.millisecondDigitsInFormat(this.inputFormat);s=h.millisecondStepFor(r)}this.dateObject.modifyPart(e,s*t),this.tryTriggerValueChange({oldValue:n,event:i}),this.forceUpdate(),this.setSelection(this.selectionBySymbol(e))}},e.prototype.tryTriggerValueChange=function(t){if(void 0===t&&(t={oldValue:null,event:{}}),!d.isEqual(this.value,t.oldValue))return this.triggerValueChange(t)},e.prototype.triggerValueChange=function(t){return void 0===t&&(t={oldValue:null,event:{}}),this.trigger("valueChange",h.extend(t,{value:this.value}))},e.prototype.triggerInput=function(t){return void 0===t&&(t={event:{}}),this.trigger("input",h.extend(t,{value:this.value}))},e.prototype.triggerInputEnd=function(t){return void 0===t&&(t={event:{},error:null,oldElementValue:"",newElementValue:""}),this.trigger("inputEnd",h.extend(t,{value:this.value}))},e.prototype.triggerFocus=function(t){return void 0===t&&(t={event:{}}),this.trigger("focus",h.extend({},t))},e.prototype.triggerFocusEnd=function(t){return void 0===t&&(t={event:{}}),this.trigger("focusEnd",h.extend({},t))},e.prototype.triggerBlur=function(t){return void 0===t&&(t={event:{}}),this.trigger("blur",h.extend({},t))},e.prototype.triggerBlurEnd=function(t){return void 0===t&&(t={event:{}}),this.trigger("blurEnd",h.extend({},t))},e.prototype.triggerChange=function(t){return void 0===t&&(t={event:{}}),this.trigger("change",h.extend(t,{value:this.value}))},e.prototype.triggerKeyDown=function(t){return void 0===t&&(t={event:{}}),this.trigger("keydown",h.extend({},t))},e.prototype.triggerMouseWheel=function(t){return void 0===t&&(t={event:{}}),this.trigger("mousewheel",h.extend({},t))},e.prototype.forceUpdate=function(){this.setTextAndFormat(),this.refreshElementValue()},e.prototype.forceUpdateWithSelection=function(){var t=this.selection,e=t.start,i=t.end,n=this.elementValue.length;this.forceUpdate();var s=this.elementValue.length-n;this.setSelection({start:e+s,end:i+s})},e.prototype.setTextAndFormat=function(){var t=this.dateObject.getTextAndFormat(),e=t.text,i=t.format;this.currentFormat=i,this.currentText=e},e.prototype.setElementValue=function(t){this.element.value=t},e.prototype.getStepFromSymbol=function(t){switch(t){case"S":return Number(this.options.steps.millisecond);case"s":return Number(this.options.steps.second);case"m":return Number(this.options.steps.minute);case"h":case"H":return Number(this.options.steps.hour);case"M":return Number(this.options.steps.month);case"d":case"E":return Number(this.options.steps.day);case"y":return Number(this.options.steps.year);default:return 1}},e.prototype.restorePreviousInputEventState=function(){this.restorePreviousElementValue(),this.restorePreviousElementSelection()},e.prototype.restorePreviousElementValue=function(){this.setElementValue(this.previousElementValue||"")},e.prototype.restorePreviousElementSelection=function(){var t=this.previousElementSelection,e=t.start,i=t.end;this.setSelection({start:e||0,end:i||0})},e.prototype.writeValue=function(t){this.verifyValue(t),this.dateObject=this.getDateObject(t),this.refreshElementValue()},e.prototype.verifyValue=function(t){if(t&&!h.isValidDate(t))throw new Error("The 'value' should be a valid JavaScript Date instance.")},e.prototype.refreshElementValue=function(){var t=this.element,e=this.isActive?this.inputFormat:this.displayFormat,i=this.dateObject.getTextAndFormat(e),n=i.text,s=i.format;this.currentFormat=s,this.currentText=n;var a=this.options.hasPlaceholder||h.isPresent(this.options.placeholder),r=!this.isActive&&a&&!this.dateObject.hasValue();a&&h.isPresent(this.options.placeholder)&&(t.placeholder=this.options.placeholder);var o=r?"":n;this.previousElementValue=this.elementValue,this.setElementValue(o)},e.prototype.caret=function(t,e){void 0===e&&(e=t);var i=void 0!==t,n=[t,t],s=this.element;if(!i||!this.options.disabled&&!this.options.readonly){try{void 0!==s.selectionStart&&(i&&(h.isDocumentAvailable()&&document.activeElement!==s&&s.focus(),s.setSelectionRange(t,e)),n=[s.selectionStart,s.selectionEnd])}catch(t){n=[]}return n}},e.prototype.selectNearestSegment=function(t){for(var e=t,i=t-1;e<this.currentFormat.length||i>=0;e++,i--){if(e<this.currentFormat.length&&"_"!==this.currentFormat[e])return void this.selectDateSegment(this.currentFormat[e]);if(i>=0&&"_"!==this.currentFormat[i])return void this.selectDateSegment(this.currentFormat[i])}},e.prototype.selectDateSegment=function(t){for(var e=-1,i=0,n=0;n<this.currentFormat.length;n++)this.currentFormat[n]===t&&(i=n+1,-1===e&&(e=n));e<0&&(e=0),this.caret(0,0),this.caret(e,i)},e.prototype.getDateObject=function(t){var e=(this.dateObject||{}||null).leadingZero;this.options.value=t;var i=this.createDateObject();return i.setLeadingZero(this.isActive?e:null),i},e.prototype.createDateObject=function(){var t=this.getDateObjectOptions();return new a.DateObject(h.extend({},t))},e.prototype.getDateObjectOptions=function(){return{intlService:this.options.intlService,formatPlaceholder:this.options.formatPlaceholder?this.options.formatPlaceholder:"formatPattern",format:this.inputFormat,cycleTime:this.options.cycleTime,twoDigitYearMax:this.options.twoDigitYearMax,autoCorrectParts:this.options.autoCorrectParts,value:this.options.value}},e.prototype.keyEventMatchesAutoSwitchKeys=function(t){var e=(this.options.autoSwitchKeys||[]).map((function(t){return t.toString().toLowerCase().trim()}));return e.indexOf(t.keyCode.toString())>=0||e.indexOf(t.keyCode)>=0||e.indexOf(t.key.toLowerCase().trim())>=0},e.prototype.autoFill=function(){var t,e,i,n,s,a,r=this.dateObject,o=new Date;(r.date||r.month||r.year||r.hours||r.minutes||r.seconds)&&(i=r.year?r.value.getFullYear():o.getFullYear(),e=r.month?r.value.getMonth():o.getMonth(),t=r.date?r.value.getDate():o.getDate(),n=r.hours?r.value.getHours():o.getHours(),s=r.minutes?r.value.getMinutes():o.getMinutes(),a=r.seconds?r.value.getSeconds():o.getSeconds(),r.setValue(new Date(i,e,t,n,s,a)),this.refreshElementValue(),this.triggerValueChange())},e}(u.Observable);e.DateInput=v},function(t,i){t.exports=e},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=i(9),a=i(3),r=i(2),o=i(1),l=/d|M|H|h|m|s/,h=function(){function t(t){var e=t.intlService,i=t.formatPlaceholder,s=t.format,a=t.cycleTime,r=void 0!==a&&a,l=t.twoDigitYearMax,h=void 0===l?o.Constants.twoDigitYearMax:l,u=t.value,c=void 0===u?null:u,d=t.autoCorrectParts,p=void 0===d||d;if(this.year=!0,this.month=!0,this.date=!0,this.hours=!0,this.minutes=!0,this.seconds=!0,this.milliseconds=!0,this.dayperiod=!0,this.leadingZero=null,this.typedMonthPart="",this.knownParts="adHhmMsEyS",this.symbols={E:"E",H:"H",M:"M",a:"a",d:"d",h:"h",m:"m",s:"s",y:"y",S:"S"},this._value=n.getDate(new Date),this.cycleTime=!1,this._partiallyInvalidDate={startDate:null,invalidDateParts:{E:{value:null,date:null,startDateOffset:0},H:{value:null,date:null,startDateOffset:0},M:{value:null,date:null,startDateOffset:0},a:{value:null,date:null,startDateOffset:0},d:{value:null,date:null,startDateOffset:0},h:{value:null,date:null,startDateOffset:0},m:{value:null,date:null,startDateOffset:0},s:{value:null,date:null,startDateOffset:0},y:{value:null,date:null,startDateOffset:0},S:{value:null,date:null,startDateOffset:0}}},this.setOptions({intlService:e,formatPlaceholder:i,format:s,cycleTime:r,twoDigitYearMax:h,value:c,autoCorrectParts:p}),c)this._value=n.cloneDate(c);else{this._value=n.getDate(new Date);for(var m=this.dateFormatString(this.value,this.format).symbols,v=0;v<m.length;v++)this.setExisting(m[v],!1)}}return Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(t){(!t||t instanceof Date)&&(this._value=t,this.resetInvalidDate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"localeId",{get:function(){for(var t=o.Constants.defaultLocaleId,e=Object.keys(this.intl.cldr),i=0;i<e.length;i++){var n=e[i],s=this.intl.cldr[n];if(s.name&&s.calendar&&s.numbers&&s.name!==o.Constants.defaultLocaleId){t=s.name;break}}return t},enumerable:!0,configurable:!0}),t.prototype.setOptions=function(t){this.intl=t.intlService,this.formatPlaceholder=t.formatPlaceholder||"wide",this.format=t.format,this.cycleTime=t.cycleTime,this.monthNames=this.allFormattedMonths(this.localeId),this.dayPeriods=this.allDayPeriods(this.localeId),this.twoDigitYearMax=t.twoDigitYearMax,this.autoCorrectParts=t.autoCorrectParts},t.prototype.setValue=function(t){t?n.isEqual(t,this._value)||(this._value=n.cloneDate(t),this.modifyExisting(!0)):(this._value=n.getDate(new Date),this.modifyExisting(!1)),this.resetInvalidDate()},t.prototype.hasValue=function(){var t=this;return this.intl.splitDateFormat(this.format,this.localeId).reduce((function(e,i){return e||"literal"!==i.type&&"dayperiod"!==i.type&&t.getExisting(i.pattern[0])}),!1)},t.prototype.getValue=function(){for(var t=0;t<this.knownParts.length;t++)if(!this.getExisting(this.knownParts[t]))return null;return n.cloneDate(this.value)},t.prototype.getFormattedDate=function(t){return this.intl.formatDate(this.getValue(),t,this.localeId)},t.prototype.getTextAndFormat=function(t){void 0===t&&(t="");var e=t||this.format,i=this.intl.formatDate(this.value,e,this.localeId),n=this.dateFormatString(this.value,e);if(!this.autoCorrectParts&&this._partiallyInvalidDate.startDate){for(var s="",o=this.intl.formatDate(this.value,e,this.localeId),l=this.getFormattedInvalidDates(e),h=0;h<o.length;h++){var u=n.symbols[h];if("literal"===n.partMap[h].type)s+=i[h];else if(this.getInvalidDatePartValue(u)){var c=this.getPartsForSegment(n,h);if("M"===u){var d=(r.parseToInt(this.getInvalidDatePartValue(u))+1).toString();if(c.length>2)s+=l[u][h];else if(this.getInvalidDatePartValue(u))s+=a.padZero(c.length-d.length)+d,h+=c.length-1;else s+=l[u][h]}else if(this.getInvalidDatePartValue(u)){d=this.getInvalidDatePartValue(u).toString();s+=a.padZero(c.length-d.length)+d,h+=c.length-1}else s+=l[u][h]}else s+=i[h]}i=s}return this.merge(i,n)},t.prototype.getFormattedInvalidDates=function(t){var e=this;void 0===t&&(t="");var i=t||this.format,n={E:"",H:"",M:"",a:"",d:"",h:"",m:"",s:"",y:"",S:""};return Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(t){var s=e.getInvalidDatePart(t).date;if(s){var a=e.intl.formatDate(s,i,e.localeId);n[t]=a}})),n},t.prototype.modifyExisting=function(t){for(var e=this.dateFormatString(this.value,this.format).symbols,i=0;i<e.length;i++)this.setExisting(e[i],t)},t.prototype.getExisting=function(t){switch(t){case"y":return this.year;case"M":case"L":return this.month;case"d":return this.date;case"E":return this.date&&this.month&&this.year;case"h":case"H":return this.hours;case"t":case"a":return this.dayperiod;case"m":return this.minutes;case"s":return this.seconds;case"S":return this.milliseconds;default:return!0}},t.prototype.setExisting=function(t,e){switch(t){case"y":this.year=e,!1===e&&this._value.setFullYear(2e3);break;case"M":this.month=e,!1===e&&this.autoCorrectParts&&this._value.setMonth(0);break;case"d":this.date=e;break;case"h":case"H":this.hours=e;break;case"t":case"a":this.dayperiod=e;break;case"m":this.minutes=e;break;case"s":this.seconds=e;break;case"S":this.milliseconds=e}this.getValue()&&this.resetInvalidDate()},t.prototype.modifyPart=function(t,e){if(r.isPresent(t)&&r.isPresent(e)&&0!==e){var i,s=n.cloneDate(this.value),a=!1,o="M"===t,l="d"===t||"E"===t,h=this.getExisting(t);if(this.autoCorrectParts||!l&&!o)switch(t){case"y":s.setFullYear(s.getFullYear()+e);break;case"M":s=n.addMonths(this.value,e);break;case"d":case"E":s.setDate(s.getDate()+e);break;case"h":case"H":s.setHours(s.getHours()+e),a=!0;break;case"m":s.setMinutes(s.getMinutes()+e),a=!0;break;case"s":s.setSeconds(s.getSeconds()+e),a=!0;break;case"S":s.setMilliseconds(s.getMilliseconds()+e);break;case"a":s.setHours(s.getHours()+12*e),a=!0}else{var u=this._partiallyInvalidDate.invalidDateParts||{},c=this.getInvalidDatePartValue(t),d=u.y.value||s.getFullYear(),p=u.M.value||s.getMonth(),m=u.d.value||u.E.value||s.getDate(),v=u.h.value||u.H.value||s.getHours(),f=u.m.value||s.getMinutes(),g=u.s.value||s.getSeconds(),y=u.S.value||s.getMilliseconds();switch(t){case"y":d+=e;break;case"M":p+=e;break;case"d":case"E":m+=e}if("M"===t){if((p<0||p>11)&&h)return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t);if(!h){if(p<0)p=r.clamp(p%11+1+11,0,11);else{var D=r.isPresent(c)?p:(e-1)%12;p=r.clamp(D,0,11)}p=r.clamp(p,0,11)}p=r.clamp(p,0,11)}else if("d"===t)if(h){if(m<=0||m>31)return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t)}else if(!h){if(r.isPresent(c)&&(m<=0||m>31))return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t);if(e<0){var E=r.isPresent(c)?m:31-Math.abs(e%31)+1;m=r.clamp(E,1,31)}else{E=r.isPresent(c)?m:e%31;m=r.clamp(E,1,31)}m=r.clamp(m,1,31)}var P=n.createDate(d,p,m,v,f,g,y),b=o||l?this.modifyDateSymbolWithValue(s,t,o?p:m):null,S=r.areDatePartsEqualTo(P,d,p,m,v,f,g,y);this.getValue()&&r.areDatePartsEqualTo(P,d,p,m,v,f,g,y)?(s=n.cloneDate(P),this.markDatePartsAsExisting()):o&&b?b.getMonth()===p?this.getExisting("d")?S?(s=n.cloneDate(P),this.resetInvalidDateSymbol(t)):(i=!0,this.setInvalidDatePart(t,{value:p,date:n.cloneDate(b),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)):S?(this.resetInvalidDateSymbol(t),s=n.cloneDate(P),this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d"))):(this.resetInvalidDateSymbol(t),s=n.cloneDate(b)):(i=!0,this.setInvalidDatePart(t,{value:p,date:n.cloneDate(b),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)):l&&b&&(b.getDate()===m?this.getExisting("M")?S?(s=n.cloneDate(P),this.resetInvalidDateSymbol(t)):(i=!0,this.setInvalidDatePart(t,{value:m,date:n.cloneDate(b),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)):S?(s=n.cloneDate(P),this.resetInvalidDateSymbol(t),this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M"))):(this.resetInvalidDateSymbol(t),s=n.cloneDate(b)):(i=!0,this.setInvalidDatePart(t,{value:m,date:n.cloneDate(this.value),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)))}this.shouldNormalizeCentury()&&(s=this.normalizeCentury(s)),a&&!this.cycleTime&&(s.getDate(),this._value.getDate()),i||(this.setExisting(t,!0),this._value=s,this.getValue()&&this.resetInvalidDate())}},t.prototype.parsePart=function(t){for(var e=t.symbol,i=t.currentChar,s=t.resetSegmentValue,o=t.cycleSegmentValue,l=t.rawTextValue,h=t.isDeleting,u=t.originalFormat,c=!o,d=this.dateFormatString(this.value,this.format),p=d.partMap.filter((function(t){return"literal"===t.type})).map((function(t,e){return{datePartIndex:e,type:t.type,pattern:t.pattern,literal:""}})),m=d.partMap.map((function(t){return{type:t.type,pattern:t.pattern,text:""}})),v=0;v<p.length;v++){for(var f=p[v],g=0;g<f.pattern.length;g++)p[v+g]&&(p[v+g].literal=f.pattern[g]);v+=f.pattern.length-1}for(v=0;v<m.length;v++){for(f=m[v],g=0;g<f.pattern.length;g++)m[v+g]&&(m[v+g].text=f.pattern[g]);v+=f.pattern.length-1}var y={value:null,switchToNext:!1,resetPart:c&&"M"===e&&d.partMap.filter((function(t){return"month"===t.type})).some((function(t){return t.pattern.length>2})),hasInvalidDatePart:!1};if(!i){if(!c)return this.resetLeadingZero(),this.setExisting(e,!1),this.resetInvalidDateSymbol(e),r.extend(y,{value:null,switchToNext:!1});for(v=0;v<p.length;v++){var D=p[v].literal,E=l.startsWith(D),P=l.endsWith(D),b=l.indexOf(D+D)>=0;if(E||P||b)return this.resetLeadingZero(),this.setExisting(e,!1),this.resetInvalidDateSymbol(e),r.extend(y,{value:null,switchToNext:!1})}}var S=this.intl.formatDate(this.value,this.format,this.localeId),M=d.symbols,I=!1,x="",O="",w="",C="",F="",V="",k="";for(v=0;v<m.length;v++)k+=m[v].text;var _=this.format===M||this.format===k||this.format===u||this.format.length===u.length,T=(_?k:u).indexOf(e),j=(_?k:u).lastIndexOf(e)-T+1,A=u.length-l.length;if(c||!c&&!this.autoCorrectParts){for(v=0;v<S.length;v++){if(M[v]===e)O+=this.getExisting(e)?S[v]:"0",A>0?w.length+A<j&&(w+=l[v]||""):w+=l[v]||"",I=!0;else I?(V+=S[v],F+=S[v]):(x+=S[v],C+=S[v])}if(_&&(k.length<l.length?w+=i:!h&&(u.length,l.length),w.length>j))return r.extend(y,{value:null,switchToNext:!1});if(!_||_&&!this.autoCorrectParts){O="",w="",x="",V="",I=!1;for(v=0;v<u.length;v++){if(u[v]===e)O+=this.getExisting(e)?S[v]||"":"0",A>0?w.length+A<j&&(w+=l[v]||""):w+=l[v]||"",I=!0;else I?V+=l[v-A]||"":x+=l[v]||""}u.length<l.length&&(w+=i)}}if(!c)if(this.autoCorrectParts){O="",w="",x="",V="",I=!1;for(v=0;v<S.length;v++){if(M[v]===e)O+=this.getExisting(e)?S[v]:"0",I=!0;else I?V+=S[v]:x+=S[v]}}else O=s?w:O;var N=null,L=this.matchMonth(i),K=this.matchDayPeriod(i,e),W="0"===i,H=this.leadingZero||{};W?("0"===w&&(w=O),0!==r.parseToInt(s?i:(c?w:O)+i)||this.isAbbrMonth(d.partMap,e)||this.incrementLeadingZero(e)):this.resetLeadingZero();var B=this.partPattern(d.partMap,e),R=B?B.pattern:null,Z=this.patternLength(R)||R.length;if(c&&h&&!w)return this.setExisting(e,!1),r.extend(y,{value:null,switchToNext:!1});var Y=O.length-3,U=!0,q=c?w:O;for(v=Math.max(0,Y);v<=O.length&&U;v++){q=s?i:c?w:O.substring(v)+i,!c&&this.autoCorrectParts||(U=!1,q=a.unpadZero(q),q=a.padZero(Z-q.length)+q);var z=parseInt(q,10),G=x+q+V;N=this.intl.parseDate(G,this.format,this.localeId);var J=!1;c&&!r.isValidDate(N)&&this.autoCorrectParts&&(N=this.intl.parseDate(C+q+F,this.format,this.localeId),J=!0);var Q=!isNaN(parseInt(i,10))||c&&h&&""===i;if(!N&&!isNaN(z)&&Q&&this.autoCorrectParts){if("M"===e&&!L){var X=z-1;X>-1&&X<12&&((N=n.cloneDate(this.value)).setMonth(X),N.getMonth()!==X&&(N=n.lastDayOfMonth(n.addMonths(N,-1))))}"y"===e&&(N=n.createDate(parseInt(q,10),this.month?this.value.getMonth():0,this.date?this.value.getDate():1,this.hours?this.value.getHours():0,this.minutes?this.value.getMinutes():0,this.seconds?this.value.getSeconds():0,this.milliseconds?this.value.getMilliseconds():0),(c&&r.isValidDate(N)||!c&&N)&&this.date&&N.getDate()!==this.value.getDate()&&(N=n.lastDayOfMonth(n.addMonths(N,-1))))}if(c&&r.isValidDate(N)||!c&&N){var $=this.peek(q,R),tt=J?""+C+$+F:""+x+$+V,et=this.intl.parseDate(tt,this.format,this.localeId),it=((this.leadingZero||{})[e]||0)+a.unpadZero(q).length>=Z,nt=null===et||(H[e]?R.length<=q.length:it);return this.shouldNormalizeCentury()&&(N=this.normalizeCentury(N)),this._value=N,this.setExisting(e,!0),this.resetInvalidDateSymbol(e),this.autoCorrectParts||("M"===e?this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d")):"d"===e&&this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M")),this.hasInvalidDatePart()||this.markDatePartsAsExisting()),r.extend(y,{value:this.value,switchToNext:nt})}}if(L&&(N=this.intl.parseDate(x+L+V,this.format,this.localeId)))return this._value=N,this.setExisting(e,!0),r.extend(y,{value:this.value,switchToNext:!1});if(K&&(N=this.intl.parseDate(x+K+V,this.format)||this.intl.parseDate(C+K+F,this.format)))return this._value=N,this.setExisting(e,!0),r.extend(y,{value:this.value,switchToNext:!0});if(W&&this.setExisting(e,!1),!this.autoCorrectParts){var st=void 0,at=c?w:q,rt=r.parseToInt(at);if(r.isNumber(rt)){if("d"===e&&(rt<=0||rt>31)||"M"===e&&(rt<0||rt>11))return r.extend(y,{value:null,switchToNext:!1});st="M"===e?rt-1:rt;var ot="M"===e,lt="d"===e,ht=n.cloneDate(this._value),ut=this._partiallyInvalidDate.invalidDateParts||{},ct=ut.y.value||ht.getFullYear(),dt=ot?st:ut.M.value||ht.getMonth(),pt=lt?st:ut.d.value||ut.E.value||ht.getDate(),mt=ut.h.value||ut.H.value||ht.getHours(),vt=ut.m.value||ht.getMinutes(),ft=ut.s.value||ht.getSeconds(),gt=ut.S.value||ht.getMilliseconds(),yt=n.createDate(ct,dt,pt,mt,vt,ft,gt),Dt=r.areDatePartsEqualTo(yt,ct,dt,pt,mt,vt,ft,gt),Et=ot||lt?this.modifyDateSymbolWithValue(ht,e,ot?dt:pt):null,Pt=!1;if(ot&&Et?Et.getMonth()===dt?this.getExisting("d")?Dt?(ht=n.cloneDate(yt),this.resetInvalidDateSymbol(e)):(Pt=!0,this.setInvalidDatePart(e,{value:dt,date:n.cloneDate(Et),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1)):Dt?(this.resetInvalidDateSymbol(e),ht=n.cloneDate(yt),this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d"))):(this.resetInvalidDateSymbol(e),ht=n.cloneDate(Et)):(Pt=!0,this.setInvalidDatePart(e,{value:dt,date:n.cloneDate(Et),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1)):lt&&Et&&(Et.getDate()===pt?this.getExisting("M")?Dt?(ht=n.cloneDate(yt),this.resetInvalidDateSymbol(e)):(Pt=!0,this.setInvalidDatePart(e,{value:pt,date:n.cloneDate(Et),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1)):Dt?(ht=n.cloneDate(yt),this.resetInvalidDateSymbol(e),this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M"))):(this.resetInvalidDateSymbol(e),ht=n.cloneDate(Et)):(Pt=!0,this.setInvalidDatePart(e,{value:pt,date:n.cloneDate(this.value),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1))),!Pt){if(this.setExisting(e,!0),c&&!r.isValidDate(N)){var bt=this.intl.parseDate(C+q+F,this.format,this.localeId);r.isValidDate(bt)&&(this._value=bt)}else this._value=ht;this.getValue()&&this.resetInvalidDate()}nt=!1;return nt="M"===e?rt>=2||at.length>=2:_?at.length===j:at.length>j,r.extend(y,{value:null,switchToNext:nt,hasInvalidDatePart:Pt})}}return r.extend(y,{value:null,switchToNext:!1})},t.prototype.symbolMap=function(t){return this.intl.splitDateFormat(this.format,this.localeId).reduce(a.dateSymbolMap,{})[t]},t.prototype.resetLeadingZero=function(){var t=null!==this.leadingZero;return this.setLeadingZero(null),t},t.prototype.setLeadingZero=function(t){this.leadingZero=t},t.prototype.getLeadingZero=function(){return this.leadingZero||{}},t.prototype.normalizeCentury=function(t){if(!r.isPresent(t))return t;var e=r.cropTwoDigitYear(t),i=this.getNormalizedCenturyBase(e);return r.setYears(t,i+e)},t.prototype.incrementLeadingZero=function(t){var e=this.leadingZero||{};e[t]=(e[t]||0)+1,this.leadingZero=e},t.prototype.isAbbrMonth=function(t,e){var i=this.partPattern(t,e);return"month"===i.type&&i.names},t.prototype.partPattern=function(t,e){return t.filter((function(t){return-1!==t.pattern.indexOf(e)}))[0]},t.prototype.peek=function(t,e){var i=t.replace(/^0*/,"")+"0";return a.padZero(e.length-i.length)+i},t.prototype.matchMonth=function(t){if(this.typedMonthPart+=t.toLowerCase(),0===this.monthNames.length)return"";for(;this.typedMonthPart.length>0;){for(var e=0;e<this.monthNames.length;e++)if(0===this.monthNames[e].toLowerCase().indexOf(this.typedMonthPart))return this.monthNames[e];var i=parseInt(this.typedMonthPart,10);if(i>=1&&i<=12&&i.toString()===this.typedMonthPart)return this.monthNames[i-1];this.typedMonthPart=this.typedMonthPart.substring(1,this.typedMonthPart.length)}return""},t.prototype.matchDayPeriod=function(t,e){var i=t.toLowerCase();if("a"===e&&this.dayPeriods){if(this.dayPeriods.am.toLowerCase().startsWith(i))return this.dayPeriods.am;if(this.dayPeriods.pm.toLowerCase().startsWith(i))return this.dayPeriods.pm}return""},t.prototype.allFormattedMonths=function(t){void 0===t&&(t="en");for(var e=this.intl.splitDateFormat(this.format,this.localeId),i=0;i<e.length;i++)if("month"===e[i].type&&e[i].names)return this.intl.dateFormatNames(t,e[i].names);return[]},t.prototype.allDayPeriods=function(t){void 0===t&&(t="en");for(var e=this.intl.splitDateFormat(this.format),i=0;i<e.length;i++)if("dayperiod"===e[i].type&&e[i].names)return this.intl.dateFormatNames(t,e[i].names);return null},t.prototype.patternLength=function(t){return"y"===t[0]?4:l.test(t)?2:0},t.prototype.dateFormatString=function(t,e){for(var i=this.intl.splitDateFormat(e,this.localeId),n=[],a=[],r=0;r<i.length;r++)for(var l=this.intl.formatDate(t,{pattern:i[r].pattern},this.localeId).length;l>0;)n.push(this.symbols[i[r].pattern[0]]||o.Constants.formatSeparator),a.push(i[r]),l--;var h=new s.Mask;return h.symbols=n.join(""),h.partMap=a,h},t.prototype.merge=function(t,e){for(var i="",n="",s=e.symbols,o=!1,l=0,h=this.getFormattedInvalidDates(s),u=s.length-1;u>=0;u--){var c=this.getPartsForSegment(e,u);if(-1===this.knownParts.indexOf(s[u])||this.getExisting(s[u]))this.autoCorrectParts?i=t[u]+i:t.length!==s.length?o?i=t[u]+i:l>0?(i=t[u]+i,--l<=0&&(o=!0)):i=(t[u+t.length-s.length]||"")+i:i=t[u]+i,n=s[u]+n;else{var d=s[u],p=0;if(this.autoCorrectParts||!this.autoCorrectParts&&!this.getInvalidDatePartValue(d)){for(;u>=0&&d===s[u];)u--;u++}if(this.leadingZero&&this.leadingZero[d])i="0"+i;else if(!this.autoCorrectParts&&this.getInvalidDatePartValue(d)){var m=this.getInvalidDatePartValue(d).toString();if("M"===d)if(m=(r.parseToInt(this.getInvalidDatePartValue(d))+1).toString(),c.length>2)i=h[d][u]+i;else m=(r.parseToInt(this.getInvalidDatePartValue(d))+1).toString(),i=a.padZero(c.length-m.length)+m+i,p=c.length-1,l=m.length-c.length;else i=a.padZero(c.length-m.length)+m+i,p=c.length-1,l=m.length-c.length}else i=this.dateFieldName(e.partMap[u])+i;for(;n.length<i.length;)n=s[u]+n;0!==p&&(u=u-p+(t.length-s.length))}}return{text:i,format:n}},t.prototype.dateFieldName=function(t){var e=this.formatPlaceholder||"wide";return e[t.type]?e[t.type]:"formatPattern"===e?t.pattern:this.intl.dateFieldName(Object.assign(t,{nameType:e}))},t.prototype.getNormalizedCenturyBase=function(t){return t>this.twoDigitYearMax?1900:2e3},t.prototype.shouldNormalizeCentury=function(){return this.intl.splitDateFormat(this.format).some((function(t){return"yy"===t.pattern}))},t.prototype.resetInvalidDate=function(){var t=this;this._partiallyInvalidDate.startDate=null,Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(e){t.resetInvalidDatePart(e)}))},t.prototype.resetInvalidDateSymbol=function(t){var e=this;this.resetInvalidDatePart(t);var i=!0;Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(t){e._partiallyInvalidDate.invalidDateParts[t]&&r.isPresent(e._partiallyInvalidDate.invalidDateParts[t].value)&&(i=!1)})),i&&this.resetInvalidDate()},t.prototype.resetInvalidDatePart=function(t){this._partiallyInvalidDate.invalidDateParts[t]&&(this._partiallyInvalidDate.invalidDateParts[t]={value:null,date:null,startDateOffset:0})},t.prototype.getInvalidDatePart=function(t){return this._partiallyInvalidDate.invalidDateParts[t]||{}},t.prototype.getInvalidDatePartValue=function(t){return(this._partiallyInvalidDate.invalidDateParts[t]||{}).value},t.prototype.setInvalidDatePart=function(t,e){var i=e.value,n=void 0===i?null:i,s=e.date,a=void 0===s?null:s,r=e.startDateOffset,o=void 0===r?0:r,l=e.startDate,h=void 0===l?null:l;this._partiallyInvalidDate.invalidDateParts[t]&&(this._partiallyInvalidDate.invalidDateParts[t].value=n,this._partiallyInvalidDate.invalidDateParts[t].date=a,this._partiallyInvalidDate.invalidDateParts[t].startDateOffset=o,this._partiallyInvalidDate.startDate=h)},t.prototype.hasInvalidDatePart=function(){var t=this,e=!1;return Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(i){t._partiallyInvalidDate.invalidDateParts[i]&&r.isPresent(t._partiallyInvalidDate.invalidDateParts[i].value)&&(e=!0)})),e},t.prototype.modifyDateSymbolWithOffset=function(t,e,i){var s=n.cloneDate(t),a=!1;switch(e){case"y":s.setFullYear(s.getFullYear()+i);break;case"M":s=n.addMonths(this.value,i);break;case"d":case"E":s.setDate(s.getDate()+i);break;case"h":case"H":s.setHours(s.getHours()+i),a=!0;break;case"m":s.setMinutes(s.getMinutes()+i),a=!0;break;case"s":s.setSeconds(s.getSeconds()+i),a=!0;break;case"S":s.setMilliseconds(s.getMilliseconds()+i);break;case"a":s.setHours(s.getHours()+12*i),a=!0}return{date:s,timeModified:a}},t.prototype.modifyDateSymbolWithValue=function(t,e,i){var s=n.cloneDate(t);switch(e){case"y":s.setFullYear(i);break;case"M":s=n.addMonths(t,i-t.getMonth());break;case"d":case"E":s.setDate(i);break;case"h":case"H":s.setHours(i);break;case"m":s.setMinutes(i);break;case"s":s.setSeconds(i);break;case"S":s.setMilliseconds(i);break;case"a":s.setHours(i)}return s},t.prototype.markDatePartsAsExisting=function(){this.modifyExisting(!0)},t.prototype.getPartsForSegment=function(t,e){for(var i=t.partMap[e],n=[],s=e;s<t.partMap.length;s++){var a=t.partMap[s];if(i.type!==a.type||i.pattern!==a.pattern)break;n.push(a)}for(s=e-1;s>=0;s--){a=t.partMap[s];if(i.type!==a.type||i.pattern!==a.pattern)break;n.unshift(a)}return n},t}();e.DateObject=h},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){this.symbols="",this.partMap=[]};e.Mask=n},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.KeyCode={BACKSPACE:8,DELETE:46,TAB:9,ENTER:13,ESCAPE:27,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40,SPACE:32,END:35,HOME:36,PAGE_UP:33,PAGE_DOWN:34}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(2),s={events:{}},a=function(){function t(t){this.options=n.extend({},s,t)}return t.prototype.destroy=function(){},t.prototype.trigger=function(t,e){void 0===e&&(e={});var i={defaultPrevented:!1,preventDefault:function(){i.defaultPrevented=!0}};return!!n.isFunction(this.options.events[t])&&(this.options.events[t](n.extend(i,e,{sender:this})),i.defaultPrevented)},t}();e.Observable=a},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.None="none",t.Caret="caret",t.Selection="selection"}(e.DateInputInteractionMode||(e.DateInputInteractionMode={}))}])}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@progress/kendo-date-math"),require("tslib")):"function"==typeof define&&define.amd?define([,],e):"object"==typeof exports?exports.KendoDateinputsCommon=e(require("@progress/kendo-date-math"),require("tslib")):t.KendoDateinputsCommon=e(t.KendoDateMath,t.self)}(window,(function(t,e){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(e,i){e.exports=t},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Constants={formatSeparator:"_",twoDigitYearMax:68,defaultDateFormat:"d",defaultLocaleId:"en"}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=i(0),a=function(t){return t&&"object"==typeof t&&!Array.isArray(t)},r=function(t){return t instanceof HTMLElement};e.isPresent=function(t){return null!=t},e.isDocumentAvailable=function(){return!!document},e.isNumber=function(t){return e.isPresent(t)&&"number"==typeof t&&!Number.isNaN(t)},e.parseToInt=function(t){return parseInt(t,10)},e.clamp=function(t,e,i){return Math.min(i,Math.max(e,t))},e.extend=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Object.assign.apply(Object,t)},e.deepExtend=function(t){for(var i,n,s=[],o=1;o<arguments.length;o++)s[o-1]=arguments[o];if(!s.length)return t;var l=s.shift();if(a(t)&&a(l))for(var h in l)r(l[h])?t[h]=l[h]:!a(l[h])||l[h]instanceof Date?e.extend(t,((n={})[h]=l[h],n)):(t[h]&&a(t[h])||e.extend(t,((i={})[h]={},i)),e.deepExtend(t[h],l[h]));return e.deepExtend.apply(void 0,[t].concat(s))},e.noop=function(){},e.isFunction=function(t){return"function"==typeof t},e.cropTwoDigitYear=function(t){return!e.isPresent(t)||isNaN(t.getTime())?0:Number(t.getFullYear().toString().slice(-2))},e.setYears=(n="setFullYear",function(t,e){var i=s.cloneDate(t);return i[n](e),i}),e.millisecondDigitsInFormat=function(t){var e=t&&t.match(/S+(\1)/);return e?e[0].length:0},e.millisecondStepFor=function(t){return Math.pow(10,3-t)},e.areDatePartsEqualTo=function(t,e,i,n,s,a,r,o){return!(!t||t.getFullYear()!==e||t.getMonth()!==i||t.getDate()!==n||t.getHours()!==s||t.getMinutes()!==a||t.getSeconds()!==r||t.getMilliseconds()!==o)},e.isValidDate=function(t){return e.isPresent(t)&&t.getTime&&e.isNumber(t.getTime())}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(1),s=i(4);e.padZero=function(t){return new Array(Math.max(t,0)).fill("0").join("")},e.unpadZero=function(t){return t.replace(/^0*/,"")},e.approximateStringMatching=function(t){var e=t.oldText,i=t.newText,a=t.formatPattern,r=t.selectionStart,o=t.isInCaretMode,l=t.keyEvent,h=r+e.length-i.length,u=e[h],c=e.substring(0,h),d=i.substring(0,r),p=[];if(c===d&&r>0)return p.push([a[r-1],d[r-1]]),p;if(0===c.indexOf(d)&&o&&(l.key===s.Key.DELETE||l.key===s.Key.BACKSPACE)||0===c.indexOf(d)&&!o&&(0===d.length||a[d.length-1]!==a[d.length])){var m="";o||1!==d.length||p.push([a[0],d[0]]);for(var f=d.length;f<c.length;f++)a[f]!==m&&a[f]!==n.Constants.formatSeparator&&(m=a[f],p.push([m,""]));return p}if(o&&(0===d.indexOf(c)||a[r-1]===n.Constants.formatSeparator)||!o&&(0===d.indexOf(c)||a[r-1]===n.Constants.formatSeparator)){var v=a[0];for(f=Math.max(0,c.length-1);f<a.length;f++)if(a[f]!==n.Constants.formatSeparator){v=a[f];break}return[[v,d[r-1]]]}return" "===d[d.length-1]||d[d.length-1]===u&&"_"===a[h]?[[a[r-1],n.Constants.formatSeparator]]:[[a[r-1],d[r-1]]]},e.dateSymbolMap=function(t,e){return t[e.pattern[0]]=e.type,t},e.isInRange=function(t,e,i){return null===t||!(e&&e>t||i&&i<t)}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Key={DELETE:"Delete",BACKSPACE:"Backspace",TAB:"Tab",ENTER:"Enter",ESCAPE:"Escape",ARROW_LEFT:"ArrowLeft",ARROW_UP:"ArrowUp",ARROW_RIGHT:"ArrowRight",ARROW_DOWN:"ArrowDown",SPACE:" ",END:"End",HOME:"Home",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown"}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(6);e.DateInput=n.DateInput},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,s=i(7),a=i(8),r=i(3),o=i(10),l=i(4),h=i(2),u=i(11),c=i(12),d=i(0),p=i(1),m={format:"d",hasPlaceholder:!1,placeholder:null,cycleTime:!0,locale:null,steps:{millisecond:1,second:1,minute:1,hour:1,day:1,month:1,year:1},formatPlaceholder:null,events:(n={},n.valueChange=null,n.input=null,n.inputEnd=null,n.focus=null,n.focusEnd=null,n.blur=null,n.blurEnd=null,n.keydown=null,n.mousewheel=null,n.change=null,n),selectNearestSegmentOnFocus:!1,selectPreviousSegmentOnBackspace:!1,enableMouseWheel:!1,allowCaretMode:!1,autoSwitchParts:!0,autoSwitchKeys:[],twoDigitYearMax:p.Constants.twoDigitYearMax,autoCorrectParts:!0,autoFill:!1},f=function(t){function e(e,i){var n=t.call(this,i)||this;return n.dateObject=null,n.currentText="",n.currentFormat="",n.interactionMode=c.DateInputInteractionMode.None,n.previousElementSelection={start:0,end:0},n.init(e,i),n}return s.__extends(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.dateObject&&this.dateObject.getValue()},enumerable:!0,configurable:!0}),e.prototype.init=function(t,e){var i=h.isValidDate(this.options.value)?d.cloneDate(this.options.value):new Date(e.formattedValue);h.isValidDate(i)||(i=null),this.element=t,this.options=h.extend({},m,e,{steps:s.__assign({},m.steps,e.steps)}),this.intl=this.options.intlService,this.dateObject=this.createDateObject(),this.dateObject.setValue(i),this.setTextAndFormat(),this.bindEvents(),this.resetSegmentValue=!0,this.interactionMode=c.DateInputInteractionMode.None,this.forceUpdate()},e.prototype.destroy=function(){this.unbindEvents(),this.dateObject=null,t.prototype.destroy.call(this)},e.prototype.bindEvents=function(){this.onElementDragStart=this.onElementDragStart.bind(this),this.element.addEventListener("dragStart",this.onElementDragStart),this.onElementDrop=this.onElementDrop.bind(this),this.element.addEventListener("drop",this.onElementDrop),this.onElementClick=this.onElementClick.bind(this),this.element.addEventListener("click",this.onElementClick),this.onElementMouseDown=this.onElementMouseDown.bind(this),this.element.addEventListener("mousedown",this.onElementMouseDown),this.element.addEventListener("touchstart",this.onElementMouseDown),this.onElementMouseUp=this.onElementMouseUp.bind(this),this.element.addEventListener("mouseup",this.onElementMouseUp),this.onElementInput=this.onElementInput.bind(this),this.element.addEventListener("input",this.onElementInput),this.onElementKeyDown=this.onElementKeyDown.bind(this),this.element.addEventListener("keydown",this.onElementKeyDown),this.onElementFocus=this.onElementFocus.bind(this),this.element.addEventListener("focus",this.onElementFocus),this.onElementBlur=this.onElementBlur.bind(this),this.element.addEventListener("blur",this.onElementBlur),this.onElementChange=this.onElementChange.bind(this),this.element.addEventListener("change",this.onElementChange),this.onElementPaste=this.onElementPaste.bind(this),this.element.addEventListener("paste",this.onElementPaste),this.onElementMouseWheel=this.onElementMouseWheel.bind(this),this.element.addEventListener("DOMMouseScroll",this.onElementMouseWheel),this.element.addEventListener("mousewheel",this.onElementMouseWheel)},e.prototype.unbindEvents=function(){this.element.removeEventListener("dragStart",this.onElementDragStart),this.element.removeEventListener("drop",this.onElementDrop),this.element.removeEventListener("touchstart",this.onElementMouseDown),this.element.removeEventListener("mousedown",this.onElementMouseDown),this.element.removeEventListener("mouseup",this.onElementMouseUp),this.element.removeEventListener("click",this.onElementClick),this.element.removeEventListener("input",this.onElementInput),this.element.removeEventListener("keydown",this.onElementKeyDown),this.element.removeEventListener("focus",this.onElementFocus),this.element.removeEventListener("blur",this.onElementBlur),this.element.removeEventListener("change",this.onElementChange),this.element.removeEventListener("paste",this.onElementPaste),this.element.removeEventListener("DOMMouseScroll",this.onElementMouseWheel),this.element.removeEventListener("mousewheel",this.onElementMouseWheel)},e.prototype.setOptions=function(t,e){void 0===e&&(e=!1),this.options=h.extend({},this.options,t,{steps:s.__assign({},m.steps,t.steps)}),this.setDateObjectOptions(),e&&(this.unbindEvents(),this.init(this.element,this.options))},e.prototype.setDateObjectOptions=function(){if(this.dateObject){var t=this.getDateObjectOptions();this.dateObject.setOptions(t)}},e.prototype.resetLocale=function(){this.unbindEvents(),this.init(this.element,this.options)},e.prototype.isInCaretMode=function(){return this.interactionMode===c.DateInputInteractionMode.Caret},e.prototype.focus=function(){this.element.focus(),this.options.selectNearestSegmentOnFocus&&this.selectNearestSegment(0)},e.prototype.onElementDragStart=function(t){t.preventDefault()},e.prototype.onElementDrop=function(t){t.preventDefault()},e.prototype.onElementMouseDown=function(){this.mouseDownStarted=!0,this.focusedPriorToMouseDown=this.isActive},e.prototype.onElementMouseUp=function(t){this.mouseDownStarted=!1,t.preventDefault()},e.prototype.onElementClick=function(t){this.mouseDownStarted=!1,this.switchedPartOnPreviousKeyAction=!1;var e=this.selection;if(this.isInCaretMode()&&this.forceUpdate(),3===t.detail);else if(this.isActive&&this.options.selectNearestSegmentOnFocus){var i=this.element.selectionStart!==this.element.selectionEnd,n=h.isPresent(this.options.placeholder)&&!this.dateObject.hasValue()&&!this.focusedPriorToMouseDown,s=!i&&n?0:this.caret()[0];this.selectNearestSegment(s)}else this.setSelection(this.selectionByIndex(e.start))},e.prototype.onElementInput=function(t){this.triggerInput({event:t});var e=this.elementValue;if(this.element&&this.dateObject){var i=this.switchedPartOnPreviousKeyAction;if(this.isPasteInProgress)return this.options.allowCaretMode&&(this.resetSegmentValue=!1),this.updateOnPaste(t),void(this.isPasteInProgress=!1);var n=this.keyDownEvent||{},s=n.keyCode===o.KeyCode.BACKSPACE||n.key===l.Key.BACKSPACE,a=n.keyCode===o.KeyCode.DELETE||n.key===l.Key.DELETE,u=this.interactionMode;!this.options.allowCaretMode||u===c.DateInputInteractionMode.Caret||a||s||(this.resetSegmentValue=!0),this.options.allowCaretMode?this.interactionMode=c.DateInputInteractionMode.Caret:this.interactionMode=c.DateInputInteractionMode.Selection;var m=this.isInCaretMode();if(m&&this.keyDownEvent.key===l.Key.SPACE)this.restorePreviousInputEventState();else{var f=this.dateObject&&this.dateObject.getValue(),v=this.dateObject?this.dateObject.value:null,g=this.dateObject.getTextAndFormat(),y=g.text,D=g.format;this.currentFormat=D;var E="";E=m&&(s||a||u===c.DateInputInteractionMode.Caret)?this.previousElementValue:y;var P=this.elementValue,b=r.approximateStringMatching({oldText:E,newText:P,formatPattern:this.currentFormat,selectionStart:this.selection.start,isInCaretMode:m,keyEvent:this.keyDownEvent});if(b&&b.length&&b[0]&&b[0][1]!==p.Constants.formatSeparator&&(this.switchedPartOnPreviousKeyAction=!1),!m||b&&0!==b.length){if(m&&1===b.length){if(!b[0]||!b[0][0])return void this.restorePreviousInputEventState();if(m&&b[0]&&(b[0][0]===p.Constants.formatSeparator||b[0][1]===p.Constants.formatSeparator))return void this.restorePreviousInputEventState()}var S=1===b.length&&b[0][1]===p.Constants.formatSeparator,M=[],x=!1,I=null;if(!S)for(var O=0;O<b.length;O++){var w=this.dateObject.parsePart({symbol:b[O][0],currentChar:b[O][1],resetSegmentValue:this.resetSegmentValue,cycleSegmentValue:!this.isInCaretMode(),rawTextValue:this.element.value,isDeleting:s||a,originalFormat:this.currentFormat});M.push(w),w.value||(I={type:"parse"}),x=w.switchToNext}this.options.autoSwitchParts||(x=!1),this.resetSegmentValue=!1;var C,V=this.options.format===this.currentFormat||h.isPresent(this.options.format)&&this.options.format.length>1,F=M[M.length-1],k=F&&!h.isPresent(F.value),T=m&&(s||a)&&k,_=!!F&&F.resetPart,A=this.dateObject.getValue(),j=!d.isEqual(f,A),N=this.dateObject.value,L=this.selection;if(m){var K=b&&b.length>0?b[0][0]:null,W=this.dateObject.getLeadingZero()[K];b.length&&b[0][0]!==p.Constants.formatSeparator?x?(this.forceUpdateWithSelection(),this.switchDateSegment(1)):_?(C=this.currentFormat[L.start])?(this.forceUpdate(),this.setSelection(this.selectionBySymbol(C))):this.restorePreviousInputEventState():T?(this.forceUpdate(),b.length&&b[0][0]!==p.Constants.formatSeparator&&this.setSelection(this.selectionBySymbol(b[0][0]))):k?"0"===t.data&&W||(h.isPresent(f)&&!h.isPresent(A)?this.restorePreviousInputEventState():!h.isPresent(f)&&h.isPresent(A)?this.forceUpdateWithSelection():h.isPresent(f)&&h.isPresent(A)?j?this.forceUpdateWithSelection():this.restorePreviousInputEventState():h.isPresent(f)||h.isPresent(A)?v!==N||this.restorePreviousInputEventState():this.forceUpdateWithSelection()):k||V||this.forceUpdateWithSelection():(this.options.autoSwitchParts||b[0][1]!==p.Constants.formatSeparator)&&this.setSelection(this.selectionBySymbol(b[0][0]))}else m||(this.forceUpdate(),b.length&&b[0][0]!==p.Constants.formatSeparator&&this.setSelection(this.selectionBySymbol(b[0][0])),this.options.autoSwitchParts?S?(this.resetSegmentValue=!0,i||this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0):x&&(this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0):F&&F.switchToNext?this.resetSegmentValue=!0:S&&(this.resetSegmentValue=!0,i||this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0),s&&this.options.selectPreviousSegmentOnBackspace&&this.switchDateSegment(-1));this.tryTriggerValueChange({oldValue:f,event:t}),this.triggerInputEnd({event:t,error:I,oldElementValue:e,newElementValue:this.elementValue}),m&&this.setTextAndFormat()}else this.restorePreviousInputEventState()}}},e.prototype.onElementFocus=function(t){this.triggerFocus({event:t})||(this.isActive=!0,this.interactionMode=c.DateInputInteractionMode.None,this.switchedPartOnPreviousKeyAction=!1,this.refreshElementValue(),this.mouseDownStarted||this.caret(0,this.elementValue.length),this.mouseDownStarted=!1,this.triggerFocusEnd({event:t}))},e.prototype.onElementBlur=function(t){this.resetSegmentValue=!0,this.isActive=!1,this.triggerBlur({event:t})||(this.options.autoFill&&this.autoFill(),this.interactionMode=c.DateInputInteractionMode.None,this.switchedPartOnPreviousKeyAction=!1,this.refreshElementValue(),this.triggerBlurEnd({event:t}))},e.prototype.onElementChange=function(t){this.triggerChange({event:t})},e.prototype.onElementKeyDown=function(t){if(!this.triggerKeyDown({event:t})){var e=this.selection,i=e.start,n=e.end,s=t;if(this.keyDownEvent=t,this.previousElementValue=this.element.value,this.previousElementSelection={start:i,end:n},this.keyEventMatchesAutoSwitchKeys(t)){var a=t.keyCode===o.KeyCode.TAB;if(!a)return t.preventDefault(),void this.switchDateSegment(1);var r=this.selection,l=r.start,h=r.end;if(t.shiftKey&&a?this.switchDateSegment(-1):this.switchDateSegment(1),l!==this.selection.start||h!==this.selection.end)return void t.preventDefault()}var u=this.currentFormat[this.selection.start],c=this.getStepFromSymbol(u),d=!1,p=this.elementValue;if(!(t.altKey||t.ctrlKey||t.metaKey||t.keyCode===o.KeyCode.TAB)){switch(t.keyCode){case o.KeyCode.ARROW_LEFT:this.switchDateSegment(-1),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ARROW_UP:this.modifyDateSegmentValue(c,u,s),p!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:p}),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ARROW_RIGHT:this.switchDateSegment(1),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ARROW_DOWN:this.modifyDateSegmentValue(-c,u,s),p!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:p}),d=!0,this.switchedPartOnPreviousKeyAction=!1;break;case o.KeyCode.ENTER:break;case o.KeyCode.HOME:this.selectNearestSegment(0),d=!0,this.switchedPartOnPreviousKeyAction=!1,this.resetSegmentValue=!0;break;case o.KeyCode.END:this.selectNearestSegment(this.elementValue.length),d=!0,this.switchedPartOnPreviousKeyAction=!1,this.resetSegmentValue=!0;break;default:return}d&&t.preventDefault()}}},e.prototype.onElementPaste=function(){this.isPasteInProgress=!0},e.prototype.onElementMouseWheel=function(t){var e=this.elementValue;if(this.options.enableMouseWheel&&!this.triggerMouseWheel({event:t})&&this.isActive){var i=t;i.shiftKey?this.switchDateSegment((i.wheelDelta||-i.detail)>0?-1:1):this.modifyDateSegmentValue((i.wheelDelta||-i.detail)>0?1:-1),i.returnValue=!1,i.preventDefault&&i.preventDefault(),i.stopPropagation&&i.stopPropagation(),e!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:e})}},e.prototype.updateOnPaste=function(t){var e=this.intl.parseDate(this.elementValue,this.inputFormat)||this.value;h.isPresent(e)&&this.dateObject.shouldNormalizeCentury()&&(e=this.dateObject.normalizeCentury(e));var i=this.dateObject&&this.dateObject.getValue();this.writeValue(e),this.tryTriggerValueChange({oldValue:i,event:t})},Object.defineProperty(e.prototype,"elementValue",{get:function(){return(this.element||{}).value||""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputFormat",{get:function(){return this.options.format?"string"==typeof this.options.format?this.options.format:this.options.format.inputFormat:p.Constants.defaultDateFormat},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayFormat",{get:function(){return this.options.format?"string"==typeof this.options.format?this.options.format:this.options.format.displayFormat:p.Constants.defaultDateFormat},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){var t={start:0,end:0};return null!==this.element&&void 0!==this.element.selectionStart&&(t={start:this.element.selectionStart,end:this.element.selectionEnd}),t},enumerable:!0,configurable:!0}),e.prototype.setSelection=function(t){this.element&&document.activeElement===this.element&&(this.element.setSelectionRange(t.start,t.end),t.start!==t.end&&(this.interactionMode=c.DateInputInteractionMode.Selection))},e.prototype.selectionBySymbol=function(t){for(var e=-1,i=0,n=0;n<this.currentFormat.length;n++)this.currentFormat[n]===t&&(i=n+1,-1===e&&(e=n));return e<0&&(e=0),this.options.autoCorrectParts||this.currentFormat.length===this.currentText.length||(this.currentFormat.length<this.currentText.length?i+=this.currentText.length-this.currentFormat.length:i=Math.max(0,i-(this.currentFormat.length-this.currentText.length))),{start:e,end:i}},e.prototype.selectionByIndex=function(t){for(var e={start:t,end:t},i=t,n=t-1;i<this.currentFormat.length||n>=0;i++,n--){if(i<this.currentFormat.length&&this.currentFormat[i]!==p.Constants.formatSeparator){e=this.selectionBySymbol(this.currentFormat[i]);break}if(n>=0&&this.currentFormat[n]!==p.Constants.formatSeparator){e=this.selectionBySymbol(this.currentFormat[n]);break}}return e},e.prototype.switchDateSegment=function(t){var e=this.selection;if(this.isInCaretMode()){var i=e.start,n=this.currentFormat[i-1],s="",a="";if(t<0){for(var r=i+t;r>=0;r--)if((a=this.currentFormat[r])!==p.Constants.formatSeparator&&a!==n){i=r,s=a;break}}else for(r=i+t;r<this.currentFormat.length;r++)if((a=this.currentFormat[r])!==p.Constants.formatSeparator&&a!==n){i=r,s=a;break}if(s)return this.forceUpdate(),this.setSelection(this.selectionBySymbol(s)),void(this.interactionMode=c.DateInputInteractionMode.Selection)}this.interactionMode=c.DateInputInteractionMode.None;var o=this.selection,l=o.start,h=o.end;if(l<h&&this.currentFormat[l]!==this.currentFormat[h-1])return this.setSelection(this.selectionByIndex(t>0?l:h-1)),this.resetSegmentValue=!0,void(this.interactionMode=c.DateInputInteractionMode.None);for(var u=this.currentFormat[l],d=l+t;d>0&&d<this.currentFormat.length&&(this.currentFormat[d]===u||this.currentFormat[d]===p.Constants.formatSeparator);)d+=t;if(this.currentFormat[d]!==p.Constants.formatSeparator){for(var m=d;m>=0&&m<this.currentFormat.length&&this.currentFormat[m]===this.currentFormat[d];)m+=t;d>m&&(m+1!==l||d+1!==h)?(this.setSelection({start:m+1,end:d+1}),this.resetSegmentValue=!0):d<m&&(d!==l||m!==h)&&(this.setSelection({start:d,end:m}),this.resetSegmentValue=!0),this.interactionMode=c.DateInputInteractionMode.None}},e.prototype.modifyDateSegmentValue=function(t,e,i){if(void 0===e&&(e=""),void 0===i&&(i={}),this.dateObject&&!this.options.readonly){var n=this.value,s=1,a=this.caret();if("S"===(e=e||this.currentFormat[a[0]])&&(!this.options.steps.millisecond||1===this.options.steps.millisecond)){var r=h.millisecondDigitsInFormat(this.inputFormat);s=h.millisecondStepFor(r)}this.dateObject.modifyPart(e,s*t),this.tryTriggerValueChange({oldValue:n,event:i}),this.forceUpdate(),this.setSelection(this.selectionBySymbol(e))}},e.prototype.tryTriggerValueChange=function(t){if(void 0===t&&(t={oldValue:null,event:{}}),!d.isEqual(this.value,t.oldValue))return this.triggerValueChange(t)},e.prototype.triggerValueChange=function(t){return void 0===t&&(t={oldValue:null,event:{}}),this.trigger("valueChange",h.extend(t,{value:this.value}))},e.prototype.triggerInput=function(t){return void 0===t&&(t={event:{}}),this.trigger("input",h.extend(t,{value:this.value}))},e.prototype.triggerInputEnd=function(t){return void 0===t&&(t={event:{},error:null,oldElementValue:"",newElementValue:""}),this.trigger("inputEnd",h.extend(t,{value:this.value}))},e.prototype.triggerFocus=function(t){return void 0===t&&(t={event:{}}),this.trigger("focus",h.extend({},t))},e.prototype.triggerFocusEnd=function(t){return void 0===t&&(t={event:{}}),this.trigger("focusEnd",h.extend({},t))},e.prototype.triggerBlur=function(t){return void 0===t&&(t={event:{}}),this.trigger("blur",h.extend({},t))},e.prototype.triggerBlurEnd=function(t){return void 0===t&&(t={event:{}}),this.trigger("blurEnd",h.extend({},t))},e.prototype.triggerChange=function(t){return void 0===t&&(t={event:{}}),this.trigger("change",h.extend(t,{value:this.value}))},e.prototype.triggerKeyDown=function(t){return void 0===t&&(t={event:{}}),this.trigger("keydown",h.extend({},t))},e.prototype.triggerMouseWheel=function(t){return void 0===t&&(t={event:{}}),this.trigger("mousewheel",h.extend({},t))},e.prototype.forceUpdate=function(){this.setTextAndFormat(),this.refreshElementValue()},e.prototype.forceUpdateWithSelection=function(){var t=this.selection,e=t.start,i=t.end,n=this.elementValue.length;this.forceUpdate();var s=this.elementValue.length-n;this.setSelection({start:e+s,end:i+s})},e.prototype.setTextAndFormat=function(){var t=this.dateObject.getTextAndFormat(),e=t.text,i=t.format;this.currentFormat=i,this.currentText=e},e.prototype.setElementValue=function(t){this.element.value=t},e.prototype.getStepFromSymbol=function(t){switch(t){case"S":return Number(this.options.steps.millisecond);case"s":return Number(this.options.steps.second);case"m":return Number(this.options.steps.minute);case"h":case"H":return Number(this.options.steps.hour);case"M":return Number(this.options.steps.month);case"d":case"E":return Number(this.options.steps.day);case"y":return Number(this.options.steps.year);default:return 1}},e.prototype.restorePreviousInputEventState=function(){this.restorePreviousElementValue(),this.restorePreviousElementSelection()},e.prototype.restorePreviousElementValue=function(){this.setElementValue(this.previousElementValue||"")},e.prototype.restorePreviousElementSelection=function(){var t=this.previousElementSelection,e=t.start,i=t.end;this.setSelection({start:e||0,end:i||0})},e.prototype.writeValue=function(t){this.verifyValue(t),this.dateObject=this.getDateObject(t),this.refreshElementValue()},e.prototype.verifyValue=function(t){if(t&&!h.isValidDate(t))throw new Error("The 'value' should be a valid JavaScript Date instance.")},e.prototype.refreshElementValue=function(){var t=this.element,e=this.isActive?this.inputFormat:this.displayFormat,i=this.dateObject.getTextAndFormat(e),n=i.text,s=i.format;this.currentFormat=s,this.currentText=n;var a=this.options.hasPlaceholder||h.isPresent(this.options.placeholder),r=!this.isActive&&a&&!this.dateObject.hasValue();a&&h.isPresent(this.options.placeholder)&&(t.placeholder=this.options.placeholder);var o=r?"":n;this.previousElementValue=this.elementValue,this.setElementValue(o)},e.prototype.caret=function(t,e){void 0===e&&(e=t);var i=void 0!==t,n=[t,t],s=this.element;if(!i||!this.options.disabled&&!this.options.readonly){try{void 0!==s.selectionStart&&(i&&(h.isDocumentAvailable()&&document.activeElement!==s&&s.focus(),s.setSelectionRange(t,e)),n=[s.selectionStart,s.selectionEnd])}catch(t){n=[]}return n}},e.prototype.selectNearestSegment=function(t){for(var e=t,i=t-1;e<this.currentFormat.length||i>=0;e++,i--){if(e<this.currentFormat.length&&"_"!==this.currentFormat[e])return void this.selectDateSegment(this.currentFormat[e]);if(i>=0&&"_"!==this.currentFormat[i])return void this.selectDateSegment(this.currentFormat[i])}},e.prototype.selectDateSegment=function(t){for(var e=-1,i=0,n=0;n<this.currentFormat.length;n++)this.currentFormat[n]===t&&(i=n+1,-1===e&&(e=n));e<0&&(e=0),this.caret(0,0),this.caret(e,i)},e.prototype.getDateObject=function(t){var e=(this.dateObject||{}||null).leadingZero;this.options.value=t;var i=this.createDateObject();return i.setLeadingZero(this.isActive?e:null),i},e.prototype.createDateObject=function(){var t=this.getDateObjectOptions();return new a.DateObject(h.extend({},t))},e.prototype.getDateObjectOptions=function(){return{intlService:this.options.intlService,formatPlaceholder:this.options.formatPlaceholder?this.options.formatPlaceholder:"formatPattern",format:this.inputFormat,cycleTime:this.options.cycleTime,twoDigitYearMax:this.options.twoDigitYearMax,autoCorrectParts:this.options.autoCorrectParts,value:this.options.value}},e.prototype.keyEventMatchesAutoSwitchKeys=function(t){var e=(this.options.autoSwitchKeys||[]).map((function(t){return t.toString().toLowerCase().trim()}));return e.indexOf(t.keyCode.toString())>=0||e.indexOf(t.keyCode)>=0||e.indexOf(t.key.toLowerCase().trim())>=0},e.prototype.autoFill=function(){var t,e,i,n,s,a,r=this.dateObject,o=new Date;(r.date||r.month||r.year||r.hours||r.minutes||r.seconds)&&(i=r.year?r.value.getFullYear():o.getFullYear(),e=r.month?r.value.getMonth():o.getMonth(),t=r.date?r.value.getDate():o.getDate(),n=r.hours?r.value.getHours():o.getHours(),s=r.minutes?r.value.getMinutes():o.getMinutes(),a=r.seconds?r.value.getSeconds():o.getSeconds(),r.setValue(new Date(i,e,t,n,s,a)),this.refreshElementValue(),this.triggerValueChange())},e}(u.Observable);e.DateInput=f},function(t,i){t.exports=e},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(0),s=i(9),a=i(3),r=i(2),o=i(1),l=/d|M|H|h|m|s/,h=function(){function t(t){var e=t.intlService,i=t.formatPlaceholder,s=t.format,a=t.cycleTime,r=void 0!==a&&a,l=t.twoDigitYearMax,h=void 0===l?o.Constants.twoDigitYearMax:l,u=t.value,c=void 0===u?null:u,d=t.autoCorrectParts,p=void 0===d||d;if(this.year=!0,this.month=!0,this.date=!0,this.hours=!0,this.minutes=!0,this.seconds=!0,this.milliseconds=!0,this.dayperiod=!0,this.leadingZero=null,this.typedMonthPart="",this.knownParts="adHhmMsEyS",this.symbols={E:"E",H:"H",M:"M",a:"a",d:"d",h:"h",m:"m",s:"s",y:"y",S:"S"},this._value=this.getDefaultDate(),this.cycleTime=!1,this._partiallyInvalidDate={startDate:null,invalidDateParts:{E:{value:null,date:null,startDateOffset:0},H:{value:null,date:null,startDateOffset:0},M:{value:null,date:null,startDateOffset:0},a:{value:null,date:null,startDateOffset:0},d:{value:null,date:null,startDateOffset:0},h:{value:null,date:null,startDateOffset:0},m:{value:null,date:null,startDateOffset:0},s:{value:null,date:null,startDateOffset:0},y:{value:null,date:null,startDateOffset:0},S:{value:null,date:null,startDateOffset:0}}},this.setOptions({intlService:e,formatPlaceholder:i,format:s,cycleTime:r,twoDigitYearMax:h,value:c,autoCorrectParts:p}),c)this._value=n.cloneDate(c);else{this._value=this.getDefaultDate();for(var m=this.dateFormatString(this.value,this.format).symbols,f=0;f<m.length;f++)this.setExisting(m[f],!1)}}return Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(t){(!t||t instanceof Date)&&(this._value=t,this.resetInvalidDate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"localeId",{get:function(){for(var t=o.Constants.defaultLocaleId,e=Object.keys(this.intl.cldr),i=0;i<e.length;i++){var n=e[i],s=this.intl.cldr[n];if(s.name&&s.calendar&&s.numbers&&s.name!==o.Constants.defaultLocaleId){t=s.name;break}}return t},enumerable:!0,configurable:!0}),t.prototype.setOptions=function(t){this.intl=t.intlService,this.formatPlaceholder=t.formatPlaceholder||"wide",this.format=t.format,this.cycleTime=t.cycleTime,this.monthNames=this.allFormattedMonths(this.localeId),this.dayPeriods=this.allDayPeriods(this.localeId),this.twoDigitYearMax=t.twoDigitYearMax,this.autoCorrectParts=t.autoCorrectParts},t.prototype.setValue=function(t){t?n.isEqual(t,this._value)||(this._value=n.cloneDate(t),this.modifyExisting(!0)):(this._value=this.getDefaultDate(),this.modifyExisting(!1)),this.resetInvalidDate()},t.prototype.hasValue=function(){var t=this;return this.intl.splitDateFormat(this.format,this.localeId).reduce((function(e,i){return e||"literal"!==i.type&&"dayperiod"!==i.type&&t.getExisting(i.pattern[0])}),!1)},t.prototype.getValue=function(){for(var t=0;t<this.knownParts.length;t++)if(!this.getExisting(this.knownParts[t]))return null;return n.cloneDate(this.value)},t.prototype.createDefaultDate=function(){return n.createDate(2e3,0,31)},t.prototype.getDefaultDate=function(){return n.getDate(this.createDefaultDate())},t.prototype.getFormattedDate=function(t){return this.intl.formatDate(this.getValue(),t,this.localeId)},t.prototype.getTextAndFormat=function(t){void 0===t&&(t="");var e=t||this.format,i=this.intl.formatDate(this.value,e,this.localeId),n=this.dateFormatString(this.value,e);if(!this.autoCorrectParts&&this._partiallyInvalidDate.startDate){for(var s="",o=this.intl.formatDate(this.value,e,this.localeId),l=this.getFormattedInvalidDates(e),h=0;h<o.length;h++){var u=n.symbols[h];if("literal"===n.partMap[h].type)s+=i[h];else if(this.getInvalidDatePartValue(u)){var c=this.getPartsForSegment(n,h);if("M"===u){var d=(r.parseToInt(this.getInvalidDatePartValue(u))+1).toString();if(c.length>2)s+=l[u][h];else if(this.getInvalidDatePartValue(u))s+=a.padZero(c.length-d.length)+d,h+=c.length-1;else s+=l[u][h]}else if(this.getInvalidDatePartValue(u)){d=this.getInvalidDatePartValue(u).toString();s+=a.padZero(c.length-d.length)+d,h+=c.length-1}else s+=l[u][h]}else s+=i[h]}i=s}return this.merge(i,n)},t.prototype.getFormattedInvalidDates=function(t){var e=this;void 0===t&&(t="");var i=t||this.format,n={E:"",H:"",M:"",a:"",d:"",h:"",m:"",s:"",y:"",S:""};return Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(t){var s=e.getInvalidDatePart(t).date;if(s){var a=e.intl.formatDate(s,i,e.localeId);n[t]=a}})),n},t.prototype.modifyExisting=function(t){for(var e=this.dateFormatString(this.value,this.format).symbols,i=0;i<e.length;i++)this.setExisting(e[i],t)},t.prototype.getExisting=function(t){switch(t){case"y":return this.year;case"M":case"L":return this.month;case"d":return this.date;case"E":return this.date&&this.month&&this.year;case"h":case"H":return this.hours;case"t":case"a":return this.dayperiod;case"m":return this.minutes;case"s":return this.seconds;case"S":return this.milliseconds;default:return!0}},t.prototype.setExisting=function(t,e){switch(t){case"y":this.year=e,!1===e&&this._value.setFullYear(2e3);break;case"M":this.month=e,!1===e&&this.autoCorrectParts&&this._value.setMonth(0);break;case"d":this.date=e;break;case"h":case"H":this.hours=e;break;case"t":case"a":this.dayperiod=e;break;case"m":this.minutes=e;break;case"s":this.seconds=e;break;case"S":this.milliseconds=e}this.getValue()&&this.resetInvalidDate()},t.prototype.modifyPart=function(t,e){if(r.isPresent(t)&&r.isPresent(e)&&0!==e){var i,s=n.cloneDate(this.value),a=!1,o="M"===t,l="d"===t||"E"===t,h=this.getExisting(t);if(this.autoCorrectParts||!l&&!o)switch(t){case"y":s.setFullYear(s.getFullYear()+e);break;case"M":s=n.addMonths(this.value,e);break;case"d":case"E":s.setDate(s.getDate()+e);break;case"h":case"H":s.setHours(s.getHours()+e),a=!0;break;case"m":s.setMinutes(s.getMinutes()+e),a=!0;break;case"s":s.setSeconds(s.getSeconds()+e),a=!0;break;case"S":s.setMilliseconds(s.getMilliseconds()+e);break;case"a":s.setHours(s.getHours()+12*e),a=!0}else{var u=this._partiallyInvalidDate.invalidDateParts||{},c=this.getInvalidDatePartValue(t),d=u.y.value||s.getFullYear(),p=u.M.value||s.getMonth(),m=u.d.value||u.E.value||s.getDate(),f=u.h.value||u.H.value||s.getHours(),v=u.m.value||s.getMinutes(),g=u.s.value||s.getSeconds(),y=u.S.value||s.getMilliseconds();switch(t){case"y":d+=e;break;case"M":p+=e;break;case"d":case"E":m+=e}if("M"===t){if((p<0||p>11)&&h)return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t);if(!h){if(p<0)p=r.clamp(p%11+1+11,0,11);else{var D=r.isPresent(c)?p:(e-1)%12;p=r.clamp(D,0,11)}p=r.clamp(p,0,11)}p=r.clamp(p,0,11)}else if("d"===t)if(h){if(m<=0||m>31)return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t)}else if(!h){if(r.isPresent(c)&&(m<=0||m>31))return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t);if(e<0){var E=r.isPresent(c)?m:31-Math.abs(e%31)+1;m=r.clamp(E,1,31)}else{E=r.isPresent(c)?m:e%31;m=r.clamp(E,1,31)}m=r.clamp(m,1,31)}var P=n.createDate(d,p,m,f,v,g,y),b=o||l?this.modifyDateSymbolWithValue(s,t,o?p:m):null,S=r.areDatePartsEqualTo(P,d,p,m,f,v,g,y);this.getValue()&&r.areDatePartsEqualTo(P,d,p,m,f,v,g,y)?(s=n.cloneDate(P),this.markDatePartsAsExisting()):o&&b?b.getMonth()===p?this.getExisting("d")?S?(s=n.cloneDate(P),this.resetInvalidDateSymbol(t)):(i=!0,this.setInvalidDatePart(t,{value:p,date:n.cloneDate(b),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)):S?(this.resetInvalidDateSymbol(t),s=n.cloneDate(P),this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d"))):(this.resetInvalidDateSymbol(t),s=n.cloneDate(b)):(i=!0,this.setInvalidDatePart(t,{value:p,date:n.cloneDate(b),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)):l&&b&&(b.getDate()===m?this.getExisting("M")?S?(s=n.cloneDate(P),this.resetInvalidDateSymbol(t)):(i=!0,this.setInvalidDatePart(t,{value:m,date:n.cloneDate(b),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)):S?(s=n.cloneDate(P),this.resetInvalidDateSymbol(t),this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M"))):(this.resetInvalidDateSymbol(t),s=n.cloneDate(b)):(i=!0,this.setInvalidDatePart(t,{value:m,date:n.cloneDate(this.value),startDateOffset:e,startDate:n.cloneDate(this.value)}),this.setExisting(t,!1)))}this.shouldNormalizeCentury()&&(s=this.normalizeCentury(s)),a&&!this.cycleTime&&(s.getDate(),this._value.getDate()),i||(this.setExisting(t,!0),this._value=s,this.getValue()&&this.resetInvalidDate())}},t.prototype.parsePart=function(t){for(var e=t.symbol,i=t.currentChar,s=t.resetSegmentValue,o=t.cycleSegmentValue,l=t.rawTextValue,h=t.isDeleting,u=t.originalFormat,c=!o,d=this.dateFormatString(this.value,this.format),p=d.partMap.filter((function(t){return"literal"===t.type})).map((function(t,e){return{datePartIndex:e,type:t.type,pattern:t.pattern,literal:""}})),m=d.partMap.map((function(t){return{type:t.type,pattern:t.pattern,text:""}})),f=0;f<p.length;f++){for(var v=p[f],g=0;g<v.pattern.length;g++)p[f+g]&&(p[f+g].literal=v.pattern[g]);f+=v.pattern.length-1}for(f=0;f<m.length;f++){for(v=m[f],g=0;g<v.pattern.length;g++)m[f+g]&&(m[f+g].text=v.pattern[g]);f+=v.pattern.length-1}var y={value:null,switchToNext:!1,resetPart:c&&"M"===e&&d.partMap.filter((function(t){return"month"===t.type})).some((function(t){return t.pattern.length>2})),hasInvalidDatePart:!1};if(!i){if(!c)return this.resetLeadingZero(),this.setExisting(e,!1),this.resetInvalidDateSymbol(e),r.extend(y,{value:null,switchToNext:!1});for(f=0;f<p.length;f++){var D=p[f].literal,E=l.startsWith(D),P=l.endsWith(D),b=l.indexOf(D+D)>=0;if(E||P||b)return this.resetLeadingZero(),this.setExisting(e,!1),this.resetInvalidDateSymbol(e),r.extend(y,{value:null,switchToNext:!1})}}var S=this.intl.formatDate(this.value,this.format,this.localeId),M=d.symbols,x=!1,I="",O="",w="",C="",V="",F="",k="";for(f=0;f<m.length;f++)k+=m[f].text;var T=this.format===M||this.format===k||this.format===u||this.format.length===u.length,_=(T?k:u).indexOf(e),A=(T?k:u).lastIndexOf(e)-_+1,j=u.length-l.length;if(c||!c&&!this.autoCorrectParts){for(f=0;f<S.length;f++){if(M[f]===e)O+=this.getExisting(e)?S[f]:"0",j>0?w.length+j<A&&(w+=l[f]||""):w+=l[f]||"",x=!0;else x?(F+=S[f],V+=S[f]):(I+=S[f],C+=S[f])}if(T&&(k.length<l.length?w+=i:!h&&(u.length,l.length),w.length>A))return r.extend(y,{value:null,switchToNext:!1});if(!T||T&&!this.autoCorrectParts){O="",w="",I="",F="",x=!1;for(f=0;f<u.length;f++){if(u[f]===e)O+=this.getExisting(e)?S[f]||"":"0",j>0?w.length+j<A&&(w+=l[f]||""):w+=l[f]||"",x=!0;else x?F+=l[f-j]||"":I+=l[f]||""}u.length<l.length&&(w+=i)}}if(!c)if(this.autoCorrectParts){O="",w="",I="",F="",x=!1;for(f=0;f<S.length;f++){if(M[f]===e)O+=this.getExisting(e)?S[f]:"0",x=!0;else x?F+=S[f]:I+=S[f]}}else O=s?w:O;var N=null,L=this.matchMonth(i),K=this.matchDayPeriod(i,e),W="0"===i,B=this.leadingZero||{};W?("0"===w&&(w=O),0!==r.parseToInt(s?i:(c?w:O)+i)||this.isAbbrMonth(d.partMap,e)||this.incrementLeadingZero(e)):this.resetLeadingZero();var H=this.partPattern(d.partMap,e),Z=H?H.pattern:null,R=this.patternLength(Z)||Z.length;if(c&&h&&!w)return this.setExisting(e,!1),r.extend(y,{value:null,switchToNext:!1});var Y=O.length-3,U=!0,q=c?w:O;for(f=Math.max(0,Y);f<=O.length&&U;f++){q=s?i:c?w:O.substring(f)+i,!c&&this.autoCorrectParts||(U=!1,q=a.unpadZero(q),q=a.padZero(R-q.length)+q);var z=parseInt(q,10),G=I+q+F;N=this.intl.parseDate(G,this.format,this.localeId);var J=!1;c&&!r.isValidDate(N)&&this.autoCorrectParts&&(N=this.intl.parseDate(C+q+V,this.format,this.localeId),J=!0);var Q=!isNaN(parseInt(i,10))||c&&h&&""===i;if(!N&&!isNaN(z)&&Q&&this.autoCorrectParts){if("M"===e&&!L){var X=z-1;X>-1&&X<12&&((N=n.cloneDate(this.value)).setMonth(X),N.getMonth()!==X&&(N=n.lastDayOfMonth(n.addMonths(N,-1))))}"y"===e&&(N=n.createDate(parseInt(q,10),this.month?this.value.getMonth():0,this.date?this.value.getDate():1,this.hours?this.value.getHours():0,this.minutes?this.value.getMinutes():0,this.seconds?this.value.getSeconds():0,this.milliseconds?this.value.getMilliseconds():0),(c&&r.isValidDate(N)||!c&&N)&&this.date&&N.getDate()!==this.value.getDate()&&(N=n.lastDayOfMonth(n.addMonths(N,-1))))}if(c&&r.isValidDate(N)||!c&&N){var $=this.isPeekDateOverflowingDatePart({useBasePrefixAndSuffix:J,middle:q,patternValue:Z,basePrefix:C,baseSuffix:V,prefix:I,suffix:F,symbol:e,patternLength:R,leadingZero:B}),tt=$.switchToNext;return this.shouldNormalizeCentury()&&(N=this.normalizeCentury(N)),this._value=N,this.setExisting(e,!0),this.resetInvalidDateSymbol(e),this.autoCorrectParts||("M"===e?this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d")):"d"===e&&this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M")),this.hasInvalidDatePart()||(this.markDatePartsAsExisting(),$.peekedDate||!$.switchToNext||this.autoCorrectParts||"M"===e||"d"===e&&30===$.parsedPeekedValue&&1===this.value.getMonth()&&(tt=!1))),r.extend(y,{value:this.value,switchToNext:tt})}}if(L&&(N=this.intl.parseDate(I+L+F,this.format,this.localeId)))return this._value=N,this.setExisting(e,!0),r.extend(y,{value:this.value,switchToNext:!1});if(K&&(N=this.intl.parseDate(I+K+F,this.format)||this.intl.parseDate(C+K+V,this.format)))return this._value=N,this.setExisting(e,!0),r.extend(y,{value:this.value,switchToNext:!0});if(W&&this.setExisting(e,!1),!this.autoCorrectParts){var et=void 0,it=c?w:q,nt=r.parseToInt(it);if(r.isNumber(nt)){if("d"===e&&(nt<=0||nt>31)||"M"===e&&(nt<=0||nt>11)){if(c)return r.extend(y,{value:null,switchToNext:!1});it=i,nt=r.parseToInt(it)}et="M"===e?nt-1:nt;var st="M"===e,at="d"===e,rt=n.cloneDate(this._value),ot=this._partiallyInvalidDate.invalidDateParts||{},lt=ot.y.value||rt.getFullYear(),ht=st?et:ot.M.value||rt.getMonth(),ut=at?et:ot.d.value||ot.E.value||rt.getDate(),ct=ot.h.value||ot.H.value||rt.getHours(),dt=ot.m.value||rt.getMinutes(),pt=ot.s.value||rt.getSeconds(),mt=ot.S.value||rt.getMilliseconds(),ft=n.createDate(lt,ht,ut,ct,dt,pt,mt),vt=r.areDatePartsEqualTo(ft,lt,ht,ut,ct,dt,pt,mt),gt=st||at?this.modifyDateSymbolWithValue(rt,e,st?ht:ut):null,yt=!1;if(st&>?gt.getMonth()===ht?this.getExisting("d")?vt?(rt=n.cloneDate(ft),this.resetInvalidDateSymbol(e)):(yt=!0,this.setInvalidDatePart(e,{value:ht,date:n.cloneDate(gt),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1)):vt?(this.resetInvalidDateSymbol(e),rt=n.cloneDate(ft),this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d"))):(this.resetInvalidDateSymbol(e),rt=n.cloneDate(gt)):(yt=!0,this.setInvalidDatePart(e,{value:ht,date:n.cloneDate(gt),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1)):at&>&&(gt.getDate()===ut?this.getExisting("M")?vt?(rt=n.cloneDate(ft),this.resetInvalidDateSymbol(e)):(yt=!0,this.setInvalidDatePart(e,{value:ut,date:n.cloneDate(gt),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1)):vt?(rt=n.cloneDate(ft),this.resetInvalidDateSymbol(e),this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M"))):(this.resetInvalidDateSymbol(e),rt=n.cloneDate(gt)):(yt=!0,this.setInvalidDatePart(e,{value:ut,date:n.cloneDate(this.value),startDate:n.cloneDate(this.value)}),this.setExisting(e,!1))),!yt){if(this.setExisting(e,!0),c&&!r.isValidDate(N)){var Dt=this.intl.parseDate(C+q+V,this.format,this.localeId);r.isValidDate(Dt)&&(this._value=Dt)}else this._value=rt;this.getValue()&&this.resetInvalidDate()}tt=!1;if("M"===e)tt=nt>=2||it.length>=2;else if(T)tt=this.isPeekDateOverflowingDatePart({useBasePrefixAndSuffix:!this.autoCorrectParts,middle:q,patternValue:Z,basePrefix:C,baseSuffix:V,prefix:I,suffix:F,symbol:e,patternLength:R,leadingZero:B}).switchToNext;else tt=it.length>A;return r.extend(y,{value:null,switchToNext:tt,hasInvalidDatePart:yt})}}return r.extend(y,{value:null,switchToNext:!1})},t.prototype.symbolMap=function(t){return this.intl.splitDateFormat(this.format,this.localeId).reduce(a.dateSymbolMap,{})[t]},t.prototype.resetLeadingZero=function(){var t=null!==this.leadingZero;return this.setLeadingZero(null),t},t.prototype.setLeadingZero=function(t){this.leadingZero=t},t.prototype.getLeadingZero=function(){return this.leadingZero||{}},t.prototype.normalizeCentury=function(t){if(!r.isPresent(t))return t;var e=r.cropTwoDigitYear(t),i=this.getNormalizedCenturyBase(e);return r.setYears(t,i+e)},t.prototype.incrementLeadingZero=function(t){var e=this.leadingZero||{};e[t]=(e[t]||0)+1,this.leadingZero=e},t.prototype.isAbbrMonth=function(t,e){var i=this.partPattern(t,e);return"month"===i.type&&i.names},t.prototype.partPattern=function(t,e){return t.filter((function(t){return-1!==t.pattern.indexOf(e)}))[0]},t.prototype.peek=function(t,e){var i=t.replace(/^0*/,"")+"0";return a.padZero(e.length-i.length)+i},t.prototype.matchMonth=function(t){if(this.typedMonthPart+=t.toLowerCase(),0===this.monthNames.length)return"";for(;this.typedMonthPart.length>0;){for(var e=0;e<this.monthNames.length;e++)if(0===this.monthNames[e].toLowerCase().indexOf(this.typedMonthPart))return this.monthNames[e];var i=parseInt(this.typedMonthPart,10);if(i>=1&&i<=12&&i.toString()===this.typedMonthPart)return this.monthNames[i-1];this.typedMonthPart=this.typedMonthPart.substring(1,this.typedMonthPart.length)}return""},t.prototype.matchDayPeriod=function(t,e){var i=t.toLowerCase();if("a"===e&&this.dayPeriods){if(this.dayPeriods.am.toLowerCase().startsWith(i))return this.dayPeriods.am;if(this.dayPeriods.pm.toLowerCase().startsWith(i))return this.dayPeriods.pm}return""},t.prototype.allFormattedMonths=function(t){void 0===t&&(t="en");for(var e=this.intl.splitDateFormat(this.format,this.localeId),i=0;i<e.length;i++)if("month"===e[i].type&&e[i].names)return this.intl.dateFormatNames(t,e[i].names);return[]},t.prototype.allDayPeriods=function(t){void 0===t&&(t="en");for(var e=this.intl.splitDateFormat(this.format),i=0;i<e.length;i++)if("dayperiod"===e[i].type&&e[i].names)return this.intl.dateFormatNames(t,e[i].names);return null},t.prototype.patternLength=function(t){return"y"===t[0]?4:l.test(t)?2:0},t.prototype.dateFormatString=function(t,e){for(var i=this.intl.splitDateFormat(e,this.localeId),n=[],a=[],r=0;r<i.length;r++)for(var l=this.intl.formatDate(t,{pattern:i[r].pattern},this.localeId).length;l>0;)n.push(this.symbols[i[r].pattern[0]]||o.Constants.formatSeparator),a.push(i[r]),l--;var h=new s.Mask;return h.symbols=n.join(""),h.partMap=a,h},t.prototype.merge=function(t,e){for(var i="",n="",s=e.symbols,o=!1,l=0,h=this.getFormattedInvalidDates(s),u=s.length-1;u>=0;u--){var c=this.getPartsForSegment(e,u);if(-1===this.knownParts.indexOf(s[u])||this.getExisting(s[u]))this.autoCorrectParts?i=t[u]+i:t.length!==s.length?o?i=t[u]+i:l>0?(i=t[u]+i,--l<=0&&(o=!0)):i=(t[u+t.length-s.length]||"")+i:i=t[u]+i,n=s[u]+n;else{var d=s[u],p=0;if(this.autoCorrectParts||!this.autoCorrectParts&&!this.getInvalidDatePartValue(d)){for(;u>=0&&d===s[u];)u--;u++}if(this.leadingZero&&this.leadingZero[d])i="0"+i;else if(!this.autoCorrectParts&&this.getInvalidDatePartValue(d)){var m=this.getInvalidDatePartValue(d).toString();if("M"===d)if(m=(r.parseToInt(this.getInvalidDatePartValue(d))+1).toString(),c.length>2)i=h[d][u]+i;else m=(r.parseToInt(this.getInvalidDatePartValue(d))+1).toString(),i=a.padZero(c.length-m.length)+m+i,p=c.length-1,l=m.length-c.length;else i=a.padZero(c.length-m.length)+m+i,p=c.length-1,l=m.length-c.length}else i=this.dateFieldName(e.partMap[u])+i;for(;n.length<i.length;)n=s[u]+n;0!==p&&(u=u-p+(t.length-s.length))}}return{text:i,format:n}},t.prototype.dateFieldName=function(t){var e=this.formatPlaceholder||"wide";return e[t.type]?e[t.type]:"formatPattern"===e?t.pattern:this.intl.dateFieldName(Object.assign(t,{nameType:e}))},t.prototype.getNormalizedCenturyBase=function(t){return t>this.twoDigitYearMax?1900:2e3},t.prototype.shouldNormalizeCentury=function(){return this.intl.splitDateFormat(this.format).some((function(t){return"yy"===t.pattern}))},t.prototype.resetInvalidDate=function(){var t=this;this._partiallyInvalidDate.startDate=null,Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(e){t.resetInvalidDatePart(e)}))},t.prototype.resetInvalidDateSymbol=function(t){var e=this;this.resetInvalidDatePart(t);var i=!0;Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(t){e._partiallyInvalidDate.invalidDateParts[t]&&r.isPresent(e._partiallyInvalidDate.invalidDateParts[t].value)&&(i=!1)})),i&&this.resetInvalidDate()},t.prototype.resetInvalidDatePart=function(t){this._partiallyInvalidDate.invalidDateParts[t]&&(this._partiallyInvalidDate.invalidDateParts[t]={value:null,date:null,startDateOffset:0})},t.prototype.getInvalidDatePart=function(t){return this._partiallyInvalidDate.invalidDateParts[t]||{}},t.prototype.getInvalidDatePartValue=function(t){return(this._partiallyInvalidDate.invalidDateParts[t]||{}).value},t.prototype.setInvalidDatePart=function(t,e){var i=e.value,n=void 0===i?null:i,s=e.date,a=void 0===s?null:s,r=e.startDateOffset,o=void 0===r?0:r,l=e.startDate,h=void 0===l?null:l;this._partiallyInvalidDate.invalidDateParts[t]&&(this._partiallyInvalidDate.invalidDateParts[t].value=n,this._partiallyInvalidDate.invalidDateParts[t].date=a,this._partiallyInvalidDate.invalidDateParts[t].startDateOffset=o,this._partiallyInvalidDate.startDate=h)},t.prototype.hasInvalidDatePart=function(){var t=this,e=!1;return Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(i){t._partiallyInvalidDate.invalidDateParts[i]&&r.isPresent(t._partiallyInvalidDate.invalidDateParts[i].value)&&(e=!0)})),e},t.prototype.modifyDateSymbolWithOffset=function(t,e,i){var s=n.cloneDate(t),a=!1;switch(e){case"y":s.setFullYear(s.getFullYear()+i);break;case"M":s=n.addMonths(this.value,i);break;case"d":case"E":s.setDate(s.getDate()+i);break;case"h":case"H":s.setHours(s.getHours()+i),a=!0;break;case"m":s.setMinutes(s.getMinutes()+i),a=!0;break;case"s":s.setSeconds(s.getSeconds()+i),a=!0;break;case"S":s.setMilliseconds(s.getMilliseconds()+i);break;case"a":s.setHours(s.getHours()+12*i),a=!0}return{date:s,timeModified:a}},t.prototype.modifyDateSymbolWithValue=function(t,e,i){var s=n.cloneDate(t);switch(e){case"y":s.setFullYear(i);break;case"M":s=n.addMonths(t,i-t.getMonth());break;case"d":case"E":s.setDate(i);break;case"h":case"H":s.setHours(i);break;case"m":s.setMinutes(i);break;case"s":s.setSeconds(i);break;case"S":s.setMilliseconds(i);break;case"a":s.setHours(i)}return s},t.prototype.markDatePartsAsExisting=function(){this.modifyExisting(!0)},t.prototype.getPartsForSegment=function(t,e){for(var i=t.partMap[e],n=[],s=e;s<t.partMap.length;s++){var a=t.partMap[s];if(i.type!==a.type||i.pattern!==a.pattern)break;n.push(a)}for(s=e-1;s>=0;s--){a=t.partMap[s];if(i.type!==a.type||i.pattern!==a.pattern)break;n.unshift(a)}return n},t.prototype.isPeekDateOverflowingDatePart=function(t){var e=t.useBasePrefixAndSuffix,i=t.middle,n=t.patternValue,s=t.basePrefix,o=t.baseSuffix,l=t.prefix,h=t.suffix,u=t.symbol,c=t.patternLength,d=t.leadingZero,p=this.peek(i,n),m=e?""+s+p+o:""+l+p+h,f=this.intl.parseDate(m,this.format,this.localeId),v=((this.leadingZero||{})[u]||0)+a.unpadZero(i).length>=c;return{peekedDate:f,peekedDateString:m,peekedValue:p,parsedPeekedValue:r.parseToInt(p),switchToNext:null===f||(d[u]?n.length<=i.length:v)}},t}();e.DateObject=h},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){this.symbols="",this.partMap=[]};e.Mask=n},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.KeyCode={BACKSPACE:8,DELETE:46,TAB:9,ENTER:13,ESCAPE:27,ARROW_LEFT:37,ARROW_UP:38,ARROW_RIGHT:39,ARROW_DOWN:40,SPACE:32,END:35,HOME:36,PAGE_UP:33,PAGE_DOWN:34}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(2),s={events:{}},a=function(){function t(t){this.options=n.extend({},s,t)}return t.prototype.destroy=function(){},t.prototype.trigger=function(t,e){void 0===e&&(e={});var i={defaultPrevented:!1,preventDefault:function(){i.defaultPrevented=!0}};return!!n.isFunction(this.options.events[t])&&(this.options.events[t](n.extend(i,e,{sender:this})),i.defaultPrevented)},t}();e.Observable=a},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.None="none",t.Caret="caret",t.Selection="selection"}(e.DateInputInteractionMode||(e.DateInputInteractionMode={}))}])}));
|
|
@@ -3,6 +3,8 @@ import { Mask } from './mask';
|
|
|
3
3
|
import { dateSymbolMap, padZero, unpadZero } from '../dateinput/utils';
|
|
4
4
|
import { extend, isPresent, cropTwoDigitYear, setYears, parseToInt, clamp, areDatePartsEqualTo, isNumber, isValidDate } from './utils';
|
|
5
5
|
import { Constants } from './constants';
|
|
6
|
+
var MONTH_INDEX_FEBRUARY = 1;
|
|
7
|
+
var DEFAULT_LEAP_YEAR = 2000;
|
|
6
8
|
var PREVIOUS_CENTURY_BASE = 1900;
|
|
7
9
|
var CURRENT_CENTURY_BASE = 2000;
|
|
8
10
|
var SHORT_PATTERN_LENGTH_REGEXP = /d|M|H|h|m|s/;
|
|
@@ -36,7 +38,7 @@ var DateObject = /** @class */ (function () {
|
|
|
36
38
|
'y': 'y',
|
|
37
39
|
'S': 'S'
|
|
38
40
|
};
|
|
39
|
-
this._value =
|
|
41
|
+
this._value = this.getDefaultDate();
|
|
40
42
|
this.cycleTime = false;
|
|
41
43
|
this._partiallyInvalidDate = {
|
|
42
44
|
startDate: null,
|
|
@@ -63,7 +65,7 @@ var DateObject = /** @class */ (function () {
|
|
|
63
65
|
autoCorrectParts: autoCorrectParts
|
|
64
66
|
});
|
|
65
67
|
if (!value) {
|
|
66
|
-
this._value =
|
|
68
|
+
this._value = this.getDefaultDate();
|
|
67
69
|
var sampleFormat = this.dateFormatString(this.value, this.format).symbols;
|
|
68
70
|
for (var i = 0; i < sampleFormat.length; i++) {
|
|
69
71
|
this.setExisting(sampleFormat[i], false);
|
|
@@ -121,7 +123,7 @@ var DateObject = /** @class */ (function () {
|
|
|
121
123
|
};
|
|
122
124
|
DateObject.prototype.setValue = function (value) {
|
|
123
125
|
if (!value) {
|
|
124
|
-
this._value =
|
|
126
|
+
this._value = this.getDefaultDate();
|
|
125
127
|
this.modifyExisting(false);
|
|
126
128
|
}
|
|
127
129
|
else if (!isEqual(value, this._value)) {
|
|
@@ -149,6 +151,23 @@ var DateObject = /** @class */ (function () {
|
|
|
149
151
|
}
|
|
150
152
|
return cloneDate(this.value);
|
|
151
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* @hidden
|
|
156
|
+
*/
|
|
157
|
+
DateObject.prototype.createDefaultDate = function () {
|
|
158
|
+
// use the leap year 2000 that has 29th February
|
|
159
|
+
// and a month that has 31 days
|
|
160
|
+
// so that the default date can accommodate maximum date values
|
|
161
|
+
// it is better to use a fixed date instead of new Date()
|
|
162
|
+
// as otherwise the
|
|
163
|
+
return createDate(DEFAULT_LEAP_YEAR, 0, 31);
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* @hidden
|
|
167
|
+
*/
|
|
168
|
+
DateObject.prototype.getDefaultDate = function () {
|
|
169
|
+
return getDate(this.createDefaultDate());
|
|
170
|
+
};
|
|
152
171
|
/**
|
|
153
172
|
* @hidden
|
|
154
173
|
*/
|
|
@@ -274,7 +293,7 @@ var DateObject = /** @class */ (function () {
|
|
|
274
293
|
// allow 2/29 dates
|
|
275
294
|
this.year = value;
|
|
276
295
|
if (value === false) {
|
|
277
|
-
this._value.setFullYear(
|
|
296
|
+
this._value.setFullYear(DEFAULT_LEAP_YEAR);
|
|
278
297
|
}
|
|
279
298
|
break;
|
|
280
299
|
case 'M':
|
|
@@ -822,17 +841,19 @@ var DateObject = /** @class */ (function () {
|
|
|
822
841
|
if ((isInCaretMode && isValidDate(parsedDate)) || (!isInCaretMode && parsedDate)) {
|
|
823
842
|
// move to next segment if the part will overflow with next char
|
|
824
843
|
// when start from empty date (01, then 010), padded zeros should be trimmed
|
|
825
|
-
var
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
844
|
+
var peekResult = this.isPeekDateOverflowingDatePart({
|
|
845
|
+
useBasePrefixAndSuffix: autoCorrectedPrefixAndSuffix,
|
|
846
|
+
middle: middle,
|
|
847
|
+
patternValue: patternValue,
|
|
848
|
+
basePrefix: basePrefix,
|
|
849
|
+
baseSuffix: baseSuffix,
|
|
850
|
+
prefix: prefix,
|
|
851
|
+
suffix: suffix,
|
|
852
|
+
symbol: symbol,
|
|
853
|
+
patternLength: patternLength,
|
|
854
|
+
leadingZero: leadingZero
|
|
855
|
+
});
|
|
856
|
+
var switchToNext = peekResult.switchToNext;
|
|
836
857
|
if (this.shouldNormalizeCentury()) {
|
|
837
858
|
parsedDate = this.normalizeCentury(parsedDate);
|
|
838
859
|
}
|
|
@@ -856,6 +877,21 @@ var DateObject = /** @class */ (function () {
|
|
|
856
877
|
}
|
|
857
878
|
if (!this.hasInvalidDatePart()) {
|
|
858
879
|
this.markDatePartsAsExisting();
|
|
880
|
+
if (!peekResult.peekedDate && peekResult.switchToNext && !this.autoCorrectParts) {
|
|
881
|
+
if (symbol === "M") {
|
|
882
|
+
// skip processing the month
|
|
883
|
+
}
|
|
884
|
+
else if (symbol === "d") {
|
|
885
|
+
if (peekResult.parsedPeekedValue === 30 &&
|
|
886
|
+
this.value.getMonth() === MONTH_INDEX_FEBRUARY) {
|
|
887
|
+
// the peekValue cannot be constructed
|
|
888
|
+
// as there cannot be more than 29 days in February
|
|
889
|
+
// still the segment should not be switched as autoCorrectParts="false"
|
|
890
|
+
// should allow typing "30"
|
|
891
|
+
switchToNext = false;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
859
895
|
}
|
|
860
896
|
}
|
|
861
897
|
return extend(parseResult, { value: this.value, switchToNext: switchToNext });
|
|
@@ -887,8 +923,21 @@ var DateObject = /** @class */ (function () {
|
|
|
887
923
|
var parsedValue = parseToInt(textToParse);
|
|
888
924
|
if (isNumber(parsedValue)) {
|
|
889
925
|
if ((symbol === "d" && (parsedValue <= 0 || parsedValue > 31)) ||
|
|
890
|
-
(symbol === "M" && (parsedValue
|
|
891
|
-
|
|
926
|
+
(symbol === "M" && (parsedValue <= 0 || parsedValue > 11))) {
|
|
927
|
+
if (isInCaretMode) {
|
|
928
|
+
return extend(parseResult, {
|
|
929
|
+
value: null,
|
|
930
|
+
switchToNext: false
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
// the value overflows the possible value range
|
|
935
|
+
// thus reset the segment value regardless of the "resetSegmentValue" flag
|
|
936
|
+
// otherwise the input is ignored and you cannot change the value,
|
|
937
|
+
// e.g. "03->(press 2)->02" will not work and the user will be blocked on "03"
|
|
938
|
+
textToParse = currentChar;
|
|
939
|
+
parsedValue = parseToInt(textToParse);
|
|
940
|
+
}
|
|
892
941
|
}
|
|
893
942
|
datePartValue = symbol === "M" ?
|
|
894
943
|
parsedValue - JS_MONTH_OFFSET :
|
|
@@ -1019,9 +1068,24 @@ var DateObject = /** @class */ (function () {
|
|
|
1019
1068
|
}
|
|
1020
1069
|
}
|
|
1021
1070
|
else {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1071
|
+
if (hasFixedFormat) {
|
|
1072
|
+
var peekDateSwitchToNext = this.isPeekDateOverflowingDatePart({
|
|
1073
|
+
useBasePrefixAndSuffix: !this.autoCorrectParts,
|
|
1074
|
+
middle: middle,
|
|
1075
|
+
patternValue: patternValue,
|
|
1076
|
+
basePrefix: basePrefix,
|
|
1077
|
+
baseSuffix: baseSuffix,
|
|
1078
|
+
prefix: prefix,
|
|
1079
|
+
suffix: suffix,
|
|
1080
|
+
symbol: symbol,
|
|
1081
|
+
patternLength: patternLength,
|
|
1082
|
+
leadingZero: leadingZero
|
|
1083
|
+
}).switchToNext;
|
|
1084
|
+
switchToNext = peekDateSwitchToNext;
|
|
1085
|
+
}
|
|
1086
|
+
else {
|
|
1087
|
+
switchToNext = textToParse.length > segmentLength;
|
|
1088
|
+
}
|
|
1025
1089
|
}
|
|
1026
1090
|
return extend(parseResult, {
|
|
1027
1091
|
value: null,
|
|
@@ -1479,6 +1543,37 @@ var DateObject = /** @class */ (function () {
|
|
|
1479
1543
|
}
|
|
1480
1544
|
return partsForSegment;
|
|
1481
1545
|
};
|
|
1546
|
+
/**
|
|
1547
|
+
* @hidden
|
|
1548
|
+
*/
|
|
1549
|
+
DateObject.prototype.isPeekDateOverflowingDatePart = function (_a) {
|
|
1550
|
+
var useBasePrefixAndSuffix = _a.useBasePrefixAndSuffix, middle = _a.middle, patternValue = _a.patternValue, basePrefix = _a.basePrefix, baseSuffix = _a.baseSuffix, prefix = _a.prefix, suffix = _a.suffix, symbol = _a.symbol, patternLength = _a.patternLength, leadingZero = _a.leadingZero;
|
|
1551
|
+
// move to next segment if the part will overflow with next char
|
|
1552
|
+
// when start from empty date (01, then 010), padded zeros should be trimmed
|
|
1553
|
+
var peekedValue = this.peek(middle, patternValue);
|
|
1554
|
+
var peekedDateString = useBasePrefixAndSuffix ?
|
|
1555
|
+
"" + basePrefix + peekedValue + baseSuffix :
|
|
1556
|
+
"" + prefix + peekedValue + suffix;
|
|
1557
|
+
var peekedDate = this.intl.parseDate(peekedDateString, this.format, this.localeId);
|
|
1558
|
+
var leadingZeroOffset = (this.leadingZero || {})[symbol] || 0;
|
|
1559
|
+
var patternSatisfied = (leadingZeroOffset + unpadZero(middle).length) >= patternLength;
|
|
1560
|
+
var parsedPeekedValue = parseToInt(peekedValue);
|
|
1561
|
+
if (symbol === "M") {
|
|
1562
|
+
}
|
|
1563
|
+
else if (symbol === "d") {
|
|
1564
|
+
}
|
|
1565
|
+
var switchToNext = peekedDate === null ||
|
|
1566
|
+
(leadingZero[symbol] ?
|
|
1567
|
+
patternValue.length <= middle.length :
|
|
1568
|
+
patternSatisfied);
|
|
1569
|
+
return {
|
|
1570
|
+
peekedDate: peekedDate,
|
|
1571
|
+
peekedDateString: peekedDateString,
|
|
1572
|
+
peekedValue: peekedValue,
|
|
1573
|
+
parsedPeekedValue: parsedPeekedValue,
|
|
1574
|
+
switchToNext: switchToNext
|
|
1575
|
+
};
|
|
1576
|
+
};
|
|
1482
1577
|
return DateObject;
|
|
1483
1578
|
}());
|
|
1484
1579
|
export { DateObject };
|