UNPKG

jb-date-input

Version:
2 lines 41.1 kB
"use strict";var e=Object.create,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,l=(l,r,o)=>(o=null!=l?e(n(l)):{},((e,n,l,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(var o,h=a(n),u=0,c=h.length;u<c;u++)o=h[u],s.call(e,o)||o===l||t(e,o,{get:(e=>n[e]).bind(null,o),enumerable:!(r=i(n,o))||r.enumerable});return e})(!r&&l&&l.__esModule?o:t(o,"default",{value:l,enumerable:!0}),l));require("jb-calendar");const r=l(require("jb-input"));require("jb-popover");const o=l(require("date-fns")),h=l(require("date-fns-jalali")),u=l(require("jb-validation")),c=l(require("jb-core"));function d(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 m(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 p,g,y,f,b,v,V,D,I,A,E,M,T;function N(e,t){let i=!1;return 8==t&&e>3&&(this.inputChar("0",t),t++),9==t&&e>1&&"3"==this.elements.input.value[8]&&(i=!0),9==t&&0==e&&"0"==this.elements.input.value[8]&&(i=!0),8==t&&0==e&&"0"==this.elements.input.value[9]&&(i=!0),8==t&&3==e&&this.elements.input.value[9]>"0"&&this.inputType==p.jalali&&(2==this.typedMonth.length&&parseInt(this.typedMonth)>6&&this.inputChar("0",9),2==this.typedMonth.length&&parseInt(this.typedMonth)<7&&this.elements.input.value[9]>"1"&&this.inputChar("1",9)),{isIgnoreChar:i,caretPos:t}}function w(e,t){let i=!1;return 5==t&&1==e&&this.elements.input.value[6]>"2"&&(i=!0),6==t&&e>2&&"1"==this.elements.input.value[5]&&(i=!0),6==t&&0==e&&"0"==this.elements.input.value[5]&&(i=!0),5==t&&0==e&&"0"==this.elements.input.value[4]&&(i=!0),{isIgnoreChar:i,caretPos:t}}(g=p||(p={})).jalali="JALALI",g.gregorian="GREGORIAN",(f=y||(y={})).jalali="JALALI",f.gregorian="GREGORIAN",f.timeStamp="TIME_STAMP";var j=class{get valueFormat(){return d(this,A,"f")}set valueFormat(e){m(this,A,e,"f")}get nicheNumbers(){return d(this,I,"f")}get yearOnEmptyBaseOnInputType(){return"JALALI"==d(this,D,"f")?d(this,I,"f").calendarYearOnEmpty.jalali:d(this,I,"f").calendarYearOnEmpty.gregorian}get monthOnEmptyBaseOnValueType(){return"JALALI"==this.valueType?d(this,I,"f").calendarMonthOnEmpty.jalali:d(this,I,"f").calendarMonthOnEmpty.gregorian}get inputType(){return d(this,D,"f")}get valueType(){return d(this,V,"f")}constructor(e){b.add(this),V.set(this,"GREGORIAN"),D.set(this,p.jalali),I.set(this,{calendarYearOnEmpty:{jalali:v.todayJalaliYear,gregorian:v.todayGregorianYear},calendarMonthOnEmpty:{jalali:v.todayJalaliMonth,gregorian:v.todayGregorianMonth}}),A.set(this,"YYYY-MM-DDTHH:mm:ss.SSS[Z]"),e.inputType&&m(this,D,e.inputType,"f"),e.valueType&&m(this,V,e.valueType,"f")}setInputType(e){m(this,D,e,"f")}setValueType(e){m(this,V,e,"f")}getYearValueBaseOnInputType(e){return d(this,D,"f")==p.jalali?e.jalali.year:e.gregorian.year}getMonthValueBaseOnInputType(e){return d(this,D,"f")==p.jalali?e.jalali.month:e.gregorian.month}getDayValueBaseOnInputType(e){return d(this,D,"f")==p.jalali?e.jalali.day:e.gregorian.day}getDateFromValueDateString(e){let t=null;if("TIME_STAMP"==this.valueType)t=v.getDateFromTimestamp(parseInt(e));else{const i=this.getDateObjectValueBaseOnFormat(e),a=parseInt(i.year),n=parseInt(i.month),s=parseInt(i.day);null!=i&&null!==a&&null!==n&&null!==s&&("GREGORIAN"==this.valueType&&(t=v.getDateFromGregorian(a,n,s)),"JALALI"==this.valueType&&(t=v.getDateFromJalali(a,n,s)))}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",s=e.time.second?.toString().padStart(2,"0")??"00",l=e.time.millisecond?.toString().padStart(3,"0")??"000",r=()=>{const{year:t,month:r,day:o}=e.gregorian,h=null==t?i:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),u=null==r?"00":r<10?"0"+r:r.toString(),c=null==o?"00":o<10?"0"+o:o.toString();return d(this,A,"f").replace("YYYY",h).replace("MM",u).replace("DD",c).replace("HH",a).replace("mm",n).replace("ss",s).replace("SSS",l).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")},o=()=>{const{year:t,month:r,day:o}=e.jalali,h=null==t?i:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),u=null==r?"00":r<10?"0"+r:r.toString(),c=null==o?"00":o<10?"0"+o:o.toString();return this.valueFormat.replace("YYYY",h).replace("MM",u).replace("DD",c).replace("HH",a).replace("mm",n).replace("ss",s).replace("SSS",l).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")};if("object"==typeof e)switch(t){case"GREGORIAN":return r();case"JALALI":return o();case"TIME_STAMP":if(e.timeStamp)return e.timeStamp.toString()}return""}getCalendarYear(e){const t=this.inputType==p.gregorian?d(this,I,"f").calendarYearOnEmpty.gregorian:d(this,I,"f").calendarYearOnEmpty.jalali;return this.getYearValueBaseOnInputType(e)||t}getCalendarMonth(e){const t=this.inputType==p.gregorian?d(this,I,"f").calendarMonthOnEmpty.gregorian:d(this,I,"f").calendarMonthOnEmpty.jalali;return this.getMonthValueBaseOnInputType(e)||t}getCalendarDay(e){return this.getDayValueBaseOnInputType(e)}setCalendarDefaultDateView(e,t,i=d(this,D,"f")){i==p.gregorian?(d(this,I,"f").calendarYearOnEmpty.gregorian=e,d(this,I,"f").calendarMonthOnEmpty.gregorian=t):i==p.jalali&&(d(this,I,"f").calendarYearOnEmpty.jalali=e,d(this,I,"f").calendarMonthOnEmpty.jalali=t)}getDateValueObjectBaseOnInputType(e,t,i,a,n,s,l,r,o){return d(this,D,"f")==p.gregorian?d(this,b,"m",E).call(this,e,t,i,a,n,s,l,r,o):d(this,D,"f")==p.jalali?d(this,b,"m",M).call(this,e,t,i,a,n,s,l,r,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,s,l,r,o){return"GREGORIAN"==d(this,V,"f")||"TIME_STAMP"==d(this,V,"f")?d(this,b,"m",E).call(this,e,t,i,a,n,s,l,r,o):"JALALI"==d(this,V,"f")?d(this,b,"m",M).call(this,e,t,i,a,n,s,l,r,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,o.getYear)(e),month:(0,o.getMonth)(e)+1,day:(0,o.getDate)(e)},jalali:{year:(0,h.getYear)(e),month:(0,h.getMonth)(e)+1,day:(0,h.getDate)(e)},timeStamp:(0,o.getTime)(e),time:{hour:(0,h.getHours)(e),minute:(0,h.getMinutes)(e),second:(0,h.getSeconds)(e),millisecond:(0,h.getMilliseconds)(e)}}}static checkJalaliDateValidation(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"),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){const n=v.getDateFromJalali(e,t,i);(0,h.isLeapYear)(n)||(a.isValid=!1,a.error="INVALID_DAY_FOR_LEAP")}return 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=v.getDateFromGregorian(e,t,i);(0,o.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=d(this,A,"f")){const i=d(v,v,"m",T).call(v,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,s,l,r){return a==p.jalali?v.getDateFromJalali(e,t,i):v.getDateFromGregorian(e,t,i)}static getDateFromGregorian(e,t,i,a,n,s,l){return new Date(e,t-1,i,a,n,s,l)}static getDateFromJalali(e,t,i,a,n,s,l){return(0,h.newDate)(e,t-1,i,a,n,s,l)}static getDateFromTimestamp(e){return new Date(e)}static get todayGregorianYear(){return(0,o.getYear)(new Date)}static get todayJalaliYear(){return(0,h.getYear)(new Date)}static get todayGregorianMonth(){return(0,o.getMonth)(new Date)+1}static get todayJalaliMonth(){return(0,h.getMonth)(new Date)+1}};v=j,V=new WeakMap,D=new WeakMap,I=new WeakMap,A=new WeakMap,b=new WeakSet,E=function e(t,i,a,n,s,l,r,u,c){const m={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}},p=v.checkGregorianDateValidation(t,i,a);if(!p.isValid)return"INVALID_MIN_DAY_NUMBER"==p.error?d(this,b,"m",e).call(this,t,i,1,n,s,l,r,u,c):"INVALID_MIN_MONTH_NUMBER"==p.error?d(this,b,"m",e).call(this,t,1,a,n,s,l,r,u,c):"INVALID_MIN_YEAR_NUMBER"==p.error?d(this,b,"m",e).call(this,1900,i,a,n,s,l,r,u,c):"INVALID_MAX_DAY_NUMBER"==p.error?d(this,b,"m",e).call(this,t,i,31,n,s,l,r,u,c):"INVALID_MAX_MONTH_NUMBER"==p.error?d(this,b,"m",e).call(this,t,12,a,n,s,l,r,u,c):"INVALID_MAX_YEAR_NUMBER"==p.error?d(this,b,"m",e).call(this,9e3,i,a,n,s,l,r,u,c):"INVALID_DAY_IN_MONTH"==p.error&&s!=i&&a>29||"INVALID_DAY_FOR_LEAP"==p.error&&n!=t&&29==a?d(this,b,"m",e).call(this,t,i,a-1,n,s,l,r,u,c):{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=v.getDateFromGregorian(t,i,a,l,r,u,c);return m.gregorian={year:(0,o.getYear)(g),month:(0,o.getMonth)(g)+1,day:(0,o.getDate)(g)},m.jalali={year:(0,h.getYear)(g),month:(0,h.getMonth)(g)+1,day:(0,h.getDate)(g)},m.timeStamp=(0,o.getTime)(g),m.time={hour:l,minute:r,second:u,millisecond:c},m},M=function e(t,i,a,n,s,l,r,u,c){const m={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}},p=v.checkJalaliDateValidation(t,i,a);if(!p.isValid)return"INVALID_MIN_DAY_NUMBER"==p.error?d(this,b,"m",e).call(this,t,i,1,n,s,l,r,u,c):"INVALID_MIN_MONTH_NUMBER"==p.error?d(this,b,"m",e).call(this,t,1,a,n,s,l,r,u,c):"INVALID_MIN_YEAR_NUMBER"==p.error?d(this,b,"m",e).call(this,1300,i,a,n,s,l,r,u,c):"INVALID_MAX_DAY_NUMBER"==p.error?d(this,b,"m",e).call(this,t,i,31,n,s,l,r,u,c):"INVALID_MAX_MONTH_NUMBER"==p.error?d(this,b,"m",e).call(this,t,12,a,n,s,l,r,u,c):"INVALID_MAX_YEAR_NUMBER"==p.error?d(this,b,"m",e).call(this,9999,i,a,n,s,l,r,u,c):"INVALID_DAY_IN_MONTH"==p.error&&s!=i&&31==a||"INVALID_DAY_FOR_LEAP"==p.error&&n!=t&&30==a?d(this,b,"m",e).call(this,t,i,a-1,n,s,l,r,u,c):{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=v.getDateFromJalali(t,i,a,l,r,u,c);return m.gregorian={year:(0,o.getYear)(g),month:(0,o.getMonth)(g)+1,day:(0,o.getDate)(g)},m.jalali={year:(0,h.getYear)(g),month:(0,h.getMonth)(g)+1,day:(0,h.getDate)(g)},m.timeStamp=(0,o.getTime)(g),m.time={hour:l,minute:r,second:u,millisecond:c},m},T=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 O={validator:e=>null!=e.inputObject.year&&null!=e.inputObject.month&&null!=e.inputObject.day,message:"لطفا مقدار تاریخ را کامل وارد کنید",stateType:"valueMissing"};function _(e){try{window.CSS.registerProperty({...e})}catch(e){}}const S={black:"oklch(0.14 0 0)",white:"oklch(1 0 0)",highlight:"oklch(0.93 0.2302 125.18)"},L={main:"oklch(0.6 0.26 256)",hover:F(.6,.26,256),pressed:B(.6,.26,256)},R={main:"oklch(0.6 0.26 286)",hover:F(.6,.26,286),pressed:B(.6,.26,286)};function Y(){!function(){_({name:"--jb-primary",syntax:"<color>",inherits:!0,initialValue:L.main}),_({name:"--jb-secondary",syntax:"<color>",inherits:!0,initialValue:R.main}),_({name:"--jb-neutral",syntax:"<color>",inherits:!0,initialValue:"oklch(0.18 0.014 258.36)"}),_({name:"--jb-black",syntax:"<color>",inherits:!0,initialValue:S.black}),_({name:"--jb-white",syntax:"<color>",inherits:!0,initialValue:S.white}),_({name:"--jb-highlight",syntax:"<color>",inherits:!0,initialValue:S.highlight}),_({name:"--jb-green",syntax:"<color>",inherits:!0,initialValue:"oklch(0.68 0.1484 162.1)"}),_({name:"--jb-red",syntax:"<color>",inherits:!0,initialValue:"oklch(0.6 0.22 23.21)"}),_({name:"--jb-neutral",syntax:"<color>",inherits:!0,initialValue:k(0)});for(let e=1;e<=10;e++)_({name:`--jb-neutral-${e}`,syntax:"<color>",inherits:!0,initialValue:k(e)})}(),_({name:"--jb-text-primary",syntax:"<color>",inherits:!0,initialValue:S.black}),_({name:"--jb-text-secondary",syntax:"<color>",inherits:!0,initialValue:k(7)}),_({name:"--jb-text-contrast",syntax:"<color>",inherits:!0,initialValue:S.white})}function k(e){return`oklch(${6*(3+1.3*e)*.01} ${.001*(14+.09*e)} 258.36)`}function F(e,t,i){return`oklch(${e+.07} ${t+.07} ${i})`}function B(e,t,i){return`oklch(${e-.1} ${t-.05} ${i})`}var C,P,x,G,H,U,J,W,q,$,Z,X,K,z,Q,ee,te,ie,ae,ne,se,le,re,oe,he,ue,ce,de,me,pe,ge,ye,fe,be,ve,Ve,De,Ie,Ae,Ee,Me,Te,Ne,we,je,Oe,_e,Se,Le,Re,Ye,ke,Fe,Be,Ce,Pe,xe,Ge,He,Ue,Je,We,qe,$e,Ze,Xe,Ke,ze,Qe,et,tt,it,at,nt;null==HTMLElement&&console.error("you cant render web component on a server side. try to load this component as a client side component");const st=" / / ";var lt=class e extends HTMLElement{get isAutoValidationDisabled(){return d(this,G,"f")}set isAutoValidationDisabled(e){m(this,G,e,"f")}get validation(){return d(this,x,"f")}get disabled(){return d(this,W,"f")}set disabled(e){m(this,W,e,"f"),this.elements.input.disabled=e,e?d(this,P,"f").states?.add("disabled"):d(this,P,"f").states?.delete("disabled")}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){m(this,q,e,"f"),d(this,C,"m",it).call(this,!1)}get required(){return d(this,q,"f")}get name(){return this.getAttribute("name")||""}get form(){return d(this,P,"f").form}get value(){return this.getDateValue()}set value(e){d(this,C,"m",we).call(this,e),d(this,C,"m",ke).call(this)}get isDirty(){return this.value!==(this.initialValue??d(this,H,"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 d(this,H,"f").getDateValueFromValueObject(d(this,$,"f"))}get inputValue(){return d(this,C,"a",Q)}get placeholder(){return d(this,K,"f")}set placeholder(e){m(this,K,e,"f"),this.elements.input.elements.input.placeholder=null!==e?e:"",d(this,C,"m",ke).call(this)}get showCalendar(){return d(this,U,"f")}set showCalendar(e){m(this,U,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"))}get inputType(){return d(this,H,"f").inputType}set inputType(e){Object.values(p).includes(e)?(d(this,H,"f").setInputType(e),this.onInputTypeChange()):console.error(`${e} is not a valid input type`)}get valueType(){return d(this,H,"f").valueType}set valueType(e){Object.values(y).includes(e)?d(this,H,"f").setValueType(e):console.error(`${e} is not a valid value type`)}get yearValue(){switch(this.valueType){case"JALALI":return d(this,$,"f").jalali.year;case"GREGORIAN":case"TIME_STAMP":return d(this,$,"f").gregorian.year;default:return null}}get yearDisplayValue(){switch(this.inputType){case"JALALI":return d(this,$,"f").jalali.year;case"GREGORIAN":return d(this,$,"f").gregorian.year;default:return null}}get monthValue(){switch(this.valueType){case"JALALI":return d(this,$,"f").jalali.month;case"GREGORIAN":case"TIME_STAMP":return d(this,$,"f").gregorian.month;default:return null}}get monthDisplayValue(){switch(this.inputType){case"JALALI":return d(this,$,"f").jalali.month;case"GREGORIAN":return d(this,$,"f").gregorian.month;default:return null}}get dayValue(){switch(this.valueType){case"JALALI":return d(this,$,"f").jalali.day;case"GREGORIAN":case"TIME_STAMP":return d(this,$,"f").gregorian.day;default:return null}}get dayDisplayValue(){switch(this.inputType){case"JALALI":return d(this,$,"f").jalali.day;case"GREGORIAN":return d(this,$,"f").gregorian.day;default:return null}}get yearBaseOnInputType(){switch(this.inputType){case p.jalali:return d(this,$,"f").jalali.year;case p.gregorian:return d(this,$,"f").gregorian.year;default:return null}}get monthBaseOnInputType(){switch(this.inputType){case p.jalali:return d(this,$,"f").jalali.month;case p.gregorian:return d(this,$,"f").gregorian.month;default:return null}}get dayBaseOnInputType(){switch(this.inputType){case p.jalali:return d(this,$,"f").jalali.day;case p.gregorian:return d(this,$,"f").gregorian.day;default:return null}}get typedYear(){return this.inputValue.substring(0,4)}get typedMonth(){return this.inputValue.substring(5,7)}get typedDay(){return this.inputValue.substring(8,10)}get sTypedYear(){return d(this,C,"a",z).substring(0,4)}get sTypedMonth(){return d(this,C,"a",z).substring(5,7)}get sTypedDay(){return d(this,C,"a",z).substring(8,10)}get valueFormat(){return d(this,H,"f").valueFormat}get showPersianNumber(){return d(this,te,"f")}set showPersianNumber(e){m(this,te,e,"f"),d(this,C,"m",ke).call(this)}constructor(){super(),C.add(this),P.set(this,void 0),x.set(this,new u.ValidationHelper({clearValidationError:this.clearValidationError.bind(this),getValue:()=>d(this,C,"a",Z),getValidations:d(this,C,"m",$e).bind(this),getValueString:e=>e.text,setValidationResult:d(this,C,"m",nt).bind(this),showValidationError:this.showValidationError.bind(this)})),G.set(this,!1),H.set(this,new j({inputType:this.getAttribute("input-type"),valueType:this.getAttribute("value-type")})),U.set(this,!1),this.inputFormat="YYYY/MM/DD",J.set(this,/^(?<year>[\u06F0-\u06F90-9,\s]{4})\/(?<month>[\u06F0-\u06F90-9,\s]{2})\/(?<day>[\u06F0-\u06F90-9,\s]{2})$/g),this.dateRestrictions={min:null,max:null},W.set(this,!1),q.set(this,!1),this.DefaultValidationErrorMessage="مقدار وارد شده نا معتبر است",$.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,K.set(this,null),te.set(this,!1),re.set(this,!1),Ce.set(this," / / "),Xe.set(this,!1),"function"==typeof this.attachInternals&&m(this,P,this.attachInternals(),"f"),d(this,C,"m",ne).call(this)}connectedCallback(){d(this,C,"m",ie).call(this),d(this,C,"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[...r.JBInputWebComponent.observedAttributes,...e.dateInputObservedAttributes]}attributeChangedCallback(t,i,a){e.dateInputObservedAttributes.includes(t)?d(this,C,"m",ue).call(this,t,a):r.JBInputWebComponent.observedAttributes.includes(t)&&this.elements.input.setAttribute(t,a)}setFormat(e){d(this,H,"f").valueFormat=e;const t=this.getAttribute("min");t&&d(this,C,"m",ce).call(this,t);const i=this.getAttribute("max");i&&d(this,C,"m",de).call(this,i)}setMinDate(e){d(this,C,"m",ce).call(this,e)}setMaxDate(e){d(this,C,"m",de).call(this,e)}inputChar(e,t){d(this,C,"m",me).call(this,e,t)}getDateValue(e=this.valueType){return d(this,H,"f").getDateValueStringFromValueObject(d(this,$,"f"),e)}focus(){this.elements.input.focus(),this.showCalendar=!0}triggerInputValidation(e=!0){return d(this,C,"m",it).call(this,e)}showValidationError(e){this.elements.input.showValidationError(e),d(this,P,"f").states?.add("invalid")}clearValidationError(){this.elements.input.clearValidationError(),d(this,P,"f").states?.delete("invalid")}async onInputTypeChange(){d(this,re,"f")||await d(this,C,"m",oe).call(this),this.elements.calendar.inputType=this.inputType,d(this,C,"m",ke).call(this)}setCalendarDefaultDateView(e,t,i){e&&t&&(d(this,H,"f").setCalendarDefaultDateView(e,t,i),d(this,C,"m",Oe).call(this))}checkValidity(){const e=d(this,x,"f").checkValiditySync({showError:!1});return e.isAllValid||d(this,C,"m",at).call(this),e.isAllValid}reportValidity(){const e=d(this,x,"f").checkValiditySync({showError:!0});return e.isAllValid||d(this,C,"m",at).call(this),e.isAllValid}get validationMessage(){return d(this,P,"f").validationMessage}};P=new WeakMap,x=new WeakMap,G=new WeakMap,H=new WeakMap,U=new WeakMap,J=new WeakMap,W=new WeakMap,q=new WeakMap,$=new WeakMap,K=new WeakMap,te=new WeakMap,re=new WeakMap,Ce=new WeakMap,Xe=new WeakMap,C=new WeakSet,Z=function(){return{inputObject:d(this,H,"f").getDateObjectValueBaseOnFormat(d(this,C,"a",z),this.inputFormat),text:d(this,C,"a",z),valueText:this.value,valueObject:d(this,$,"f")}},X=function(){d(this,P,"f")&&"function"==typeof d(this,P,"f").setFormValue&&d(this,P,"f").setFormValue(this.value)},z=function(){let e=d(this,C,"a",Q);return d(this,te,"f")&&(e=(0,c.faToEnDigits)(e)),e},Q=function(){return this.elements.input.value},ee=function(e){this.elements.input.value=e},ie=function(){const e=new CustomEvent("load",{bubbles:!0,composed:!0});this.dispatchEvent(e)},ae=function(){const e=new CustomEvent("init",{bubbles:!0,composed:!0});this.dispatchEvent(e)},ne=function(){const e=this.attachShadow({mode:"open",delegatesFocus:!0});Y();const t=document.createElement("template");t.innerHTML='<style>:host{--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, var(--jb-neutral))}:host(:focus),:host(:focus-visible){outline:none}.jb-date-input-web-component{width:100%;margin:var(--jb-date-input-margin, 0 0);position:relative}.jb-date-input-web-component:focus-visible{outline:none}.jb-date-input-web-component .calendar-trigger{display:var(--jb-date-input-calendar-trigger-display, block);width:var(--jb-date-input-calendar-trigger-width, 1.5rem);height:var(--jb-date-input-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)}</style>\n<div class="jb-date-input-web-component">\r\n <jb-input disable-auto-validation part="input">\r\n <div class="date-input-end-section" slot="end-section">\r\n <div class="calendar-trigger" tabindex="0">\r\n <slot name="calendar-trigger-icon">\r\n <svg xmlns="http://www.w3.org/2000/svg" id="CalendarIcon" viewBox="0 0 44.97 44.46">\r\n <defs>\r\n <style></style>\r\n </defs>\r\n <g>\r\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)"/>\r\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"/>\r\n </g>\r\n </svg>\r\n </slot>\r\n </div>\r\n </div>\r\n \x3c!-- <slot name="end-section"></slot> --\x3e\r\n </jb-input>\r\n <jb-popover part="popover">\r\n <jb-calendar tabindex="0" part="calendar"></jb-calendar>\r\n </jb-popover>\r\n</div>',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")},d(this,C,"m",le).call(this),d(this,C,"m",se).call(this)},se=function(){(0,c.isMobile)()?this.elements.input.setAttribute("readonly","true"):this.elements.input.removeAttribute("readonly")},le=function(){this.elements.input.addEventListener("beforeinput",d(this,C,"m",ve).bind(this)),(0,c.listenAndSilentEvent)(this.elements.input,"focus",d(this,C,"m",xe).bind(this),{passive:!0}),(0,c.listenAndSilentEvent)(this.elements.input,"blur",d(this,C,"m",He).bind(this),{passive:!0}),(0,c.listenAndSilentEvent)(this.elements.input,"keypress",d(this,C,"m",Ve).bind(this)),(0,c.listenAndSilentEvent)(this.elements.input,"keyup",d(this,C,"m",De).bind(this)),(0,c.listenAndSilentEvent)(this.elements.input,"keydown",d(this,C,"m",Ae).bind(this)),this.elements.calendarTriggerButton.addEventListener("focus",d(this,C,"m",Ke).bind(this)),this.elements.calendarTriggerButton.addEventListener("blur",d(this,C,"m",ze).bind(this)),this.elements.calendarTriggerButton.addEventListener("click",d(this,C,"m",Qe).bind(this)),this.elements.calendar.addEventListener("select",(e=>d(this,C,"m",et).call(this,e))),this.elements.calendar.addEventListener("init",d(this,C,"m",Ze).bind(this)),this.elements.calendar.addEventListener("blur",d(this,C,"m",Je).bind(this),{passive:!0}),this.elements.popover.addEventListener("close",d(this,C,"m",We).bind(this),{passive:!0})},oe=async function(){return d(this,re,"f")||(await customElements.whenDefined("jb-input"),await customElements.whenDefined("jb-calendar"),await customElements.whenDefined("jb-popover"),m(this,re,!0,"f")),Promise.resolve()},he=function(){d(this,C,"m",oe).call(this).then((()=>{d(this,C,"m",je).call(this),this.value=this.getAttribute("value")||"",d(this,C,"m",ae).call(this)}))},ue=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":d(this,C,"m",ce).call(this,t);break;case"max":d(this,C,"m",de).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,this.elements.calendar.showPersianNumber=!0),"false"!=t&&null!=t||(this.showPersianNumber=!1,this.elements.calendar.showPersianNumber=!1);break;case"placeholder":this.placeholder=t;break;case"disabled":this.disabled=""===t||"true"==t;break;case"error":this.reportValidity()}},ce=function(e){let t=null;t="string"==typeof e?d(this,H,"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 : "+d(this,H,"f").valueFormat)},de=function(e){let t=null;t="string"==typeof e?d(this,H,"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 : "+d(this,H,"f").valueFormat)},me=function(e,t){if(4!=t&&7!=t||(e="/"),t>9||t<0)return;d(this,J,"f").lastIndex=0;const i=d(this,C,"a",Q).split("");d(this,te,"f")&&(e=(0,c.enToFaDigits)(e)),i[t]=e;const a=i.join("");m(this,C,a,"a",ee)},pe=function(e){return/[\u06F0-\u06F90-9/]/g.test(e)},ge=function(e){return(0,c.faToEnDigits)(e).replace(/[^\u06F0-\u06F90-9/]/g,"")},ye=function(e){d(this,C,"m",fe).call(this,e)},fe=function(e){const t=(0,c.createInputEvent)("input",e,{cancelable:!1});this.dispatchEvent(t)},be=function(e){e.stopPropagation();const t=(0,c.createInputEvent)("beforeinput",e,{cancelable:!0});return this.dispatchEvent(t),t.defaultPrevented&&e.preventDefault(),t.defaultPrevented},ve=function(e){if(d(this,C,"m",be).call(this,e))return;const t=e.target.selectionStart,i=t,a=e.data;if(a){this.placeholder&&""===d(this,C,"a",Q)&&m(this,C,st,"a",ee);d(this,C,"m",ge).call(this,a).split("").forEach(((t,a)=>{let n=i+a;if(!d(this,C,"m",pe).call(this,t))return void e.preventDefault();4!=n&&7!=n||("/"==t&&e.target.setSelectionRange(n+1,n+1),n++);let s=!1;if("/"==t)return;const l=parseInt(t);5==n&&l>1&&(d(this,C,"m",me).call(this,"0",n),n++);const r=w.call(this,l,n);n=r.caretPos;const o=N.call(this,l,n);n=o.caretPos,s=s||o.isIgnoreChar||r.isIgnoreChar,s||(d(this,C,"m",me).call(this,t,n),e.target.setSelectionRange(n+1,n+1))})),e.preventDefault()}if("deleteContentBackward"==e.inputType||"deleteContentForward"==e.inputType||"delete"==e.inputType||"deleteByCut"==e.inputType||"deleteByDrag"==e.inputType){const i=e.target.selectionEnd;let a=0;"deleteContentBackward"==e.inputType&&(a=-1);for(let e=t;e<=i;e++)d(this,C,"m",me).call(this," ",e+a);this.elements.input.setSelectionRange(t+a,t+a),this.placeholder&&d(this,C,"a",Q)==st&&m(this,C,"","a",ee),e.preventDefault()}d(this,C,"m",ye).call(this,e)},Ve=function(e){e.stopPropagation();const t=(0,c.createKeyboardEvent)("keypress",e,{cancelable:!1});this.dispatchEvent(t)},De=function(e){d(this,C,"m",Fe).call(this,d(this,C,"a",z)),d(this,C,"m",Ie).call(this,e)},Ie=function(e){e.stopPropagation();const t=(0,c.createKeyboardEvent)("keyup",e,{cancelable:!1});this.dispatchEvent(t)},Ae=function(e){if(!d(this,C,"m",Ee).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?d(this,C,"m",Me).call(this,1):d(this,C,"m",Me).call(this,-1),t.setSelectionRange(0,4)),i>4&&i<8&&(38==e.keyCode?d(this,C,"m",Te).call(this,1):d(this,C,"m",Te).call(this,-1),t.setSelectionRange(5,7)),i>7&&(38==e.keyCode?d(this,C,"m",Ne).call(this,1):d(this,C,"m",Ne).call(this,-1),t.setSelectionRange(8,10)),e.preventDefault()}},Ee=function(e){e.stopPropagation();const t=(0,c.createKeyboardEvent)("keydown",e,{cancelable:!1});return this.dispatchEvent(t)},Me=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:d(this,H,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1,a=this.dayDisplayValue||1,{hour:n,minute:s,millisecond:l,second:r}=d(this,$,"f").time;d(this,C,"m",Ye).call(this,t+e,i,a,n,s,r,l),d(this,C,"m",ke).call(this)},Te=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:d(this,H,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1,a=this.dayDisplayValue||1,{hour:n,minute:s,millisecond:l,second:r}=d(this,$,"f").time;d(this,C,"m",Ye).call(this,t,i+e,a,n,s,r,l),d(this,C,"m",ke).call(this)},Ne=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:d(this,H,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1,a=this.dayDisplayValue||1,{hour:n,minute:s,millisecond:l,second:r}=d(this,$,"f").time;d(this,C,"m",Ye).call(this,t,i,a+e,n,s,r,l),d(this,C,"m",ke).call(this)},we=function(e){if("string"==typeof e)switch(d(this,H,"f").valueType){case"GREGORIAN":case"JALALI":d(this,C,"m",Le).call(this,e);break;case"TIME_STAMP":d(this,C,"m",Se).call(this,e)}else e instanceof Date&&d(this,C,"m",_e).call(this,e);d(this,C,"m",X).call(this)},je=function(){m(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}},"f")},Oe=function(){const e={year:d(this,H,"f").getCalendarYear(d(this,$,"f")),month:d(this,H,"f").getCalendarMonth(d(this,$,"f")),day:d(this,H,"f").getCalendarDay(d(this,$,"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)},_e=function(e){const t=d(this,H,"f").getDateObjectValueFromDateValue(e);m(this,$,t,"f"),d(this,C,"m",Oe).call(this)},Se=function(e){const t=parseInt(e);m(this,$,d(this,H,"f").getDateValueObjectFromTimeStamp(t),"f"),d(this,C,"m",Oe).call(this)},Le=function(e){const t=d(this,H,"f").getDateObjectValueBaseOnFormat(e);t.year&&t.month&&t.day?d(this,C,"m",Re).call(this,parseInt(t.year),parseInt(t.month),parseInt(t.day),parseInt(t.hour??"00"),parseInt(t.minute??"00"),parseInt(t.second??"00"),parseInt(t.millisecond??"000")):null!=e&&""!==e?console.error("your inputted Date doest match default or your specified Format"):d(this,C,"m",je).call(this)},Re=function(e,t,i,a,n,s,l){const r=this.yearValue,o=this.monthValue,h=d(this,H,"f").getDateValueObjectBaseOnValueType(e,t,i,r,o,a,n,s,l);m(this,$,h,"f"),d(this,C,"m",Oe).call(this)},Ye=function(e,t,i,a,n,s,l){const r=this.yearBaseOnInputType,o=this.monthBaseOnInputType,h=d(this,H,"f").getDateValueObjectBaseOnInputType(e,t,i,r,o,a,n,s,l);m(this,$,h,"f"),d(this,C,"m",Oe).call(this),d(this,C,"m",X).call(this)},ke=function(){const{year:e,month:t,day:i}=this.inputType==p.jalali?d(this,$,"f").jalali:d(this,$,"f").gregorian;if(this.placeholder&&!(e&&t&&i))return void m(this,C,"","a",ee);let a=this.inputFormat,n=" ",s=" ",l=" ";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)||(s=t<10?"0"+t:t.toString()),null==i||Number.isNaN(i)||(l=i<10?"0"+i:i.toString()),d(this,te,"f")&&(n=(0,c.enToFaDigits)(n),s=(0,c.enToFaDigits)(s),l=(0,c.enToFaDigits)(l)),a=a.replace("YYYY",n).replace("MM",s).replace("DD",l),m(this,C,a,"a",ee)},Fe=function(e){const t=d(this,J,"f").exec(e);if(t&&t.groups){const{hour:e,minute:i,millisecond:a,second:n}=d(this,$,"f").time,s=parseInt(t.groups.year),l=parseInt(t.groups.month),r=parseInt(t.groups.day);s&&l&&r&&d(this,C,"m",Ye).call(this,s,l,r,e,i,n,a)}},Be=function(){const e=this.elements.input.selectionStart;if(e){const t=this.typedYear.trim().length;if(t<e&&e<=4)return void this.elements.input.setSelectionRange(t,t);const i=this.typedMonth.trim().length;if(i+5<e&&e>4&&e<=7)return void this.elements.input.setSelectionRange(i+5,i+5);const a=this.typedDay.trim().length;if(a+8<e&&e>7&&e<=10)return void this.elements.input.setSelectionRange(a+8,a+8)}},Pe=function(e){const t=()=>{m(this,Ce,e,"f")};return d(this,Ce,"f")!=e?(m(this,Ce,e,"f"),{isUpdated:!0,updatePrevValue:t}):{isUpdated:!1,updatePrevValue:t}},xe=function(e){m(this,Ce,d(this,C,"a",z),"f"),this.focus(),document.addEventListener("selectionchange",d(this,C,"m",Be).bind(this)),d(this,C,"m",Ge).call(this,e)},Ge=function(e){e.stopPropagation();const t=(0,c.createFocusEvent)("focus",e,{cancelable:!1});this.dispatchEvent(t)},He=function(e){document.removeEventListener("selectionchange",d(this,C,"m",Be).bind(this));const t=e.relatedTarget;t!==this.elements.calendar&&t!==this.elements.calendarTriggerButton&&(this.showCalendar=!1);const i=d(this,C,"a",z),a=d(this,C,"m",Pe).call(this,i);if(a.isUpdated){d(this,C,"m",Fe).call(this,i);const t=d(this,C,"m",qe).call(this);d(this,C,"m",it).call(this,!0),t.defaultPrevented?(e.preventDefault(),d(this,C,"m",Fe).call(this,d(this,Ce,"f"))):a.updatePrevValue()}d(this,C,"m",Ue).call(this,e)},Ue=function(e){e.stopPropagation();const t=(0,c.createFocusEvent)("blur",e,{cancelable:!1});this.dispatchEvent(t)},Je=function(e){const t=e.relatedTarget;t!==this.elements.input&&t!==this.elements.calendarTriggerButton&&(this.showCalendar=!1)},We=function(){this.showCalendar=!1,this.elements.input.blur()},qe=function(){const e=new Event("change",{composed:!0,bubbles:!0,cancelable:!0});return this.dispatchEvent(e),e},$e=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(O),this.dateRestrictions.min&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),i=this.dateRestrictions.min,(0,o.isAfter)(t,i)||(0,o.isEqual)(t,i);var t,i},message:"تاریخ انتخابی کمتر از بازه مجاز است",stateType:"rangeUnderflow"}),this.dateRestrictions.max&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),i=this.dateRestrictions.max,(0,o.isBefore)(t,i)||(0,o.isEqual)(t,i);var t,i},message:"تاریخ انتخابی بیشتر از بازه مجاز است",stateType:"rangeOverflow"}),e},Ze=function(){this.elements.calendar.dateRestrictions.min=this.dateRestrictions.min,this.elements.calendar.dateRestrictions.max=this.dateRestrictions.max,this.elements.calendar.defaultCalendarData={gregorian:{year:d(this,H,"f").nicheNumbers.calendarYearOnEmpty.gregorian,month:d(this,H,"f").nicheNumbers.calendarMonthOnEmpty.gregorian},jalali:{year:d(this,H,"f").nicheNumbers.calendarYearOnEmpty.jalali,month:d(this,H,"f").nicheNumbers.calendarMonthOnEmpty.jalali}},d(this,C,"m",Oe).call(this)},Ke=function(e){const t=e.relatedTarget;this.showCalendar&&t&&[this.elements.calendar,this.elements.input].includes(t)?(t.focus(),this.showCalendar=!1):(m(this,Xe,!0,"f"),this.showCalendar=!0)},ze=function(e){[this.elements.calendar,this.elements.input].includes(e.relatedTarget)||(this.showCalendar=!1)},Qe=function(){const e=this.shadowRoot?.activeElement;e&&!d(this,Xe,"f")&&e==this.elements.calendarTriggerButton&&(this.showCalendar=!this.showCalendar),m(this,Xe,!1,"f")},et=function(e){const t=e.target,{year:i,month:a,day:n}=t.value;if(i&&a&&n){const t=structuredClone(this.valueInDate),{hour:s,minute:l,millisecond:r,second:o}=d(this,$,"f").time;d(this,C,"m",Ye).call(this,i,a,n,s,l,o,r),d(this,C,"m",ke).call(this),this.showCalendar=!1,d(this,C,"m",tt).call(this),d(this,C,"m",it).call(this,!0);d(this,C,"m",qe).call(this).defaultPrevented&&(e.preventDefault(),d(this,C,"m",_e).call(this,t),d(this,C,"m",ke).call(this))}},tt=function(){const e=new CustomEvent("select");this.dispatchEvent(e)},it=function(e){if(!this.isAutoValidationDisabled)return d(this,x,"f").checkValidity({showError:e})},at=function(){const e=new CustomEvent("invalid");this.dispatchEvent(e)},nt=function(e){if(e.isAllValid)d(this,P,"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))})),d(this,P,"f").setValidity(t,i)}},lt.formAssociated=!0;!customElements.get("jb-date-input")&&window.customElements.define("jb-date-input",lt),Object.defineProperty(exports,"InputTypes",{enumerable:!0,get:function(){return p}}),exports.JBDateInputWebComponent=lt,Object.defineProperty(exports,"ValueTypes",{enumerable:!0,get:function(){return y}}); //# sourceMappingURL=jb-date-input.cjs.js.map