jb-date-input
Version:
jalali date input web component
2 lines • 40.6 kB
JavaScript
var e=Object.create,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.getPrototypeOf,r=Object.prototype.hasOwnProperty,s=(s,l,o)=>(o=null!=s?e(n(s)):{},((e,n,s,l)=>{if(n&&"object"==typeof n||"function"==typeof n)for(var o,u=a(n),h=0,c=u.length;h<c;h++)o=u[h],r.call(e,o)||o===s||t(e,o,{get:(e=>n[e]).bind(null,o),enumerable:!(l=i(n,o))||l.enumerable});return e})(!l&&s&&s.__esModule?o:t(o,"default",{value:s,enumerable:!0}),s));require("jb-calendar");const l=s(require("jb-input"));require("jb-popover");const o=s(require("jb-validation")),u=s(require("jb-core")),h=s(require("jb-core/theme")),c=s(require("date-fns")),d=s(require("date-fns-jalali")),m=s(require("jb-core/i18n"));function p(e,t,i,a){if("a"===i&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?a:"a"===i?a.call(e):a?a.value:t.get(e)}function g(e,t,i,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,i):n?n.value=i:t.set(e,i),i}var f,y;(y=f||(f={})).jalali="JALALI",y.gregorian="GREGORIAN",y.timeStamp="TIME_STAMP";const b=" / / ",v="YYYY/MM/DD",V=/^(?<year>[\u06F0-\u06F90-9,\s]{4})\/(?<month>[\u06F0-\u06F90-9,\s]{2})\/(?<day>[\u06F0-\u06F90-9,\s]{2})$/g;var D,I,A,N,E,M,T,w,j,O,_;function S(e){return[1,5,9,13,17,22,26,30].includes(e%33)}function R(e){return e.substring(5,7)}function L(e){return e.substring(0,4)}function Y(e){return e.substring(8,10)}function B(e){const{showPersianNumber:t,dateInputType:i,selection:a,event:{data:n,inputType:r}}=e,s=a.start;let l=s,o=e.value;var h;return n&&(h=e.event.data||"",(0,u.faToEnDigits)(h).replace(/[^\u06F0-\u06F90-9/]/g,"")).split("").forEach(((e,t)=>{let a=s+t;if(!/[\u06F0-\u06F90-9/]/g.test(e))return;4!=a&&7!=a||("/"==e&&d(a+1),a++);let n=!1;if("/"==e)return;const r=Number(e);5==a&&r>1&&(c("0",a),a++);const l=function(e,t,i){let a=!1;return 5==i&&1==t&&e[6]>"2"&&(a=!0),6==i&&t>2&&"1"==e[5]&&(a=!0),6==i&&0==t&&"0"==e[5]&&(a=!0),5==i&&0==t&&"0"==e[4]&&(a=!0),{isIgnoreChar:a,caretPos:i}}(o,r,a);a=l.caretPos;const u=function(e,t,i,a,n){let r=!1;if(8==i&&t>3&&(n("0",i),i++),9==i&&t>1&&"3"==a[8]&&(r=!0),9==i&&0==t&&"0"==a[8]&&(r=!0),8==i&&0==t&&"0"==a[9]&&(r=!0),"JALALI"==e&&!r){const e=R(a),s=Number(e);if(9==i&&"3"==a[8]&&t>0&&s>6&&(r=!0),8==i&&3==t){if(12==s){const e=Number(L(a));!Number.isNaN(e)&&S(e)||(r=!0)}a[9]>"0"&&(2==e.length&&parseInt(a)>6&&n("0",9),2==e.length&&s<7&&a[9]>"1"&&n("1",9))}}return{isIgnoreChar:r,caretPos:i}}(i,r,a,o,c);a=u.caretPos,n=n||u.isIgnoreChar||l.isIgnoreChar,n||(c(e,a),d(a+1))})),"deleteContentBackward"!=r&&"deleteContentForward"!=r&&"delete"!=r&&"deleteByCut"!=r&&"deleteByDrag"!=r||function(e,t,i,a,n){let r=0;"deleteContentBackward"==e&&(r=t!==i?0:-1);for(let e=t;e<=i;e++)a(" ",e+r);n(t+r)}(r,a.start,a.end,c,d),{value:o,selectionStart:l,selectionEnd:l};function c(e,i){o=function(e,t,i,a){if(4!=t&&7!=t||(e="/"),t>9||t<0)return i;const n=i.split("");return a&&(e=(0,u.enToFaDigits)(e)),n[t]=e,n.join("")}(e,i,o,t)}function d(e){l=e}}function F(e){const t=e.selectionStart;if(t){const i=L(e.inputValue).trim().length,a=R(e.inputValue).trim().length,n=Y(e.inputValue).trim().length;if(i<t&&(t<=4||0==a&&0==n))return i;if(t>4&&(t<=7&&a+5<t||0==n&&a<2))return a+5;if(n+8<t&&t>7&&t<=10)return n+8}return null}(I=D||(D={})).jalali="JALALI",I.gregorian="GREGORIAN";var C=class{get valueFormat(){return p(this,w,"f")}set valueFormat(e){g(this,w,e,"f")}get nicheNumbers(){return p(this,T,"f")}get yearOnEmptyBaseOnInputType(){return"JALALI"==p(this,M,"f")?p(this,T,"f").calendarYearOnEmpty.jalali:p(this,T,"f").calendarYearOnEmpty.gregorian}get monthOnEmptyBaseOnValueType(){return"JALALI"==this.valueType?p(this,T,"f").calendarMonthOnEmpty.jalali:p(this,T,"f").calendarMonthOnEmpty.gregorian}get inputType(){return p(this,M,"f")}get valueType(){return p(this,E,"f")}constructor(e){A.add(this),E.set(this,"GREGORIAN"),M.set(this,"persian"==m.i18n.locale.calendar?D.jalali:D.gregorian),T.set(this,{calendarYearOnEmpty:{jalali:N.todayJalaliYear,gregorian:N.todayGregorianYear},calendarMonthOnEmpty:{jalali:N.todayJalaliMonth,gregorian:N.todayGregorianMonth}}),w.set(this,"YYYY-MM-DDTHH:mm:ss.SSS[Z]"),e.inputType&&g(this,M,e.inputType,"f"),e.valueType&&g(this,E,e.valueType,"f")}setInputType(e){g(this,M,e,"f")}setValueType(e){g(this,E,e,"f")}getYearValueBaseOnInputType(e){return p(this,M,"f")==D.jalali?e.jalali.year:e.gregorian.year}getMonthValueBaseOnInputType(e){return p(this,M,"f")==D.jalali?e.jalali.month:e.gregorian.month}getDayValueBaseOnInputType(e){return p(this,M,"f")==D.jalali?e.jalali.day:e.gregorian.day}getDateFromValueDateString(e){let t=null;if("TIME_STAMP"==this.valueType)t=N.getDateFromTimestamp(parseInt(e));else{const i=this.getDateObjectValueBaseOnFormat(e),a=parseInt(i.year),n=parseInt(i.month),r=parseInt(i.day);null!=i&&null!==a&&null!==n&&null!==r&&("GREGORIAN"==this.valueType&&(t=N.getDateFromGregorian(a,n,r)),"JALALI"==this.valueType&&(t=N.getDateFromJalali(a,n,r)))}return t}getDateValueFromValueObject(e){if(e.gregorian.year&&e.gregorian.month&&e.gregorian.day){return new Date(e.gregorian.year,e.gregorian.month-1,e.gregorian.day)}return null}getDateValueStringFromValueObject(e,t=this.valueType){const i="0000",a=e.time.hour?.toString().padStart(2,"0")??"00",n=e.time.minute?.toString().padStart(2,"0")??"00",r=e.time.second?.toString().padStart(2,"0")??"00",s=e.time.millisecond?.toString().padStart(3,"0")??"000",l=()=>{const{year:t,month:l,day:o}=e.gregorian,u=null==t?i:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),h=null==l?"00":l<10?"0"+l:l.toString(),c=null==o?"00":o<10?"0"+o:o.toString();return p(this,w,"f").replace("YYYY",u).replace("MM",h).replace("DD",c).replace("HH",a).replace("mm",n).replace("ss",r).replace("SSS",s).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")},o=()=>{const{year:t,month:l,day:o}=e.jalali,u=null==t?i:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),h=null==l?"00":l<10?"0"+l:l.toString(),c=null==o?"00":o<10?"0"+o:o.toString();return this.valueFormat.replace("YYYY",u).replace("MM",h).replace("DD",c).replace("HH",a).replace("mm",n).replace("ss",r).replace("SSS",s).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")};if("object"==typeof e)switch(t){case"GREGORIAN":return l();case"JALALI":return o();case"TIME_STAMP":if(e.timeStamp)return e.timeStamp.toString()}return""}getCalendarYear(e){const t=this.inputType==D.gregorian?p(this,T,"f").calendarYearOnEmpty.gregorian:p(this,T,"f").calendarYearOnEmpty.jalali;return this.getYearValueBaseOnInputType(e)||t}getCalendarMonth(e){const t=this.inputType==D.gregorian?p(this,T,"f").calendarMonthOnEmpty.gregorian:p(this,T,"f").calendarMonthOnEmpty.jalali;return this.getMonthValueBaseOnInputType(e)||t}getCalendarDay(e){return this.getDayValueBaseOnInputType(e)}setCalendarDefaultDateView(e,t,i=p(this,M,"f")){i==D.gregorian?(p(this,T,"f").calendarYearOnEmpty.gregorian=e,p(this,T,"f").calendarMonthOnEmpty.gregorian=t):i==D.jalali&&(p(this,T,"f").calendarYearOnEmpty.jalali=e,p(this,T,"f").calendarMonthOnEmpty.jalali=t)}getDateValueObjectBaseOnInputType(e,t,i,a,n,r,s,l,o){return p(this,M,"f")==D.gregorian?p(this,A,"m",j).call(this,e,t,i,a,n,r,s,l,o):p(this,M,"f")==D.jalali?p(this,A,"m",O).call(this,e,t,i,a,n,r,s,l,o):(console.error("INVALID_INPUT_TYPE"),{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}})}getDateValueObjectBaseOnValueType(e,t,i,a,n,r,s,l,o){return"GREGORIAN"==p(this,E,"f")||"TIME_STAMP"==p(this,E,"f")?p(this,A,"m",j).call(this,e,t,i,a,n,r,s,l,o):"JALALI"==p(this,E,"f")?p(this,A,"m",O).call(this,e,t,i,a,n,r,s,l,o):(console.error("INVALID_INPUT_TYPE"),{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}})}getDateValueObjectFromTimeStamp(e){const t=new Date(e);return isFinite(+t)?this.getDateObjectValueFromDateValue(t):{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}}}getDateObjectValueFromDateValue(e){return{gregorian:{year:(0,c.getYear)(e),month:(0,c.getMonth)(e)+1,day:(0,c.getDate)(e)},jalali:{year:(0,d.getYear)(e),month:(0,d.getMonth)(e)+1,day:(0,d.getDate)(e)},timeStamp:(0,c.getTime)(e),time:{hour:(0,d.getHours)(e),minute:(0,d.getMinutes)(e),second:(0,d.getSeconds)(e),millisecond:(0,d.getMilliseconds)(e)}}}static checkJalaliDateValidation(e,t,i){const a={isValid:!0,error:null};return isNaN(e)&&(a.isValid=!1,a.error="INVALID_YEAR"),isNaN(t)&&(a.isValid=!1,a.error="INVALID_MONTH"),isNaN(i)&&(a.isValid=!1,a.error="INVALID_DAY"),t<1&&(a.isValid=!1,a.error="INVALID_MIN_MONTH_NUMBER"),i<1&&(a.isValid=!1,a.error="INVALID_MIN_DAY_NUMBER"),t>12&&(a.isValid=!1,a.error="INVALID_MAX_MONTH_NUMBER"),i>31&&(a.isValid=!1,a.error="INVALID_MAX_DAY_NUMBER"),e<1e3&&(a.isValid=!1,a.error="INVALID_MIN_YEAR_NUMBER"),e>9999&&(a.isValid=!1,a.error="INVALID_MAX_YEAR_NUMBER"),t>6&&t<12&&i>30&&(a.isValid=!1,a.error="INVALID_DAY_IN_MONTH"),12==t&&i>30&&(a.isValid=!1,a.error="INVALID_DAY_IN_MONTH"),a.isValid&&12==t&&12==t&&30==i&&(S(e)||(a.isValid=!1,a.error="INVALID_DAY_FOR_LEAP")),a}static checkGregorianDateValidation(e,t,i){const a={isValid:!0,error:null};if(isNaN(e)&&(a.isValid=!1,a.error="INVALID_YEAR"),isNaN(t)&&(a.isValid=!1,a.error="INVALID_MONTH"),isNaN(i)&&(a.isValid=!1,a.error="INVALID_DAY"),t<1&&(a.isValid=!1,a.error="INVALID_MIN_MONTH_NUMBER"),i<1&&(a.isValid=!1,a.error="INVALID_MIN_DAY_NUMBER"),t>12&&(a.isValid=!1,a.error="INVALID_MAX_MONTH_NUMBER"),i>31&&(a.isValid=!1,a.error="INVALID_MAX_DAY_NUMBER"),e<1e3&&(a.isValid=!1,a.error="INVALID_MIN_YEAR_NUMBER"),e>9999&&(a.isValid=!1,a.error="INVALID_MAX_YEAR_NUMBER"),[2,4,6,9,11].includes(i)&&i>30&&(a.isValid=!1,a.error="INVALID_DAY_IN_MONTH"),2==t&&i>28)if(29==i){const n=N.getDateFromGregorian(e,t,i);(0,c.isLeapYear)(n)||(a.isValid=!1,a.error="INVALID_DAY_FOR_LEAP")}else a.isValid=!1,a.error="INVALID_DAY_IN_MONTH";return a}getDateObjectValueBaseOnFormat(e,t=p(this,w,"f")){const i=p(N,N,"m",_).call(N,e,t),a={year:null,month:null,day:null,hour:null,millisecond:null,minute:null,second:null};return i&&i.groups&&(a.year=i.groups.year,a.month=i.groups.month,a.day=i.groups.day,a.hour=i.groups.hour,a.minute=i.groups.minute,a.second=i.groups.second,a.millisecond=i.groups.millisecond),a}static getDate(e,t,i,a,n,r,s,l){return a==D.jalali?N.getDateFromJalali(e,t,i):N.getDateFromGregorian(e,t,i)}static getDateFromGregorian(e,t,i,a,n,r,s){return new Date(e,t-1,i,a,n,r,s)}static getDateFromJalali(e,t,i,a,n,r,s){return(0,d.newDate)(e,t-1,i,a,n,r,s)}static getDateFromTimestamp(e){return new Date(e)}static get todayGregorianYear(){return(0,c.getYear)(new Date)}static get todayJalaliYear(){return(0,d.getYear)(new Date)}static get todayGregorianMonth(){return(0,c.getMonth)(new Date)+1}static get todayJalaliMonth(){return(0,d.getMonth)(new Date)+1}};N=C,E=new WeakMap,M=new WeakMap,T=new WeakMap,w=new WeakMap,A=new WeakSet,j=function e(t,i,a,n,r,s,l,o,u){const h={gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},m=N.checkGregorianDateValidation(t,i,a);if(!m.isValid)return"INVALID_MIN_DAY_NUMBER"==m.error?p(this,A,"m",e).call(this,t,i,1,n,r,s,l,o,u):"INVALID_MIN_MONTH_NUMBER"==m.error?p(this,A,"m",e).call(this,t,1,a,n,r,s,l,o,u):"INVALID_MIN_YEAR_NUMBER"==m.error?p(this,A,"m",e).call(this,1900,i,a,n,r,s,l,o,u):"INVALID_MAX_DAY_NUMBER"==m.error?p(this,A,"m",e).call(this,t,i,31,n,r,s,l,o,u):"INVALID_MAX_MONTH_NUMBER"==m.error?p(this,A,"m",e).call(this,t,12,a,n,r,s,l,o,u):"INVALID_MAX_YEAR_NUMBER"==m.error?p(this,A,"m",e).call(this,9e3,i,a,n,r,s,l,o,u):"INVALID_DAY_IN_MONTH"==m.error&&r!=i&&a>29||"INVALID_DAY_FOR_LEAP"==m.error&&n!=t&&29==a?p(this,A,"m",e).call(this,t,i,a-1,n,r,s,l,o,u):{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}};const g=N.getDateFromGregorian(t,i,a,s,l,o,u);return h.gregorian={year:(0,c.getYear)(g),month:(0,c.getMonth)(g)+1,day:(0,c.getDate)(g)},h.jalali={year:(0,d.getYear)(g),month:(0,d.getMonth)(g)+1,day:(0,d.getDate)(g)},h.timeStamp=(0,c.getTime)(g),h.time={hour:s,minute:l,second:o,millisecond:u},h},O=function e(t,i,a,n,r,s,l,o,u){const h={gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},m=N.checkJalaliDateValidation(t,i,a);if(!m.isValid){if("INVALID_MIN_DAY_NUMBER"==m.error)return p(this,A,"m",e).call(this,t,i,1,n,r,s,l,o,u);if("INVALID_MIN_MONTH_NUMBER"==m.error)return p(this,A,"m",e).call(this,t,1,a,n,r,s,l,o,u);if("INVALID_MIN_YEAR_NUMBER"==m.error)return p(this,A,"m",e).call(this,1300,i,a,n,r,s,l,o,u);if("INVALID_MAX_DAY_NUMBER"==m.error)return p(this,A,"m",e).call(this,t,i,31,n,r,s,l,o,u);if("INVALID_MAX_MONTH_NUMBER"==m.error)return p(this,A,"m",e).call(this,t,12,a,n,r,s,l,o,u);if("INVALID_MAX_YEAR_NUMBER"==m.error)return p(this,A,"m",e).call(this,9999,i,a,n,r,s,l,o,u);if("INVALID_DAY_IN_MONTH"==m.error&&r!=i&&31==a)return p(this,A,"m",e).call(this,t,i,a-1,n,r,s,l,o,u);if("INVALID_DAY_FOR_LEAP"==m.error){const a=S(t)?30:29;return p(this,A,"m",e).call(this,t,i,a,n,r,s,l,o,u)}return{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}}}const g=N.getDateFromJalali(t,i,a,s,l,o,u);return h.gregorian={year:(0,c.getYear)(g),month:(0,c.getMonth)(g)+1,day:(0,c.getDate)(g)},h.jalali={year:(0,d.getYear)(g),month:(0,d.getMonth)(g)+1,day:(0,d.getDate)(g)},h.timeStamp=(0,c.getTime)(g),h.time={hour:s,minute:l,second:o,millisecond:u},h},_=function(e,t){const i=t.replace("YYYY","(?<year>[\\d]{4})").replace("MM","(?<month>[\\d]{2})").replace("DD","(?<day>[\\d]{2})").replace("HH","(?<hour>[\\d]{2})").replace("mm","(?<minute>[\\d]{2})").replace("ss","(?<second>[\\d]{2})").replace("SSS","(?<millisecond>[\\d]{3})").replace("[Z]","Ž").replace("Z","(?<zone>([\\+,-]\\d{2}:\\d{2}))").replace("Ž","Z");return new RegExp(i,"g").exec(e)};const k=new m.JBDictionary({fa:{minRangeViolation:"تاریخ انتخابی کمتر از بازه مجاز است",maxRangeViolation:"تاریخ انتخابی بیشتر از بازه مجاز است",required:"لطفا مقدار تاریخ را کامل وارد کنید"},en:{minRangeViolation:"Your selected date is before valid date range",maxRangeViolation:"Your selected date is after valid date range",required:"Please fill date completely"}}),P={validator:e=>null!=e.inputObject.year&&null!=e.inputObject.month&&null!=e.inputObject.day,message:k.get(m.i18n,"required"),stateType:"valueMissing"};var x,G,H,U,J,q,W,Z,X,$,K,z,Q,ee,te,ie,ae,ne,re,se,le,oe,ue,he,ce,de,me,pe,ge,fe,ye,be,ve,Ve,De,Ie,Ae,Ne,Ee,Me,Te,we,je,Oe,_e,Se,Re,Le,Ye,Be,Fe,Ce,ke,Pe,xe,Ge,He,Ue,Je,qe,We,Ze,Xe,$e,Ke,ze,Qe,et,tt,it;null==HTMLElement&&console.error("you cant render web component on a server side. try to load this component as a client side component");var at=class e extends HTMLElement{get isAutoValidationDisabled(){return p(this,U,"f")}set isAutoValidationDisabled(e){g(this,U,e,"f")}get validation(){return p(this,H,"f")}get disabled(){return p(this,W,"f")}set disabled(e){g(this,W,e,"f"),this.elements.input.disabled=e,e?(p(this,G,"f").states?.add("disabled"),p(this,G,"f").ariaDisabled="true"):(p(this,G,"f").states?.delete("disabled"),p(this,G,"f").ariaDisabled="false")}get selectionStart(){return this.elements.input.selectionStart}set selectionStart(e){this.elements.input.selectionStart=e}get selectionEnd(){return this.elements.input.selectionEnd}set selectionEnd(e){this.elements.input.selectionEnd=e}get selectionDirection(){return this.elements.input.selectionDirection}set selectionDirection(e){this.elements.input.selectionDirection=e}setSelectionRange(e,t,i){this.elements.input.setSelectionRange(e,t,i)}set required(e){g(this,Z,e,"f"),p(this,G,"f").ariaRequired=e?"true":"false",p(this,x,"m",et).call(this,!1)}get required(){return p(this,Z,"f")}get name(){return this.getAttribute("name")||""}get form(){return p(this,G,"f").form}get value(){return this.getDateValue()}set value(e){p(this,x,"m",Me).call(this,e),p(this,x,"m",Le).call(this)}get isDirty(){return this.value!==(this.initialValue??p(this,J,"f").getDateValueStringFromValueObject({gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},this.valueType))}setMonthList(e,t){this.elements.calendar.setMonthList(e,t)}get valueInDate(){return p(this,J,"f").getDateValueFromValueObject(p(this,X,"f"))}get inputValue(){return p(this,x,"a",ee)}get placeholder(){return p(this,z,"f")}set placeholder(e){g(this,z,e,"f"),p(this,G,"f").ariaPlaceholder=e,this.elements.input.elements.input.placeholder=null!==e?e:"",p(this,x,"m",Le).call(this)}get showCalendar(){return p(this,q,"f")}set showCalendar(e){g(this,q,e,"f"),1==e?(this.elements.calendar.setupStyleBaseOnCssDirection(),this.elements.popover.open(),this.elements.calendarTriggerButton.classList.add("--active")):(this.elements.popover.close(),this.elements.calendarTriggerButton.classList.remove("--active"),p(this,x,"m",we).call(this))}get inputType(){return p(this,J,"f").inputType}set inputType(e){Object.values(D).includes(e)?(p(this,J,"f").setInputType(e),this.onInputTypeChange()):console.error(`${e} is not a valid input type`)}get valueType(){return p(this,J,"f").valueType}set valueType(e){Object.values(f).includes(e)?p(this,J,"f").setValueType(e):console.error(`${e} is not a valid value type`)}get yearValue(){switch(this.valueType){case"JALALI":return p(this,X,"f").jalali.year;case"GREGORIAN":case"TIME_STAMP":return p(this,X,"f").gregorian.year;default:return null}}get yearDisplayValue(){switch(this.inputType){case"JALALI":return p(this,X,"f").jalali.year;case"GREGORIAN":return p(this,X,"f").gregorian.year;default:return null}}get monthValue(){switch(this.valueType){case"JALALI":return p(this,X,"f").jalali.month;case"GREGORIAN":case"TIME_STAMP":return p(this,X,"f").gregorian.month;default:return null}}get monthDisplayValue(){switch(this.inputType){case"JALALI":return p(this,X,"f").jalali.month;case"GREGORIAN":return p(this,X,"f").gregorian.month;default:return null}}get dayValue(){switch(this.valueType){case"JALALI":return p(this,X,"f").jalali.day;case"GREGORIAN":case"TIME_STAMP":return p(this,X,"f").gregorian.day;default:return null}}get dayDisplayValue(){switch(this.inputType){case"JALALI":return p(this,X,"f").jalali.day;case"GREGORIAN":return p(this,X,"f").gregorian.day;default:return null}}get yearBaseOnInputType(){switch(this.inputType){case D.jalali:return p(this,X,"f").jalali.year;case D.gregorian:return p(this,X,"f").gregorian.year;default:return null}}get monthBaseOnInputType(){switch(this.inputType){case D.jalali:return p(this,X,"f").jalali.month;case D.gregorian:return p(this,X,"f").gregorian.month;default:return null}}get dayBaseOnInputType(){switch(this.inputType){case D.jalali:return p(this,X,"f").jalali.day;case D.gregorian:return p(this,X,"f").gregorian.day;default:return null}}get typedYear(){return L(this.inputValue)}get typedMonth(){return R(this.inputValue)}get typedDay(){return Y(this.inputValue)}get sTypedYear(){return L(p(this,x,"a",Q))}get sTypedMonth(){return R(p(this,x,"a",Q))}get sTypedDay(){return Y(p(this,x,"a",Q))}get valueFormat(){return p(this,J,"f").valueFormat}get showPersianNumber(){return p(this,ie,"f")}set showPersianNumber(e){g(this,ie,e,"f"),this.elements.calendar.showPersianNumber=e,p(this,x,"m",Le).call(this)}constructor(){super(),x.add(this),G.set(this,void 0),H.set(this,new o.ValidationHelper({clearValidationError:this.clearValidationError.bind(this),getValue:()=>p(this,x,"a",$),getValidations:p(this,x,"m",qe).bind(this),getValueString:e=>e.text,setValidationResult:p(this,x,"m",it).bind(this),showValidationError:this.showValidationError.bind(this)})),U.set(this,!1),J.set(this,new C({inputType:this.getAttribute("input-type"),valueType:this.getAttribute("value-type")})),q.set(this,!1),this.dateRestrictions={min:null,max:null},W.set(this,!1),Z.set(this,!1),X.set(this,{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}}),this.initialValue=null,z.set(this,null),ie.set(this,"arabext"==m.i18n.locale.numberingSystem),oe.set(this,!1),Fe.set(this,b),Ze.set(this,!1),"function"==typeof this.attachInternals&&g(this,G,this.attachInternals(),"f"),p(this,x,"m",re).call(this)}connectedCallback(){p(this,x,"m",ae).call(this),p(this,x,"m",he).call(this)}static get dateInputObservedAttributes(){return["value-type","value","name","format","min","max","required","input-type","direction","show-persian-number","placeholder","disabled","error"]}static get observedAttributes(){return[...l.JBInputWebComponent.observedAttributes,...e.dateInputObservedAttributes]}attributeChangedCallback(t,i,a){e.dateInputObservedAttributes.includes(t)?p(this,x,"m",ce).call(this,t,a):l.JBInputWebComponent.observedAttributes.includes(t)&&this.elements.input.setAttribute(t,a)}setFormat(e){p(this,J,"f").valueFormat=e;const t=this.getAttribute("min");t&&p(this,x,"m",de).call(this,t);const i=this.getAttribute("max");i&&p(this,x,"m",me).call(this,i)}setMinDate(e){p(this,x,"m",de).call(this,e)}setMaxDate(e){p(this,x,"m",me).call(this,e)}getDateValue(e=this.valueType){return p(this,J,"f").getDateValueStringFromValueObject(p(this,X,"f"),e)}focus(){this.elements.input.focus(),this.showCalendar=!0}triggerInputValidation(e=!0){return p(this,x,"m",et).call(this,e)}showValidationError(e){this.elements.input.showValidationError(e),p(this,G,"f").states?.add("invalid")}clearValidationError(){this.elements.input.clearValidationError(),p(this,G,"f").states?.delete("invalid")}async onInputTypeChange(){p(this,oe,"f")||await p(this,x,"m",ue).call(this),this.elements.calendar.inputType=this.inputType,p(this,x,"m",Le).call(this)}setCalendarDefaultDateView(e,t,i){e&&t&&(p(this,J,"f").setCalendarDefaultDateView(e,t,i),p(this,x,"m",we).call(this))}checkValidity(){const e=p(this,H,"f").checkValiditySync({showError:!1});return e.isAllValid||p(this,x,"m",tt).call(this),e.isAllValid}reportValidity(){const e=p(this,H,"f").checkValiditySync({showError:!0});return e.isAllValid||p(this,x,"m",tt).call(this),e.isAllValid}get validationMessage(){return p(this,G,"f").validationMessage}};G=new WeakMap,H=new WeakMap,U=new WeakMap,J=new WeakMap,q=new WeakMap,W=new WeakMap,Z=new WeakMap,X=new WeakMap,z=new WeakMap,ie=new WeakMap,oe=new WeakMap,Fe=new WeakMap,Ze=new WeakMap,x=new WeakSet,$=function(){return{inputObject:p(this,J,"f").getDateObjectValueBaseOnFormat(p(this,x,"a",Q),v),text:p(this,x,"a",Q),valueText:this.value,valueObject:p(this,X,"f")}},K=function(){p(this,G,"f")&&"function"==typeof p(this,G,"f").setFormValue&&p(this,G,"f").setFormValue(this.value)},Q=function(){let e=p(this,x,"a",ee);return p(this,ie,"f")&&(e=(0,u.faToEnDigits)(e)),e},ee=function(){return this.elements.input.value},te=function(e){this.elements.input.value=e},ae=function(){const e=new CustomEvent("load",{bubbles:!0,composed:!0});this.dispatchEvent(e)},ne=function(){const e=new CustomEvent("init",{bubbles:!0,composed:!0});this.dispatchEvent(e)},re=function(){const e=this.attachShadow({mode:"open",delegatesFocus:!0});(0,h.registerDefaultVariables)();const t=document.createElement("template");t.innerHTML='<style>:host{display:block}:host(:focus),:host(:focus-visible){outline:none}.jb-date-input-web-component{width:100%;margin:var(--margin);position:relative}.jb-date-input-web-component:focus-visible{outline:none}.jb-date-input-web-component .calendar-trigger{display:var(--calendar-trigger-display,block);width:var(--calendar-trigger-width,1.5rem);height:var(--calendar-trigger-height,1.5rem);cursor:pointer;object-fit:contain}.jb-date-input-web-component .calendar-trigger.--active svg .cls-1{fill:var(--calendar-icon-color-active)}.jb-date-input-web-component .calendar-trigger svg{width:100%;height:100%}.jb-date-input-web-component .calendar-trigger svg .cls-1{fill:var(--calendar-icon-color)} :host{--margin:var(--jb-date-input-margin,0 0);--calendar-trigger-display:var(--jb-date-input-calendar-trigger-display,block);--calendar-trigger-width:var(--jb-date-input-calendar-trigger-width,1.5rem);--calendar-trigger-height:var(--jb-date-input-calendar-trigger-height,1.5rem);--calendar-icon-color:var(--jb-date-input-calendar-icon-color,var(--jb-neutral-6));--calendar-icon-color-active:var(--jb-date-input-calendar-icon-color-active,var(--jb-neutral))}</style>\n\n <div class="jb-date-input-web-component">\n <jb-input disable-auto-validation part="input">\n <div class="date-input-end-section" slot="end-section">\n <div class="calendar-trigger" tabindex="0" >\n <slot name="calendar-trigger-icon">\n <svg xmlns="http://www.w3.org/2000/svg" id="CalendarIcon" viewBox="0 0 44.97 44.46">\n <defs>\n <style></style>\n </defs>\n <g>\n <path id="Path_11948" data-name="Path 11948" class="cls-1" d="M41.91,12H3.67C2,12,.61,12.59.61,13.37S2,14.78,3.67,14.78H41.91c1.69,0,3.06-.63,3.06-1.41S43.6,12,41.91,12Z" transform="translate(0 0)"/>\n <path id="Path_11946" data-name="Path 11946" class="cls-1" d="M33.73,2.22H33V1.36A1.58,1.58,0,0,0,31.33,0a1.61,1.61,0,0,0-1.69,1.36v.86l-5.88,0V1.48A1.46,1.46,0,0,0,22.31,0h-.12a1.59,1.59,0,0,0-1.7,1.48v.74l-6.07,0V1.36A1.6,1.6,0,0,0,12.76,0C11.93,0,11,.61,11,1.36v.89C4.87,2.58,0,7.18,0,12.79v21.1c0,5.83,5.24,10.57,11.68,10.57h21.6C39.73,44.46,45,39.72,45,33.89V12.79C45,7,40.17,2.22,33.73,2.22ZM42,33.89c0,4.33-3.89,7.85-8.68,7.85H11.69C6.9,41.74,3,38.22,3,33.89V12.79C3,8.67,6.53,5.29,11,5v.68C11,6.4,12,7,12.76,7a1.63,1.63,0,0,0,1.67-1.36V4.93h6.06v.85c0,.75,1,1.23,1.71,1.23s1.56-.48,1.56-1.23V4.93h5.88v.72A1.62,1.62,0,0,0,31.33,7,1.59,1.59,0,0,0,33,5.65V4.93h.3c4.79,0,8.68,3.53,8.68,7.86Z"/>\n </g>\n </svg>\n </slot>\n </div>\n </div>\n \x3c!-- <slot name="end-section"></slot> --\x3e\n </jb-input>\n <jb-popover part="popover">\n <jb-calendar tabindex="0" part="calendar"></jb-calendar>\n </jb-popover>\n </div>\n ',e.appendChild(t.content.cloneNode(!0)),this.elements={input:e.querySelector("jb-input"),calendarTriggerButton:e.querySelector(".calendar-trigger"),calendar:e.querySelector("jb-calendar"),popover:e.querySelector("jb-popover")},p(this,x,"m",le).call(this),p(this,x,"m",se).call(this)},se=function(){(0,u.isMobile)()?this.elements.input.setAttribute("readonly","true"):this.elements.input.removeAttribute("readonly")},le=function(){this.elements.input.addEventListener("beforeinput",p(this,x,"m",ye).bind(this)),(0,u.listenAndSilentEvent)(this.elements.input,"focus",p(this,x,"m",ke).bind(this),{passive:!0}),(0,u.listenAndSilentEvent)(this.elements.input,"blur",p(this,x,"m",xe).bind(this),{passive:!0}),(0,u.listenAndSilentEvent)(this.elements.input,"keypress",p(this,x,"m",be).bind(this)),(0,u.listenAndSilentEvent)(this.elements.input,"keyup",p(this,x,"m",ve).bind(this)),(0,u.listenAndSilentEvent)(this.elements.input,"keydown",p(this,x,"m",De).bind(this)),this.elements.calendarTriggerButton.addEventListener("focus",p(this,x,"m",Xe).bind(this)),this.elements.calendarTriggerButton.addEventListener("blur",p(this,x,"m",$e).bind(this)),this.elements.calendarTriggerButton.addEventListener("click",p(this,x,"m",Ke).bind(this)),this.elements.calendar.addEventListener("select",(e=>p(this,x,"m",ze).call(this,e))),this.elements.calendar.addEventListener("init",p(this,x,"m",We).bind(this)),this.elements.calendar.addEventListener("blur",p(this,x,"m",He).bind(this),{passive:!0}),this.elements.popover.addEventListener("close",p(this,x,"m",Ue).bind(this),{passive:!0})},ue=async function(){return p(this,oe,"f")||(await customElements.whenDefined("jb-input"),await customElements.whenDefined("jb-calendar"),await customElements.whenDefined("jb-popover"),g(this,oe,!0,"f")),Promise.resolve()},he=function(){p(this,x,"m",ue).call(this).then((()=>{p(this,x,"m",Te).call(this),this.value=this.getAttribute("value")||"",p(this,x,"m",ne).call(this)}))},ce=function(e,t){switch(e){case"value":this.value=t;break;case"name":this.elements.input.setAttribute("name",t);break;case"value-type":this.valueType=t;break;case"format":this.setFormat(t);break;case"min":p(this,x,"m",de).call(this,t);break;case"max":p(this,x,"m",me).call(this,t);break;case"required":this.required=""===t||"true"==t;break;case"input-type":this.inputType=t;break;case"direction":this.elements.calendar.setAttribute("direction",t);break;case"show-persian-number":"true"==t||""===t?this.showPersianNumber=!0:"false"!=t&&null!=t||(this.showPersianNumber=!1);break;case"placeholder":this.placeholder=t;break;case"disabled":this.disabled=""===t||"true"==t;break;case"error":this.reportValidity()}},de=function(e){let t=null;t="string"==typeof e?p(this,J,"f").getDateFromValueDateString(e):e,t?(this.dateRestrictions.min=t,this.elements.calendar.dateRestrictions&&(this.elements.calendar.dateRestrictions.min=t)):console.error(`min date ${e} is not valid and it will be ignored`,"\n","please provide min date in format : "+p(this,J,"f").valueFormat)},me=function(e){let t=null;t="string"==typeof e?p(this,J,"f").getDateFromValueDateString(e):e,t?(this.dateRestrictions.max=t,this.elements.calendar.dateRestrictions&&(this.elements.calendar.dateRestrictions.max=t)):console.error(`max date ${e} is not valid and it will be ignored`,"\n","please provide max date in format : "+p(this,J,"f").valueFormat)},pe=function(e){p(this,x,"m",ge).call(this,e)},ge=function(e){const t=(0,u.createInputEvent)("input",e,{cancelable:!1});this.dispatchEvent(t)},fe=function(e){e.stopPropagation();const t=(0,u.createInputEvent)("beforeinput",e,{cancelable:!0});return this.dispatchEvent(t),t.defaultPrevented&&e.preventDefault(),t.defaultPrevented},ye=function(e){if(p(this,x,"m",fe).call(this,e))return;const t=e.target;e.data&&this.placeholder&&""===t.value&&(g(this,x,b,"a",te),t.setSelectionRange(0,0));const i=B({dateInputType:p(this,J,"f").inputType,showPersianNumber:this.showPersianNumber,value:p(this,x,"a",ee),selection:{start:t.selectionStart,end:t.selectionEnd},event:{data:e.data,inputType:e.inputType}});e.preventDefault(),g(this,x,i.value,"a",te),t.setSelectionRange(i.selectionStart,i.selectionEnd),this.placeholder&&t.value==b&&g(this,x,"","a",te),p(this,x,"m",pe).call(this,e)},be=function(e){e.stopPropagation();const t=(0,u.createKeyboardEvent)("keypress",e,{cancelable:!1});this.dispatchEvent(t)},ve=function(e){p(this,x,"m",Ye).call(this,p(this,x,"a",Q)),p(this,x,"m",Ve).call(this,e)},Ve=function(e){e.stopPropagation();const t=(0,u.createKeyboardEvent)("keyup",e,{cancelable:!1});this.dispatchEvent(t)},De=function(e){if(!p(this,x,"m",Ie).call(this,e))return void e.preventDefault();const t=e.target;if(38==e.keyCode||40==e.keyCode){const i=t.selectionStart;i<5&&(38==e.keyCode?p(this,x,"m",Ae).call(this,1):p(this,x,"m",Ae).call(this,-1),t.setSelectionRange(0,4)),i>4&&i<8&&(38==e.keyCode?p(this,x,"m",Ne).call(this,1):p(this,x,"m",Ne).call(this,-1),t.setSelectionRange(5,7)),i>7&&(38==e.keyCode?p(this,x,"m",Ee).call(this,1):p(this,x,"m",Ee).call(this,-1),t.setSelectionRange(8,10)),e.preventDefault()}},Ie=function(e){e.stopPropagation();const t=(0,u.createKeyboardEvent)("keydown",e,{cancelable:!1});return this.dispatchEvent(t)},Ae=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:p(this,J,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1,a=this.dayDisplayValue||1,{hour:n,minute:r,millisecond:s,second:l}=p(this,X,"f").time;p(this,x,"m",Re).call(this,t+e,i,a,n,r,l,s),p(this,x,"m",Le).call(this)},Ne=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:p(this,J,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1;let a=this.dayDisplayValue||1;const{hour:n,minute:r,millisecond:s,second:l}=p(this,X,"f").time;p(this,x,"m",Re).call(this,t,i+e,a,n,r,l,s),p(this,x,"m",Le).call(this)},Ee=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:p(this,J,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1,a=this.dayDisplayValue||1,{hour:n,minute:r,millisecond:s,second:l}=p(this,X,"f").time;p(this,x,"m",Re).call(this,t,i,a+e,n,r,l,s),p(this,x,"m",Le).call(this)},Me=function(e){if("string"==typeof e)switch(p(this,J,"f").valueType){case"GREGORIAN":case"JALALI":p(this,x,"m",_e).call(this,e);break;case"TIME_STAMP":p(this,x,"m",Oe).call(this,e)}else e instanceof Date&&p(this,x,"m",je).call(this,e);p(this,x,"m",K).call(this)},Te=function(){g(this,X,{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},"f")},we=function(){const e={year:p(this,J,"f").getCalendarYear(p(this,X,"f")),month:p(this,J,"f").getCalendarMonth(p(this,X,"f")),day:p(this,J,"f").getCalendarDay(p(this,X,"f"))};e.year&&e.month&&e.day?this.elements.calendar.value=e:e.year&&e.month&&(this.elements.calendar.data.selectedYear=e.year,this.elements.calendar.data.selectedMonth=e.month)},je=function(e){const t=p(this,J,"f").getDateObjectValueFromDateValue(e);g(this,X,t,"f"),p(this,x,"m",we).call(this)},Oe=function(e){const t=Number(e);g(this,X,p(this,J,"f").getDateValueObjectFromTimeStamp(t),"f"),p(this,x,"m",we).call(this)},_e=function(e){const t=p(this,J,"f").getDateObjectValueBaseOnFormat(e);t.year&&t.month&&t.day?p(this,x,"m",Se).call(this,Number(t.year),Number(t.month),Number(t.day),Number(t.hour??"00"),Number(t.minute??"00"),Number(t.second??"00"),Number(t.millisecond??"000")):null!=e&&""!==e?console.error("your inputted Date doest match default or your specified Format"):p(this,x,"m",Te).call(this)},Se=function(e,t,i,a,n,r,s){const l=this.yearValue,o=this.monthValue,u=p(this,J,"f").getDateValueObjectBaseOnValueType(e,t,i,l,o,a,n,r,s);g(this,X,u,"f"),p(this,x,"m",we).call(this)},Re=function(e,t,i,a,n,r,s){const l=this.yearBaseOnInputType,o=this.monthBaseOnInputType,u=p(this,J,"f").getDateValueObjectBaseOnInputType(e,t,i,l,o,a,n,r,s);g(this,X,u,"f"),p(this,x,"m",we).call(this),p(this,x,"m",K).call(this)},Le=function(){const{year:e,month:t,day:i}=this.inputType==D.jalali?p(this,X,"f").jalali:p(this,X,"f").gregorian;if(this.placeholder&&!(e&&t&&i))return void g(this,x,"","a",te);let a=v,n=" ",r=" ",s=" ";null==e||Number.isNaN(e)||(n=e<10?"000"+e:e<100?"00"+e:e<1e3?"0"+e:e.toString()),null==t||Number.isNaN(t)||(r=t<10?"0"+t:t.toString()),null==i||Number.isNaN(i)||(s=i<10?"0"+i:i.toString()),p(this,ie,"f")&&(n=(0,u.enToFaDigits)(n),r=(0,u.enToFaDigits)(r),s=(0,u.enToFaDigits)(s)),a=a.replace("YYYY",n).replace("MM",r).replace("DD",s),g(this,x,a,"a",te)},Ye=function(e){V.lastIndex=0;const t=V.exec(e);if(t&&t.groups){const{hour:e,minute:i,millisecond:a,second:n}=p(this,X,"f").time,r=Number(t.groups.year),s=Number(t.groups.month),l=Number(t.groups.day);r&&s&&l&&p(this,x,"m",Re).call(this,r,s,l,e,i,n,a)}},Be=function(){const e=F({inputValue:this.inputValue,selectionStart:this.elements.input.selectionStart});null!==e&&e!==this.elements.input.selectionStart&&this.elements.input.setSelectionRange(e,e);const t=function(e){return e<5?"YEAR":e<8?"MONTH":e<11?"DAY":null}(e??this.elements.input.selectionStart);t&&(this.elements.calendar.activeSection=t)},Ce=function(e){const t=()=>{g(this,Fe,e,"f")};return p(this,Fe,"f")!=e?(g(this,Fe,e,"f"),{isUpdated:!0,updatePrevValue:t}):{isUpdated:!1,updatePrevValue:t}},ke=function(e){g(this,Fe,p(this,x,"a",Q),"f"),this.focus(),document.addEventListener("selectionchange",p(this,x,"m",Be).bind(this)),p(this,x,"m",Pe).call(this,e)},Pe=function(e){e.stopPropagation();const t=(0,u.createFocusEvent)("focus",e,{cancelable:!1});this.dispatchEvent(t)},xe=function(e){document.removeEventListener("selectionchange",p(this,x,"m",Be).bind(this));const t=e.relatedTarget;t!==this.elements.calendar&&t!==this.elements.calendarTriggerButton&&(this.showCalendar=!1);const i=p(this,x,"a",Q),a=p(this,x,"m",Ce).call(this,i);if(a.isUpdated){p(this,x,"m",Ye).call(this,i);const t=p(this,x,"m",Je).call(this);p(this,x,"m",et).call(this,!0),t.defaultPrevented?(e.preventDefault(),p(this,x,"m",Ye).call(this,p(this,Fe,"f"))):a.updatePrevValue()}p(this,x,"m",Ge).call(this,e)},Ge=function(e){e.stopPropagation();const t=(0,u.createFocusEvent)("blur",e,{cancelable:!1});this.dispatchEvent(t)},He=function(e){const t=e.relatedTarget;t!==this.elements.input&&t!==this.elements.calendarTriggerButton&&(this.showCalendar=!1)},Ue=function(){this.showCalendar=!1,this.elements.input.blur()},Je=function(){const e=new Event("change",{composed:!0,bubbles:!0,cancelable:!0});return this.dispatchEvent(e),e},qe=function(){const e=[];return null!==this.getAttribute("error")&&this.getAttribute("error").trim().length>0&&e.push({validator:void 0,message:this.getAttribute("error"),stateType:"customError"}),this.required&&e.push(P),this.dateRestrictions.min&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),i=this.dateRestrictions.min,(0,c.isAfter)(t,i)||(0,c.isEqual)(t,i);var t,i},message:k.get(m.i18n,"minRangeViolation"),stateType:"rangeUnderflow"}),this.dateRestrictions.max&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),i=this.dateRestrictions.max,(0,c.isBefore)(t,i)||(0,c.isEqual)(t,i);var t,i},message:k.get(m.i18n,"maxRangeViolation"),stateType:"rangeOverflow"}),e},We=function(){this.elements.calendar.dateRestrictions.min=this.dateRestrictions.min,this.elements.calendar.dateRestrictions.max=this.dateRestrictions.max,this.elements.calendar.defaultCalendarData={gregorian:{year:p(this,J,"f").nicheNumbers.calendarYearOnEmpty.gregorian,month:p(this,J,"f").nicheNumbers.calendarMonthOnEmpty.gregorian},jalali:{year:p(this,J,"f").nicheNumbers.calendarYearOnEmpty.jalali,month:p(this,J,"f").nicheNumbers.calendarMonthOnEmpty.jalali}},p(this,x,"m",we).call(this)},Xe=function(e){const t=e.relatedTarget;this.showCalendar&&t&&[this.elements.calendar,this.elements.input].includes(t)?(t.focus(),this.showCalendar=!1):(g(this,Ze,!0,"f"),this.showCalendar=!0)},$e=function(e){[this.elements.calendar,this.elements.input].includes(e.relatedTarget)||(this.showCalendar=!1)},Ke=function(){const e=this.shadowRoot?.activeElement;e&&!p(this,Ze,"f")&&e==this.elements.calendarTriggerButton&&(this.showCalendar=!this.showCalendar),g(this,Ze,!1,"f")},ze=function(e){const t=e.target,{year:i,month:a,day:n}=t.value;if(i&&a&&n){const t=structuredClone(this.valueInDate),{hour:r,minute:s,millisecond:l,second:o}=p(this,X,"f").time;p(this,x,"m",Re).call(this,i,a,n,r,s,o,l),p(this,x,"m",Le).call(this),this.showCalendar=!1,p(this,x,"m",Qe).call(this),p(this,x,"m",et).call(this,!0);p(this,x,"m",Je).call(this).defaultPrevented&&(e.preventDefault(),p(this,x,"m",je).call(this,t),p(this,x,"m",Le).call(this))}},Qe=function(){const e=new CustomEvent("select");this.dispatchEvent(e)},et=function(e){if(!this.isAutoValidationDisabled)return p(this,H,"f").checkValidity({showError:e})},tt=function(){const e=new CustomEvent("invalid");this.dispatchEvent(e)},it=function(e){if(e.isAllValid)p(this,G,"f").setValidity({},"");else{const t={};let i="";e.validationList.forEach((e=>{e.isValid||(e.validation.stateType?t[e.validation.stateType]=!0:t.customError=!0,""==i&&(i=e.message))})),p(this,G,"f").setValidity(t,i)}},at.formAssociated=!0;!customElements.get("jb-date-input")&&window.customElements.define("jb-date-input",at),Object.defineProperty(exports,"InputTypes",{enumerable:!0,get:function(){return D}}),exports.JBDateInputWebComponent=at,Object.defineProperty(exports,"ValueTypes",{enumerable:!0,get:function(){return f}}),exports.dictionary=k,exports.emptyInputValueString=b,exports.getFixedCaretPos=F,exports.handleBeforeInput=B;
//# sourceMappingURL=jb-date-input.cjs.js.map