UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines (2 loc) 47.4 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("kendo.date-math.cmn.chunk.js")):"function"==typeof define&&define.amd?define(["exports","kendo.date-math.cmn.chunk"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).kendo=t.kendo||{},t.kendo._globals=t.kendo._globals||{},t.kendo._globals.DateinputsCommonCmnChunk={}),t.kendo._globals.DateMathCmnChunk)}(this,(function(t,e){var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},i(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}var n=function(){return n=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},n.apply(this,arguments)};Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;var a,r,o,l=function(){this.symbols="",this.partMap=[]},h="_",u=68,c="d",d="en",m="Delete",p="Backspace",g=" ",v=function(t){return new Array(Math.max(t,0)).fill("0").join("")},f=function(t){return t.replace(/^0*/,"")},y=function(t,e){return t[e.pattern[0]]=e.type,t},D=function(t){return null!=t},E=function(){return!!document},b=function(t){return D(t)&&"number"==typeof t&&!Number.isNaN(t)},P=function(t){return parseInt(t,10)},S=function(t){return b(P(t))&&/^[0-9]+$/.test(t)},M=function(t,e,i){return Math.min(i,Math.max(e,t))},x=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Object.assign.apply(Object,t)},I=(a="setFullYear",function(t,i){var s=e.c(t);return s[a](i),s}),w=function(t,e,i,s,n,a,r,o){return!(!t||t.getFullYear()!==e||t.getMonth()!==i||t.getDate()!==s||t.getHours()!==n||t.getMinutes()!==a||t.getSeconds()!==r||t.getMilliseconds()!==o)},O=function(t){return D(t)&&t.getTime&&b(t.getTime())},V=/d|M|H|h|m|s/,F=function(){function t(t){var i=t.intlService,s=t.formatPlaceholder,n=t.format,a=t.cycleTime,r=void 0!==a&&a,o=t.twoDigitYearMax,l=void 0===o?u:o,h=t.value,c=void 0===h?null:h,d=t.autoCorrectParts,m=void 0===d||d,p=t.toggleDayPeriod,g=void 0!==p&&p;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:i,formatPlaceholder:s,format:n,cycleTime:r,twoDigitYearMax:l,value:c,autoCorrectParts:m,toggleDayPeriod:g}),c)this._value=e.c(c);else{this._value=this.getDefaultDate();for(var v=this.dateFormatString(this.value,this.format).symbols,f=0;f<v.length;f++)this.setExisting(v[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=d,e=Object.keys(this.intl.cldr),i=0;i<e.length;i++){var s=e[i],n=this.intl.cldr[s];if(n.name&&n.calendar&&n.numbers&&n.name!==d){t=n.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,this.toggleDayPeriod=t.toggleDayPeriod},t.prototype.setValue=function(t){t?e.i(t,this._value)||(this._value=e.c(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 e.c(this.value)},t.prototype.createDefaultDate=function(){return e.a(2e3,0,31)},t.prototype.getDefaultDate=function(){return e.g(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),s=this.dateFormatString(this.value,e);if(!this.autoCorrectParts&&this._partiallyInvalidDate.startDate){for(var n="",a=this.intl.formatDate(this.value,e,this.localeId),r=this.getFormattedInvalidDates(e),o=0;o<a.length;o++){var l=s.symbols[o];if("literal"===s.partMap[o].type)n+=i[o];else if(this.getInvalidDatePartValue(l)){var h=this.getPartsForSegment(s,o);if("M"===l){var u=(P(this.getInvalidDatePartValue(l))+1).toString();if(h.length>2)n+=r[l][o];else if(this.getInvalidDatePartValue(l))n+=v(h.length-u.length)+u,o+=h.length-1;else n+=r[l][o]}else if(this.getInvalidDatePartValue(l)){u=this.getInvalidDatePartValue(l).toString();n+=v(h.length-u.length)+u,o+=h.length-1}else n+=r[l][o]}else n+=i[o]}i=n}return this.merge(i,s)},t.prototype.getFormattedInvalidDates=function(t){var e=this;void 0===t&&(t="");var i=t||this.format,s={E:"",H:"",M:"",a:"",d:"",h:"",m:"",s:"",y:"",S:""};return Object.keys(this._partiallyInvalidDate.invalidDateParts).forEach((function(t){var n=e.getInvalidDatePart(t).date;if(n){var a=e.intl.formatDate(n,i,e.localeId);s[t]=a}})),s},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,i){if(D(t)&&D(i)&&0!==i){var s,n=e.c(this.value),a=!1,r="M"===t,o="d"===t||"E"===t,l=this.getExisting(t);if(this.autoCorrectParts||!o&&!r)switch(t){case"y":n.setFullYear(n.getFullYear()+i);break;case"M":n=e.b(this.value,i);break;case"d":case"E":n.setDate(n.getDate()+i);break;case"h":case"H":n.setHours(n.getHours()+i),a=!0;break;case"m":n.setMinutes(n.getMinutes()+i),a=!0;break;case"s":n.setSeconds(n.getSeconds()+i),a=!0;break;case"S":n.setMilliseconds(n.getMilliseconds()+i);break;case"a":var h=n.getHours();this.toggleDayPeriod?n.setHours(h>=12?h-12:h+12):n.setHours(n.getHours()+12*i),a=!0}else{var u=this._partiallyInvalidDate.invalidDateParts||{},c=this.getInvalidDatePartValue(t),d=u.y.value||n.getFullYear(),m=u.M.value||n.getMonth(),p=u.d.value||u.E.value||n.getDate(),g=u.h.value||u.H.value||n.getHours(),v=u.m.value||n.getMinutes(),f=u.s.value||n.getSeconds(),y=u.S.value||n.getMilliseconds();switch(t){case"y":d+=i;break;case"M":m+=i;break;case"d":case"E":p+=i}if("M"===t){if((m<0||m>11)&&l)return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t);if(!l){if(m<0)m=M(m%11+1+11,0,11);else{var E=D(c)?m:(i-1)%12;m=M(E,0,11)}m=M(m,0,11)}m=M(m,0,11)}else if("d"===t)if(l){if(p<=0||p>31)return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t)}else if(!l){if(D(c)&&(p<=0||p>31))return this.setExisting(t,!1),void this.resetInvalidDateSymbol(t);if(i<0){var b=D(c)?p:31-Math.abs(i%31)+1;p=M(b,1,31)}else{b=D(c)?p:i%31;p=M(b,1,31)}p=M(p,1,31)}var P=e.a(d,m,p,g,v,f,y),S=r||o?this.modifyDateSymbolWithValue(n,t,r?m:p):null,x=w(P,d,m,p,g,v,f,y);this.getValue()&&w(P,d,m,p,g,v,f,y)?(n=e.c(P),this.markDatePartsAsExisting()):r&&S?S.getMonth()===m?this.getExisting("d")?x?(n=e.c(P),this.resetInvalidDateSymbol(t)):(s=!0,this.setInvalidDatePart(t,{value:m,date:e.c(S),startDateOffset:i,startDate:e.c(this.value)}),this.setExisting(t,!1)):x?(this.resetInvalidDateSymbol(t),n=e.c(P),this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d"))):(this.resetInvalidDateSymbol(t),n=e.c(S)):(s=!0,this.setInvalidDatePart(t,{value:m,date:e.c(S),startDateOffset:i,startDate:e.c(this.value)}),this.setExisting(t,!1)):o&&S&&(S.getDate()===p?this.getExisting("M")?x?(n=e.c(P),this.resetInvalidDateSymbol(t)):(s=!0,this.setInvalidDatePart(t,{value:p,date:e.c(S),startDateOffset:i,startDate:e.c(this.value)}),this.setExisting(t,!1)):x?(n=e.c(P),this.resetInvalidDateSymbol(t),this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M"))):(this.resetInvalidDateSymbol(t),n=e.c(S)):(s=!0,this.setInvalidDatePart(t,{value:p,date:e.c(this.value),startDateOffset:i,startDate:e.c(this.value)}),this.setExisting(t,!1)))}this.shouldNormalizeCentury()&&(n=this.normalizeCentury(n)),a&&!this.cycleTime&&(n.getDate(),this._value.getDate()),s||(this.setExisting(t,!0),this._value=n,this.getValue()&&this.resetInvalidDate())}},t.prototype.parsePart=function(t){for(var i=t.symbol,s=t.currentChar,n=t.resetSegmentValue,a=t.cycleSegmentValue,r=t.rawTextValue,o=t.isDeleting,l=t.originalFormat,h=!a,u=this.dateFormatString(this.value,this.format),c=u.partMap.filter((function(t){return"literal"===t.type})).map((function(t,e){return{datePartIndex:e,type:t.type,pattern:t.pattern,literal:""}})),d=u.partMap.map((function(t){return{type:t.type,pattern:t.pattern,text:""}})),m=0;m<c.length;m++){for(var p=c[m],g=0;g<p.pattern.length;g++)c[m+g]&&(c[m+g].literal=p.pattern[g]);m+=p.pattern.length-1}for(m=0;m<d.length;m++){for(p=d[m],g=0;g<p.pattern.length;g++)d[m+g]&&(d[m+g].text=p.pattern[g]);m+=p.pattern.length-1}var y={value:null,switchToNext:!1,resetPart:h&&"M"===i&&u.partMap.filter((function(t){return"month"===t.type})).some((function(t){return t.pattern.length>2})),hasInvalidDatePart:!1};if(!s){if(!h)return this.resetLeadingZero(),this.setExisting(i,!1),this.resetInvalidDateSymbol(i),x(y,{value:null,switchToNext:!1});for(m=0;m<c.length;m++){var D=c[m].literal,E=r.startsWith(D),M=r.endsWith(D),I=r.indexOf(D+D)>=0;if(E||M||I)return this.resetLeadingZero(),this.setExisting(i,!1),this.resetInvalidDateSymbol(i),x(y,{value:null,switchToNext:!1})}}var V=this.intl.formatDate(this.value,this.format,this.localeId),F=u.symbols,k=!1,C="",N="",j="",T="",_="",L="",A="";for(m=0;m<d.length;m++)A+=d[m].text;var H=this.format===F||this.format===A||this.format===l||this.format.length===l.length,K=(H?A:l).indexOf(i),B=(H?A:l).lastIndexOf(i)-K+1,W=l.length-r.length;if(h||!h&&!this.autoCorrectParts){for(m=0;m<V.length;m++){if(F[m]===i)N+=this.getExisting(i)?V[m]:"0",W>0?j.length+W<B&&(j+=r[m]||""):j+=r[m]||"",k=!0;else k?(L+=V[m],_+=V[m]):(C+=V[m],T+=V[m])}if(H&&(A.length<r.length?j+=s:!o&&(l.length,r.length),j.length>B))return x(y,{value:null,switchToNext:!1});if(!H||H&&!this.autoCorrectParts){N="",j="",C="",L="",k=!1;for(m=0;m<l.length;m++){if(l[m]===i)N+=this.getExisting(i)?V[m]||"":"0",W>0?j.length+W<B&&(j+=r[m]||""):j+=r[m]||"",k=!0;else k?L+=r[m-W]||"":C+=r[m]||""}l.length<r.length&&(j+=s)}}if(!h)if(this.autoCorrectParts){N="",j="",C="",L="",k=!1;for(m=0;m<V.length;m++){if(F[m]===i)N+=this.getExisting(i)?V[m]:"0",k=!0;else k?L+=V[m]:C+=V[m]}}else N=n?j:N;var Z=null,Y=this.matchMonth(s),U=this.matchDayPeriod(s,i),z="0"===s,R=this.leadingZero||{};z?("0"===j&&(j=N),0!==P(n?s:(h?j:N)+s)||this.isAbbrMonth(u.partMap,i)||this.incrementLeadingZero(i)):this.resetLeadingZero();var q=this.partPattern(u.partMap,i),J=q?q.pattern:null,$=this.patternLength(J)||J.length;if(h&&o&&!j)return this.setExisting(i,!1),x(y,{value:null,switchToNext:!1});var G=N.length-3,Q=!0,X=h?j:N;for(m=Math.max(0,G);m<=N.length&&Q;m++){X=n?s:h?j:N.substring(m)+s,!h&&this.autoCorrectParts||(Q=!1,X=f(X),X=v($-X.length)+X);var tt=parseInt(X,10),et=C+X+L;Z=this.intl.parseDate(et,this.format,this.localeId);var it=!1;h&&!O(Z)&&this.autoCorrectParts&&(Z=this.intl.parseDate(T+X+_,this.format,this.localeId),it=!0);var st=!isNaN(parseInt(s,10))||h&&o&&""===s;if(!Z&&!isNaN(tt)&&st&&this.autoCorrectParts){if("M"===i&&!Y){var nt=tt-1;nt>-1&&nt<12&&((Z=e.c(this.value)).setMonth(nt),Z.getMonth()!==nt&&(Z=e.l(e.b(Z,-1))))}"y"===i&&(Z=e.a(parseInt(X,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),(h&&O(Z)||!h&&Z)&&this.date&&Z.getDate()!==this.value.getDate()&&(Z=e.l(e.b(Z,-1))))}if(h&&O(Z)||!h&&Z){var at=this.isPeekDateOverflowingDatePart({useBasePrefixAndSuffix:it,middle:X,patternValue:J,basePrefix:T,baseSuffix:_,prefix:C,suffix:L,symbol:i,patternLength:$,leadingZero:R}),rt=at.switchToNext;return this.shouldNormalizeCentury()&&(Z=this.normalizeCentury(Z)),"H"===i&&Z.getHours()>=12&&this.setExisting("a",!0),this._value=Z,this.setExisting(i,!0),this.resetInvalidDateSymbol(i),this.autoCorrectParts||("M"===i?this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d")):"d"===i&&this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M")),this.hasInvalidDatePart()||(this.markDatePartsAsExisting(),at.peekedDate||!at.switchToNext||this.autoCorrectParts||"M"===i||"d"===i&&30===at.parsedPeekedValue&&1===this.value.getMonth()&&(rt=!1))),x(y,{value:this.value,switchToNext:rt})}}if(Y&&(Z=this.intl.parseDate(C+Y+L,this.format,this.localeId)))return this._value=Z,this.setExisting(i,!0),x(y,{value:this.value,switchToNext:!1});if(U&&(Z=this.intl.parseDate(C+U+L,this.format)||this.intl.parseDate(T+U+_,this.format)))return this._value=Z,this.setExisting(i,!0),x(y,{value:this.value,switchToNext:!0});if(z&&this.setExisting(i,!1),!this.autoCorrectParts){var ot=void 0,lt=h?j:X,ht=P(lt);if(b(ht)&&S(lt)){if("d"===i&&(ht<=0||ht>31)||"M"===i&&(ht<=0||ht>11)){if(h)return x(y,{value:null,switchToNext:!1});ht=P(lt=s)}if(!b(ht)||!S(lt))return x(y,{value:null,switchToNext:!1});ot="M"===i?ht-1:ht;var ut="M"===i,ct="d"===i,dt=e.c(this._value),mt=this._partiallyInvalidDate.invalidDateParts||{},pt=mt.y.value||dt.getFullYear(),gt=ut?ot:mt.M.value||dt.getMonth(),vt=ct?ot:mt.d.value||mt.E.value||dt.getDate(),ft=mt.h.value||mt.H.value||dt.getHours(),yt=mt.m.value||dt.getMinutes(),Dt=mt.s.value||dt.getSeconds(),Et=mt.S.value||dt.getMilliseconds(),bt=e.a(pt,gt,vt,ft,yt,Dt,Et),Pt=w(bt,pt,gt,vt,ft,yt,Dt,Et),St=ut||ct?this.modifyDateSymbolWithValue(dt,i,ut?gt:vt):null,Mt=!1;if(ut&&St?St.getMonth()===gt?this.getExisting("d")?Pt?(dt=e.c(bt),this.resetInvalidDateSymbol(i)):(Mt=!0,this.setInvalidDatePart(i,{value:gt,date:e.c(St),startDate:e.c(this.value)}),this.setExisting(i,!1)):Pt?(this.resetInvalidDateSymbol(i),dt=e.c(bt),this.getExisting("M")&&this.getExisting("y")&&(this.setExisting("d",!0),this.resetInvalidDateSymbol("d"))):(this.resetInvalidDateSymbol(i),dt=e.c(St)):(Mt=!0,this.setInvalidDatePart(i,{value:gt,date:e.c(St),startDate:e.c(this.value)}),this.setExisting(i,!1)):ct&&St&&(St.getDate()===vt?this.getExisting("M")?Pt?(dt=e.c(bt),this.resetInvalidDateSymbol(i)):(Mt=!0,this.setInvalidDatePart(i,{value:vt,date:e.c(St),startDate:e.c(this.value)}),this.setExisting(i,!1)):Pt?(dt=e.c(bt),this.resetInvalidDateSymbol(i),this.getExisting("d")&&this.getExisting("y")&&(this.setExisting("M",!0),this.resetInvalidDateSymbol("M"))):(this.resetInvalidDateSymbol(i),dt=e.c(St)):(Mt=!0,this.setInvalidDatePart(i,{value:vt,date:e.c(this.value),startDate:e.c(this.value)}),this.setExisting(i,!1))),!Mt){if(this.setExisting(i,!0),h&&!O(Z)){var xt=this.intl.parseDate(T+X+_,this.format,this.localeId);O(xt)&&(this._value=xt)}else this._value=dt;this.getValue()&&this.resetInvalidDate()}rt=!1;if("M"===i)rt=ht>=2||lt.length>=2;else if(H)rt=this.isPeekDateOverflowingDatePart({useBasePrefixAndSuffix:!this.autoCorrectParts,middle:X,patternValue:J,basePrefix:T,baseSuffix:_,prefix:C,suffix:L,symbol:i,patternLength:$,leadingZero:R}).switchToNext;else rt=lt.length>B;return x(y,{value:null,switchToNext:rt,hasInvalidDatePart:Mt})}}return x(y,{value:null,switchToNext:!1})},t.prototype.symbolMap=function(t){return this.intl.splitDateFormat(this.format,this.localeId).reduce(y,{})[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(!D(t))return t;var e=function(t){return!D(t)||isNaN(t.getTime())?0:Number(t.getFullYear().toString().slice(-2))}(t),i=this.getNormalizedCenturyBase(e);return I(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 v(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:V.test(t)?2:0},t.prototype.dateFormatString=function(t,e){for(var i=this.intl.splitDateFormat(e,this.localeId),s=[],n=[],a=0;a<i.length;a++)for(var r=this.intl.formatDate(t,{pattern:i[a].pattern},this.localeId).length;r>0;)s.push(this.symbols[i[a].pattern[0]]||h),n.push(i[a]),r--;var o=new l;return o.symbols=s.join(""),o.partMap=n,o},t.prototype.merge=function(t,e){for(var i="",s="",n=e.symbols,a=!1,r=0,o=this.getFormattedInvalidDates(n),l=n.length-1;l>=0;l--){var h=this.getPartsForSegment(e,l);if(-1===this.knownParts.indexOf(n[l])||this.getExisting(n[l]))this.autoCorrectParts?i=t[l]+i:t.length!==n.length?a?i=t[l]+i:r>0?(i=t[l]+i,--r<=0&&(a=!0)):i=(t[l+t.length-n.length]||"")+i:i=t[l]+i,s=n[l]+s;else{var u=n[l],c=0;if(this.autoCorrectParts||!this.autoCorrectParts&&!this.getInvalidDatePartValue(u)){for(;l>=0&&u===n[l];)l--;l++}if(this.leadingZero&&this.leadingZero[u])i="0"+i;else if(!this.autoCorrectParts&&this.getInvalidDatePartValue(u)){var d=this.getInvalidDatePartValue(u).toString();if("M"===u)if(d=(P(this.getInvalidDatePartValue(u))+1).toString(),h.length>2)i=o[u][l]+i;else d=(P(this.getInvalidDatePartValue(u))+1).toString(),i=v(h.length-d.length)+d+i,c=h.length-1,r=d.length-h.length;else i=v(h.length-d.length)+d+i,c=h.length-1,r=d.length-h.length}else i=this.dateFieldName(e.partMap[l])+i;for(;s.length<i.length;)s=n[l]+s;0!==c&&(l=l-c+(t.length-n.length))}}return{text:i,format:s}},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]&&D(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,s=void 0===i?null:i,n=e.date,a=void 0===n?null:n,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=s,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]&&D(t._partiallyInvalidDate.invalidDateParts[i].value)&&(e=!0)})),e},t.prototype.modifyDateSymbolWithOffset=function(t,i,s){var n=e.c(t),a=!1;switch(i){case"y":n.setFullYear(n.getFullYear()+s);break;case"M":n=e.b(this.value,s);break;case"d":case"E":n.setDate(n.getDate()+s);break;case"h":case"H":n.setHours(n.getHours()+s),a=!0;break;case"m":n.setMinutes(n.getMinutes()+s),a=!0;break;case"s":n.setSeconds(n.getSeconds()+s),a=!0;break;case"S":n.setMilliseconds(n.getMilliseconds()+s);break;case"a":n.setHours(n.getHours()+12*s),a=!0}return{date:n,timeModified:a}},t.prototype.modifyDateSymbolWithValue=function(t,i,s){var n=e.c(t);switch(i){case"y":n.setFullYear(s);break;case"M":n=e.b(t,s-t.getMonth());break;case"d":case"E":n.setDate(s);break;case"h":case"H":case"a":n.setHours(s);break;case"m":n.setMinutes(s);break;case"s":n.setSeconds(s);break;case"S":n.setMilliseconds(s)}return n},t.prototype.markDatePartsAsExisting=function(){this.modifyExisting(!0)},t.prototype.getPartsForSegment=function(t,e){for(var i=t.partMap[e],s=[],n=e;n<t.partMap.length;n++){var a=t.partMap[n];if(i.type!==a.type||i.pattern!==a.pattern)break;s.push(a)}for(n=e-1;n>=0;n--){a=t.partMap[n];if(i.type!==a.type||i.pattern!==a.pattern)break;s.unshift(a)}return s},t.prototype.isPeekDateOverflowingDatePart=function(t){var e=t.useBasePrefixAndSuffix,i=t.middle,s=t.patternValue,n=t.basePrefix,a=t.baseSuffix,r=t.prefix,o=t.suffix,l=t.symbol,h=t.patternLength,u=t.leadingZero,c=this.peek(i,s),d=e?""+n+c+a:""+r+c+o,m=this.intl.parseDate(d,this.format,this.localeId),p=((this.leadingZero||{})[l]||0)+f(i).length>=h;return{peekedDate:m,peekedDateString:d,peekedValue:c,parsedPeekedValue:P(c),switchToNext:null===m||(u[l]?s.length<=i.length:p)}},t}(),k=8,C=46,N=9,j=13,T=37,_=38,L=39,A=40,H=35,K=36,B={events:{}},W=function(){function t(t){this.options=x({},B,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"function"==typeof this.options.events[t]&&(this.options.events[t](x(i,e,{sender:this})),i.defaultPrevented)},t}();!function(t){t.None="none",t.Caret="caret",t.Selection="selection"}(r||(r={}));var Z="dragStart",Y="drop",U="touchstart",z="mousedown",R="mouseup",q="click",J="input",$="keydown",G="focus",Q="blur",X="paste",tt="DOMMouseScroll",et="mousewheel",it="valueChange",st="inputEnd",nt="blurEnd",at="focusEnd",rt="change",ot={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:(o={},o[it]=null,o[J]=null,o[st]=null,o[G]=null,o[at]=null,o[Q]=null,o[nt]=null,o[$]=null,o[et]=null,o[rt]=null,o),selectNearestSegmentOnFocus:!1,selectPreviousSegmentOnBackspace:!1,enableMouseWheel:!1,allowCaretMode:!1,autoSwitchParts:!0,autoSwitchKeys:[],twoDigitYearMax:u,autoCorrectParts:!0,autoFill:!1,toggleDayPeriod:!1},lt=function(t){function i(e,i){var s=t.call(this,i)||this;return s.dateObject=null,s.currentText="",s.currentFormat="",s.interactionMode=r.None,s.previousElementSelection={start:0,end:0},s.init(e,i),s}return s(i,t),Object.defineProperty(i.prototype,"value",{get:function(){return this.dateObject&&this.dateObject.getValue()},enumerable:!0,configurable:!0}),i.prototype.init=function(t,i){var s=O(this.options.value)?e.c(this.options.value):new Date(i.formattedValue);O(s)||(s=null),this.element=t,this.options=x({},ot,i,{steps:n({},ot.steps,i.steps)}),this.intl=this.options.intlService,this.dateObject=this.createDateObject(),this.dateObject.setValue(s),this.setTextAndFormat(),this.bindEvents(),this.resetSegmentValue=!0,this.interactionMode=r.None,this.forceUpdate()},i.prototype.destroy=function(){this.unbindEvents(),this.dateObject=null,t.prototype.destroy.call(this)},i.prototype.bindEvents=function(){this.onElementDragStart=this.onElementDragStart.bind(this),this.element.addEventListener(Z,this.onElementDragStart),this.onElementDrop=this.onElementDrop.bind(this),this.element.addEventListener(Y,this.onElementDrop),this.onElementClick=this.onElementClick.bind(this),this.element.addEventListener(q,this.onElementClick),this.onElementMouseDown=this.onElementMouseDown.bind(this),this.element.addEventListener(z,this.onElementMouseDown),this.element.addEventListener(U,this.onElementMouseDown),this.onElementMouseUp=this.onElementMouseUp.bind(this),this.element.addEventListener(R,this.onElementMouseUp),this.onElementInput=this.onElementInput.bind(this),this.element.addEventListener(J,this.onElementInput),this.onElementKeyDown=this.onElementKeyDown.bind(this),this.element.addEventListener($,this.onElementKeyDown),this.onElementFocus=this.onElementFocus.bind(this),this.element.addEventListener(G,this.onElementFocus),this.onElementBlur=this.onElementBlur.bind(this),this.element.addEventListener(Q,this.onElementBlur),this.onElementChange=this.onElementChange.bind(this),this.element.addEventListener(rt,this.onElementChange),this.onElementPaste=this.onElementPaste.bind(this),this.element.addEventListener(X,this.onElementPaste),this.onElementMouseWheel=this.onElementMouseWheel.bind(this),this.element.addEventListener(tt,this.onElementMouseWheel),this.element.addEventListener(et,this.onElementMouseWheel)},i.prototype.unbindEvents=function(){this.element.removeEventListener(Z,this.onElementDragStart),this.element.removeEventListener(Y,this.onElementDrop),this.element.removeEventListener(U,this.onElementMouseDown),this.element.removeEventListener(z,this.onElementMouseDown),this.element.removeEventListener(R,this.onElementMouseUp),this.element.removeEventListener(q,this.onElementClick),this.element.removeEventListener(J,this.onElementInput),this.element.removeEventListener($,this.onElementKeyDown),this.element.removeEventListener(G,this.onElementFocus),this.element.removeEventListener(Q,this.onElementBlur),this.element.removeEventListener(rt,this.onElementChange),this.element.removeEventListener(X,this.onElementPaste),this.element.removeEventListener(tt,this.onElementMouseWheel),this.element.removeEventListener(et,this.onElementMouseWheel)},i.prototype.setOptions=function(t,e){void 0===e&&(e=!1),this.options=x({},this.options,t,{steps:n({},ot.steps,t.steps)}),this.setDateObjectOptions(),e&&(this.unbindEvents(),this.init(this.element,this.options))},i.prototype.setDateObjectOptions=function(){if(this.dateObject){var t=this.getDateObjectOptions();this.dateObject.setOptions(t)}},i.prototype.resetLocale=function(){this.unbindEvents(),this.init(this.element,this.options)},i.prototype.isInCaretMode=function(){return this.interactionMode===r.Caret},i.prototype.focus=function(){this.element.focus(),this.options.selectNearestSegmentOnFocus&&this.selectNearestSegment(0)},i.prototype.onElementDragStart=function(t){t.preventDefault()},i.prototype.onElementDrop=function(t){t.preventDefault()},i.prototype.onElementMouseDown=function(){this.mouseDownStarted=!0,this.focusedPriorToMouseDown=this.isActive},i.prototype.onElementMouseUp=function(t){this.mouseDownStarted=!1,t.preventDefault()},i.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,s=D(this.options.placeholder)&&!this.dateObject.hasValue()&&!this.focusedPriorToMouseDown,n=!i&&s?0:this.caret()[0];this.selectNearestSegment(n)}else this.setSelection(this.selectionByIndex(e.start))},i.prototype.onElementInput=function(t){this.triggerInput({event:t});var i=this.elementValue;if(this.element&&this.dateObject){var s=this.switchedPartOnPreviousKeyAction;if(this.isPasteInProgress)return this.options.allowCaretMode&&(this.resetSegmentValue=!1),this.updateOnPaste(t),void(this.isPasteInProgress=!1);var n=this.keyDownEvent||{},a=n.keyCode===k||n.key===p,o=n.keyCode===C||n.key===m,l=this.interactionMode;!this.options.allowCaretMode||l===r.Caret||o||a||(this.resetSegmentValue=!0),this.options.allowCaretMode?this.interactionMode=r.Caret:this.interactionMode=r.Selection;var u=this.isInCaretMode();if(u&&this.keyDownEvent.key===g)this.restorePreviousInputEventState();else{var c=this.dateObject&&this.dateObject.getValue(),d=this.dateObject?this.dateObject.value:null,v=this.dateObject.getTextAndFormat(),f=v.text,y=v.format;this.currentFormat=y;var E=function(t){var e=t.oldText,i=t.newText,s=t.formatPattern,n=t.selectionStart,a=t.isInCaretMode,r=t.keyEvent,o=n+e.length-i.length,l=e[o],u=e.substring(0,o),c=i.substring(0,n),d=[];if(u===c&&n>0)return d.push([s[n-1],c[n-1]]),d;if(0===u.indexOf(c)&&a&&(r.key===m||r.key===p)||0===u.indexOf(c)&&!a&&(0===c.length||s[c.length-1]!==s[c.length])){var g="";a||1!==c.length||d.push([s[0],c[0]]);for(var v=c.length;v<u.length;v++)s[v]!==g&&s[v]!==h&&(g=s[v],d.push([g,""]));return d}if(a&&(0===c.indexOf(u)||s[n-1]===h)||!a&&(0===c.indexOf(u)||s[n-1]===h)){var f=s[0];for(v=Math.max(0,u.length-1);v<s.length;v++)if(s[v]!==h){f=s[v];break}return[[f,c[n-1]]]}return" "===c[c.length-1]||c[c.length-1]===l&&"_"===s[o]?[[s[n-1],h]]:[[s[n-1],c[n-1]]]}({oldText:u&&(a||o||l===r.Caret)?this.previousElementValue:f,newText:this.elementValue,formatPattern:this.currentFormat,selectionStart:this.selection.start,isInCaretMode:u,keyEvent:this.keyDownEvent});if(E&&E.length&&E[0]&&E[0][1]!==h&&(this.switchedPartOnPreviousKeyAction=!1),!u||E&&0!==E.length){if(u&&1===E.length){if(!E[0]||!E[0][0])return void this.restorePreviousInputEventState();if(u&&E[0]&&(E[0][0]===h||E[0][1]===h))return void this.restorePreviousInputEventState()}var b=1===E.length&&E[0][1]===h,P=[],S=!1,M=null;if(!b)for(var x=0;x<E.length;x++){var I=this.dateObject.parsePart({symbol:E[x][0],currentChar:E[x][1],resetSegmentValue:this.resetSegmentValue,cycleSegmentValue:!this.isInCaretMode(),rawTextValue:this.element.value,isDeleting:a||o,originalFormat:this.currentFormat});P.push(I),I.value||(M={type:"parse"}),S=I.switchToNext}this.options.autoSwitchParts||(S=!1),this.resetSegmentValue=!1;var w,O=this.options.format===this.currentFormat||D(this.options.format)&&this.options.format.length>1,V=P[P.length-1],F=V&&!D(V.value),N=u&&(a||o)&&F,j=!!V&&V.resetPart,T=this.dateObject.getValue(),_=!e.i(c,T),L=this.dateObject.value,A=this.selection;if(u){var H=E&&E.length>0?E[0][0]:null,K=this.dateObject.getLeadingZero()[H];E.length&&E[0][0]!==h?S?(this.forceUpdateWithSelection(),this.switchDateSegment(1)):j?(w=this.currentFormat[A.start])?(this.forceUpdate(),this.setSelection(this.selectionBySymbol(w))):this.restorePreviousInputEventState():N?(this.forceUpdate(),E.length&&E[0][0]!==h&&this.setSelection(this.selectionBySymbol(E[0][0]))):F?"0"===t.data&&K||(D(c)&&!D(T)?this.restorePreviousInputEventState():!D(c)&&D(T)?this.forceUpdateWithSelection():D(c)&&D(T)?_?this.forceUpdateWithSelection():this.restorePreviousInputEventState():D(c)||D(T)?d!==L||this.restorePreviousInputEventState():this.forceUpdateWithSelection()):F||O||this.forceUpdateWithSelection():(this.options.autoSwitchParts||E[0][1]!==h)&&this.setSelection(this.selectionBySymbol(E[0][0]))}else u||(this.forceUpdate(),E.length&&E[0][0]!==h&&this.setSelection(this.selectionBySymbol(E[0][0])),this.options.autoSwitchParts?b?(this.resetSegmentValue=!0,s||this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0):S&&(this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0):V&&V.switchToNext?this.resetSegmentValue=!0:b&&(this.resetSegmentValue=!0,s||this.switchDateSegment(1),this.switchedPartOnPreviousKeyAction=!0),a&&this.options.selectPreviousSegmentOnBackspace&&this.switchDateSegment(-1));this.tryTriggerValueChange({oldValue:c,event:t}),this.triggerInputEnd({event:t,error:M,oldElementValue:i,newElementValue:this.elementValue}),u&&this.setTextAndFormat()}else this.restorePreviousInputEventState()}}},i.prototype.onElementFocus=function(t){this.triggerFocus({event:t})||(this.isActive=!0,this.interactionMode=r.None,this.switchedPartOnPreviousKeyAction=!1,this.refreshElementValue(),this.mouseDownStarted||this.caret(0,this.elementValue.length),this.mouseDownStarted=!1,this.triggerFocusEnd({event:t}))},i.prototype.onElementBlur=function(t){this.resetSegmentValue=!0,this.isActive=!1,this.triggerBlur({event:t})||(this.options.autoFill&&this.autoFill(),this.interactionMode=r.None,this.switchedPartOnPreviousKeyAction=!1,this.refreshElementValue(),this.triggerBlurEnd({event:t}))},i.prototype.onElementChange=function(t){this.triggerChange({event:t})},i.prototype.onElementKeyDown=function(t){if(!this.triggerKeyDown({event:t})){var e=this.selection,i=e.start,s=e.end,n=t;if(this.keyDownEvent=t,this.previousElementValue=this.element.value,this.previousElementSelection={start:i,end:s},this.keyEventMatchesAutoSwitchKeys(t)){var a=t.keyCode===N;if(!a)return t.preventDefault(),void this.switchDateSegment(1);var r=this.selection,o=r.start,l=r.end;if(t.shiftKey&&a?this.switchDateSegment(-1):this.switchDateSegment(1),o!==this.selection.start||l!==this.selection.end)return void t.preventDefault()}var h=this.currentFormat[this.selection.start],u=this.getStepFromSymbol(h),c=!1,d=this.elementValue;if(!(t.altKey||t.ctrlKey||t.metaKey||t.keyCode===N)){switch(t.keyCode){case T:this.switchDateSegment(-1),c=!0,this.switchedPartOnPreviousKeyAction=!1;break;case _:this.modifyDateSegmentValue(u,h,n),d!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:d}),c=!0,this.switchedPartOnPreviousKeyAction=!1;break;case L:this.switchDateSegment(1),c=!0,this.switchedPartOnPreviousKeyAction=!1;break;case A:this.modifyDateSegmentValue(-u,h,n),d!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:d}),c=!0,this.switchedPartOnPreviousKeyAction=!1;break;case j:break;case K:this.selectNearestSegment(0),c=!0,this.switchedPartOnPreviousKeyAction=!1,this.resetSegmentValue=!0;break;case H:this.selectNearestSegment(this.elementValue.length),c=!0,this.switchedPartOnPreviousKeyAction=!1,this.resetSegmentValue=!0;break;default:return}c&&t.preventDefault()}}},i.prototype.onElementPaste=function(){this.isPasteInProgress=!0},i.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(),e!==this.elementValue&&this.triggerInputEnd({event:t,error:null,newElementValue:this.elementValue,oldElementValue:e})}},i.prototype.updateOnPaste=function(t){var e=this.intl.parseDate(this.elementValue,this.inputFormat)||this.value;D(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(i.prototype,"elementValue",{get:function(){return(this.element||{}).value||""},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"inputFormat",{get:function(){return this.options.format?"string"==typeof this.options.format?this.options.format:this.options.format.inputFormat:c},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayFormat",{get:function(){return this.options.format?"string"==typeof this.options.format?this.options.format:this.options.format.displayFormat:c},enumerable:!0,configurable:!0}),Object.defineProperty(i.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}),i.prototype.setSelection=function(t){this.element&&document.activeElement===this.element&&(this.element.setSelectionRange(t.start,t.end),E()&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/i.test(navigator.userAgent))&&this.element.scrollIntoView({block:"nearest",inline:"nearest"}),t.start!==t.end&&(this.interactionMode=r.Selection))},i.prototype.selectionBySymbol=function(t){for(var e=-1,i=0,s=0;s<this.currentFormat.length;s++)this.currentFormat[s]===t&&(i=s+1,-1===e&&(e=s));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}},i.prototype.selectionByIndex=function(t){for(var e={start:t,end:t},i=t,s=t-1;i<this.currentFormat.length||s>=0;i++,s--){if(i<this.currentFormat.length&&this.currentFormat[i]!==h){e=this.selectionBySymbol(this.currentFormat[i]);break}if(s>=0&&this.currentFormat[s]!==h){e=this.selectionBySymbol(this.currentFormat[s]);break}}return e},i.prototype.switchDateSegment=function(t){var e=this.selection;if(this.isInCaretMode()){var i=e.start,s=this.currentFormat[i-1],n="",a="";if(t<0){for(var o=i+t;o>=0;o--)if((a=this.currentFormat[o])!==h&&a!==s){i=o,n=a;break}}else for(o=i+t;o<this.currentFormat.length;o++)if((a=this.currentFormat[o])!==h&&a!==s){i=o,n=a;break}if(n)return this.forceUpdate(),this.setSelection(this.selectionBySymbol(n)),void(this.interactionMode=r.Selection)}this.interactionMode=r.None;var l=this.selection,u=l.start,c=l.end;if(u<c&&this.currentFormat[u]!==this.currentFormat[c-1])return this.setSelection(this.selectionByIndex(t>0?u:c-1)),this.resetSegmentValue=!0,void(this.interactionMode=r.None);for(var d=this.currentFormat[u],m=u+t;m>0&&m<this.currentFormat.length&&(this.currentFormat[m]===d||this.currentFormat[m]===h);)m+=t;if(this.currentFormat[m]!==h){for(var p=m;p>=0&&p<this.currentFormat.length&&this.currentFormat[p]===this.currentFormat[m];)p+=t;m>p&&(p+1!==u||m+1!==c)?(this.setSelection({start:p+1,end:m+1}),this.resetSegmentValue=!0):m<p&&(m!==u||p!==c)&&(this.setSelection({start:m,end:p}),this.resetSegmentValue=!0),this.interactionMode=r.None}},i.prototype.modifyDateSegmentValue=function(t,e,i){if(void 0===e&&(e=""),void 0===i&&(i={}),this.dateObject&&!this.options.readonly){var s,n,a,r=this.value,o=1,l=this.caret();if("S"===(e=e||this.currentFormat[l[0]])&&(!this.options.steps.millisecond||1===this.options.steps.millisecond)){var h=(n=this.inputFormat,(a=n&&n.match(/S+(\1)/))?a[0].length:0);s=h,o=Math.pow(10,3-s)}this.dateObject.modifyPart(e,o*t),this.tryTriggerValueChange({oldValue:r,event:i}),this.forceUpdate(),this.setSelection(this.selectionBySymbol(e))}},i.prototype.tryTriggerValueChange=function(t){if(void 0===t&&(t={oldValue:null,event:{}}),!e.i(this.value,t.oldValue))return this.triggerValueChange(t)},i.prototype.triggerValueChange=function(t){return void 0===t&&(t={oldValue:null,event:{}}),this.trigger(it,x(t,{value:this.value}))},i.prototype.triggerInput=function(t){return void 0===t&&(t={event:{}}),this.trigger(J,x(t,{value:this.value}))},i.prototype.triggerInputEnd=function(t){return void 0===t&&(t={event:{},error:null,oldElementValue:"",newElementValue:""}),this.trigger(st,x(t,{value:this.value}))},i.prototype.triggerFocus=function(t){return void 0===t&&(t={event:{}}),this.trigger(G,x({},t))},i.prototype.triggerFocusEnd=function(t){return void 0===t&&(t={event:{}}),this.trigger(at,x({},t))},i.prototype.triggerBlur=function(t){return void 0===t&&(t={event:{}}),this.trigger(Q,x({},t))},i.prototype.triggerBlurEnd=function(t){return void 0===t&&(t={event:{}}),this.trigger(nt,x({},t))},i.prototype.triggerChange=function(t){return void 0===t&&(t={event:{}}),this.trigger(rt,x(t,{value:this.value}))},i.prototype.triggerKeyDown=function(t){return void 0===t&&(t={event:{}}),this.trigger($,x({},t))},i.prototype.triggerMouseWheel=function(t){return void 0===t&&(t={event:{}}),this.trigger(et,x({},t))},i.prototype.forceUpdate=function(){this.setTextAndFormat(),this.refreshElementValue()},i.prototype.forceUpdateWithSelection=function(){var t=this.selection,e=t.start,i=t.end,s=this.elementValue.length;this.forceUpdate();var n=this.elementValue.length-s;this.setSelection({start:e+n,end:i+n})},i.prototype.setTextAndFormat=function(){var t=this.dateObject.getTextAndFormat(),e=t.text,i=t.format;this.currentFormat=i,this.currentText=e},i.prototype.setElementValue=function(t){this.element.value=t},i.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}},i.prototype.restorePreviousInputEventState=function(){this.restorePreviousElementValue(),this.restorePreviousElementSelection()},i.prototype.restorePreviousElementValue=function(){this.setElementValue(this.previousElementValue||"")},i.prototype.restorePreviousElementSelection=function(){var t=this.previousElementSelection,e=t.start,i=t.end;this.setSelection({start:e||0,end:i||0})},i.prototype.writeValue=function(t){this.verifyValue(t),this.dateObject=this.getDateObject(t),this.refreshElementValue()},i.prototype.verifyValue=function(t){if(t&&!O(t))throw new Error("The 'value' should be a valid JavaScript Date instance.")},i.prototype.refreshElementValue=function(){var t=this.element,e=this.isActive?this.inputFormat:this.displayFormat,i=this.dateObject.getTextAndFormat(e),s=i.text,n=i.format;this.currentFormat=n,this.currentText=s;var a=this.options.hasPlaceholder||D(this.options.placeholder),r=!this.isActive&&a&&!this.dateObject.hasValue();a&&D(this.options.placeholder)&&(t.placeholder=this.options.placeholder);var o=r?"":s;this.previousElementValue=this.elementValue,this.setElementValue(o)},i.prototype.caret=function(t,e){void 0===e&&(e=t);var i=void 0!==t,s=[t,t],n=this.element;if(!i||!this.options.disabled&&!this.options.readonly){try{void 0!==n.selectionStart&&(i&&(E()&&document.activeElement!==n&&n.focus(),n.setSelectionRange(t,e)),s=[n.selectionStart,n.selectionEnd])}catch(t){s=[]}return s}},i.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])}},i.prototype.selectDateSegment=function(t){for(var e=-1,i=0,s=0;s<this.currentFormat.length;s++)this.currentFormat[s]===t&&(i=s+1,-1===e&&(e=s));e<0&&(e=0),this.caret(0,0),this.caret(e,i)},i.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},i.prototype.createDateObject=function(){var t=this.getDateObjectOptions();return new F(x({},t))},i.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,toggleDayPeriod:this.options.toggleDayPeriod}},i.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},i.prototype.autoFill=function(){var t,e,i,s,n,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(),s=r.hours?r.value.getHours():o.getHours(),n=r.minutes?r.value.getMinutes():o.getMinutes(),a=r.seconds?r.value.getSeconds():o.getSeconds(),r.setValue(new Date(i,e,t,s,n,a)),this.refreshElementValue(),this.triggerValueChange())},i}(W);t.D=lt,t.__meta__={id:"dateinputs-common.cmn.chunk",name:"DateinputsCommonCmnChunk",category:"web",description:"A reusable outputed chunk of code",depends:["date-math.cmn.chunk"],hidden:!0,chunk:!0}})); //# sourceMappingURL=kendo.dateinputs-common.cmn.chunk.min.js.map