react-js-cron
Version:
A React cron editor with antd inspired by jqCron
2 lines (1 loc) • 25.4 kB
JavaScript
import{jsx as e,Fragment as o,jsxs as n}from"react/jsx-runtime";import{Select as r,Button as t}from"antd";import{useRef as l,useEffect as i,useMemo as a,useCallback as u,useState as d}from"react";var c=function(){return c=Object.assign||function(e){for(var o,n=1,r=arguments.length;n<r;n++)for(var t in o=arguments[n])Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t]);return e},c.apply(this,arguments)};function s(e,o){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var t=0;for(r=Object.getOwnPropertySymbols(e);t<r.length;t++)o.indexOf(r[t])<0&&Object.prototype.propertyIsEnumerable.call(e,r[t])&&(n[r[t]]=e[r[t]])}return n}function v(e,o,n){if(n||2===arguments.length)for(var r,t=0,l=o.length;t<l;t++)!r&&t in o||(r||(r=Array.prototype.slice.call(o,0,t)),r[t]=o[t]);return e.concat(r||Array.prototype.slice.call(o))}var p=[{name:"@yearly",value:"0 0 1 1 *"},{name:"@annually",value:"0 0 1 1 *"},{name:"@monthly",value:"0 0 1 * *"},{name:"@weekly",value:"0 0 * * 0"},{name:"@daily",value:"0 0 * * *"},{name:"@midnight",value:"0 0 * * *"},{name:"@hourly",value:"0 * * * *"}],m=[{type:"minutes",min:0,max:59,total:60},{type:"hours",min:0,max:23,total:24},{type:"month-days",min:1,max:31,total:31},{type:"months",min:1,max:12,total:12,alt:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]},{type:"week-days",min:0,max:6,total:7,alt:["SUN","MON","TUE","WED","THU","FRI","SAT"]}],f={everyText:"every",emptyMonths:"every month",emptyMonthDays:"every day of the month",emptyMonthDaysShort:"day of the month",emptyWeekDays:"every day of the week",emptyWeekDaysShort:"day of the week",emptyHours:"every hour",emptyMinutes:"every minute",emptyMinutesForHourPeriod:"every",yearOption:"year",monthOption:"month",weekOption:"week",dayOption:"day",hourOption:"hour",minuteOption:"minute",rebootOption:"reboot",prefixPeriod:"Every",prefixMonths:"in",prefixMonthDays:"on",prefixWeekDays:"on",prefixWeekDaysForMonthAndYearPeriod:"and",prefixHours:"at",prefixMinutes:":",prefixMinutesForHourPeriod:"at",suffixMinutesForHourPeriod:"minute(s)",errorInvalidCron:"Invalid cron expression",clearButtonText:"Clear",weekDays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],altWeekDays:["SUN","MON","TUE","WED","THU","FRI","SAT"],altMonths:["JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]};function y(e,o){for(var n=[],r=e;r<=o;r++)n.push(r);return n}function h(e){return e.sort((function(e,o){return e-o})),e}function g(e){var o=[];return e.forEach((function(e){o.indexOf(e)<0&&o.push(e)})),o}function w(e){return Object.entries(e).filter((function(e){var o=e[0],n=e[1];return o&&n})).map((function(e){return e[0]})).join(" ")}function O(e,o){e&&e({type:"invalid_cron",description:o.errorInvalidCron||f.errorInvalidCron})}function b(e){var o=parseInt(e,10),n=Number(e);return o===n?n:NaN}function k(e,o,n,r,t,l,i,a,u,d,c,s,v,m){n&&n(void 0),o(!1);var f=!1;if(!e){if("always"===r||l&&"for-default-value"===r)return;f=!0}if(!f){if(a&&(!0===a||a.includes(e))){if("@reboot"===e)return void m("reboot");var y=p.find((function(o){return o.name===e}));y&&(e=y.value)}try{var h=P(e),g=function(e){if(e[3].length>0)return"year";if(e[2].length>0)return"month";if(e[4].length>0)return"week";if(e[1].length>0)return"day";if(e[0].length>0)return"hour";return"minute"}(h);m(g),u(h[0]),d(h[1]),c(h[2]),s(h[3]),v(h[4])}catch(e){f=!0}}f&&(t.current=e,o(!0),O(n,i))}function C(e,o,n,r,t,l,i,a){if("reboot"===e)return"@reboot";var u=function(e,o,n){return e.map((function(e,r){var t,l=m[r],i=x(e,l),a=null==n?void 0:n[l.type];return N(i,l,null!==(t=null==a?void 0:a.humanizeValue)&&void 0!==t?t:o)}))}(["minute"!==e&&l?l:[],"minute"!==e&&"hour"!==e&&t?t:[],"year"!==e&&"month"!==e||!n?[]:n,"year"===e&&o?o:[],"year"!==e&&"month"!==e&&"week"!==e||!r?[]:r],i,a);return u.join(" ")}function N(e,o,n,r,t){var l="";if(function(e,o){return e.length===o.max-o.min+1}(e,o)||0===e.length)l="*";else{var i=function(e){if(e.length>2){var o=e[1]-e[0];if(o>1)return o}}(e);l=i&&function(e,o){for(var n=1;n<e.length;n++){var r=e[n-1];if(e[n]-r!==o)return!1}return!0}(e,i)?function(e,o,n){var r=S(e),t=F(e),l=e.length===(t-r)/n+1;if(r===o.min&&t+n>o.max&&l)return!0;return!1}(e,o,i)?"*/".concat(i):"".concat(D(S(e),o,n,r,t),"-").concat(D(F(e),o,n,r,t),"/").concat(i):function(e){var o=[],n=null;return e.forEach((function(e,r,t){e!==t[r+1]-1?null!==n?(o.push([n,e]),n=null):o.push(e):null===n&&(n=e)})),o}(e).map((function(e){return Array.isArray(e)?"".concat(D(e[0],o,n,r,t),"-").concat(D(e[1],o,n,r,t)):D(e,o,n,r,t)})).join(",")}return l}function D(e,o,n,r,t){var l=e.toString(),i=o.type,a=o.alt,u=o.min,d=r&&(!0===r||r.includes(i)),c="24-hour-clock"===t&&("hours"===i||"minutes"===i);if(n&&"week-days"===i||n&&"months"===i?l=a[e-u]:e<10&&(d||c)&&(l=l.padStart(2,"0")),"hours"===i&&"12-hour-clock"===t){var s=e>=12?"PM":"AM",v=e%12||12;v<10&&d&&(v=v.toString().padStart(2,"0")),l="".concat(v).concat(s)}return l}function x(e,o){var n=h(g(M(e,o)));if(0===n.length)return n;var r=j(n,o);if(void 0!==r)throw new Error('Value "'.concat(r,'" out of range for ').concat(o.type));return n}function P(e){if("string"!=typeof e)throw new Error("Invalid cron string");var o=e.replace(/\s+/g," ").trim().split(" ");if(5===o.length)return o.map((function(e,o){return function(e,o){if("*"===e||"*/1"===e)return[];var n=h(g(M(function(e,o,n){if(n){e=e.toUpperCase();for(var r=0;r<n.length;r++)e=e.replace(n[r],"".concat(r+o))}return e}(e,o.min,o.alt).split(",").map((function(n){var r,t=n.split("/");if(t.length>2)throw new Error('Invalid value "'.concat(e,' for "').concat(o.type,'"'));var l=t[0],i=t[1];r="*"===l?y(o.min,o.max):function(e,o,n){var r=e.split("-");if(1===r.length){var t=b(r[0]);if(isNaN(t))throw new Error('Invalid value "'.concat(o,'" for ').concat(n.type));return[t]}if(2===r.length){var l=b(r[0]),i=b(r[1]);if(isNaN(l)||isNaN(i))throw new Error('Invalid value "'.concat(o,'" for ').concat(n.type));if(i<l)throw new Error('Max range is less than min range in "'.concat(e,'" for ').concat(n.type));return y(l,i)}throw new Error('Invalid value "'.concat(e,'" for ').concat(n.type))}(l,e,o);var a=function(e,o){if(void 0!==e){var n=b(e);if(isNaN(n)||n<1)throw new Error('Invalid interval step value "'.concat(e,'" for ').concat(o.type));return n}}(i,o),u=function(e,o){if(o){var n=e[0];e=e.filter((function(e){return e%o==n%o||e===n}))}return e}(r,a);return u})).flat(),o))),r=j(n,o);if(void 0!==r)throw new Error('Value "'.concat(r,'" out of range for ').concat(o.type));if(n.length===o.total)return[];return n}(e,m[o])}));throw new Error("Invalid cron string format")}function M(e,o){return"week-days"===o.type&&(e=e.map((function(e){return 7===e?0:e}))),e}function j(e,o){var n=e[0],r=e[e.length-1];return n<o.min?n:r>o.max?r:void 0}function S(e){return e[0]}function F(e){return e[e.length-1]}var A=Object.freeze({__proto__:null,setValuesFromCronString:k,getCronStringFromValues:C,partToString:N,formatValue:D,parsePartArray:x,parseCronString:P});function V(n){var t=n.value,i=n.grid,d=void 0===i||i,p=n.optionsList,m=n.setValue,y=n.locale,g=n.className,O=n.humanizeLabels,b=n.disabled,k=n.readOnly,C=n.leadingZero,P=n.clockFormat,M=n.period,j=n.unit,S=n.periodicityOnDoubleClick,F=n.mode,A=n.allowClear,V=n.filterOption,E=void 0===V?function(){return!0}:V,W=n.getPopupContainer,H=s(n,["value","grid","optionsList","setValue","locale","className","humanizeLabels","disabled","readOnly","leadingZero","clockFormat","period","unit","periodicityOnDoubleClick","mode","allowClear","filterOption","getPopupContainer"]),T=a((function(){if(t&&Array.isArray(t))return t.map((function(e){return e.toString()}))}),[t]),I=a((function(){return p?p.map((function(e,o){return{value:(0===j.min?o:o+1).toString(),label:e}})).filter(E):v([],Array(j.total),!0).map((function(e,o){var n=0===j.min?o:o+1;return{value:n.toString(),label:D(n,j,O,C,P)}})).filter(E)}),[p,C,O,P]),L=JSON.stringify(y),J=u((function(n){var r=n.value;if(!t||t[0]!==Number(r))return e(o,{});var l=N(x(t,j),j,O,C,P),i=l.match(/^\*\/([0-9]+),?/)||[];return e("div",{children:i[1]?"".concat(y.everyText||f.everyText," ").concat(i[1]):l})}),[t,L,O,C,P]),Z=u((function(e){var o=Array.isArray(e)?h(e):[e],n=o;t&&(n="single"===F?[]:v([],t,!0),o.forEach((function(e){var o=Number(e);n=t.some((function(e){return e===o}))?n.filter((function(e){return e!==o})):h(v(v([],n,!0),[o],!1))}))),n.length===j.total?m([]):m(n)}),[m,t]),z=u((function(e){if(0!==e&&1!==e){for(var o=j.total+j.min,n=[],r=j.min;r<o;r++)r%e==0&&n.push(r);var l=t&&n&&t.length===n.length&&t.every((function(e,o){return e===n[o]})),i=n.length===I.length;m(i||l?[]:n)}else m([])}),[t,I,m]),U=l([]),B=u((function(e){if(!k){var o=U.current;o.push({time:(new Date).getTime(),value:Number(e)});var n=window.setTimeout((function(){S&&o.length>1&&o[o.length-1].time-o[o.length-2].time<300?o[o.length-1].value===o[o.length-2].value?z(Number(e)):Z([o[o.length-2].value,o[o.length-1].value]):Z(Number(e)),U.current=[]}),300);return function(){window.clearTimeout(n)}}}),[U,Z,z,k,S]),R=u((function(){k||m([])}),[m,k]),Y=a((function(){var e;return w(((e={"react-js-cron-select":!0,"react-js-cron-custom-select":!0})["".concat(g,"-select")]=!!g,e))}),[g]),_=a((function(){var e;return w(((e={"react-js-cron-select-dropdown":!0})["react-js-cron-select-dropdown-".concat(j.type)]=!0,e["react-js-cron-custom-select-dropdown"]=!0,e["react-js-cron-custom-select-dropdown-".concat(j.type)]=!0,e["react-js-cron-custom-select-dropdown-minutes-large"]="minutes"===j.type&&"hour"!==M&&"day"!==M,e["react-js-cron-custom-select-dropdown-minutes-medium"]="minutes"===j.type&&("day"===M||"hour"===M),e["react-js-cron-custom-select-dropdown-hours-twelve-hour-clock"]="hours"===j.type&&"12-hour-clock"===P,e["react-js-cron-custom-select-dropdown-grid"]=!!d,e["".concat(g,"-select-dropdown")]=!!g,e["".concat(g,"-select-dropdown-").concat(j.type)]=!!g,e))}),[g,d,P,M]);return e(r,c({mode:"single"!==F||S?"multiple":void 0,allowClear:null!=A?A:!k,virtual:!1,open:!k&&void 0,value:T,onClear:R,tagRender:J,className:Y,popupClassName:_,options:I,showSearch:!1,suffixIcon:k?null:void 0,menuItemSelectedIcon:null,popupMatchSelectWidth:!1,onSelect:B,onDeselect:B,disabled:b,dropdownAlign:"minutes"!==j.type&&"hours"!==j.type||"day"===M||"hour"===M?void 0:{points:["tr","br"]},"data-testid":"custom-select-".concat(j.type),getPopupContainer:W},H))}function E(o){var r=o.value,t=o.setValue,l=o.locale,i=o.className,u=o.disabled,d=o.readOnly,s=o.leadingZero,v=o.clockFormat,p=o.period,y=o.periodicityOnDoubleClick,h=o.mode,g=o.allowClear,O=o.filterOption,b=o.getPopupContainer,k=a((function(){var e;return w(((e={"react-js-cron-field":!0,"react-js-cron-hours":!0})["".concat(i,"-field")]=!!i,e["".concat(i,"-hours")]=!!i,e))}),[i]);return n("div",c({className:k},{children:[""!==l.prefixHours&&e("span",{children:l.prefixHours||f.prefixHours}),e(V,{placeholder:l.emptyHours||f.emptyHours,value:r,unit:m[1],setValue:t,locale:l,className:i,disabled:u,readOnly:d,leadingZero:s,clockFormat:v,period:p,periodicityOnDoubleClick:y,mode:h,allowClear:g,filterOption:O,getPopupContainer:b})]}))}function W(o){var r=o.value,t=o.setValue,l=o.locale,i=o.className,u=o.disabled,d=o.readOnly,s=o.leadingZero,v=o.clockFormat,p=o.period,y=o.periodicityOnDoubleClick,h=o.mode,g=o.allowClear,O=o.filterOption,b=o.getPopupContainer,k=a((function(){var e;return w(((e={"react-js-cron-field":!0,"react-js-cron-minutes":!0})["".concat(i,"-field")]=!!i,e["".concat(i,"-minutes")]=!!i,e))}),[i]);return n("div",c({className:k},{children:["hour"===p?""!==l.prefixMinutesForHourPeriod&&e("span",{children:l.prefixMinutesForHourPeriod||f.prefixMinutesForHourPeriod}):""!==l.prefixMinutes&&e("span",{children:l.prefixMinutes||f.prefixMinutes}),e(V,{placeholder:"hour"===p?l.emptyMinutesForHourPeriod||f.emptyMinutesForHourPeriod:l.emptyMinutes||f.emptyMinutes,value:r,unit:m[0],setValue:t,locale:l,className:i,disabled:u,readOnly:d,leadingZero:s,clockFormat:v,period:p,periodicityOnDoubleClick:y,mode:h,allowClear:g,filterOption:O,getPopupContainer:b}),"hour"===p&&""!==l.suffixMinutesForHourPeriod&&e("span",{children:l.suffixMinutesForHourPeriod||f.suffixMinutesForHourPeriod})]}))}function H(o){var r=o.value,t=o.setValue,l=o.locale,i=o.className,u=o.weekDays,d=o.disabled,s=o.readOnly,v=o.leadingZero,p=o.period,y=o.periodicityOnDoubleClick,h=o.mode,g=o.allowClear,O=o.filterOption,b=o.getPopupContainer,k=!u||0===u.length,C=a((function(){var e;return w(((e={"react-js-cron-field":!0,"react-js-cron-month-days":!0,"react-js-cron-month-days-placeholder":!k})["".concat(i,"-field")]=!!i,e["".concat(i,"-month-days")]=!!i,e))}),[i,k]),N=JSON.stringify(l),D=a((function(){return k?l.emptyMonthDays||f.emptyMonthDays:l.emptyMonthDaysShort||f.emptyMonthDaysShort}),[k,N]);return!s||r&&r.length>0||(!r||0===r.length)&&(!u||0===u.length)?n("div",c({className:C},{children:[""!==l.prefixMonthDays&&e("span",{children:l.prefixMonthDays||f.prefixMonthDays}),e(V,{placeholder:D,value:r,setValue:t,unit:m[2],locale:l,className:i,disabled:d,readOnly:s,leadingZero:v,period:p,periodicityOnDoubleClick:y,mode:h,allowClear:g,filterOption:O,getPopupContainer:b})]})):null}function T(o){var r=o.value,t=o.setValue,l=o.locale,i=o.className,u=o.humanizeLabels,d=o.disabled,s=o.readOnly,v=o.period,p=o.periodicityOnDoubleClick,y=o.mode,h=o.allowClear,g=o.filterOption,O=o.getPopupContainer,b=l.months||f.months,k=a((function(){var e;return w(((e={"react-js-cron-field":!0,"react-js-cron-months":!0})["".concat(i,"-field")]=!!i,e["".concat(i,"-months")]=!!i,e))}),[i]);return n("div",c({className:k},{children:[""!==l.prefixMonths&&e("span",{children:l.prefixMonths||f.prefixMonths}),e(V,{placeholder:l.emptyMonths||f.emptyMonths,optionsList:b,grid:!1,value:r,unit:c(c({},m[3]),{alt:l.altMonths||f.altMonths}),setValue:t,locale:l,className:i,humanizeLabels:u,disabled:d,readOnly:s,period:v,periodicityOnDoubleClick:p,mode:y,allowClear:h,filterOption:g,getPopupContainer:O})]}))}function I(o){var t=o.value,l=o.setValue,i=o.locale,d=o.className,s=o.disabled,v=o.readOnly,p=o.shortcuts,m=o.allowedPeriods,y=o.allowClear,h=o.getPopupContainer,g=[];m.includes("year")&&g.push({value:"year",label:i.yearOption||f.yearOption}),m.includes("month")&&g.push({value:"month",label:i.monthOption||f.monthOption}),m.includes("week")&&g.push({value:"week",label:i.weekOption||f.weekOption}),m.includes("day")&&g.push({value:"day",label:i.dayOption||f.dayOption}),m.includes("hour")&&g.push({value:"hour",label:i.hourOption||f.hourOption}),m.includes("minute")&&g.push({value:"minute",label:i.minuteOption||f.minuteOption}),m.includes("reboot")&&p&&(!0===p||p.includes("@reboot"))&&g.push({value:"reboot",label:i.rebootOption||f.rebootOption});var O=u((function(e){v||l(e)}),[l,v]),b=a((function(){var e;return w(((e={"react-js-cron-field":!0,"react-js-cron-period":!0})["".concat(d,"-field")]=!!d,e["".concat(d,"-period")]=!!d,e))}),[d]),k=a((function(){var e;return w(((e={"react-js-cron-select":!0,"react-js-cron-select-no-prefix":""===i.prefixPeriod})["".concat(d,"-select")]=!!d,e))}),[d,i.prefixPeriod]),C=a((function(){var e;return w(((e={"react-js-cron-select-dropdown":!0,"react-js-cron-select-dropdown-period":!0})["".concat(d,"-select-dropdown")]=!!d,e["".concat(d,"-select-dropdown-period")]=!!d,e))}),[d]);return n("div",c({className:b},{children:[""!==i.prefixPeriod&&e("span",{children:i.prefixPeriod||f.prefixPeriod}),e(r,{defaultValue:t,value:t,onChange:O,options:g,className:k,popupClassName:C,disabled:s,suffixIcon:v?null:void 0,open:!v&&void 0,"data-testid":"select-period",allowClear:y,getPopupContainer:h},JSON.stringify(i))]}))}function L(o){var r=o.value,t=o.setValue,l=o.locale,i=o.className,u=o.humanizeLabels,d=o.monthDays,s=o.disabled,v=o.readOnly,p=o.period,y=o.periodicityOnDoubleClick,h=o.mode,g=o.allowClear,O=o.filterOption,b=o.getPopupContainer,k=l.weekDays||f.weekDays,C="week"===p||!d||0===d.length,N=a((function(){var e;return w(((e={"react-js-cron-field":!0,"react-js-cron-week-days":!0,"react-js-cron-week-days-placeholder":!C})["".concat(i,"-field")]=!!i,e["".concat(i,"-week-days")]=!!i,e))}),[i,C]),D=JSON.stringify(l),x=a((function(){return C?l.emptyWeekDays||f.emptyWeekDays:l.emptyWeekDaysShort||f.emptyWeekDaysShort}),[C,D]),P="week"===p||!v||r&&r.length>0||(!r||0===r.length)&&(!d||0===d.length),M=!v||d&&d.length>0||(!d||0===d.length)&&(!r||0===r.length);return P?n("div",c({className:N},{children:[""!==l.prefixWeekDays&&("week"===p||!M)&&e("span",{children:l.prefixWeekDays||f.prefixWeekDays}),""!==l.prefixWeekDaysForMonthAndYearPeriod&&"week"!==p&&M&&e("span",{children:l.prefixWeekDaysForMonthAndYearPeriod||f.prefixWeekDaysForMonthAndYearPeriod}),e(V,{placeholder:x,optionsList:k,grid:!1,value:r,unit:c(c({},m[4]),{alt:l.altWeekDays||f.altWeekDays}),setValue:t,locale:l,className:i,humanizeLabels:u,disabled:s,readOnly:v,period:p,periodicityOnDoubleClick:y,mode:h,allowClear:g,filterOption:O,getPopupContainer:b})]})):null}function J(r){var v,p,m,y,h,g,b,N,D,x,P,M,j,S,F,A,V,J,Z,z,U,B,R,Y,_,G,q,K,Q,X,$,ee,oe,ne,re,te,le,ie,ae,ue,de,ce,se,ve,pe,me,fe,ye,he,ge,we,Oe,be,ke,Ce,Ne,De,xe,Pe,Me,je,Se,Fe,Ae,Ve,Ee,We,He,Te,Ie,Le,Je=r.clearButton,Ze=void 0===Je||Je,ze=r.clearButtonProps,Ue=void 0===ze?{}:ze,Be=r.clearButtonAction,Re=void 0===Be?"fill-with-every":Be,Ye=r.locale,_e=void 0===Ye?f:Ye,Ge=r.value,qe=void 0===Ge?"":Ge,Ke=r.setValue,Qe=r.displayError,Xe=void 0===Qe||Qe,$e=r.onError,eo=r.className,oo=r.defaultPeriod,no=void 0===oo?"day":oo,ro=r.allowEmpty,to=void 0===ro?"for-default-value":ro,lo=r.humanizeLabels,io=void 0===lo||lo,ao=r.humanizeValue,uo=void 0!==ao&&ao,co=r.disabled,so=void 0!==co&&co,vo=r.readOnly,po=void 0!==vo&&vo,mo=r.leadingZero,fo=void 0!==mo&&mo,yo=r.shortcuts,ho=void 0===yo?["@yearly","@annually","@monthly","@weekly","@daily","@midnight","@hourly"]:yo,go=r.clockFormat,wo=r.periodicityOnDoubleClick,Oo=void 0===wo||wo,bo=r.mode,ko=void 0===bo?"multiple":bo,Co=r.allowedDropdowns,No=void 0===Co?["period","months","month-days","week-days","hours","minutes"]:Co,Do=r.allowedPeriods,xo=void 0===Do?["year","month","week","day","hour","minute","reboot"]:Do,Po=r.allowClear,Mo=r.dropdownsConfig,jo=r.getPopupContainer,So=l(qe),Fo=l(no),Ao=d(),Vo=Ao[0],Eo=Ao[1],Wo=d(),Ho=Wo[0],To=Wo[1],Io=d(),Lo=Io[0],Jo=Io[1],Zo=d(),zo=Zo[0],Uo=Zo[1],Bo=d(),Ro=Bo[0],Yo=Bo[1],_o=d(),Go=_o[0],qo=_o[1],Ko=d(!1),Qo=Ko[0],Xo=Ko[1],$o=d(!1),en=$o[0],on=$o[1],nn=function(e){var o=l(e);return i((function(){o.current=e}),[e]),o.current}(en),rn=JSON.stringify(_e);i((function(){k(qe,Xo,$e,to,So,!0,_e,ho,qo,Yo,To,Jo,Uo,Eo)}),[]),i((function(){qe!==So.current&&k(qe,Xo,$e,to,So,!1,_e,ho,qo,Yo,To,Jo,Uo,Eo)}),[qe,So,rn,to,ho]),i((function(){if(!(Vo||Go||Lo||Ho||zo||Ro)||en||nn)en&&on(!1);else{var e=Vo||Fo.current,o=C(e,Lo,Ho,zo,Ro,Go,uo,Mo);Ke(o,{selectedPeriod:e}),So.current=o,$e&&$e(void 0),Xo(!1)}}),[Vo,Ho,Lo,zo,Ro,Go,uo,en,Mo]);var tn=u((function(){To(void 0),Jo(void 0),Uo(void 0),Yo(void 0),qo(void 0);var e="",o="reboot"!==Vo&&Vo?Vo:Fo.current;(o!==Vo&&Eo(o),"fill-with-every"===Re)&&(e=C(o,void 0,void 0,void 0,void 0,void 0,void 0,void 0));Ke(e,{selectedPeriod:o}),So.current=e,on(!0),"never"===to&&"empty"===Re?(Xo(!0),O($e,_e)):($e&&$e(void 0),Xo(!1))}),[Vo,Ke,$e,Re]),ln=a((function(){var e;return w(((e={"react-js-cron":!0,"react-js-cron-error":Qo&&Xe,"react-js-cron-disabled":so,"react-js-cron-read-only":po})["".concat(eo)]=!!eo,e["".concat(eo,"-error")]=Qo&&Xe&&!!eo,e["".concat(eo,"-disabled")]=so&&!!eo,e["".concat(eo,"-read-only")]=po&&!!eo,e))}),[eo,Qo,Xe,so,po]),an=Ue.className,un=s(Ue,["className"]),dn=a((function(){var e;return w(((e={"react-js-cron-clear-button":!0})["".concat(eo,"-clear-button")]=!!eo,e["".concat(an)]=!!an,e))}),[eo,an]),cn=JSON.stringify(un),sn=a((function(){return Ze&&!po?e(t,c({className:dn,danger:!0,type:"primary",disabled:so},un,{onClick:tn},{children:_e.clearButtonText||f.clearButtonText})):null}),[Ze,po,rn,dn,so,cn,tn]),vn=Vo||Fo.current;return n("div",c({className:ln},{children:[No.includes("period")&&e(I,{value:vn,setValue:Eo,locale:_e,className:eo,disabled:null!==(p=null===(v=null==Mo?void 0:Mo.period)||void 0===v?void 0:v.disabled)&&void 0!==p?p:so,readOnly:null!==(y=null===(m=null==Mo?void 0:Mo.period)||void 0===m?void 0:m.readOnly)&&void 0!==y?y:po,shortcuts:ho,allowedPeriods:xo,allowClear:null!==(g=null===(h=null==Mo?void 0:Mo.period)||void 0===h?void 0:h.allowClear)&&void 0!==g?g:Po,getPopupContainer:jo}),"reboot"===vn?sn:n(o,{children:["year"===vn&&No.includes("months")&&e(T,{value:Lo,setValue:Jo,locale:_e,className:eo,humanizeLabels:null!==(N=null===(b=null==Mo?void 0:Mo.months)||void 0===b?void 0:b.humanizeLabels)&&void 0!==N?N:io,disabled:null!==(x=null===(D=null==Mo?void 0:Mo.months)||void 0===D?void 0:D.disabled)&&void 0!==x?x:so,readOnly:null!==(M=null===(P=null==Mo?void 0:Mo.months)||void 0===P?void 0:P.readOnly)&&void 0!==M?M:po,period:vn,periodicityOnDoubleClick:null!==(S=null===(j=null==Mo?void 0:Mo.months)||void 0===j?void 0:j.periodicityOnDoubleClick)&&void 0!==S?S:Oo,mode:null!==(A=null===(F=null==Mo?void 0:Mo.months)||void 0===F?void 0:F.mode)&&void 0!==A?A:ko,allowClear:null!==(J=null===(V=null==Mo?void 0:Mo.months)||void 0===V?void 0:V.allowClear)&&void 0!==J?J:Po,filterOption:null===(Z=null==Mo?void 0:Mo.months)||void 0===Z?void 0:Z.filterOption,getPopupContainer:jo}),("year"===vn||"month"===vn)&&No.includes("month-days")&&e(H,{value:Ho,setValue:To,locale:_e,className:eo,weekDays:zo,disabled:null!==(U=null===(z=null==Mo?void 0:Mo["month-days"])||void 0===z?void 0:z.disabled)&&void 0!==U?U:so,readOnly:null!==(R=null===(B=null==Mo?void 0:Mo["month-days"])||void 0===B?void 0:B.readOnly)&&void 0!==R?R:po,leadingZero:null!==(_=null===(Y=null==Mo?void 0:Mo["month-days"])||void 0===Y?void 0:Y.leadingZero)&&void 0!==_?_:fo,period:vn,periodicityOnDoubleClick:null!==(q=null===(G=null==Mo?void 0:Mo["month-days"])||void 0===G?void 0:G.periodicityOnDoubleClick)&&void 0!==q?q:Oo,mode:null!==(Q=null===(K=null==Mo?void 0:Mo["month-days"])||void 0===K?void 0:K.mode)&&void 0!==Q?Q:ko,allowClear:null!==($=null===(X=null==Mo?void 0:Mo["month-days"])||void 0===X?void 0:X.allowClear)&&void 0!==$?$:Po,filterOption:null===(ee=null==Mo?void 0:Mo["month-days"])||void 0===ee?void 0:ee.filterOption,getPopupContainer:jo}),("year"===vn||"month"===vn||"week"===vn)&&No.includes("week-days")&&e(L,{value:zo,setValue:Uo,locale:_e,className:eo,humanizeLabels:null!==(ne=null===(oe=null==Mo?void 0:Mo["week-days"])||void 0===oe?void 0:oe.humanizeLabels)&&void 0!==ne?ne:io,monthDays:Ho,disabled:null!==(te=null===(re=null==Mo?void 0:Mo["week-days"])||void 0===re?void 0:re.disabled)&&void 0!==te?te:so,readOnly:null!==(ie=null===(le=null==Mo?void 0:Mo["week-days"])||void 0===le?void 0:le.readOnly)&&void 0!==ie?ie:po,period:vn,periodicityOnDoubleClick:null!==(ue=null===(ae=null==Mo?void 0:Mo["week-days"])||void 0===ae?void 0:ae.periodicityOnDoubleClick)&&void 0!==ue?ue:Oo,mode:null!==(ce=null===(de=null==Mo?void 0:Mo["week-days"])||void 0===de?void 0:de.mode)&&void 0!==ce?ce:ko,allowClear:null!==(ve=null===(se=null==Mo?void 0:Mo["week-days"])||void 0===se?void 0:se.allowClear)&&void 0!==ve?ve:Po,filterOption:null===(pe=null==Mo?void 0:Mo["week-days"])||void 0===pe?void 0:pe.filterOption,getPopupContainer:jo}),n("div",{children:["minute"!==vn&&"hour"!==vn&&No.includes("hours")&&e(E,{value:Ro,setValue:Yo,locale:_e,className:eo,disabled:null!==(fe=null===(me=null==Mo?void 0:Mo.hours)||void 0===me?void 0:me.disabled)&&void 0!==fe?fe:so,readOnly:null!==(he=null===(ye=null==Mo?void 0:Mo.hours)||void 0===ye?void 0:ye.readOnly)&&void 0!==he?he:po,leadingZero:null!==(we=null===(ge=null==Mo?void 0:Mo.hours)||void 0===ge?void 0:ge.leadingZero)&&void 0!==we?we:fo,clockFormat:go,period:vn,periodicityOnDoubleClick:null!==(be=null===(Oe=null==Mo?void 0:Mo.hours)||void 0===Oe?void 0:Oe.periodicityOnDoubleClick)&&void 0!==be?be:Oo,mode:null!==(Ce=null===(ke=null==Mo?void 0:Mo.hours)||void 0===ke?void 0:ke.mode)&&void 0!==Ce?Ce:ko,allowClear:null!==(De=null===(Ne=null==Mo?void 0:Mo.hours)||void 0===Ne?void 0:Ne.allowClear)&&void 0!==De?De:Po,filterOption:null===(xe=null==Mo?void 0:Mo.hours)||void 0===xe?void 0:xe.filterOption,getPopupContainer:jo}),"minute"!==vn&&No.includes("minutes")&&e(W,{value:Go,setValue:qo,locale:_e,period:vn,className:eo,disabled:null!==(Me=null===(Pe=null==Mo?void 0:Mo.minutes)||void 0===Pe?void 0:Pe.disabled)&&void 0!==Me?Me:so,readOnly:null!==(Se=null===(je=null==Mo?void 0:Mo.minutes)||void 0===je?void 0:je.readOnly)&&void 0!==Se?Se:po,leadingZero:null!==(Ae=null===(Fe=null==Mo?void 0:Mo.minutes)||void 0===Fe?void 0:Fe.leadingZero)&&void 0!==Ae?Ae:fo,clockFormat:go,periodicityOnDoubleClick:null!==(Ee=null===(Ve=null==Mo?void 0:Mo.minutes)||void 0===Ve?void 0:Ve.periodicityOnDoubleClick)&&void 0!==Ee?Ee:Oo,mode:null!==(He=null===(We=null==Mo?void 0:Mo.minutes)||void 0===We?void 0:We.mode)&&void 0!==He?He:ko,allowClear:null!==(Ie=null===(Te=null==Mo?void 0:Mo.minutes)||void 0===Te?void 0:Te.allowClear)&&void 0!==Ie?Ie:Po,filterOption:null===(Le=null==Mo?void 0:Mo.minutes)||void 0===Le?void 0:Le.filterOption,getPopupContainer:jo}),sn]})]})]}))}export{J as Cron,A as converter,J as default};