const e=require("../../../_util/classNames.js"),t=require("../../../_util/KeyCode.js"),n=require("../../hooks/useMergeProps.js"),r=require("../../utils/timeUtil.js"),i=require("../../utils/miscUtil.js"),a=require("../DatePanel/index.js"),o=require("../TimePanel/index.js");let s=require("vue");var c=i.tuple(`date`,`time`);function l(i){let l=n.default(i),{prefixCls:u,operationRef:d,generateConfig:f,value:p,defaultValue:m,disabledTime:h,showTime:g,onSelect:_}=l,v=`${u}-datetime-panel`,y=(0,s.ref)(null),b=(0,s.ref)({}),x=(0,s.ref)({}),S=typeof g==`object`?{...g}:{};function C(e){return c[c.indexOf(y.value)+e]||null}let w=e=>{x.value.onBlur&&x.value.onBlur(e),y.value=null};d.value={onKeydown:e=>{if(e.which===t.default.TAB){let t=C(e.shiftKey?-1:1);return y.value=t,t&&e.preventDefault(),!0}if(y.value){let t=y.value===`date`?b:x;return t.value&&t.value.onKeydown&&t.value.onKeydown(e),!0}return[t.default.LEFT,t.default.RIGHT,t.default.UP,t.default.DOWN].includes(e.which)?(y.value=`date`,!0):!1},onBlur:w,onClose:w};let T=(e,t)=>{let n=e;t===`date`&&!p&&S.defaultValue?(n=f.setHour(n,f.getHour(S.defaultValue)),n=f.setMinute(n,f.getMinute(S.defaultValue)),n=f.setSecond(n,f.getSecond(S.defaultValue))):t===`time`&&!p&&m&&(n=f.setYear(n,f.getYear(m)),n=f.setMonth(n,f.getMonth(m)),n=f.setDate(n,f.getDate(m))),_&&_(n,`mouse`)},E=h?h(p||null):{};return(0,s.createVNode)(`div`,{class:e.default(v,{[`${v}-active`]:y.value})},[(0,s.createVNode)(a.default,{...l,operationRef:b,active:y.value===`date`,onSelect:e=>{T(r.setDateTime(f,e,!p&&typeof g==`object`?g.defaultValue:null),`date`)}},null),(0,s.createVNode)(o.default,{...l,format:void 0,...S,...E,disabledTime:null,defaultValue:void 0,operationRef:x,active:y.value===`time`,onSelect:e=>{T(e,`time`)}},null)])}l.displayName=`DatetimePanel`,l.inheritAttrs=!1,exports.default=l;