persian-date-kit 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";const w=require("react/jsx-runtime"),je=require("react"),ge=require("react-dom");function $e(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>t[s]})}}return n.default=t,Object.freeze(n)}const x=$e(je);function Gt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wt={exports:{}},Me=wt.exports,Ut;function Kt(){return Ut||(Ut=1,(function(t,n){(function(s,r){t.exports=r()})(Me,(function(){var s=1e3,r=6e4,l=36e5,c="millisecond",D="second",C="minute",_="hour",v="day",P="week",S="month",R="quarter",L="year",T="date",H="Invalid Date",O=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,I=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,J={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var o=["th","st","nd","rd"],a=e%100;return"["+e+(o[(a-20)%10]||o[a]||o[0])+"]"}},G=function(e,o,a){var y=String(e);return!y||y.length>=o?e:""+Array(o+1-y.length).join(a)+e},F={s:G,z:function(e){var o=-e.utcOffset(),a=Math.abs(o),y=Math.floor(a/60),u=a%60;return(o<=0?"+":"-")+G(y,2,"0")+":"+G(u,2,"0")},m:function e(o,a){if(o.date()<a.date())return-e(a,o);var y=12*(a.year()-o.year())+(a.month()-o.month()),u=o.clone().add(y,S),p=a-u<0,M=o.clone().add(y+(p?-1:1),S);return+(-(y+(a-u)/(p?u-M:M-u))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:S,y:L,w:P,d:v,D:T,h:_,m:C,s:D,ms:c,Q:R}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return e===void 0}},k="en",j={};j[k]=J;var W="$isDayjsObject",Q=function(e){return e instanceof N||!(!e||!e[W])},f=function e(o,a,y){var u;if(!o)return k;if(typeof o=="string"){var p=o.toLowerCase();j[p]&&(u=p),a&&(j[p]=a,u=p);var M=o.split("-");if(!u&&M.length>1)return e(M[0])}else{var g=o.name;j[g]=o,u=g}return!y&&u&&(k=u),u||!y&&k},d=function(e,o){if(Q(e))return e.clone();var a=typeof o=="object"?o:{};return a.date=e,a.args=arguments,new N(a)},h=F;h.l=f,h.i=Q,h.w=function(e,o){return d(e,{locale:o.$L,utc:o.$u,x:o.$x,$offset:o.$offset})};var N=(function(){function e(a){this.$L=f(a.locale,null,!0),this.parse(a),this.$x=this.$x||a.x||{},this[W]=!0}var o=e.prototype;return o.parse=function(a){this.$d=(function(y){var u=y.date,p=y.utc;if(u===null)return new Date(NaN);if(h.u(u))return new Date;if(u instanceof Date)return new Date(u);if(typeof u=="string"&&!/Z$/i.test(u)){var M=u.match(O);if(M){var g=M[2]-1||0,A=(M[7]||"0").substring(0,3);return p?new Date(Date.UTC(M[1],g,M[3]||1,M[4]||0,M[5]||0,M[6]||0,A)):new Date(M[1],g,M[3]||1,M[4]||0,M[5]||0,M[6]||0,A)}}return new Date(u)})(a),this.init()},o.init=function(){var a=this.$d;this.$y=a.getFullYear(),this.$M=a.getMonth(),this.$D=a.getDate(),this.$W=a.getDay(),this.$H=a.getHours(),this.$m=a.getMinutes(),this.$s=a.getSeconds(),this.$ms=a.getMilliseconds()},o.$utils=function(){return h},o.isValid=function(){return this.$d.toString()!==H},o.isSame=function(a,y){var u=d(a);return this.startOf(y)<=u&&u<=this.endOf(y)},o.isAfter=function(a,y){return d(a)<this.startOf(y)},o.isBefore=function(a,y){return this.endOf(y)<d(a)},o.$g=function(a,y,u){return h.u(a)?this[y]:this.set(u,a)},o.unix=function(){return Math.floor(this.valueOf()/1e3)},o.valueOf=function(){return this.$d.getTime()},o.startOf=function(a,y){var u=this,p=!!h.u(y)||y,M=h.p(a),g=function(ut,U){var et=h.w(u.$u?Date.UTC(u.$y,U,ut):new Date(u.$y,U,ut),u);return p?et:et.endOf(v)},A=function(ut,U){return h.w(u.toDate()[ut].apply(u.toDate("s"),(p?[0,0,0,0]:[23,59,59,999]).slice(U)),u)},Y=this.$W,E=this.$M,K=this.$D,tt="set"+(this.$u?"UTC":"");switch(M){case L:return p?g(1,0):g(31,11);case S:return p?g(1,E):g(0,E+1);case P:var q=this.$locale().weekStart||0,nt=(Y<q?Y+7:Y)-q;return g(p?K-nt:K+(6-nt),E);case v:case T:return A(tt+"Hours",0);case _:return A(tt+"Minutes",1);case C:return A(tt+"Seconds",2);case D:return A(tt+"Milliseconds",3);default:return this.clone()}},o.endOf=function(a){return this.startOf(a,!1)},o.$set=function(a,y){var u,p=h.p(a),M="set"+(this.$u?"UTC":""),g=(u={},u[v]=M+"Date",u[T]=M+"Date",u[S]=M+"Month",u[L]=M+"FullYear",u[_]=M+"Hours",u[C]=M+"Minutes",u[D]=M+"Seconds",u[c]=M+"Milliseconds",u)[p],A=p===v?this.$D+(y-this.$W):y;if(p===S||p===L){var Y=this.clone().set(T,1);Y.$d[g](A),Y.init(),this.$d=Y.set(T,Math.min(this.$D,Y.daysInMonth())).$d}else g&&this.$d[g](A);return this.init(),this},o.set=function(a,y){return this.clone().$set(a,y)},o.get=function(a){return this[h.p(a)]()},o.add=function(a,y){var u,p=this;a=Number(a);var M=h.p(y),g=function(E){var K=d(p);return h.w(K.date(K.date()+Math.round(E*a)),p)};if(M===S)return this.set(S,this.$M+a);if(M===L)return this.set(L,this.$y+a);if(M===v)return g(1);if(M===P)return g(7);var A=(u={},u[C]=r,u[_]=l,u[D]=s,u)[M]||1,Y=this.$d.getTime()+a*A;return h.w(Y,this)},o.subtract=function(a,y){return this.add(-1*a,y)},o.format=function(a){var y=this,u=this.$locale();if(!this.isValid())return u.invalidDate||H;var p=a||"YYYY-MM-DDTHH:mm:ssZ",M=h.z(this),g=this.$H,A=this.$m,Y=this.$M,E=u.weekdays,K=u.months,tt=u.meridiem,q=function(U,et,it,ot){return U&&(U[et]||U(y,p))||it[et].slice(0,ot)},nt=function(U){return h.s(g%12||12,U,"0")},ut=tt||function(U,et,it){var ot=U<12?"AM":"PM";return it?ot.toLowerCase():ot};return p.replace(I,(function(U,et){return et||(function(it){switch(it){case"YY":return String(y.$y).slice(-2);case"YYYY":return h.s(y.$y,4,"0");case"M":return Y+1;case"MM":return h.s(Y+1,2,"0");case"MMM":return q(u.monthsShort,Y,K,3);case"MMMM":return q(K,Y);case"D":return y.$D;case"DD":return h.s(y.$D,2,"0");case"d":return String(y.$W);case"dd":return q(u.weekdaysMin,y.$W,E,2);case"ddd":return q(u.weekdaysShort,y.$W,E,3);case"dddd":return E[y.$W];case"H":return String(g);case"HH":return h.s(g,2,"0");case"h":return nt(1);case"hh":return nt(2);case"a":return ut(g,A,!0);case"A":return ut(g,A,!1);case"m":return String(A);case"mm":return h.s(A,2,"0");case"s":return String(y.$s);case"ss":return h.s(y.$s,2,"0");case"SSS":return h.s(y.$ms,3,"0");case"Z":return M}return null})(U)||M.replace(":","")}))},o.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},o.diff=function(a,y,u){var p,M=this,g=h.p(y),A=d(a),Y=(A.utcOffset()-this.utcOffset())*r,E=this-A,K=function(){return h.m(M,A)};switch(g){case L:p=K()/12;break;case S:p=K();break;case R:p=K()/3;break;case P:p=(E-Y)/6048e5;break;case v:p=(E-Y)/864e5;break;case _:p=E/l;break;case C:p=E/r;break;case D:p=E/s;break;default:p=E}return u?p:h.a(p)},o.daysInMonth=function(){return this.endOf(S).$D},o.$locale=function(){return j[this.$L]},o.locale=function(a,y){if(!a)return this.$L;var u=this.clone(),p=f(a,y,!0);return p&&(u.$L=p),u},o.clone=function(){return h.w(this.$d,this)},o.toDate=function(){return new Date(this.valueOf())},o.toJSON=function(){return this.isValid()?this.toISOString():null},o.toISOString=function(){return this.$d.toISOString()},o.toString=function(){return this.$d.toUTCString()},e})(),$=N.prototype;return d.prototype=$,[["$ms",c],["$s",D],["$m",C],["$H",_],["$W",v],["$M",S],["$y",L],["$D",T]].forEach((function(e){$[e[1]]=function(o){return this.$g(o,e[0],e[1])}})),d.extend=function(e,o){return e.$i||(e(o,N,d),e.$i=!0),d},d.locale=f,d.isDayjs=Q,d.unix=function(e){return d(1e3*e)},d.en=j[k],d.Ls=j,d.p={},d}))})(wt)),wt.exports}var _e=Kt();const Yt=Gt(_e);var bt={exports:{}},De=bt.exports,Wt;function we(){return Wt||(Wt=1,(function(t,n){(function(s,r){t.exports=r(Kt())})(De,(function(s){function r(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}var l=r(s),c={name:"fa",weekdays:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysShort:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_"),weekdaysMin:"ی_د_س_چ_پ_ج_ش".split("_"),weekStart:6,months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),ordinal:function(D){return D},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return l.default.locale(c,null,!0),c}))})(bt)),bt.exports}var be=we();const xe=Gt(be);function Se(t,n,s){let r=B((t+B(n-8,6)+100100)*1461,4)+B(153*yt(n+9,12)+2,5)+s-34840408;return r=r-B(B(t+100100+B(n-8,6),100)*3,4)+752,r}const _t=[-61,9,38,199,426,686,756,818,1111,1181,1210,1635,2060,2097,2192,2262,2324,2394,2456,3178],lt=Math.floor;function yt(t,n){return t-~~(t/n)*n}function B(t,n){return~~(t/n)}function ke(t,n){const s=_t.length,r=t+621;let l=-14,c=_t[0],D,C,_;if(t<c||t>=_t[s-1])throw new Error(`Invalid Jalaali year ${t}`);for(let S=1;S<s&&(D=_t[S],C=D-c,!(t<D));S+=1)l=l+B(C,33)*8+B(yt(C,33),4),c=D;_=t-c,l=l+B(_,33)*8+B(yt(_,33)+3,4),yt(C,33)===4&&C-_===4&&(l+=1);const v=B(r,4)-B((B(r,100)+1)*3,4)-150,P=20+l-v;return{gy:r,march:P}}function Te(t,n,s){const r=ke(t);return Se(r.gy,3,r.march)+(n-1)*31-B(n,7)*(n-7)+s-1}function Ne(t){let n=4*t+139361631;n=n+B(B(4*t+183187720,146097)*3,4)*4-3908;const s=B(yt(n,1461),4)*5+308,r=B(yt(s,153),5)+1,l=yt(B(s,153),12)+1;return[B(n,1461)-100100+B(8-l,6),l,r]}function Ce(t,n,s){return Ne(Te(t,n,s))}function Ie(t,n,s){const r={year:t,month:n,day:s},l=[0,31,59,90,120,151,181,212,243,273,304,334];let c;t<=1600?(t-=621,r.year=0):(t-=1600,r.year=979);const D=t>2?t+1:t;return c=lt((D+3)/4)+365*t-lt((D+99)/100)-80+l[n-1]+lt((D+399)/400)+s,r.year+=33*lt(c/12053),c%=12053,r.year+=4*lt(c/1461),c%=1461,c>365&&(r.year+=lt((c-1)/365),c=(c-1)%365),r.month=c<186?1+lt(c/31):7+lt((c-186)/30),r.day=1+(c<186?c%31:(c-186)%30),[r.year,r.month,r.day]}var Dt={J:(t,n,s)=>Ie(t,n,s),G:(t,n,s)=>Ce(t,n,s)};const He=/^(\d{4})[-/]?(\d{1,2})[-/]?(\d{0,2})(.*)$/,Le=/\[.*?\]|jY{2,4}|jM{1,4}|jD{1,2}|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,It="date",vt="day",ht="month",pt="year",zt="week",Ye="YYYY-MM-DDTHH:mm:ssZ",Oe={jmonths:"فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_")},Ae=(t,n,s)=>{const r=n.prototype,l=r.$utils(),c=f=>f.$C==="jalali",D=l.prettyUnit||l.p,C=l.isUndefined||l.u,_=l.padStart||l.s,v=l.monthDiff||l.m,P=l.absFloor||l.a,S=f=>function(...d){const h=f.bind(this)(...d);return h.$C=this.$C,h.isJalali()&&h.InitJalali(),h};r.startOf=S(r.startOf),r.endOf=S(r.endOf),r.add=S(r.add),r.subtract=S(r.subtract),r.set=S(r.set);const R=r.parse,L=r.init,T=r.startOf,H=r.$set,O=r.add,I=r.format,J=r.diff,G=r.year,F=r.month,k=r.date,j=r.daysInMonth,W=r.toArray;s.$C="gregory",s.$fdow=6,s.calendar=function(f){return s.$C=f,s},r.calendar=function(f){const d=this.clone();return d.$C=f,d.isJalali()&&d.InitJalali(),d},r.isJalali=function(){return c(this)},s.en.jmonths="Farvardin_Ordibehesht_Khordaad_Tir_Mordaad_Shahrivar_Mehr_Aabaan_Aazar_Dey_Bahman_Esfand".split("_"),s.locale("fa",{...xe,...Oe},!0);const Q=function(f,d){return s(f,{locale:d.$L,utc:d.$u,calendar:d.$C})};r.init=function(f={}){L.bind(this)(f),this.isJalali()&&this.InitJalali()},r.parse=function(f){if(this.$C=f.calendar||this.$C||s.$C,f.jalali&&typeof f.date=="string"&&/.*[^Z]$/i.test(f.date)){const d=f.date.match(He);if(d){const[h,N,$]=Dt.G(Number.parseInt(d[1],10),Number.parseInt(d[2],10),Number.parseInt(d[3]||1,10));f.date=`${h}-${N}-${$}${d[4]||""}`}}return R.bind(this)(f)},r.InitJalali=function(){const[f,d,h]=Dt.J(this.$y,this.$M+1,this.$D);this.$jy=f,this.$jM=d-1,this.$jD=h},r.startOf=function(f,d){if(!c(this))return T.bind(this)(f,d);const h=C(d)?!0:d,N=D(f),$=(o,a,y=this.$jy)=>{const[u,p,M]=Dt.G(y,a+1,o),g=Q(new Date(u,p-1,M),this);return(h?g:g.endOf(vt)).$set("hour",1)},e=(this.$W+(7-s.$fdow))%7;switch(N){case pt:return h?$(1,0):$(0,0,this.$jy+1);case ht:return h?$(1,this.$jM):$(0,(this.$jM+1)%12,this.$jy+Math.floor((this.$jM+1)/12));case zt:return h?$(this.$jD-e,this.$jM):$(this.$jD+(6-e),this.$jM);default:return T.bind(this)(f,d)}},r.$set=function(f,d){if(!c(this))return H.bind(this)(f,d);const h=D(f),N=($,e,o=this.$jy)=>{const[a,y,u]=Dt.G(o,e+1,$);return this.$d.setFullYear(a),this.$d.setMonth(y-1),this.$d.setDate(u),this};switch(h){case It:case vt:N(d,this.$jM);break;case ht:N(this.$jD,d);break;case pt:N(this.$jD,this.$jM,d);break;default:return H.bind(this)(f,d)}return this.init(),this},r.add=function(f,d){if(!c(this))return O.bind(this)(f,d);f=Number(f);const h=d&&(d.length===1||d==="ms")?d:D(d),N=($,e)=>{const o=this.set(It,1).set($,e+f);return o.set(It,Math.min(this.$jD,o.daysInMonth()))};if(["M",ht].includes(h)){const $=this.$jM+f,e=$<0?-Math.ceil(-$/12):Math.floor($/12),o=this.$jD,a=this.set(vt,1).add(e,pt).set(ht,$-e*12);return a.set(vt,Math.min(a.daysInMonth(),o))}if(["y",pt].includes(h))return N(pt,this.$jy);if(["d",vt].includes(h)){const $=new Date(this.$d);return $.setDate($.getDate()+f),Q($,this)}if(["w",zt].includes(h)){const $=new Date(this.$d);return $.setDate($.getDate()+f*7),Q($,this)}return O.bind(this)(f,d)},r.format=function(f,d){if(!c(this))return I.bind(this)(f,d);const h=f||Ye,N=d||this.$locale(),{jmonths:$}=N;return h.replace(Le,e=>{if(e.includes("["))return e.replace(/\[|\]/g,"");switch(e){case"YY":return String(this.$jy).slice(-2);case"YYYY":return String(this.$jy);case"M":return String(this.$jM+1);case"MM":return _(this.$jM+1,2,"0");case"MMM":return $[this.$jM].slice(0,3);case"MMMM":return $[this.$jM];case"D":return String(this.$jD);case"DD":return _(this.$jD,2,"0");default:return I.bind(this)(e,d)}})},r.diff=function(f,d,h){if(!c(this))return J.bind(this)(f,d,h);const N=D(d),$=s(f);let e=v(this,$);switch(N){case pt:e/=12;break;case ht:break;default:return J.bind(this)(f,d,h)}return h?e:P(e)},r.$g=function(f,d,h){return C(f)?this[d]:this.set(h,f)},r.year=function(f){return c(this)?this.$g(f,"$jy",pt):G.bind(this)(f)},r.month=function(f){return c(this)?this.$g(f,"$jM",ht):F.bind(this)(f)},r.date=function(f){return c(this)?this.$g(f,"$jD",vt):k.bind(this)(f)},r.daysInMonth=function(){return c(this)?this.endOf(ht).$jD:j.bind(this)()},W&&(r.toArray=function(){return c(this)?[this.$jy,this.$jM,this.$jD,this.$H,this.$m,this.$s,this.$ms]:W.bind(this)()}),r.clone=function(){return Q(this.toDate(),this)}};var Pe=Ae;Yt.extend(Pe);function St(t){return String(t).padStart(2,"0")}function qt(t){return String(t).padStart(4,"0")}function at(t){const n=Yt(t).calendar("jalali");return{jy:n.year(),jm:n.month()+1,jd:n.date()}}function X(t){const{jy:n,jm:s,jd:r}=t,l=`${qt(n)}-${St(s)}-${St(r)}`,c=Yt(l,{jalali:!0}).calendar("gregory").startOf("day");if(!c.isValid())throw new Error(`Invalid Jalali date parts: ${l}`);return c.toDate()}function Zt(t,n={}){const s=n.separator??"/";return`${qt(t.jy)}${s}${St(t.jm)}${s}${St(t.jd)}`}function Ee(t,n="HH:mm"){const s=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");if(n==="HH:mm:ss"){const l=String(t.getSeconds()).padStart(2,"0");return`${s}:${r}:${l}`}return`${s}:${r}`}function jt(t,n,s){let r=Math.max(0,Math.min(23,Math.floor(t))),l=Math.max(0,Math.min(59,Math.floor(n))),c=s!==void 0?Math.max(0,Math.min(59,Math.floor(s))):0;return{hour:r,minute:l,second:c}}function st(t,n,s,r){const l=new Date(t);return l.setHours(n,s,r??0,0),l}function Ot(t){const n=at(t);return{...n,formatted:Zt(n)}}function Re(t,n){const s=Ot(t);if(n){const r=Ee(t,n);return`${s.formatted} ${r}`}return s.formatted}function Xt(t){return t.replace(/[^\d]+/g,"-")}function Je(t){return X(t)}function At(t,n={}){const s=t.trim();if(!s)return null;const l=(n.allowLooseSeparators?Xt(s):s).match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/);if(!l)return null;const c=Number(l[1]),D=Number(l[2]),C=Number(l[3]);try{return X({jy:c,jm:D,jd:C})}catch{return null}}function Fe(t,n={}){const s=t.trim();if(!s)return null;const r=n.timeFormat??"HH:mm",l=r==="HH:mm:ss"?/(\d{1,2}):(\d{1,2}):(\d{1,2})/:/(\d{1,2}):(\d{1,2})/,c=s.match(l);if(c){const D=s.substring(0,c.index).trim(),_=(n.allowLooseSeparators?Xt(D):D).match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/);if(!_)return null;const v=Number(_[1]),P=Number(_[2]),S=Number(_[3]),R=Number(c[1]),L=Number(c[2]),T=r==="HH:mm:ss"?Number(c[3]):0;if(R<0||R>23||L<0||L>59||T<0||T>59)return null;try{const H=X({jy:v,jm:P,jd:S});return H.setHours(R,L,T,0),H}catch{return null}}return At(t,n)}const Be=1440*60*1e3;function kt(t){return Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())}function dt(t,n){const s=kt(t),r=kt(n);return s===r?0:s<r?-1:1}function xt(t,n){return dt(t,n)===0}function mt(t,n){const s=new Date(t);return s.setDate(s.getDate()+n),s}function $t(t,n,s){return!(n&&dt(t,n)<0||s&&dt(t,s)>0)}function Ue(t,n,s){return n&&dt(t,n)<0?new Date(n):s&&dt(t,s)>0?new Date(s):new Date(t)}function Qt(t,n){const s=t.jy*12+(t.jm-1)+n,r=Math.floor(s/12),l=(s%12+12)%12+1;return{jy:r,jm:l}}function te(t,n){const s=X({jy:t,jm:n,jd:1}),r=Qt({jy:t,jm:n},1),l=X({jy:r.jy,jm:r.jm,jd:1});return Math.round((kt(l)-kt(s))/Be)}function Lt(t,n){const s=at(t),r=Qt({jy:s.jy,jm:s.jm},n),l=te(r.jy,r.jm),c=Math.min(s.jd,l);return X({jy:r.jy,jm:r.jm,jd:c})}function ee(t){const{jy:n,jm:s}=t,r=t.weekStartsOn??6,l=X({jy:n,jm:s,jd:1}),D=(l.getDay()-r+7)%7,C=mt(l,-D),_=[];for(let v=0;v<6;v++){const P=[];for(let S=0;S<7;S++){const R=v*7+S,L=mt(C,R),T=at(L);P.push({gregorian:L,jalali:T,inCurrentMonth:T.jy===n&&T.jm===s})}_.push(P)}return _.length>0&&(_[_.length-1].some(S=>S.inCurrentMonth)||_.pop()),_}const We=["bottom","top","left","right"];function Vt(t,n,s){return Math.min(Math.max(t,n),s)}const ze=typeof window<"u"?x.useLayoutEffect:x.useEffect;function ne(t,n,s,r={}){const l=r.gutter??8,c=r.padding??8,D=r.strategy??"fixed",C=r.align??"end",_=r.placements?.join("|")??"",v=x.useMemo(()=>r.placements&&r.placements.length?r.placements:We,[_]),[P,S]=x.useState("bottom"),[R,L]=x.useState(()=>({position:D,top:0,left:0})),T=x.useCallback(()=>{const H=n.current,O=s.current;if(!H||!O)return;const I=H.getBoundingClientRect(),J=O.getBoundingClientRect(),G=window.innerWidth,F=window.innerHeight,k=F-I.bottom-c,j=I.top-c,W=I.left-c,Q=G-I.right-c;function f(e){return e==="bottom"?k:e==="top"?j:e==="left"?W:Q}function d(e){return e==="bottom"||e==="top"?J.height+l<=f(e):J.width+l<=f(e)}let h=v.find(d)??v.reduce((e,o)=>f(o)>f(e)?o:e,v[0]),N=0,$=0;h==="bottom"||h==="top"?(N=h==="bottom"?I.bottom+l:I.top-l-J.height,C==="start"?$=I.left:C==="center"?$=I.left+(I.width-J.width)/2:$=I.right-J.width):($=h==="right"?I.right+l:I.left-l-J.width,C==="start"?N=I.top:C==="center"?N=I.top+(I.height-J.height)/2:N=I.bottom-J.height),N=Vt(N,c,F-c-J.height),$=Vt($,c,G-c-J.width),D==="absolute"&&(N+=window.scrollY,$+=window.scrollX),S(e=>e===h?e:h),L(e=>e.position===D&&e.top===N&&e.left===$?e:{position:D,top:N,left:$})},[C,n,l,c,s,D,v]);return ze(()=>{if(!t)return;T();const H=window.requestAnimationFrame(T);return()=>window.cancelAnimationFrame(H)},[t,T]),x.useEffect(()=>{if(!t)return;let H=0;const O=()=>{H||(H=window.requestAnimationFrame(()=>{H=0,T()}))};return window.addEventListener("resize",O),document.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",O),document.removeEventListener("scroll",O,!0),H&&window.cancelAnimationFrame(H)}},[t,T]),{style:R,placement:P,update:T}}function Z(...t){return t.filter(Boolean).join(" ")}function Ve(t){const{value:n,onChange:s,format:r="HH:mm",showSeconds:l=!1,hourStep:c=1,minuteStep:D=1,secondStep:C=1,disabled:_=!1,classes:v}=t,P=n.getHours(),S=n.getMinutes(),R=n.getSeconds(),L=x.useRef(null),T=x.useRef(null),H=x.useRef(null),O=x.useRef(null),I=x.useRef(null),J=x.useRef(200),G=x.useRef(null);x.useEffect(()=>()=>{L.current&&clearInterval(L.current),T.current&&clearInterval(T.current),H.current&&clearInterval(H.current),O.current&&clearTimeout(O.current),I.current&&clearTimeout(I.current)},[]);function F(){L.current&&(clearInterval(L.current),L.current=null),T.current&&(clearInterval(T.current),T.current=null),H.current&&(clearInterval(H.current),H.current=null),O.current&&(clearTimeout(O.current),O.current=null),I.current&&(clearTimeout(I.current),I.current=null),J.current=200,G.current=null}function k(e,o){if(_)return;F(),j(e,o),G.current=Date.now(),J.current=200;const a=()=>{if(!G.current)return;j(e,o);const y=J.current,u=setTimeout(()=>{a()},y);e==="hour"?L.current=u:e==="minute"?T.current=u:H.current=u};a(),O.current=setTimeout(()=>{G.current&&(J.current=50)},500),I.current=setTimeout(()=>{G.current&&(J.current=20)},1e3)}function j(e,o){const y=o*(e==="hour"?c:e==="minute"?D:C);if(e==="hour"){const u=(P+y+24)%24,p=jt(u,S,l?R:void 0);s(st(n,p.hour,p.minute,p.second))}else if(e==="minute"){const u=(S+y+60)%60,p=jt(P,u,l?R:void 0);s(st(n,p.hour,p.minute,p.second))}else{const u=(R+y+60)%60,p=jt(P,S,u);s(st(n,p.hour,p.minute,p.second))}}function W(e){if(_)return;const o=parseInt(e.target.value,10);if(!isNaN(o)&&o>=0&&o<=23){const a=jt(o,S,l?R:void 0);s(st(n,a.hour,a.minute,a.second))}}function Q(e){if(_)return;const o=parseInt(e.target.value,10);if(!isNaN(o)&&o>=0&&o<=59){const a=jt(P,o,l?R:void 0);s(st(n,a.hour,a.minute,a.second))}}function f(e){if(_)return;const o=parseInt(e.target.value,10);if(!isNaN(o)&&o>=0&&o<=59){const a=jt(P,S,o);s(st(n,a.hour,a.minute,a.second))}}function d(e){_||(e.key==="ArrowUp"?(e.preventDefault(),j("hour",1)):e.key==="ArrowDown"&&(e.preventDefault(),j("hour",-1)))}function h(e){_||(e.key==="ArrowUp"?(e.preventDefault(),j("minute",1)):e.key==="ArrowDown"&&(e.preventDefault(),j("minute",-1)))}function N(e){_||(e.key==="ArrowUp"?(e.preventDefault(),j("second",1)):e.key==="ArrowDown"&&(e.preventDefault(),j("second",-1)))}function $(e,o){if(_)return;e.preventDefault();const a=e.deltaY>0?-1:1;j(o,a)}return w.jsxs("div",{className:Z("dvx-pdp__time",v?.root),children:[w.jsxs("div",{className:Z("dvx-pdp__timeStepper",v?.stepper),children:[w.jsx("button",{type:"button",className:Z("dvx-pdp__timeStepperButton",v?.stepperButton,v?.stepperButtonUp),onMouseDown:e=>{e.preventDefault(),k("hour",1)},onMouseUp:F,onMouseLeave:F,disabled:_,"aria-label":"افزایش ساعت",children:"▲"}),w.jsx("input",{type:"number",className:Z("dvx-pdp__timeStepperInput",v?.stepperInput),value:String(P).padStart(2,"0"),onChange:W,onKeyDown:d,onWheel:e=>$(e,"hour"),min:0,max:23,disabled:_,"aria-label":"ساعت"}),w.jsx("button",{type:"button",className:Z("dvx-pdp__timeStepperButton",v?.stepperButton,v?.stepperButtonDown),onMouseDown:e=>{e.preventDefault(),k("hour",-1)},onMouseUp:F,onMouseLeave:F,disabled:_,"aria-label":"کاهش ساعت",children:"▼"})]}),w.jsx("span",{className:Z("dvx-pdp__timeSeparator",v?.separator),children:":"}),w.jsxs("div",{className:Z("dvx-pdp__timeStepper",v?.stepper),children:[w.jsx("button",{type:"button",className:Z("dvx-pdp__timeStepperButton",v?.stepperButton,v?.stepperButtonUp),onMouseDown:e=>{e.preventDefault(),k("minute",1)},onMouseUp:F,onMouseLeave:F,disabled:_,"aria-label":"افزایش دقیقه",children:"▲"}),w.jsx("input",{type:"number",className:Z("dvx-pdp__timeStepperInput",v?.stepperInput),value:String(S).padStart(2,"0"),onChange:Q,onKeyDown:h,onWheel:e=>$(e,"minute"),min:0,max:59,disabled:_,"aria-label":"دقیقه"}),w.jsx("button",{type:"button",className:Z("dvx-pdp__timeStepperButton",v?.stepperButton,v?.stepperButtonDown),onMouseDown:e=>{e.preventDefault(),k("minute",-1)},onMouseUp:F,onMouseLeave:F,disabled:_,"aria-label":"کاهش دقیقه",children:"▼"})]}),l&&r==="HH:mm:ss"&&w.jsxs(w.Fragment,{children:[w.jsx("span",{className:Z("dvx-pdp__timeSeparator",v?.separator),children:":"}),w.jsxs("div",{className:Z("dvx-pdp__timeStepper",v?.stepper),children:[w.jsx("button",{type:"button",className:Z("dvx-pdp__timeStepperButton",v?.stepperButton,v?.stepperButtonUp),onMouseDown:e=>{e.preventDefault(),k("second",1)},onMouseUp:F,onMouseLeave:F,disabled:_,"aria-label":"افزایش ثانیه",children:"▲"}),w.jsx("input",{type:"number",className:Z("dvx-pdp__timeStepperInput",v?.stepperInput),value:String(R).padStart(2,"0"),onChange:f,onKeyDown:N,onWheel:e=>$(e,"second"),min:0,max:59,disabled:_,"aria-label":"ثانیه"}),w.jsx("button",{type:"button",className:Z("dvx-pdp__timeStepperButton",v?.stepperButton,v?.stepperButtonDown),onMouseDown:e=>{e.preventDefault(),k("second",-1)},onMouseUp:F,onMouseLeave:F,disabled:_,"aria-label":"کاهش ثانیه",children:"▼"})]})]})]})}function V(...t){return t.filter(Boolean).join(" ")}function Ge(t,n){return n?.enabled?Re(t,n.format):Ot(t).formatted}function Ke(t,n){return n?.enabled?Fe(t,{allowLooseSeparators:!0,timeFormat:n.format}):At(t,{allowLooseSeparators:!0})}function qe(t,n,s){return $t(t,n,s)?t:null}function gt(t){const s=at(t??new Date);return{jy:s.jy,jm:s.jm}}function Ht(){const t=new Date;return t.setHours(0,0,0,0),t}function Ze(t){const{value:n,onChange:s,minDate:r,maxDate:l,disabled:c,placeholder:D,open:C,onOpenChange:_,mode:v="popover",theme:P="light",popover:S,timePicker:R,formatValue:L,parseValue:T,weekdays:H,monthLabels:O,renderMonthLabel:I,prevIcon:J,nextIcon:G,className:F,classes:k}=t,j=x.useMemo(()=>typeof R=="boolean"?R?{enabled:!0}:{enabled:!1}:R??{enabled:!1},[R]),W=x.useCallback(i=>L?L(i):Ge(i,j),[L,j]),Q=x.useCallback(i=>T?T(i):Ke(i,j),[T,j]),f=P==="dark"?"dvx-pdp--theme-dark":P==="auto"?"dvx-pdp--theme-auto":void 0,d=x.useRef(null),h=x.useRef(null),N=x.useRef(null),$=x.useRef(null),e=x.useRef(!1),[o,a]=x.useState(!1),[y,u]=x.useState(!1),p=v==="inline"?!0:C??y,M=x.useCallback(i=>{_?.(i),v!=="inline"&&C===void 0&&u(i)},[v,_,C]);x.useEffect(()=>{a(!0)},[]);const[g,A]=x.useState(()=>gt(n)),[Y,E]=x.useState(()=>n??Ht()),[K,tt]=x.useState(()=>n?W(n):""),[q,nt]=x.useState("days"),[ut,U]=x.useState(()=>{const i=gt(n).jy;return i-i%12}),[et,it]=x.useState(()=>gt(n).jy);x.useEffect(()=>{if(e.current)return;tt(n?W(n):""),A(gt(n)),E(n??Ht());const i=gt(n).jy;it(i),U(i-i%12)},[n,W]),x.useEffect(()=>{if(v!=="popover"||!p)return;const i=m=>{const b=d.current;if(!b)return;const z=h.current;m.target instanceof Node&&!b.contains(m.target)&&!(z&&z.contains(m.target))&&M(!1)};return document.addEventListener("pointerdown",i),()=>document.removeEventListener("pointerdown",i)},[v,p,M]),x.useEffect(()=>{p&&$.current?.focus()},[p]);const ot=S??{},Pt=ot.portal??!0,{style:Et}=ne(v==="popover"&&p,N,h,{gutter:ot.gutter,padding:ot.padding,strategy:Pt?ot.strategy:"fixed",placements:ot.placements,align:ot.align??"end"}),re=x.useMemo(()=>I?I(g.jy,g.jm):O&&O.length===12?`${O[g.jm-1]??String(g.jm)} ${g.jy}`:`${g.jy} / ${g.jm}`,[O,I,g.jm,g.jy]),se=x.useMemo(()=>H&&H.length===7?H:["1","2","3","4","5","6","7"],[H]),oe=x.useMemo(()=>ee({jy:g.jy,jm:g.jm}),[g.jm,g.jy]),ft=n??null,Rt=x.useMemo(()=>Ht(),[]);function ae(i){const m=at(i);A({jy:m.jy,jm:m.jm})}function Tt(){if(c)return;M(!0);const i=ft??Y??Rt;ae(i),nt("days");const m=at(i).jy;it(m),U(m-m%12)}function Nt(){M(!1),nt("days"),N.current?.focus()}function Jt(i){const m=i.trim();if(!m){if(j.enabled&&j.defaultTime){const ct=st(new Date,j.defaultTime.hour,j.defaultTime.minute,j.defaultTime.second);s(ct)}else s(null);return}const b=Q(m);if(!b){tt(ft?W(ft):m);return}const z=qe(b,r,l);if(!z){tt(ft?W(ft):m);return}s(z)}function ie(i){if(!c){if(i.key==="ArrowDown"){i.preventDefault(),Tt();return}if(i.key==="Escape"){p&&(i.preventDefault(),Nt());return}if(i.key==="Enter"){i.preventDefault(),Jt(K);return}}}function ue(i){if(p&&!c){if(i.key==="Escape"){i.preventDefault(),Nt();return}if(q==="days"){if(i.key==="ArrowLeft"){i.preventDefault(),E(m=>mt(m,-1));return}if(i.key==="ArrowRight"){i.preventDefault(),E(m=>mt(m,1));return}if(i.key==="ArrowUp"){i.preventDefault(),E(m=>mt(m,-7));return}if(i.key==="ArrowDown"){i.preventDefault(),E(m=>mt(m,7));return}if(i.key==="PageUp"){i.preventDefault(),Mt(-1);return}if(i.key==="PageDown"){i.preventDefault(),Mt(1);return}if(i.key==="Enter"){if(i.preventDefault(),!$t(Y,r,l))return;let m=Y;j.enabled&&n?m=st(Y,n.getHours(),n.getMinutes(),n.getSeconds()):j.enabled&&j.defaultTime&&(m=st(Y,j.defaultTime.hour,j.defaultTime.minute,j.defaultTime.second)),s(m),tt(W(m)),Nt()}}}}x.useEffect(()=>{if(!p)return;const i=at(Y);A(m=>m.jy===i.jy&&m.jm===i.jm?m:{jy:i.jy,jm:i.jm})},[Y,p]);function ce(i){if(c||!$t(i.gregorian,r,l))return;let m=i.gregorian;j.enabled&&n?m=st(i.gregorian,n.getHours(),n.getMinutes(),n.getSeconds()):j.enabled&&j.defaultTime&&(m=st(i.gregorian,j.defaultTime.hour,j.defaultTime.minute,j.defaultTime.second)),s(m),tt(W(m)),E(m),M(!1),N.current?.focus()}function le(i){return c?!0:!$t(i.gregorian,r,l)}function Mt(i){const m=X({jy:g.jy,jm:g.jm,jd:1}),b=Lt(m,i),z=at(b);A({jy:z.jy,jm:z.jm}),E(rt=>{const ct=at(rt);return ct.jy===g.jy&&ct.jm===g.jm?Lt(rt,i):b})}function de(){Mt(-1)}function fe(){Mt(1)}function he(i){const m=X({jy:i,jm:1,jd:1}),b=X({jy:i+1,jm:1,jd:1});return{start:m,endExclusive:b}}function pe(i,m){const b=X({jy:i,jm:m,jd:1}),z=m===12?{jy:i+1,jm:1}:{jy:i,jm:m+1},rt=X({jy:z.jy,jm:z.jm,jd:1});return{start:b,endExclusive:rt}}function Ft(i){return!(r&&dt(i.endExclusive,r)<=0||l&&dt(i.start,l)>0)}function me(){if(q==="days"){nt("years");const i=g.jy;it(i),U(i-i%12)}else nt("days")}function ye(i){it(i),nt("months")}function ve(i){const m={jy:et,jm:i};A(m),E(()=>{const b=at(Y).jd;try{return X({jy:m.jy,jm:m.jm,jd:b})}catch{return X({jy:m.jy,jm:m.jm,jd:1})}}),nt("days")}const Ct=w.jsxs("div",{ref:$,tabIndex:-1,className:"dvx-pdp__calendar",onKeyDown:ue,children:[w.jsxs("div",{className:V("dvx-pdp__header",k?.header),children:[w.jsx("button",{type:"button",className:V("dvx-pdp__nav",k?.navButton),onClick:q==="days"?de:()=>U(i=>i-12),"aria-label":"Previous month",children:J??"‹"}),w.jsx("button",{type:"button",className:V("dvx-pdp__monthLabel",k?.monthLabel),onClick:me,"aria-label":"Choose month and year",children:q==="days"?re:et}),w.jsx("button",{type:"button",className:V("dvx-pdp__nav",k?.navButton),onClick:q==="days"?fe:()=>U(i=>i+12),"aria-label":"Next month",children:G??"›"})]}),q==="days"?w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:V("dvx-pdp__grid",k?.grid),children:[w.jsx("div",{className:"dvx-pdp__weekdays","aria-hidden":"true",children:se.map((i,m)=>w.jsx("div",{className:V("dvx-pdp__weekday",k?.weekday),children:i},m))}),w.jsx("div",{className:"dvx-pdp__days",children:oe.map((i,m)=>w.jsx("div",{className:"dvx-pdp__row",children:i.map(b=>{const z=le(b),rt=ft?xt(b.gregorian,ft):!1,ct=xt(b.gregorian,Rt),Bt=xt(b.gregorian,Y);return w.jsx("button",{type:"button",className:V("dvx-pdp__day",k?.day,!b.inCurrentMonth&&V("dvx-pdp__day--outside",k?.dayOutside),z&&V("dvx-pdp__day--disabled",k?.dayDisabled),rt&&V("dvx-pdp__day--selected",k?.daySelected),ct&&V("dvx-pdp__day--today",k?.dayToday),Bt&&"dvx-pdp__day--focused"),disabled:z,onClick:()=>ce(b),onMouseEnter:()=>{b.inCurrentMonth&&E(b.gregorian)},"aria-pressed":rt,children:b.jalali.jd},`${b.jalali.jy}-${b.jalali.jm}-${b.jalali.jd}`)})},m))})]}),j.enabled&&(()=>{const i=n??(()=>{const m=new Date;return j.defaultTime?st(m,j.defaultTime.hour,j.defaultTime.minute,j.defaultTime.second):m})();return w.jsx(Ve,{value:i,onChange:m=>{s(m),tt(W(m))},format:j.format,showSeconds:j.showSeconds,hourStep:j.hourStep,minuteStep:j.minuteStep,secondStep:j.secondStep,disabled:c,classes:{root:k?.timePicker,stepper:k?.timeStepper,stepperButton:k?.timeStepperButton,stepperInput:k?.timeStepperInput,separator:k?.timeSeparator}})})()]}):q==="years"?w.jsx("div",{className:"dvx-pdp__panel",children:w.jsx("div",{className:"dvx-pdp__panelGrid",children:Array.from({length:12}).map((i,m)=>{const b=ut+m,z=Ft(he(b)),rt=b===g.jy;return w.jsx("button",{type:"button",className:V("dvx-pdp__cell",rt&&"dvx-pdp__cell--active"),disabled:!z,onClick:()=>ye(b),children:b},b)})})}):w.jsx("div",{className:"dvx-pdp__panel",children:w.jsx("div",{className:"dvx-pdp__panelGrid",children:Array.from({length:12}).map((i,m)=>{const b=m+1,z=Ft(pe(et,b)),rt=et===g.jy&&b===g.jm,ct=O&&O.length===12?O[b-1]??String(b):String(b);return w.jsx("button",{type:"button",className:V("dvx-pdp__cell",rt&&"dvx-pdp__cell--active"),disabled:!z,onClick:()=>ve(b),children:ct},b)})})})]});return w.jsxs("div",{ref:d,className:V("dvx-pdp",f,v==="inline"&&"dvx-pdp--inline",F,k?.root),dir:"rtl",children:[v==="inline"?null:w.jsxs("div",{className:"dvx-pdp__control",children:[w.jsx("input",{ref:N,className:V("dvx-pdp__input",k?.input),disabled:c,placeholder:D,inputMode:"numeric",autoComplete:"off",value:K,onChange:i=>tt(i.target.value),onClick:()=>{p||Tt()},onFocus:()=>{e.current=!0},onBlur:()=>{e.current=!1,Jt(K)},onKeyDown:ie,"aria-haspopup":"dialog","aria-expanded":p}),w.jsx("button",{type:"button",className:V("dvx-pdp__button",k?.button),onClick:()=>p?M(!1):Tt(),disabled:c,"aria-label":"Open calendar",children:w.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":"true",children:w.jsx("path",{fill:"currentColor",d:"M7 2a1 1 0 0 1 1 1v1h8V3a1 1 0 1 1 2 0v1h1.5A2.5 2.5 0 0 1 22 6.5v13A2.5 2.5 0 0 1 19.5 22h-15A2.5 2.5 0 0 1 2 19.5v-13A2.5 2.5 0 0 1 4.5 4H6V3a1 1 0 0 1 1-1Zm0 6H4v11.5c0 .276.224.5.5.5h15c.276 0 .5-.224.5-.5V8H7Zm-2.5-2c-.276 0-.5.224-.5.5V6h16v.5c0-.276-.224-.5-.5-.5H4.5Z"})})})]}),v==="inline"?Ct:p?Pt&&o?ge.createPortal(w.jsx("div",{ref:h,className:V("dvx-pdp","dvx-pdp__popover","dvx-pdp__popover--portal",f,k?.popover),dir:"rtl",style:{...Et,right:"auto",bottom:"auto"},role:"dialog","aria-modal":"false",children:Ct}),document.body):w.jsx("div",{ref:h,className:V("dvx-pdp__popover",k?.popover),style:{...Et,right:"auto",bottom:"auto"},role:"dialog","aria-modal":"false",children:Ct}):null]})}exports.PersianDatePicker=Ze;exports.addDays=mt;exports.addJalaliMonths=Lt;exports.buildJalaliMonthGrid=ee;exports.clampToRange=Ue;exports.compareDays=dt;exports.formatJalali=Zt;exports.fromJalaliParts=X;exports.getJalaliMonthLength=te;exports.isSameDay=xt;exports.isWithinRange=$t;exports.parseJalaliText=At;exports.toGregorian=Je;exports.toJalali=Ot;exports.toJalaliParts=at;exports.usePopoverPosition=ne;