import{j as e,r as k}from"./app-BBZbvTSO.js";import d from"./FieldBase-C0gzKbbb.js";import{B as b}from"./button-CZmOQP7j.js";import{I as y}from"./input-error-Bz7f2c6i.js";import{T as v}from"./trash-2-BBs2y9vd.js";import{P as w}from"./plus-D8fMMvfS.js";import{C as g}from"./clock-gA1FmRyJ.js";/* empty css            */import"./label-BPDCCRHl.js";import"./index-13DH8-b5.js";import"./utils-YhN_nlHn.js";function z({field:a,value:s,onChange:o,processing:l,errors:c}){var m;const f=()=>{if(!Array.isArray(s)){o(a,[{value:null}]);return}const r=[...s,{value:null}];o(a,r)},x=r=>{if(!Array.isArray(s))return;const i=[...s];i.splice(r,1),o(a,i)},u=(r,i)=>{var t;if((t=a.options)!=null&&t.repeatable&&typeof i=="number"){const n=[...s];n[i]={value:r},o(a,n)}else o(a,r)},p=({value:r,onChange:i,disabled:t})=>{const n=k.useRef(null),h=()=>{n.current&&!t&&(n.current.focus(),n.current.showPicker())};return e.jsxs("div",{className:"relative inline-block w-auto",children:[e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 cursor-pointer",onClick:h,children:e.jsx(g,{className:"h-4 w-4 text-foreground opacity-70 hover:opacity-100"})}),e.jsx("input",{ref:n,type:"time",value:r||"",onChange:j=>i(j.target.value),disabled:t,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 text-foreground pr-10 [&::-webkit-calendar-picker-indicator]:opacity-0 [&::-webkit-calendar-picker-indicator]:absolute [&::-webkit-calendar-picker-indicator]:inset-0 [&::-webkit-calendar-picker-indicator]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-clear-button]:appearance-none"})]})};if((m=a.options)!=null&&m.repeatable){const r=Array.isArray(s)?s:[{value:null}];return e.jsx(d,{field:a,value:s,onChange:o,processing:l,errors:c,children:e.jsxs("div",{className:"space-y-2",children:[r.map((i,t)=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(p,{value:i.value,onChange:n=>u(n,t),disabled:l}),t!==0&&e.jsx(b,{type:"button",variant:"destructive",size:"icon",onClick:()=>x(t),disabled:l,children:e.jsx(v,{className:"h-4 w-4"})})]}),e.jsx(y,{message:c[`data.${a.name}.${t}.value`]})]},t)),e.jsxs(b,{type:"button",variant:"outline",size:"sm",onClick:f,disabled:l,className:"text-xs",children:[e.jsx(w,{className:"h-4 w-4 mr-1"}),"Add a new line"]})]})})}return e.jsx(d,{field:a,value:s,onChange:o,processing:l,errors:c,children:e.jsx("div",{className:"flex gap-2 items-center space-y-1",children:e.jsx(p,{value:s,onChange:r=>u(r),disabled:l})})})}export{z as default};
