UNPKG

react-nepali-datetime

Version:

React components for a Nepali DateTime picker, built on top of nepali-datetime.

32 lines (29 loc) 24.2 kB
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('._selector_dblms_1{background-color:#fff;color:#000;padding:8px 10px;border:1px solid #ccc;border-radius:4px;scrollbar-width:thin;scrollbar-color:#2096f5}._selector_dblms_1:focus{outline:none}._selector_dblms_1::-webkit-scrollbar{width:6px}._selector_dblms_1::-webkit-scrollbar-thumb{background-color:#2096f5;border-radius:4px}._selector_dblms_1::-webkit-scrollbar-track{border-radius:4px}._calendarContainer_1osiy_1{margin-top:16px;color:#666;font-family:sans-serif;font-size:14px;font-weight:300;font-style:normal}._calendarGrid_1osiy_10{display:grid;grid-template-columns:repeat(7,1fr)}._calendarCell_1osiy_15{display:inline-flex;align-items:center;justify-content:center;width:45px;height:40px;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}._calendarCellInactive_1osiy_28{opacity:.5}._calendarCell_1osiy_15:not(._calendarCellInactive_1osiy_28,._calendarCellHeader_1osiy_32){cursor:pointer}._calendarCellCurrent_1osiy_36{color:#2096f5;font-weight:700}._calendarCellSelected_1osiy_41{position:relative;color:#fff;z-index:1}._calendarCellSelected_1osiy_41:after{content:"";background-color:#2096f5;border-radius:50%;width:40px;height:40px;position:absolute;z-index:-1}._prevNext_1osiy_56{width:22px;height:22px}._prevNext_1osiy_56 span{cursor:pointer}._calendarControls_1osiy_64{display:flex;justify-content:space-between;align-items:center}._popoverContent_qysd3_1{position:absolute;left:0;padding:16px;background-color:#fff;color:#444;box-shadow:0 4px 6px #0000001a;z-index:101}._nepaliDateInput_1xgfv_1{width:100%;padding:4px 8px;line-height:22px;border-radius:5px;border-width:1px;border-style:solid;outline:0;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}._nepaliDateInputError_1xgfv_14{color:#fb4141}._nepaliDateInputError_1xgfv_14 input{color:inherit}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})(); (function(A,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react"),require("nepali-datetime")):typeof define=="function"&&define.amd?define(["exports","react","nepali-datetime"],R):(A=typeof globalThis<"u"?globalThis:A||self,R(A["react-nepali-datetime"]={},A.React,A.NepaliDateTime))})(this,function(A,R,L){"use strict";var Z={exports:{}},K={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ve;function ze(){if(ve)return K;ve=1;var t=R,a=Symbol.for("react.element"),u=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,v=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,E={key:!0,ref:!0,__self:!0,__source:!0};function m(h,d,x){var p,T={},_=null,C=null;x!==void 0&&(_=""+x),d.key!==void 0&&(_=""+d.key),d.ref!==void 0&&(C=d.ref);for(p in d)o.call(d,p)&&!E.hasOwnProperty(p)&&(T[p]=d[p]);if(h&&h.defaultProps)for(p in d=h.defaultProps,d)T[p]===void 0&&(T[p]=d[p]);return{$$typeof:a,type:h,key:_,ref:C,props:T,_owner:v.current}}return K.Fragment=u,K.jsx=m,K.jsxs=m,K}var G={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var pe;function Ze(){return pe||(pe=1,process.env.NODE_ENV!=="production"&&function(){var t=R,a=Symbol.for("react.element"),u=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),m=Symbol.for("react.provider"),h=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),C=Symbol.for("react.offscreen"),w=Symbol.iterator,S="@@iterator";function i(e){if(e===null||typeof e!="object")return null;var r=w&&e[w]||e[S];return typeof r=="function"?r:null}var N=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];F("error",e,n)}}function F(e,r,n){{var s=N.ReactDebugCurrentFrame,g=s.getStackAddendum();g!==""&&(r+="%s",n=n.concat([g]));var y=n.map(function(f){return String(f)});y.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,y)}}var J=!1,_r=!1,gr=!1,Er=!1,yr=!1,Re;Re=Symbol.for("react.module.reference");function mr(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===E||yr||e===v||e===x||e===p||Er||e===C||J||_r||gr||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===T||e.$$typeof===m||e.$$typeof===h||e.$$typeof===d||e.$$typeof===Re||e.getModuleId!==void 0))}function br(e,r,n){var s=e.displayName;if(s)return s;var g=r.displayName||r.name||"";return g!==""?n+"("+g+")":n}function we(e){return e.displayName||"Context"}function W(e){if(e==null)return null;if(typeof e.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case u:return"Portal";case E:return"Profiler";case v:return"StrictMode";case x:return"Suspense";case p:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case h:var r=e;return we(r)+".Consumer";case m:var n=e;return we(n._context)+".Provider";case d:return br(e,e.render,"ForwardRef");case T:var s=e.displayName||null;return s!==null?s:W(e.type)||"Memo";case _:{var g=e,y=g._payload,f=g._init;try{return W(f(y))}catch{return null}}}return null}var V=Object.assign,X=0,je,Te,Pe,Se,Oe,ke,Ie;function Ne(){}Ne.__reactDisabledLog=!0;function xr(){{if(X===0){je=console.log,Te=console.info,Pe=console.warn,Se=console.error,Oe=console.group,ke=console.groupCollapsed,Ie=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}X++}}function Cr(){{if(X--,X===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},e,{value:je}),info:V({},e,{value:Te}),warn:V({},e,{value:Pe}),error:V({},e,{value:Se}),group:V({},e,{value:Oe}),groupCollapsed:V({},e,{value:ke}),groupEnd:V({},e,{value:Ie})})}X<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=N.ReactCurrentDispatcher,se;function $(e,r,n){{if(se===void 0)try{throw Error()}catch(g){var s=g.stack.trim().match(/\n( *(at )?)/);se=s&&s[1]||""}return` `+se+e}}var ie=!1,q;{var Rr=typeof WeakMap=="function"?WeakMap:Map;q=new Rr}function Me(e,r){if(!e||ie)return"";{var n=q.get(e);if(n!==void 0)return n}var s;ie=!0;var g=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var y;y=oe.current,oe.current=null,xr();try{if(r){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(I){s=I}Reflect.construct(e,[],f)}else{try{f.call()}catch(I){s=I}e.call(f.prototype)}}else{try{throw Error()}catch(I){s=I}e()}}catch(I){if(I&&s&&typeof I.stack=="string"){for(var c=I.stack.split(` `),O=s.stack.split(` `),j=c.length-1,P=O.length-1;j>=1&&P>=0&&c[j]!==O[P];)P--;for(;j>=1&&P>=0;j--,P--)if(c[j]!==O[P]){if(j!==1||P!==1)do if(j--,P--,P<0||c[j]!==O[P]){var M=` `+c[j].replace(" at new "," at ");return e.displayName&&M.includes("<anonymous>")&&(M=M.replace("<anonymous>",e.displayName)),typeof e=="function"&&q.set(e,M),M}while(j>=1&&P>=0);break}}}finally{ie=!1,oe.current=y,Cr(),Error.prepareStackTrace=g}var U=e?e.displayName||e.name:"",D=U?$(U):"";return typeof e=="function"&&q.set(e,D),D}function wr(e,r,n){return Me(e,!1)}function jr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function ee(e,r,n){if(e==null)return"";if(typeof e=="function")return Me(e,jr(e));if(typeof e=="string")return $(e);switch(e){case x:return $("Suspense");case p:return $("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return wr(e.render);case T:return ee(e.type,r,n);case _:{var s=e,g=s._payload,y=s._init;try{return ee(y(g),r,n)}catch{}}}return""}var z=Object.prototype.hasOwnProperty,Ae={},Ye=N.ReactDebugCurrentFrame;function re(e){if(e){var r=e._owner,n=ee(e.type,e._source,r?r.type:null);Ye.setExtraStackFrame(n)}else Ye.setExtraStackFrame(null)}function Tr(e,r,n,s,g){{var y=Function.call.bind(z);for(var f in e)if(y(e,f)){var c=void 0;try{if(typeof e[f]!="function"){var O=Error((s||"React class")+": "+n+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw O.name="Invariant Violation",O}c=e[f](r,f,s,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(j){c=j}c&&!(c instanceof Error)&&(re(g),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",n,f,typeof c),re(null)),c instanceof Error&&!(c.message in Ae)&&(Ae[c.message]=!0,re(g),b("Failed %s type: %s",n,c.message),re(null))}}}var Pr=Array.isArray;function le(e){return Pr(e)}function Sr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function Or(e){try{return Le(e),!1}catch{return!0}}function Le(e){return""+e}function Fe(e){if(Or(e))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Sr(e)),Le(e)}var We=N.ReactCurrentOwner,kr={key:!0,ref:!0,__self:!0,__source:!0},Ve,De;function Ir(e){if(z.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Nr(e){if(z.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Mr(e,r){typeof e.ref=="string"&&We.current}function Ar(e,r){{var n=function(){Ve||(Ve=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function Yr(e,r){{var n=function(){De||(De=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var Lr=function(e,r,n,s,g,y,f){var c={$$typeof:a,type:e,key:r,ref:n,props:f,_owner:y};return c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:g}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function Fr(e,r,n,s,g){{var y,f={},c=null,O=null;n!==void 0&&(Fe(n),c=""+n),Nr(r)&&(Fe(r.key),c=""+r.key),Ir(r)&&(O=r.ref,Mr(r,g));for(y in r)z.call(r,y)&&!kr.hasOwnProperty(y)&&(f[y]=r[y]);if(e&&e.defaultProps){var j=e.defaultProps;for(y in j)f[y]===void 0&&(f[y]=j[y])}if(c||O){var P=typeof e=="function"?e.displayName||e.name||"Unknown":e;c&&Ar(f,P),O&&Yr(f,P)}return Lr(e,c,O,g,s,We.current,f)}}var ce=N.ReactCurrentOwner,Be=N.ReactDebugCurrentFrame;function H(e){if(e){var r=e._owner,n=ee(e.type,e._source,r?r.type:null);Be.setExtraStackFrame(n)}else Be.setExtraStackFrame(null)}var ue;ue=!1;function fe(e){return typeof e=="object"&&e!==null&&e.$$typeof===a}function He(){{if(ce.current){var e=W(ce.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function Wr(e){return""}var Ue={};function Vr(e){{var r=He();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=` Check the top-level render call using <`+n+">.")}return r}}function Ke(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=Vr(r);if(Ue[n])return;Ue[n]=!0;var s="";e&&e._owner&&e._owner!==ce.current&&(s=" It was passed a child from "+W(e._owner.type)+"."),H(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,s),H(null)}}function Ge(e,r){{if(typeof e!="object")return;if(le(e))for(var n=0;n<e.length;n++){var s=e[n];fe(s)&&Ke(s,r)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var g=i(e);if(typeof g=="function"&&g!==e.entries)for(var y=g.call(e),f;!(f=y.next()).done;)fe(f.value)&&Ke(f.value,r)}}}function Dr(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===d||r.$$typeof===T))n=r.propTypes;else return;if(n){var s=W(r);Tr(n,e.props,"prop",s,e)}else if(r.PropTypes!==void 0&&!ue){ue=!0;var g=W(r);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",g||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Br(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var s=r[n];if(s!=="children"&&s!=="key"){H(e),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),H(null);break}}e.ref!==null&&(H(e),b("Invalid attribute `ref` supplied to `React.Fragment`."),H(null))}}var Je={};function Xe(e,r,n,s,g,y){{var f=mr(e);if(!f){var c="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(c+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var O=Wr();O?c+=O:c+=He();var j;e===null?j="null":le(e)?j="array":e!==void 0&&e.$$typeof===a?(j="<"+(W(e.type)||"Unknown")+" />",c=" Did you accidentally export a JSX literal instead of a component?"):j=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,c)}var P=Fr(e,r,n,g,y);if(P==null)return P;if(f){var M=r.children;if(M!==void 0)if(s)if(le(M)){for(var U=0;U<M.length;U++)Ge(M[U],e);Object.freeze&&Object.freeze(M)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ge(M,e)}if(z.call(r,"key")){var D=W(e),I=Object.keys(r).filter(function(Xr){return Xr!=="key"}),de=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!Je[D+de]){var Jr=I.length>0?"{"+I.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,de,D,Jr,D),Je[D+de]=!0}}return e===o?Br(P):Dr(P),P}}function Hr(e,r,n){return Xe(e,r,n,!0)}function Ur(e,r,n){return Xe(e,r,n,!1)}var Kr=Ur,Gr=Hr;G.Fragment=o,G.jsx=Kr,G.jsxs=Gr}()),G}var he;function Qe(){return he||(he=1,process.env.NODE_ENV==="production"?Z.exports=ze():Z.exports=Ze()),Z.exports}var l=Qe();const _e={selector:"_selector_dblms_1"},ne=["०","१","२","३","४","५","६","७","८","९"],$e="en",B="ne",Q=$e,te=L.minSupportedNepaliDate().getYear(),ge=L.maxSupportedNepaliDate().getYear(),qe=["Baisakh","Jestha","Asar","Shrawan","Bhadra","Aswin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],er=["बैशाख","जेठ","असार","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पौष","माघ","फाल्गुण","चैत्र"],rr=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],nr=["आइत","सोम","मंगल","बुध","बिहि","शुक्र","शनि"],Ee=t=>t.toString().split("").map(a=>isNaN(Number(a))?a:ne[Number(a)]).join(""),tr=t=>t.toString().split("").map(a=>ne.includes(a)?ne.indexOf(a):a).join(""),ar=Array.from({length:ge-te+1},(t,a)=>a+te),or=({selectedYear:t,onChange:a,locale:u=Q})=>l.jsx("select",{value:t,onChange:o=>a&&a(Number(o.target.value)),className:_e.selector,tabIndex:-1,children:ar.map(o=>l.jsx("option",{value:o,children:u===B?Ee(o):o},o))}),sr=t=>t===B?er:qe,ir=({selectedMonth:t,onChange:a,locale:u=Q})=>l.jsx("select",{value:t,onChange:o=>a&&a(Number(o.target.value)),className:_e.selector,tabIndex:-1,children:sr(u).map((o,v)=>l.jsx("option",{value:v,children:o},o))}),ye=7,me=(t,a)=>{try{return L.getDaysOfMonth(t,a)}catch{return null}},lr=(t,a)=>{const u=me(t,a);if(!u)return[];const o=new L(t,a,1).getDay(),[v,E]=a===0?[t-1,11]:[t,a-1],m=me(v,E),[h,d]=a===11?[t+1,0]:[t,a+1],x=Math.ceil((o+u)/ye)*ye;return Array(x).fill(null).map((T,_)=>{let C,w,S,i;return _<o?(C=m?m-(o-_-1):null,w=E,S=v,i=!1):_<o+u?(C=_-o+1,w=a,S=t,i=!0):(C=_-(o+u)+1,w=d,S=h,i=!1),{index:_,active:i,year:S,month:w,date:C}})},Y=(...t)=>t.filter(Boolean).join(" "),k={calendarContainer:"_calendarContainer_1osiy_1",calendarGrid:"_calendarGrid_1osiy_10",calendarCell:"_calendarCell_1osiy_15",calendarCellInactive:"_calendarCellInactive_1osiy_28",calendarCellHeader:"_calendarCellHeader_1osiy_32",calendarCellCurrent:"_calendarCellCurrent_1osiy_36",calendarCellSelected:"_calendarCellSelected_1osiy_41",prevNext:"_prevNext_1osiy_56",calendarControls:"_calendarControls_1osiy_64"},be=({selectedNepaliDate:t,onDateSelect:a=null,locale:u=Q})=>{const o=new L,v=u===B?nr:rr,[E,m]=R.useState(o.getYear()),[h,d]=R.useState(o.getMonth());R.useEffect(()=>{t&&(m(t==null?void 0:t.getYear()),d(t==null?void 0:t.getMonth()))},[t]);const x=i=>i.year===o.getYear()&&i.month===o.getMonth()&&i.date===o.getDate(),p=i=>t&&i.year===t.getYear()&&i.month===t.getMonth()&&i.date===t.getDate(),T=i=>{!i.active||!i.date||!a||a(new L(E,h,i.date))},_=()=>{if(E===te&&h===0)return;const[i,N]=h===0?[E-1,11]:[E,h-1];m(i),d(N)},C=()=>{if(E===ge&&h===11)return;const[i,N]=h===11?[E+1,0]:[E,h+1];m(i),d(N)},w=()=>{const i=new L;m(i.getYear()),d(i.getMonth()),a&&a(i)},S=lr(E,h);return l.jsxs("div",{className:"ndt-calendar",children:[l.jsxs("div",{className:`ndt-calendar-controls ${k.calendarControls}`,children:[l.jsx("div",{className:`ndt-prev ${k.prevNext}`,children:l.jsx("span",{onClick:_,children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 24 24",children:l.jsx("path",{fill:"none",fillRule:"evenodd",stroke:"currentcolor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2.4",d:"M16.283 18.907L9.6 12l6.683-5.438"})})})}),l.jsx("div",{className:`ndt-prev ${k.prevNext}`,children:l.jsx("span",{onClick:_,children:l.jsx("div",{className:`ndt-prev ${k.prevNext}`,children:l.jsx("span",{onClick:w,children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"20",height:"20",viewBox:"0 0 1024 1024",children:l.jsx("path",{d:"M946.5 505L534.6 93.4a31.93 31.93 0 0 0-45.2 0L77.5 505c-12 12-18.8 28.3-18.8 45.3 0 35.3 28.7 64 64 64h43.4V908c0 17.7 14.3 32 32 32H448V716h112v224h265.9c17.7 0 32-14.3 32-32V614.3h43.4c17 0 33.3-6.7 45.3-18.8 24.9-25 24.9-65.5-.1-90.5z"})})})})})}),l.jsxs("div",{children:[l.jsx(or,{selectedYear:E,onChange:i=>m(i),locale:u}),l.jsx(ir,{selectedMonth:h,onChange:i=>d(i),locale:u})]}),l.jsx("div",{className:`ndt-next ${k.prevNext}`,children:l.jsx("span",{onClick:C,children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 24 24",children:l.jsx("path",{transform:"rotate(180 12 12)",fill:"none",fillRule:"evenodd",stroke:"currentcolor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2.4",d:"M16.283 18.907L9.6 12l6.683-5.438"})})})})]}),l.jsxs("div",{className:`ndt-calendar-container ${k.calendarContainer}`,children:[l.jsx("div",{className:`ndt-calendar-grid ${k.calendarGrid}`,children:v.map(i=>l.jsx("div",{className:Y("ndt-calendar-cell-header",k.calendarCellHeader,k.calendarCell),children:i},i))}),l.jsx("div",{className:`ndt-calendar-grid ${k.calendarGrid}`,children:S.map(i=>l.jsx("div",{onClick:()=>T(i),className:Y("ndt-calendar-cell",k.calendarCell,p(i)&&Y("ndt-calendar-cell-selected",k.calendarCellSelected),x(i)&&Y("ndt-calendar-cell-current",k.calendarCellCurrent),!i.active&&k.calendarCellInactive),children:i.date&&u===B?Ee(i.date):i.date},i.index))})]})]})},cr={popoverContent:"_popoverContent_qysd3_1"},ur=150,fr=({popoverChildRef:t,children:a,onOutsideClick:u,onMouseDown:o,onMouseEnter:v,onBlur:E})=>{const m=R.useRef(null),[h,d]=R.useState(),x=R.useCallback(()=>{const _=t==null?void 0:t.current;if(!_){d({});return}const{bottom:C,height:w}=_.getBoundingClientRect(),S=C+ur>window.innerHeight;d(S?{bottom:w}:{top:w})},[t]),p=R.useCallback(_=>{var w,S;if(!u)return;const C=_.target;!((w=t==null?void 0:t.current)!=null&&w.contains(C))&&!((S=m.current)!=null&&S.contains(C))&&u()},[t,u]),T=_=>{var w,S;if(E==null||E(_),!u)return;const C=_.relatedTarget;!((w=m==null?void 0:m.current)!=null&&w.contains(C))&&!((S=t==null?void 0:t.current)!=null&&S.contains(C))&&u()};return R.useLayoutEffect(()=>(x(),document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p,x]),h?l.jsx("div",{className:Y("ndt-popover-content",cr.popoverContent),ref:m,style:h,onMouseDown:o,onMouseEnter:v,onBlur:T,tabIndex:-1,children:a}):null},dr=({children:t,content:a,open:u=!1,className:o,onOpenChange:v,onContentMouseDown:E,onContentMouseEnter:m,onContentBlur:h})=>{const d=R.useRef(null),x=p=>v==null?void 0:v(p);return l.jsxs("div",{className:Y("ndt-popover",o),style:{position:"relative"},children:[l.jsx("div",{className:"ndt-popover-child",style:{display:"flex"},ref:d,onClick:()=>x(!0),children:t}),u&&l.jsx(fr,{onOutsideClick:()=>x(!1),popoverChildRef:d,onMouseDown:E,onMouseEnter:m,onBlur:h,children:a})]})},ae={nepaliDateInput:"_nepaliDateInput_1xgfv_1",nepaliDateInputError:"_nepaliDateInputError_1xgfv_14"},vr="Enter",pr=({value:t,inputElement:a,className:u,hasError:o,onComplete:v,onChange:E,...m})=>{const x={...m,value:t,onChange:E,autoComplete:"off",onKeyDown:T=>T.key===vr&&(v==null?void 0:v()),onBlur:()=>v==null?void 0:v(),className:Y("ndt-date-input",o&&ae.nepaliDateInputError,u)};if(a)return R.cloneElement(a,x);const p={...x,className:Y("ndt-date-input",o&&ae.nepaliDateInputError,u,ae.nepaliDateInput)};return l.jsx("input",{type:"text",...p})},xe=(t,a,u)=>u===B?t.formatNepali(a):t.format(a),Ce=(t,a,u)=>{if(t.trim()==="")return null;const o=u===B?tr(t):t;try{return new L(o,a)}catch{return null}},hr=({value:t="",format:a="YYYY-MM-DD",inputElement:u,onDateSelect:o,locale:v=Q,...E})=>{const[m,h]=R.useState(!1),[d,x]=R.useState(t),[p,T]=R.useState(),_=R.useRef(!1),C=!!(d&&!p),w=R.useCallback(()=>{if(C){x(""),o==null||o("",null);return}if(p){const b=xe(p,a,v);x(b),o==null||o(b,p)}},[a,C,v,p,o]);R.useEffect(()=>{x(t),T(Ce(t,a,v))},[t,v,a]);const S=b=>{const F=xe(b,a,v);x(F),T(b),o==null||o(F,b),h(!1)},i=b=>{const F=b.target.value,J=Ce(F,a,v);x(F),T(J),J&&(o==null||o(F,J))},N=()=>{if(_.current){_.current=!1;return}w(),h(!1)};return l.jsx(dr,{className:Y("ndt-date-picker"),open:m,onOpenChange:b=>h(b),onContentMouseDown:()=>{_.current=!0},onContentBlur:()=>{_.current=!1},onContentMouseEnter:()=>w(),content:l.jsx(be,{locale:v,selectedNepaliDate:p,onDateSelect:S}),children:l.jsx(pr,{value:d,inputElement:u,hasError:C,onChange:i,onComplete:N,onFocus:()=>h(!0),...E})})};A.NepaliCalendar=be,A.NepaliDatePicker=hr,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});