UNPKG

react-nepali-datetime

Version:

[![npm version](https://img.shields.io/npm/v/react-nepali-datetime?color=48c21a)](https://www.npmjs.com/package/react-nepali-datetime) [![License](https://img.shields.io/npm/l/react-nepali-datetime?label=License)](https://github.com/opensource-nepal/react

32 lines (29 loc) 21.5 kB
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('._calendarContainer_13lxa_1{margin-top:16px;color:#666;font-family:sans-serif;font-size:14px;font-weight:300;font-style:normal}._calendarGrid_13lxa_10{display:grid;grid-template-columns:repeat(7,1fr)}._calendarCell_13lxa_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_13lxa_28{opacity:.5}._calendarCell_13lxa_15:not(._calendarCellInactive_13lxa_28){cursor:pointer}._calendarCellCurrent_13lxa_36{color:#2096f5;font-weight:700}._calendarCellSelected_13lxa_41{position:relative;color:#fff;z-index:1}._calendarCellSelected_13lxa_41:after{content:"";background-color:#2096f5;border-radius:50%;width:40px;height:40px;position:absolute;z-index:-1}._prevNext_13lxa_56{width:22px;height:22px}._prevNext_13lxa_56 span{cursor:pointer}._calendarControls_13lxa_64{display:flex;justify-content:space-between}._popoverContent_qysd3_1{position:absolute;left:0;padding:16px;background-color:#fff;color:#444;box-shadow:0 4px 6px #0000001a;z-index:101}._pickerInput_1txhx_1{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})(); (function(M,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react"),require("nepali-datetime")):typeof define=="function"&&define.amd?define(["exports","react","nepali-datetime"],x):(M=typeof globalThis<"u"?globalThis:M||self,x(M["react-nepali-datetime"]={},M.React,M.NepaliDateTime))})(this,function(M,x,Y){"use strict";var X={exports:{}},G={};/** * @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 ue;function Be(){if(ue)return G;ue=1;var t=x,a=Symbol.for("react.element"),v=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,E=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function y(p,d,R){var g,C={},S=null,P=null;R!==void 0&&(S=""+R),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(P=d.ref);for(g in d)s.call(d,g)&&!_.hasOwnProperty(g)&&(C[g]=d[g]);if(p&&p.defaultProps)for(g in d=p.defaultProps,d)C[g]===void 0&&(C[g]=d[g]);return{$$typeof:a,type:p,key:S,ref:P,props:C,_owner:E.current}}return G.Fragment=v,G.jsx=y,G.jsxs=y,G}var H={};/** * @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 fe;function Ge(){return fe||(fe=1,process.env.NODE_ENV!=="production"&&function(){var t=x,a=Symbol.for("react.element"),v=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),p=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),P=Symbol.for("react.offscreen"),j=Symbol.iterator,i="@@iterator";function N(e){if(e===null||typeof e!="object")return null;var r=j&&e[j]||e[i];return typeof r=="function"?r:null}var V=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];fr("error",e,n)}}function fr(e,r,n){{var o=V.ReactDebugCurrentFrame,f=o.getStackAddendum();f!==""&&(r+="%s",n=n.concat([f]));var h=n.map(function(c){return String(c)});h.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,h)}}var dr=!1,vr=!1,pr=!1,hr=!1,_r=!1,me;me=Symbol.for("react.module.reference");function gr(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===_||_r||e===E||e===R||e===g||hr||e===P||dr||vr||pr||typeof e=="object"&&e!==null&&(e.$$typeof===S||e.$$typeof===C||e.$$typeof===y||e.$$typeof===p||e.$$typeof===d||e.$$typeof===me||e.getModuleId!==void 0))}function mr(e,r,n){var o=e.displayName;if(o)return o;var f=r.displayName||r.name||"";return f!==""?n+"("+f+")":n}function Ee(e){return e.displayName||"Context"}function I(e){if(e==null)return null;if(typeof e.tag=="number"&&w("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 s:return"Fragment";case v:return"Portal";case _:return"Profiler";case E:return"StrictMode";case R:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var r=e;return Ee(r)+".Consumer";case y:var n=e;return Ee(n._context)+".Provider";case d:return mr(e,e.render,"ForwardRef");case C:var o=e.displayName||null;return o!==null?o:I(e.type)||"Memo";case S:{var f=e,h=f._payload,c=f._init;try{return I(c(h))}catch{return null}}}return null}var L=Object.assign,J=0,ye,be,Ce,xe,Re,Se,je;function we(){}we.__reactDisabledLog=!0;function Er(){{if(J===0){ye=console.log,be=console.info,Ce=console.warn,xe=console.error,Re=console.group,Se=console.groupCollapsed,je=console.groupEnd;var e={configurable:!0,enumerable:!0,value:we,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}J++}}function yr(){{if(J--,J===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},e,{value:ye}),info:L({},e,{value:be}),warn:L({},e,{value:Ce}),error:L({},e,{value:xe}),group:L({},e,{value:Re}),groupCollapsed:L({},e,{value:Se}),groupEnd:L({},e,{value:je})})}J<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ne=V.ReactCurrentDispatcher,te;function $(e,r,n){{if(te===void 0)try{throw Error()}catch(f){var o=f.stack.trim().match(/\n( *(at )?)/);te=o&&o[1]||""}return` `+te+e}}var ae=!1,Z;{var br=typeof WeakMap=="function"?WeakMap:Map;Z=new br}function Te(e,r){if(!e||ae)return"";{var n=Z.get(e);if(n!==void 0)return n}var o;ae=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var h;h=ne.current,ne.current=null,Er();try{if(r){var c=function(){throw Error()};if(Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(O){o=O}Reflect.construct(e,[],c)}else{try{c.call()}catch(O){o=O}e.call(c.prototype)}}else{try{throw Error()}catch(O){o=O}e()}}catch(O){if(O&&o&&typeof O.stack=="string"){for(var l=O.stack.split(` `),T=o.stack.split(` `),m=l.length-1,b=T.length-1;m>=1&&b>=0&&l[m]!==T[b];)b--;for(;m>=1&&b>=0;m--,b--)if(l[m]!==T[b]){if(m!==1||b!==1)do if(m--,b--,b<0||l[m]!==T[b]){var k=` `+l[m].replace(" at new "," at ");return e.displayName&&k.includes("<anonymous>")&&(k=k.replace("<anonymous>",e.displayName)),typeof e=="function"&&Z.set(e,k),k}while(m>=1&&b>=0);break}}}finally{ae=!1,ne.current=h,yr(),Error.prepareStackTrace=f}var B=e?e.displayName||e.name:"",D=B?$(B):"";return typeof e=="function"&&Z.set(e,D),D}function Cr(e,r,n){return Te(e,!1)}function xr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function Q(e,r,n){if(e==null)return"";if(typeof e=="function")return Te(e,xr(e));if(typeof e=="string")return $(e);switch(e){case R:return $("Suspense");case g:return $("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return Cr(e.render);case C:return Q(e.type,r,n);case S:{var o=e,f=o._payload,h=o._init;try{return Q(h(f),r,n)}catch{}}}return""}var K=Object.prototype.hasOwnProperty,Oe={},Pe=V.ReactDebugCurrentFrame;function q(e){if(e){var r=e._owner,n=Q(e.type,e._source,r?r.type:null);Pe.setExtraStackFrame(n)}else Pe.setExtraStackFrame(null)}function Rr(e,r,n,o,f){{var h=Function.call.bind(K);for(var c in e)if(h(e,c)){var l=void 0;try{if(typeof e[c]!="function"){var T=Error((o||"React class")+": "+n+" type `"+c+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[c]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw T.name="Invariant Violation",T}l=e[c](r,c,o,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(m){l=m}l&&!(l instanceof Error)&&(q(f),w("%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).",o||"React class",n,c,typeof l),q(null)),l instanceof Error&&!(l.message in Oe)&&(Oe[l.message]=!0,q(f),w("Failed %s type: %s",n,l.message),q(null))}}}var Sr=Array.isArray;function oe(e){return Sr(e)}function jr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function wr(e){try{return ke(e),!1}catch{return!0}}function ke(e){return""+e}function Ae(e){if(wr(e))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",jr(e)),ke(e)}var Ne=V.ReactCurrentOwner,Tr={key:!0,ref:!0,__self:!0,__source:!0},Me,Ie;function Or(e){if(K.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Pr(e){if(K.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function kr(e,r){typeof e.ref=="string"&&Ne.current}function Ar(e,r){{var n=function(){Me||(Me=!0,w("%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 Nr(e,r){{var n=function(){Ie||(Ie=!0,w("%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 Mr=function(e,r,n,o,f,h,c){var l={$$typeof:a,type:e,key:r,ref:n,props:c,_owner:h};return l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function Ir(e,r,n,o,f){{var h,c={},l=null,T=null;n!==void 0&&(Ae(n),l=""+n),Pr(r)&&(Ae(r.key),l=""+r.key),Or(r)&&(T=r.ref,kr(r,f));for(h in r)K.call(r,h)&&!Tr.hasOwnProperty(h)&&(c[h]=r[h]);if(e&&e.defaultProps){var m=e.defaultProps;for(h in m)c[h]===void 0&&(c[h]=m[h])}if(l||T){var b=typeof e=="function"?e.displayName||e.name||"Unknown":e;l&&Ar(c,b),T&&Nr(c,b)}return Mr(e,l,T,f,o,Ne.current,c)}}var se=V.ReactCurrentOwner,Ye=V.ReactDebugCurrentFrame;function U(e){if(e){var r=e._owner,n=Q(e.type,e._source,r?r.type:null);Ye.setExtraStackFrame(n)}else Ye.setExtraStackFrame(null)}var ie;ie=!1;function le(e){return typeof e=="object"&&e!==null&&e.$$typeof===a}function Fe(){{if(se.current){var e=I(se.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function Yr(e){return""}var Le={};function Fr(e){{var r=Fe();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 De(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=Fr(r);if(Le[n])return;Le[n]=!0;var o="";e&&e._owner&&e._owner!==se.current&&(o=" It was passed a child from "+I(e._owner.type)+"."),U(e),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,o),U(null)}}function We(e,r){{if(typeof e!="object")return;if(oe(e))for(var n=0;n<e.length;n++){var o=e[n];le(o)&&De(o,r)}else if(le(e))e._store&&(e._store.validated=!0);else if(e){var f=N(e);if(typeof f=="function"&&f!==e.entries)for(var h=f.call(e),c;!(c=h.next()).done;)le(c.value)&&De(c.value,r)}}}function Lr(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===C))n=r.propTypes;else return;if(n){var o=I(r);Rr(n,e.props,"prop",o,e)}else if(r.PropTypes!==void 0&&!ie){ie=!0;var f=I(r);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",f||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Dr(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var o=r[n];if(o!=="children"&&o!=="key"){U(e),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",o),U(null);break}}e.ref!==null&&(U(e),w("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}var Ve={};function Ue(e,r,n,o,f,h){{var c=gr(e);if(!c){var l="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(l+=" 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 T=Yr();T?l+=T:l+=Fe();var m;e===null?m="null":oe(e)?m="array":e!==void 0&&e.$$typeof===a?(m="<"+(I(e.type)||"Unknown")+" />",l=" Did you accidentally export a JSX literal instead of a component?"):m=typeof e,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",m,l)}var b=Ir(e,r,n,f,h);if(b==null)return b;if(c){var k=r.children;if(k!==void 0)if(o)if(oe(k)){for(var B=0;B<k.length;B++)We(k[B],e);Object.freeze&&Object.freeze(k)}else w("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 We(k,e)}if(K.call(r,"key")){var D=I(e),O=Object.keys(r).filter(function(Hr){return Hr!=="key"}),ce=O.length>0?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}";if(!Ve[D+ce]){var Gr=O.length>0?"{"+O.join(": ..., ")+": ...}":"{}";w(`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} />`,ce,D,Gr,D),Ve[D+ce]=!0}}return e===s?Dr(b):Lr(b),b}}function Wr(e,r,n){return Ue(e,r,n,!0)}function Vr(e,r,n){return Ue(e,r,n,!1)}var Ur=Vr,Br=Wr;H.Fragment=s,H.jsx=Ur,H.jsxs=Br}()),H}var de;function He(){return de||(de=1,process.env.NODE_ENV==="production"?X.exports=Be():X.exports=Ge()),X.exports}var u=He();const ee=["०","१","२","३","४","५","६","७","८","९"],Je="en",W="ne",z=Je,re=Y.minSupportedNepaliDate().getYear(),ve=Y.maxSupportedNepaliDate().getYear(),Ke=["Baisakh","Jestha","Asar","Shrawan","Bhadra","Aswin","Kartik","Mangsir","Poush","Magh","Falgun","Chaitra"],Xe=["बैशाख","जेठ","असार","श्रावण","भाद्र","आश्विन","कार्तिक","मंसिर","पौष","माघ","फाल्गुण","चैत्र"],ze=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],$e=["आइत","सोम","मंगल","बुध","बिहि","शुक्र","शनि"],pe=t=>t.toString().split("").map(a=>isNaN(Number(a))?a:ee[Number(a)]).join(""),Ze=t=>t.toString().split("").map(a=>ee.includes(a)?ee.indexOf(a):a).join(""),Qe=Array.from({length:ve-re+1},(t,a)=>a+re),qe=({selectedYear:t,onChange:a,locale:v=z})=>u.jsx("select",{value:t,onChange:s=>a&&a(Number(s.target.value)),children:Qe.map(s=>u.jsx("option",{value:s,children:v===W?pe(s):s},s))}),er=t=>t===W?Xe:Ke,rr=({selectedMonth:t,onChange:a,locale:v=z})=>u.jsx("select",{value:t,onChange:s=>a&&a(Number(s.target.value)),children:er(v).map((s,E)=>u.jsx("option",{value:E,children:s},s))}),he=7,_e=(t,a)=>{try{return Y.getDaysOfMonth(t,a)}catch{return null}},nr=(t,a)=>{const v=_e(t,a);if(!v)return[];const s=new Y(t,a,1).getDay(),[E,_]=a===0?[t-1,11]:[t,a-1],y=_e(E,_),[p,d]=a===11?[t+1,0]:[t,a+1],R=Math.ceil((s+v)/he)*he;return Array(R).fill(null).map((C,S)=>{let P,j,i,N;return S<s?(P=y?y-(s-S-1):null,j=_,i=E,N=!1):S<s+v?(P=S-s+1,j=a,i=t,N=!0):(P=S-(s+v)+1,j=d,i=p,N=!1),{index:S,active:N,year:i,month:j,date:P}})},F=(...t)=>t.filter(Boolean).join(" "),A={calendarContainer:"_calendarContainer_13lxa_1",calendarGrid:"_calendarGrid_13lxa_10",calendarCell:"_calendarCell_13lxa_15",calendarCellInactive:"_calendarCellInactive_13lxa_28",calendarCellCurrent:"_calendarCellCurrent_13lxa_36",calendarCellSelected:"_calendarCellSelected_13lxa_41",prevNext:"_prevNext_13lxa_56",calendarControls:"_calendarControls_13lxa_64"},ge=({selectedNepaliDate:t,onDateSelect:a=null,locale:v=z})=>{const s=new Y,E=v===W?$e:ze,[_,y]=x.useState((t==null?void 0:t.getYear())??s.getYear()),[p,d]=x.useState((t==null?void 0:t.getMonth())??s.getMonth()),R=i=>i.year===s.getYear()&&i.month===s.getMonth()&&i.date===s.getDate(),g=i=>t&&i.year===t.getYear()&&i.month===t.getMonth()&&i.date===t.getDate(),C=i=>{!i.active||!i.date||!a||a(new Y(_,p,i.date))},S=()=>{if(_===re&&p===0)return;const[i,N]=p===0?[_-1,11]:[_,p-1];y(i),d(N)},P=()=>{if(_===ve&&p===11)return;const[i,N]=p===11?[_+1,0]:[_,p+1];y(i),d(N)},j=nr(_,p);return u.jsxs("div",{className:"ndt-calendar",children:[u.jsxs("div",{className:`ndt-calendar-controls ${A.calendarControls}`,children:[u.jsx("div",{className:`ndt-prev ${A.prevNext}`,children:u.jsx("span",{onClick:S,children:u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 24 24",children:u.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"})})})}),u.jsxs("div",{children:[u.jsx(qe,{selectedYear:_,onChange:i=>y(i),locale:v}),u.jsx(rr,{selectedMonth:p,onChange:i=>d(i),locale:v})]}),u.jsx("div",{className:`ndt-next ${A.prevNext}`,children:u.jsx("span",{onClick:P,children:u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 24 24",children:u.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"})})})})]}),u.jsxs("div",{className:`ndt-calendar-container ${A.calendarContainer}`,children:[u.jsx("div",{className:`ndt-calendar-grid ${A.calendarGrid}`,children:E.map(i=>u.jsx("div",{className:F("ndt-calendar-header",A.calendarCell),children:i},i))}),u.jsx("div",{className:`ndt-calendar-grid ${A.calendarGrid}`,children:j.map(i=>u.jsx("div",{onClick:()=>C(i),className:F("ndt-calendar-cell",A.calendarCell,g(i)&&F("ndt-calendar-cell-selected",A.calendarCellSelected),R(i)&&F("ndt-calendar-cell-current",A.calendarCellCurrent),!i.active&&A.calendarCellInactive),children:i.date&&v===W?pe(i.date):i.date},i.index))})]})]})},tr={popoverContent:"_popoverContent_qysd3_1"},ar=150,or=({popoverChildRef:t,children:a,onOutsideClick:v})=>{const s=x.useRef(null),[E,_]=x.useState(),y=x.useCallback(()=>{const d=t==null?void 0:t.current;if(!d){_({});return}const{bottom:R,height:g}=d.getBoundingClientRect(),C=R+ar>window.innerHeight;_(C?{bottom:g}:{top:g})},[t]),p=x.useCallback(d=>{var g,C;if(!v)return;const R=d.target;!((g=t==null?void 0:t.current)!=null&&g.contains(R))&&!((C=s.current)!=null&&C.contains(R))&&v()},[t,v]);return x.useLayoutEffect(()=>(y(),document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)),[p,y]),E?u.jsx("div",{className:F("ndt-popover-content",tr.popoverContent),ref:s,style:E,children:a}):null},sr=({children:t,content:a,open:v=!1,onOpenChange:s,className:E})=>{const _=x.useRef(null),y=p=>{s&&s(p)};return u.jsxs("div",{className:F("ndt-popover",E),style:{position:"relative"},children:[u.jsx("div",{className:"ndt-popover-child",ref:_,onClick:()=>y(!0),children:t}),v&&u.jsx(or,{onOutsideClick:()=>y(!1),popoverChildRef:_,children:a})]})},ir={pickerInput:"_pickerInput_1txhx_1"},lr=({className:t,...a})=>u.jsx("input",{className:F("ndt-picker-input",ir.pickerInput,t),type:"text",...a}),cr=(t,a,v)=>{const s=v===W?Ze(t):t;try{return new Y(s,a)}catch{return null}},ur=({value:t="",format:a="YYYY-MM-DD",inputElement:v=null,onDateSelect:s=null,locale:E=z,..._})=>{const[y,p]=x.useState(!1),[d,R]=x.useState(t),g={value:d,readOnly:!0};x.useEffect(()=>{R(t)},[t]);const C=j=>{R(j),s&&s(j)},S=j=>{const i=E===W?j.formatNepali(a):j.format(a);C(i),p(!1)},P=v&&x.cloneElement(v,{..._,...g});return u.jsx(sr,{className:"ndt-date-picker",open:y,onOpenChange:j=>p(j),content:u.jsx(ge,{locale:E,selectedNepaliDate:cr(d,a,E),onDateSelect:S}),children:P||u.jsx(lr,{..._,...g})})};M.NepaliCalendar=ge,M.NepaliDatePicker=ur,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});