Liferay.Loader.define("@liferay/object-js-components-web@1.0.58/components/DatePicker",["module","exports","require","@frontend-taglib-clay$clayui/date-picker","liferay!frontend-js-dependencies-web$moment/min/moment-with-locales","liferay!frontend-js-react-web$react","liferay!frontend-js-dependencies-web$text-mask-core","../utils/createAutoCorrectedDatePipe","../utils/datetime","./FieldBase"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.DatePicker=function DatePicker({className:e,defaultLanguageId:t=Liferay.ThemeDisplay.getDefaultLanguageId(),disabled:r,error:a,feedbackMessage:s,hideFeedback:f,id:p,label:y,locale:m=Liferay.ThemeDisplay.getLanguageId(),onChange:b,name:g,range:D,required:w,type:h,value:j}){const[O,v]=(0,i.useState)(!1),k=(0,o.default)().locale(null!=m?m:t),P=k.localeData().months(),_=k.localeData().weekdaysShort(),M=(0,i.useRef)(null),S=(0,i.useRef)(null),{clayFormat:F,firstDayOfWeek:C,isDateTime:q=!1,momentFormat:W="",placeholder:R,serverFormat:E="",use12Hours:T}=(0,i.useMemo)((()=>{let e={};return e=(0,c.generateDateConfigurations)({defaultLanguageId:t,locale:m,type:h}),e}),[t,m,h]),L=(0,i.useMemo)((()=>{let e="",r=(0,o.default)().year();const a=null!=j?j:"";if(""!==a){const n=(0,o.default)(a,E,!0);e=n.locale(null!=m?m:t).format(W),r=n.year()}return{formattedDate:e,locale:m,name:g,rawDate:a,value:j,years:{end:r+5,start:r-5}}}),[W,t,m,g,E,j]),[{formattedDate:$,rawDate:I,years:x},A]=(0,i.useState)(L);return(0,i.useEffect)((()=>{A((({formattedDate:e,name:t,rawDate:r,value:a})=>t===L.name&&a===L.value&&""===r?_objectSpread(_objectSpread({},L),{},{formattedDate:e}):L))}),[L]),(0,i.useEffect)((()=>{const{mask:e,pipeFormat:t}=(0,c.generateInputMask)(W);S.current=(0,u.createTextMaskInputElement)({guide:!0,inputElement:M.current,keepCharPositions:!0,mask:e,pipe:(0,l.createAutoCorrectedDatePipe)(t),showMask:!0})}),[W]),i.default.createElement(d.FieldBase,{className:e,disabled:r,errorMessage:a,helpMessage:s,hideFeedback:f,id:p,label:y,required:w},i.default.createElement(n.default,{dateFormat:F,expanded:O,firstDayOfWeek:C,months:P,onChange:e=>{const t=(0,c.generateDate)({isDateTime:q,momentFormat:W,serverFormat:E,value:e});A((e=>_objectSpread(_objectSpread({},e),t))),t.rawDate!==I&&b(t.rawDate),v(!1)},onExpandedChange:()=>{v(!O)},onInput:({target:{value:e}})=>{try{var t;null===(t=S.current)||void 0===t||t.update(e)}catch(e){var r;null===(r=S.current)||void 0===r||r.update("")}},placeholder:R,range:D,ref:M,time:q,use12Hours:T,value:$,weekdaysShort:_,years:x,yearsCheck:!1}))};var a,n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/date-picker")),o=_interopRequireDefault(r("liferay!frontend-js-dependencies-web$moment/min/moment-with-locales")),i=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=a?Object.getOwnPropertyDescriptor(e,n):null;o&&(o.get||o.set)?Object.defineProperty(r,n,o):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),u=r("liferay!frontend-js-dependencies-web$text-mask-core"),l=r("../utils/createAutoCorrectedDatePipe"),c=r("../utils/datetime"),d=r("./FieldBase");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e[e.Sunday=0]="Sunday",e[e.Monday=1]="Monday",e[e.Tuesday=2]="Tuesday",e[e.Wednesday=3]="Wednesday",e[e.Thursday=4]="Thursday",e[e.Friday=5]="Friday",e[e.Saturday=6]="Saturday"}(a||(a={}))}}));
//# sourceMappingURL=DatePicker.js.map