"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("vue"),_=require("../../../_util/vnode.js"),A=require("../../utils/miscUtil.js"),$=require("../../utils/timeUtil.js"),D=require("./TimeUnitColumn.js");function U(e,r,o,v){const s=[];for(let n=e;n<=r;n+=o)s.push({label:A.leftPad(n,2),value:n,disabled:(v||[]).includes(n)});return s}const j=u.defineComponent({compatConfig:{MODE:3},name:"TimeBody",inheritAttrs:!1,props:["generateConfig","prefixCls","operationRef","activeColumnIndex","value","showHour","showMinute","showSecond","use12Hours","hourStep","minuteStep","secondStep","disabledHours","disabledMinutes","disabledSeconds","disabledTime","hideDisabledOptions","onSelect"],setup(e){const r=u.computed(()=>e.value?e.generateConfig.getHour(e.value):-1),o=u.computed(()=>e.use12Hours?r.value>=12:!1),v=u.computed(()=>e.use12Hours?r.value%12:r.value),s=u.computed(()=>e.value?e.generateConfig.getMinute(e.value):-1),n=u.computed(()=>e.value?e.generateConfig.getSecond(e.value):-1),k=u.ref(e.generateConfig.getNow()),g=u.ref(),b=u.ref(),h=u.ref();u.onBeforeUpdate(()=>{k.value=e.generateConfig.getNow()}),u.watchEffect(()=>{if(e.disabledTime){const t=e.disabledTime(k);[g.value,b.value,h.value]=[t.disabledHours,t.disabledMinutes,t.disabledSeconds]}else[g.value,b.value,h.value]=[e.disabledHours,e.disabledMinutes,e.disabledSeconds]});const M=(t,a,i,N)=>{let m=e.value||e.generateConfig.getNow();const S=Math.max(0,a),T=Math.max(0,i),y=Math.max(0,N);return m=$.setTime(e.generateConfig,m,!e.use12Hours||!t?S:S+12,T,y),m},P=u.computed(()=>U(0,23,e.hourStep??1,g.value&&g.value())),q=u.computed(()=>{if(!e.use12Hours)return[!1,!1];const t=[!0,!0];return P.value.forEach(({disabled:a,value:i})=>{a||(i>=12?t[1]=!1:t[0]=!1)}),t}),E=u.computed(()=>e.use12Hours?P.value.filter(o.value?t=>t.value>=12:t=>t.value<12).map(t=>{const a=t.value%12,i=a===0?"12":A.leftPad(a,2);return{...t,label:i,value:a}}):P.value),O=u.computed(()=>U(0,59,e.minuteStep??1,b.value&&b.value(r.value))),B=u.computed(()=>U(0,59,e.secondStep??1,h.value&&h.value(r.value,s.value)));return()=>{const{prefixCls:t,operationRef:a,activeColumnIndex:i,showHour:N,showMinute:m,showSecond:S,use12Hours:T,hideDisabledOptions:y,onSelect:C}=e,H=[],L=`${t}-content`,R=`${t}-time-panel`;a.value={onUpDown:l=>{const d=H[i];if(d){const x=d.units.findIndex(c=>c.value===d.value),f=d.units.length;for(let c=1;c<f;c+=1){const V=d.units[(x+l*c+f)%f];if(V.disabled!==!0){d.onSelect(V.value);break}}}}};function w(l,d,x,f,c){l!==!1&&H.push({node:_.cloneElement(d,{prefixCls:R,value:x,active:i===H.length,onSelect:c,units:f,hideDisabledOptions:y}),onSelect:c,value:x,units:f})}w(N,u.createVNode(D.default,{key:"hour"},null),v.value,E.value,l=>{C(M(o.value,l,s.value,n.value),"mouse")}),w(m,u.createVNode(D.default,{key:"minute"},null),s.value,O.value,l=>{C(M(o.value,v.value,l,n.value),"mouse")}),w(S,u.createVNode(D.default,{key:"second"},null),n.value,B.value,l=>{C(M(o.value,v.value,s.value,l),"mouse")});let I=-1;return typeof o.value=="boolean"&&(I=o.value?1:0),w(T===!0,u.createVNode(D.default,{key:"12hours"},null),I,[{label:"AM",value:0,disabled:q.value[0]},{label:"PM",value:1,disabled:q.value[1]}],l=>{C(M(!!l,v.value,s.value,n.value),"mouse")}),u.createVNode("div",{class:L},[H.map(({node:l})=>l)])}}});exports.default=j;
